Typescript
Typescript is a super-set of JavaScript which provides type definitions. It is a strongly typed programming language.
Starting a Typescript Project
- To start a TypeScript Project, first of all, install
TypeScript
andts-node
as a dev-dependency
yarn add typescript ts-node -D
- Create a
tsconfig.json
file at the root of your project and add the following configurations (Enough Config to get started).
{"compilerOptions": {"outDir": "./dist","lib": ["ESNext"],"esModuleInterop": true}}
Property | Function |
---|---|
outDir | Where your compiled JavaScript will be stored |
lib | Include API's from specified versions. |
esModuleInterop | With flag esModuleInterop we can import CommonJS modules in compliance with es6 modules spec. |
- Inside
package.json
, add the following scripts
"scripts": {"build": "tsc","dev": "ts-node app.ts"}
- Run
yarn dev
to run your app.