name: typescript-typing description: Incremental TypeScript typing for a JS-first repository. Use for JSDoc, shared typedefs, .d.ts promotion, declaration validation, and safer narrowing without broad TS migration. license: MIT
Skill — TypeScript Typing (JS-First)
Overview
This skill governs incremental typing in a JS-first codebase.
The normative repository canon lives in:
The default path is:
- JSDoc in source files
// @ts-check- shared
.d.tsonly when a type is reused across modules - declaration validation through
emitDeclarationOnly
When To Use
- Adding or strengthening types in JavaScript
- Extracting repeated contracts into shared typedefs or
.d.ts - Replacing
anywith something narrower - Building type guards and discriminated unions
- Aligning static typing with JSON Schema or runtime schema boundaries
When Not To Use
- The task is purely documentation with no structural type change
- The task is strict-lane stabilization across configs; use
typing-node24-esm-tsserver
Inputs / Preconditions
- Confirm whether the type is local or shared
- Prefer existing contracts in
src/types/**/*.d.tswhen they already exist - Keep runtime behavior unchanged unless the task explicitly asks otherwise
Workflow
- Start in JS with JSDoc.
- Narrow
unknownwith type guards or shape checks instead of dropping toany. - Promote only genuinely shared types to
src/types/**/*.d.ts. - Keep file-local types local when they serve one module.
- Use declaration emit (
typecheck:declarations) to validate public JS APIs. - Align JSON payload artifacts with JSON Schema, not with ad-hoc object comments alone.
- Para
src/dashboard-ui: rodarnpm run typecheck:dashboard(vue-tsc --noEmit); consultar a skillvue-tsc-dashboardpara tipagem de SFCs, props, emits e stores Pinia.
Guardrails
- JS-first, TS later: do not migrate files to
.tsunless there is a concrete payoff. - Do not replace dynamic but valid contracts with fake certainty.
- Do not spread identical typedefs across multiple files.
- Do not introduce
@ts-ignore.
Validation / Done Criteria
- Types are narrower than
anywhere feasible. - Shared types live in one place.
- Public contracts stay consistent with declaration emit and schema layers.
typecheck:reporemains green.