I try to write tests in typescript (ES6) using WebStorm IDE. E.g.:
// Imports...
describe(\'Message\', () => {
const server = express();
serv
I had this problem with IntelliJ and resolved by changing my IDE settings:
Settings -> Language & Frameworks -> TypeScript
then in the "Options" field add:
--lib es2015
Adding
"lib": [ "es2015" ]
to tsconfig.json should fix the issue.
However it seems that your spec files are not included in your tsconfig.json (check "include":[]
and "exclude":[]
values). So the Typescript service must be using a different tsconfig.json for your files (may be a default one, if no tsconfig.json files that include your specs can be found)
To fix the issue, make sure to specify the lib
property in config that is used for your spec files processing
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./src",
"lib": ["es2015"]
},
"include": [
"src/**/*",
"**/*.spec.ts"
],
"exclude": [
"node_modules"
]
}
adding "lib":["es2015"]
to "compilerOptions"
as per @lena's answer and Removing **/*.spec.ts
from "exclude":[]
and adding it to "include":[]
solved it for me.
Add "lib": [ "es2015" ] in tsconfig.json under compilerOptions as
{
"compilerOptions": {
"lib": [ "es2015" ]
}
}