Commands
TypeScript
TypeScript is a language that builds on JavaScript by adding syntax for type declarations and annotations. It is a superset of JavaScript and is maintained by Microsoft.
Usage
npx ayanokoji typescript initThis command initializes TypeScript in your project through an interactive process where you can configure:
- Strictness settings (
strictmode,noUncheckedIndexedAccess,noImplicitOverride) - Transpilation method (
tscvs other build tools) - Runtime environment (browser DOM vs
Node.js) - Library configuration
- Monorepo settings
- Dependencies to install (
TypeScript,@types/node,@types/bun,@cloudflare/workers-types)
The command creates a tsconfig.json with optimized defaults including:
- ES2022 target
- Module resolution for Node.js/ESM
- JSON module support
- Source map generation
- Strict type checking (optional)
The command will fail if a tsconfig.json file already exists in your project.
TSConfig Options
The generated tsconfig.json includes carefully selected options:
Base Options
target: "es2022"- Compiles to modern JavaScript featuresesModuleInterop: true- Enables cleaner imports from CommonJS modulesskipLibCheck: true- Skips type-checking of declaration files for better performanceallowJs: true- Allows JavaScript files to be importedresolveJsonModule: true- Enables importing JSON filesmoduleDetection: "force"- Treats each file as a moduleverbatimModuleSyntax: true- Ensures explicit imports/exportserasableSyntaxOnly: true- Limits TypeScript syntax to features that can be easily erased to JavaScript. Disallowsenums,namespaceswith runtime code,parameter propertiesin classes, and non-ECMAScriptimport/exportassignments.// ❌ error: An `import ... = require(...)` alias import foo = require("foo"); // ❌ error: A namespace with runtime code. namespace container { foo.method(); export type Bar = string; } // ❌ error: An `import =` alias import Bar = container.Bar; class Point { // ❌ error: Parameter properties constructor(public x: number, public y: number) {} } // ❌ error: An `export =` assignment. export = Point; // ❌ error: An enum declaration. enum Direction { Up, Down, Left, Right, }
Strictness Options (Optional)
strict: true- Enables all strict type checking options.noUncheckedIndexedAccess: true- Addsundefinedto indexed access likearray[0].noImplicitOverride: true- Ensures explicitoverridekeywords for inherited methods.
Build Options
When using tsc:
moduleResolution: "NodeNext"- Modern Node.js module resolution.module: "NodeNext"- Uses Node.js module format.outDir: "dist"- Outputs compiled files to dist folder.sourceMap: true- Generates source maps for debugging.
When using other build tools:
moduleResolution: "Bundler"- Modern bundler-style resolution.module: "Preserve"- Preserves the original module syntax.noEmit: true- Skips generating output files.
Library Options (Optional)
composite: true- Tells TypeScript to emit.tsbuildinfofiles. This tells TypeScript that your project is part of a monorepo, and also helps it to cache builds to run faster.declaration: true- Tells TypeScript to emit.d.tsfiles. This is needed so that libraries can get autocomplete on the.jsfiles you're creating.declarationMap: true- Generates source maps for.d.tsfiles. These are needed so that when consumers of your libraries are debugging, they can jump to the original source code using go-to-definition.
Edit on GitHub
Last updated on