Auto-generated tile from GitHub (10 skills)
92
94%
Does it follow best practices?
Impact
92%
1.16xAverage score across 44 eval scenarios
Advisory
Suggest reviewing before use
Node.js 22.6+ supports running TypeScript files directly by stripping types at runtime. In Node.js 23.6+ and 24+, type stripping is enabled by default.
Enable with the experimental flag:
node --experimental-strip-types app.tsTypeScript files run directly without flags:
node app.tsType stripping works by removing type annotations without transforming code. Your TypeScript must follow these rules:
Always use type keyword for type imports:
// GOOD - type-only import
import type { User, Config } from './types.ts';
import { createUser } from './user.ts';
// GOOD - inline type imports
import { createUser, type User } from './user.ts';
// BAD - may fail with type stripping
import { User, createUser } from './user.ts';Enums require code transformation. Use const objects instead:
// BAD - enums don't work with type stripping
enum Status {
Active = 'active',
Inactive = 'inactive',
}
// GOOD - const object with type
const Status = {
Active: 'active',
Inactive: 'inactive',
} as const;
type Status = (typeof Status)[keyof typeof Status];Namespaces require transformation:
// BAD - namespaces don't work
namespace Utils {
export function format(s: string): string {
return s.trim();
}
}
// GOOD - use modules
export function format(s: string): string {
return s.trim();
}Parameter properties require transformation:
// BAD - parameter properties don't work
class User {
constructor(public name: string, private age: number) {}
}
// GOOD - explicit property declaration
class User {
name: string;
private age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
}Use the TC39 decorator syntax (stage 3):
// BAD - legacy/experimental decorators
@Injectable()
class Service {}
// Decorators support depends on Node.js version
// Check compatibility before usingUse .ts extensions in imports. TypeScript will rewrite them to .js during build:
// GOOD - .ts extension (works with type stripping, rewritten during build)
import { helper } from './helper.ts';
import type { Config } from './types.ts';
// JSON imports
import config from './config.json' with { type: 'json' };Configure TypeScript for development with type stripping:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"allowImportingTsExtensions": true,
"lib": ["ES2022"],
"types": ["node"]
},
"include": ["src/**/*.ts", "test/**/*.ts"],
"exclude": ["node_modules"]
}Key options:
noEmit: No compilation, Node.js runs TypeScript directlyallowImportingTsExtensions: Allow .ts importsverbatimModuleSyntax: Enforces type-only importsisolatedModules: Ensures compatibility with type strippingCreate a separate config for building distributable packages:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
"resolveJsonModule": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"lib": ["ES2022"],
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "test"]
}Key build options:
rewriteRelativeImportExtensions: Rewrites .ts imports to .js in outputdeclaration: Generates .d.ts type declaration filesdeclarationMap: Generates source maps for declarationsoutDir: Output directory for compiled filesUse the built-in test runner with TypeScript:
# Node.js 22.19+/23.6+/24+
node --test test/*.test.tsUse tsc with the build config for publishing packages:
# Build with tsc
tsc -p tsconfig.build.jsonConfigure package.json for ESM with TypeScript:
{
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"files": ["dist", "README.md", "LICENSE"],
"scripts": {
"build": "tsc -p tsconfig.build.json",
"clean": "rm -rf dist",
"prepublishOnly": "npm run clean && npm run build",
"test": "node --test test/*.test.ts",
"typecheck": "tsc --noEmit"
},
"engines": {
"node": ">=22.6.0"
}
}Run type checking separately since type stripping doesn't validate types:
# Check types without emitting
tsc --noEmit
# Watch mode for development
tsc --noEmit --watchevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
scenario-36
scenario-37
scenario-38
scenario-39
scenario-40
scenario-41
scenario-42
scenario-43
scenario-44
skills
documentation
fastify
init
linting-neostandard-eslint9
node
nodejs-core
rules
oauth
octocat
snipgrapher