'Unknown file extension ".ts" when setting up typescript
I am having some troubles with setting up typescript compiler with webstorm for the first time.
This is the error I get: Unknown file extension ".ts" when the webstorm runs the test with:
/usr/local/bin/node /path/to/mocha/mocha --require ts-node/register --ui bdd --reporter /Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js /path/to/testfile/test-index.ts
This is project structure:
and this are the contents of tsconfig.json and source/tsconfig.json
tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"exclude": [
"source",
"node_modules",
"dist"
]
}
source/tsconfig.json:
{
"compilerOptions": {
"outDir": "../dist",
"sourceMap": true,
"declaration": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
}
package.json:
{
"name": "page",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/mocha": "^9.1.0",
"axios": "^0.26.1",
"dateformat": "^5.0.3",
"mariadb": "^3.0.0",
"mocha": "^9.2.2"
},
"devDependencies": {
"@types/node": "^17.0.23",
"nyc": "^15.1.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
}
if I remove the line "module": "es2020", than the error changes to SyntaxError: Unexpected token 'export'
Any idea what I did wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

