Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use different tsconfig file for test files in vscode?

This question is similar to this question: How to use different tsconfig file for tests? But I am asking for visual studio code.

I have two tsconfig files:

  • tsconfig.json for all application files
  • tsconfig.test.json for all test files

tsconfig.json excludes all *.spec.ts while tsconfig.test.json only includes these files.

How can I make visual studio code to understand that an opened .spec.ts file belongs to tsconfig.test.json?

I dont want to separate all my tests into an own test directory with its own tsconfig.json included but rather keep them next to the application files.

like image 943
Michael Hilus Avatar asked Jul 15 '19 17:07

Michael Hilus


1 Answers

VS Code has limitation to a single tsconfig.json for now (see: https://github.com/microsoft/vscode/issues/12463).

Considering the project structure is:

  • src/
  • tsconfig.json
  • tsconfig.test.json

Create ./src/tsconfig.json file with content:

{
  "extends": "../tsconfig.test.json"
}
like image 112
yavulan Avatar answered Sep 29 '22 16:09

yavulan