TypeScript
Beginner
1 min read
Setting Up TypeScript with tsconfig.json
Example
// Terminal setup
// npm install --save-dev typescript
// npx tsc --init
// tsconfig.json (recommended strict config)
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
// src/index.ts
const greet = (name: string): string => `Hello, ${name}!`;
console.log(greet("TypeScript"));
// Compile: npx tsc
// Run output: node dist/index.js
// Or use ts-node for direct execution:
// npx ts-node src/index.ts
Related Resources
TypeScript Reference
Complete tag & property list
TypeScript How-To Guides
Step-by-step practical guides
TypeScript Exercises
Practice what you've learned
More in TypeScript