SuperAPI AI Directory

typescript

Coding & development

View repository

Updated 10-15 20:09

About this skill

TypeScript

Only types,tsconfig, and compiler behavior. For how to run with Node, .ts delegate to the node skill; for Vue SFC / Volar, delegate to the vue skill. Build tools, CSS, and state libraries follow the project; do not specify them in this skill.

Do not write APIs from training data. First determine the version, then read the corresponding reference.

Determine the version

  1. Readthe installed's typescript version:node_modules/typescript/package.json 's version, or the lockfile. Do not just look at package.json 's ^ / >= range.
  2. When both typescript@7 and @typescript/typescript6(or npm alias) are installed: for application code and the project's existing typecheck entrypoint, go by 7; for tools that need the programmatic API, go by 6. See references/7.md。
  3. Take major(5.8.4 → 5), open the table below. When writing code, only open the current tier; do not blindly read the whole folder.5.x, also note the minor: use only the 5.0 … 5.y subsection.
major file
5 references/5.md
6 references/6.md
7 references/7.md

Newer majors not listed: use the highest covered tier as a base, then check the official Announcing / handbook release notes. Older: do not use the new APIs in this skill.

Baseline syntax (all 5.0+ should use)

  • Use satisfiesfor literal narrowing, not as as a catch-all.
  • When library authors want to preserve tuples / object literals, write the generic parameter as const T, do not make callers sprinkle as const。
  • New decorators usestandard decorators. Do not enable experimentalDecorators, unless the project has already pinned the old semantics.
  • Enable verbatimModuleSyntax: value imports and import type are separate; do not rely on import elision.
  • moduleResolution: use bundlerfor bundler / Vite; for running Node directly use the current tier's nodenext / node20 / node18. Do not use node10 / node。
  • The resolution strategy must match --module ; for details (bundler can it be paired with commonjs、require(esm) which moduleit falls under) see the current tier.