express run typescript project code example
Example 1: add typescript in node
npm init-y
yarn add -D @types/node typescript ts-node
npx tsconfig.json
"start": "ts-node src/index.ts",
console.log("Hello TypeScript");
yarn start
Example 2: express typescript tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.test.ts"]
}