neo-typescript
Installation
SKILL.md
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,
readonlyonly 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
allowSyntheticDefaultImportswithoutesModuleInteropallows code to pass compile-time type checks but causes an immediate runtime crash (TypeError: default is not a function) due to the lack of__importDefaultemit helpers in transpile output. - Double Default Trap for Library Creators: Using
export defaultin libraries forces Node.js ESM consumers to call.default()to access the module. The golden standard is to completely abandonexport defaultand adoptexport =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.jsonsettings, focusing specifically on the configuration of"strict": true,"strictNullChecks", and"strictFunctionTypes". - Identify the target module format and resolution mechanism (
"moduleResolution").