Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2019 does not recognize tsconfig.json

I just installed Visual Studio 2019 and tried it with my current solution. It seems like it ignores the tsconfig.json file, while it worked in VS 2017. In Visual Studio 2017 in project properties: TypeScript Build, it shows:

One or more tsconfig.json or jsconfig.json files detected. Project properties are disabled.

enter image description here

This works good and compiles the files according to my tsconfig.json file.

Now the newly installed Visual Studio 2019 behaves differently. It does not show that sentence and I have to configure all the settings in the project properties. It seems like it does not recognize my tsconfig.json file at all.

How do I get VS 2019 to use the tsconfig.json instead of the project properties?

like image 339
Tigerware Avatar asked Nov 26 '19 16:11

Tigerware


People also ask

What is Tsconfig Lib json?

The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.

What is Tsconfig JSON file TypeScript?

json file is a file of JSON format which allows us to point the root level files and different compiler options to setup that require to compile a TypeScript based projects. The existence of this file in a project specifies that the given directory is the TypeScript project folder root.


2 Answers

The Build Action property (F4) for the tsconfig.json file has to be set to Content. Otherwise Visual Studio ignores this file since VS 2019.

There is a downside though: After this change VS 2017 will complain about the Build Action:

Error NETSDK1022

Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'tsconfig.json'

like image 128
Tigerware Avatar answered Oct 25 '22 15:10

Tigerware


If anyone comes here because Visual Studio 2019 builder seems to ignore the exclude section of tsconfig.json, you can invert the filters and use an include section instead, that works

VS2019 tsconfig.json Example: https://docs.microsoft.com/en-us/visualstudio/javascript/compile-typescript-code-npm?view=vs-2019

like image 30
Lucio M. Tato Avatar answered Oct 25 '22 17:10

Lucio M. Tato