Last active
February 4, 2021 06:05
-
-
Save GuillaumeDesforges/bf7383f8403e1683b2b9467db3964185 to your computer and use it in GitHub Desktop.
Simplest use of TypeScript for node development with VS Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Run server (dev)", | |
"type": "node-terminal", | |
"request": "launch", | |
"command": "yarn dev", | |
"cwd": "${workspaceFolder}" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "yourpackage", | |
"version": "1.0.0", | |
"main": "dist/index.js", | |
"license": "MIT", | |
"private": true, | |
"scripts": { | |
"build": "tsc", | |
"start": "node dist/index.js", | |
"dev": "ts-node-dev --inspect=4321 --respawn --transpile-only src/index.ts" | |
}, | |
"dependencies": { | |
"express": "4.17.1", | |
"typescript": "4.1.3", | |
"@types/express": "4.17.11" | |
}, | |
"devDependencies": { | |
"ts-node-dev": "1.1.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from "express"; | |
const app = express(); | |
app.get("/", async (req, res) => { | |
res.send("Hello world!"); | |
}); | |
app.listen(3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"sourceMap": true, | |
"outDir": "./dist", | |
"removeComments": true, | |
"strict": true, | |
"moduleResolution": "node", | |
"esModuleInterop": true, | |
"skipLibCheck": true, | |
"forceConsistentCasingInFileNames": true, | |
"noImplicitAny": false, | |
"noImplicitThis": false | |
}, | |
"include": ["./src"], | |
"exclude": ["./node_modules"] | |
} |
Thanks Guillaume!
Small typo,"dev": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"
should be--transpile-only
since v1.0.
Thanks for the feedback @phil294 ! Updated
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Guillaume!
Small typo,
"dev": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"
should be--transpile-only
since v1.0.