AgentSkillsCN

typescript

Next.js开发中的TypeScript最佳实践。涵盖tsconfig.json配置、利用Next.js 15的异步参数实现类型安全的路由、泛型组件模式、Next.js内置类型(Metadata、NextRequest、NextResponse)、严格模式、模块解析,以及路径别名等。

SKILL.md
--- frontmatter
name: typescript
description: "TypeScript best practices for Next.js development. Covers tsconfig.json configuration, type-safe routing with Next.js 15 async params, generic component patterns, Next.js built-in types (Metadata, NextRequest, NextResponse), strict mode, module resolution, and path aliases."
license: MIT
metadata:
  author: Balazs Barta
  version: "0.1.0"

TypeScript for Next.js

TypeScript is essential for building scalable Next.js applications with confidence. This skill covers configuration, Next.js-specific types, and common patterns.

Key Topics

  • tsconfig.json: Configuring TypeScript for Next.js (generated by create-next-app)
  • Next.js 15 Routing: Type-safe async params and searchParams
  • Built-in Types: Metadata, ResolvingMetadata, NextRequest, NextResponse, PageProps
  • Generic Patterns: Reusable component and utility patterns
  • Strict Mode: Benefits and enabling best practices
  • Module Resolution: Bundler option and path aliases
  • Environment Variables: Type-safe access with zod or module declarations
  • Server Actions: Type-safe server function patterns
  • Common Errors: Typical TypeScript issues in Next.js and their fixes

Documentation Lookup

For TypeScript language features, use Context7 to resolve and fetch the TypeScript documentation. For Next.js-specific types and patterns, consult the Next.js documentation with a "typescript" topic filter, or refer to the type definitions included in the next package.

References