I am looking to configure my TypeScript tests in such a way that they receive linting, code completion, and VSCode intellisense (TypeScript language features) when the test folder is placed next to the src folder. However, I want to ensure that my tests do not transpile when building my TypeScript project.
The structure of my TypeScript node project looks like this:
.
├── server
│ │
│ │
│ ├── src
│ │ │
│ │ └── app.ts
│ ├── test
│ │ │
│ │ └── app.test.ts
│ ├── node_modules/
│ ├── package-lock.json
│ ├── package.json
│ ├── tslint.json
│ └── tsconfig.json
├── front_end/
└── README.md
Here's an excerpt from my tsconfig:
{
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"target": "ESNext",
"paths": {
"*": ["node_modules/*"]
}
},
"include": ["src/**/*"]
}
When I access my test files in VSCode, the language feature does not recognize types and packages installed in node_modules. Interestingly, if I open VSCode only in the server folder (which is not the root based on my folder structure), the language features work properly 🧐.
My tests utilize ts-jest
for execution, hence eliminating the need for tsc
. Would it be recommended to extend a separate tsconfig.json
specifically for tests 🤔?
Should I try tweaking some settings or consider submitting a bug report to https://github.com/microsoft/vscode/issues/new/choose.