Neo TypeScript Expert Skill
This skill guides the AI Agent to write code that adheres to the strictest type safety, high maintainability, and advanced meta-programming flexibility, while thoroughly preventing runtime issues such as ESM/CJS interoperability pitfalls.
💡 Gotchas
- Aliasing Writable Reference Bypasses Readonly: In TypeScript,
readonly only restricts the assignment to the property itself. The internal members of the referenced object/array remain mutable. Furthermore, a readonly object can be assigned to a writable alias, which completely bypasses compiler readonly checks.
- Fatal Crash via Partial esModuleInterop: Enabling
allowSyntheticDefaultImports without esModuleInterop allows code to pass compile-time type checks but causes an immediate runtime crash (TypeError: default is not a function) due to the lack of __importDefault emit helpers in transpile output.
- Double Default Trap for Library Creators: Using
export default in libraries forces Node.js ESM consumers to call .default() to access the module. The golden standard is to completely abandon export default and adopt export = or named exports instead.
📋 Static Code & Type Safety Review SOP
When asked to write, modify, refactor, or review TypeScript code, strictly execute the following workflow:
Step 1 — Project Environment Perception (Perceive)
- Inspect the project's
tsconfig.json settings, focusing specifically on the configuration of "strict": true, "strictNullChecks", and "strictFunctionTypes".
- Identify the target module format and resolution mechanism (
"moduleResolution").
Step 2 — Core Type Routing (Reason)
Based on the specific technical domain of the task, progressively disclose and load the corresponding reference files in the skill. Do not load all files at once to save context token space:
- Basics, Narrowing, Classes, & Function Design ➡️ Load type-system-basics.md
- Generic Constraints, Variance, & Advanced Types from Types ➡️ Load advanced-meta-types.md
- Structural Compatibility, Decorators, & ESM/CJS Interop ➡️ Load compatibility-and-interop.md
Step 3 — Precise Code Generation & Review (Act)
- Ensure all generated or modified code strictly adheres to the loaded reference guidelines (e.g., never declare optional callback parameters, ensure generic type parameters appear at least twice to establish correlation).
- For advanced type generation, recommend clear unit test assertions based on the evals configuration.
🛠️ Available Resources (Relative Paths)
- Type System Basics Guide
- Advanced Meta Types Guide
- Compatibility and Interop Guide
1---2name: neo-typescript3description: Use this skill when writing, reviewing, debugging, or architecting TypeScript code. Trigger for tsconfig/compiler options, strict mode, generics, conditional/mapped/template literal types, structural typing, ESM/CJS interop, decorators, library typing, or TypeScript runtime boundary issues.4license: MIT5---67# Neo TypeScript Expert Skill89This skill guides the AI Agent to write code that adheres to the strictest type safety, high maintainability, and advanced meta-programming flexibility, while thoroughly preventing runtime issues such as ESM/CJS interoperability pitfalls.1011## 💡 Gotchas12* **Aliasing Writable Reference Bypasses Readonly**: In TypeScript, `readonly` only restricts the assignment to the property itself. The internal members of the referenced object/array remain mutable. Furthermore, a readonly object can be assigned to a writable alias, which completely bypasses compiler readonly checks.13* **Fatal Crash via Partial esModuleInterop**: Enabling `allowSyntheticDefaultImports` without `esModuleInterop` allows code to pass compile-time type checks but causes an immediate runtime crash (TypeError: default is not a function) due to the lack of `__importDefault` emit helpers in transpile output.14* **Double Default Trap for Library Creators**: Using `export default` in libraries forces Node.js ESM consumers to call `.default()` to access the module. The golden standard is to completely abandon `export default` and adopt `export =` or named exports instead.1516## 📋 Static Code & Type Safety Review SOP1718When asked to write, modify, refactor, or review TypeScript code, strictly execute the following workflow:1920### Step 1 — Project Environment Perception (Perceive)211. Inspect the project's `tsconfig.json` settings, focusing specifically on the configuration of `"strict": true`, `"strictNullChecks"`, and `"strictFunctionTypes"`.222. Identify the target module format and resolution mechanism (`"moduleResolution"`).2324### Step 2 — Core Type Routing (Reason)25Based on the specific technical domain of the task, **progressively disclose** and load the corresponding reference files in the skill. Do not load all files at once to save context token space:26* **Basics, Narrowing, Classes, & Function Design** ➡️ Load [type-system-basics.md](references/type-system-basics.md)27* **Generic Constraints, Variance, & Advanced Types from Types** ➡️ Load [advanced-meta-types.md](references/advanced-meta-types.md)28* **Structural Compatibility, Decorators, & ESM/CJS Interop** ➡️ Load [compatibility-and-interop.md](references/compatibility-and-interop.md)2930### Step 3 — Precise Code Generation & Review (Act)311. Ensure all generated or modified code strictly adheres to the loaded reference guidelines (e.g., never declare optional callback parameters, ensure generic type parameters appear at least twice to establish correlation).322. For advanced type generation, recommend clear unit test assertions based on the evals configuration.3334---3536## 🛠️ Available Resources (Relative Paths)37* [Type System Basics Guide](references/type-system-basics.md)38* [Advanced Meta Types Guide](references/advanced-meta-types.md)39* [Compatibility and Interop Guide](references/compatibility-and-interop.md)