I'm unable to find standard instructions that help me set up a working typescript
node.js
project
I followed the popular tutorials like DigitalOcean & Scotch which are of no help!
npm run tsc -- --init
to generate a well-commented tsconfig.json
.Initially
tsc --init
was not generatingtsconfig.json
but then I found that addingtsc
as the script solved the problem
Added some files with .ts
extension to the project.
Now when I run tsc
to transpile .ts
files to .js
files - I get the following error:
error TS5014: Failed to parse file 'tsconfig.json': Unexpected token / in JSON at position 31.
What I have tried to solve this so far:
typescript
npm install typescript --save-dev
cmd
instead of bash
tsc -p tsconfig.json
"rootDir": "./src"
&& "include": ["src/**/*.ts"]
When I remove all the comments from the auto-generated config, I get the following valid JSON:
{
"include": ["src/**/*.ts"],
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true
}
}
With this tsconfig.json
in place - when I run tsc
, I get the following errors:
error TS5023: Unknown compiler option 'strict'.
error TS5023: Unknown compiler option 'esModuleInterop'.
When I use the standard config and run tsc
I get the following errors:
error TS5023: Unknown compiler option 'esModuleInterop'.
error TS5023: Unknown compiler option 'moduleResolution'.
Dependencies in the package.json
are:
"devDependencies": {
"@types/express": "^4.17.6",
"tslint": "^6.1.2",
"typescript": "^3.9.5"
},
"dependencies": {
"express": "^4.17.1"
}
Environment
npm -v : 6.13.4
node -v : v12.16.1
tsc -v : Version 1.5.3
Windows 10
This is a very first step towards making a typescript project and if there are so many problems - how can one make a project?
To transpile from .ts
to .js
Add tsc:tsc
script to package.json
Run npm run tsc
instead of tsc