OldBros recommended typescript configuration
npm install --save-dev @oldbros/tsconfig
Add this line to your tsconfig.json
file:
{
"extends": "@oldbros/tsconfig"
}
Add check script to your package.json
file:
{
"scripts": {
"check": "npx tsc --project ."
}
}
Run npm run check
command to check js files with ts compiler
- Support latest ECMAScript2022 language features
- Uses ECMAScript Modules
- Recommended for NodeJS v18 and higher
- No typescript experimental features
This configuration is to check JavaScript with TypeScript compiler.
- There is no TypeScript RFC. Nobody knows what TypeScript actually is in details.
- TypeScript is not a JavaScript superset. It does not support all JavaScript syntax such as
await new
and many others - TypeScript specific features. Enums, Namespaces, Decorators,
private
keyword (there are native js private fields)
- Explicit interfaces. They are especially useful for designing libraries and applications.
- IDE autocompletion and hints. Those are quite useful during development time.
- More elegant than JSDoc. The problem with JSDoc - it is quite heavy compare to TypeScript types.
- Disctinct types and interfaces declarations with
d.ts
files are sometimes useful.