-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07_ts_and_node.ts
17 lines (12 loc) · 1.03 KB
/
07_ts_and_node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//node and ts can work together using a package called ts-node
//however it is also possible without tsnode 3rd party library
//created tsconfig.json here using tsc --init
//to use node features in ts file, use npm i --save-dev @types/node
//--save-dev is for using the module only in a dev environment and since we will use js files in prod, we dont need such features in prod once the ts compiles to js file
//even after installing types/node, i was getting error on 'require' below. changing the target from es2016 to es2018 in tsconfig fixed that
//even after using types/node, we will not get any 'completion' support in the IDE. for that install @types/express also
//const express = require('express'); //even after installing express types, we are not getting completion. this is because of the import. we need to use different style of import
//import express from 'express';
const express = require('express'); //but using the above import is creating some compiler error so reusing this for now.
const app = express()
app.listen(3000)