How can I exclude typescript files from being transpiled but still ensure that they work properly with the linter in the Atom editor?
I'm getting this error in my *.spec.ts
files:
An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your
--lib
option.
The problem occurs because I'm explicitly excluding the directory with all of my test files (see the tsconfig file below), because I don't want these files to be transpiled to JavaScript when I build the project. However, I do want these files to be properly linted by the tslint plugin while I'm viewing them in the Atom editor.
My setup:
My tsconfig.json
file:
{
"compileOnSave": false,
"compilerOptions": {
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"baseUrl": ".",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"inlineSources": true,
"lib": [
"es2017",
"dom"
],
"moduleResolution": "node",
"newLine": "lf",
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./dist",
"target": "es5",
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"./spec",
"./dist"
]
}
You'll need to use two tsconfig.json
files, one for the editor (which includes the *.spec.ts
files) and another for compilation (which excludes them). You can use extends
to share most of the options between the two files. See this discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With