So I was writing in some comments in a new component I was writing, and then to my dismay, my laptop ran out of battery and turned off. I had my server running whilst this happened.
Normally this would be no big deal, I'll just turn it back on and boot up my server again, and continue developing. This time it decided to give me some errors:
cannot find name 'describe'
, and expect
, and beforeEach
, etc.
Note: this is essentially the same problem outlined in the bellow sources:
- https://github.com/TypeStrong/atom-typescript/issues/1125
- Angular 2 Unit Tests: Cannot find name 'describe'
Now this being said, I am aware of the import {} from 'jasmine';
work-around. However, this is where my question stems from.
The above is just that, a "work-around". From all the time I've been working on my website, it has worked perfectly without ever needing the extra import on the spec files. I want to solve this issue, and make it work without the extra import. Thus far in my research I don't believe anyone has solved this issue.
Like in the above issues, I have node_modules/@types
listed under "typeRoots"
in my tsconfig.json
.
I have @types/jasmine
installed on the project.
The only thing I can think of right now is the fact that there are separate tsconfig files in the /src
directory (/src/tsconfig.spec.json
, /src/tsconfig.app.json
), rather than the /tsconfig.json
file.
In these files, there is another "types"
section, and I see other "include"
sections that I've seen some people reference.
Anyway, I'll include some config files for reference:
/src/tscongif.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
/src/tsconfig.spec.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
/tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
let me know if you guys want any other files, and I'll add them.
Update
With the comments bellow, I have deleted the node_modules
folder and re-installed the project. I have also verified npm's cache using the command npm cache verify
. After this, my issue still persists.