I would like my typescript tests to receive linting, code completion, vscode intellisense (ts language features) when the test
folder is adjacent to the src
. I do NOT want the tests to transpile when I build my typescript project.
My typescript node project is structured 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
With my tsconfig:
{
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"target": "ESNext",
"paths": {
"*": ["node_modules/*"]
}
},
"include": ["src/**/*"]
}
When I navigate to my test files in vscode, the vscode language feature wont recognize types and packages installed in node_modules. SURPRISINGLY, if I open vscode only in the server folder (as you can see from my folder structure server is not the root), the language features work 🧐.
The tests use ts-jest
to run so the tsc
is not needed here. Would it be better practice to extend a tsconfig.json
for tests 🤔?
Is this something that can be fixed in the settings or should I submit a bug to https://github.com/microsoft/vscode/issues/new/choose.
tsconfig.tests.json
and how should it be related to the maintsconfig.json
in your answer? – Dudek