Open hungdao-testing opened 3 years ago
I think this should resolve your issue: https://github.com/jest-community/jest-extended/issues/282
To your tsconfig.json
, add:
{
...
"files": ["path/to/global.d.ts"]
}
The problem is fixed, I thought maybe I didn't create tsconfig.json in my project. After created this file, and added few basic options. This issue is gone.
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
One note that, currently I removed babel out of the project
Isn't this a better solution to a global.d.ts file:
tsconfig.json
...
"types": ["node", "jest", "jest-extended"],
...
Bug
package
version:node
version: v15.5.0npm
(oryarn
) version: npm: 7.3.0Relevant code or config
Pre-condition:
Install Vscode
Create a project with structure -jest-axios ---configs ---tests -----babel.config.js -----global.d.ts -----jest.config.js
What you did:
import 'jest-extended';
This issue would happen when re-opening the file or vscode.
Work-around: open
global.d.ts
hit Save, the error in spec file is disappeared ,or enterimport 'jest-extended';
in spec file