Why does Visual studio 2019 adds <TypeScriptCompile Remove /> in my project?

Viewed 2416

I have an asp.net core 2.2 project running on .net 4.7.2, which includes the Microsoft.TypeScript.MSBuild nuget package.

Every time I add a new typescript (.ts or .tsx) file to my project, visual studio automatically adds a:

<ItemGroup><TypeScriptCompile Remove="myFile.ts" /></ItemGroup>

line into my project .csproj file.

Here is my tsconfig file:

{
  "compilerOptions": {
    // Target latest version of ECMAScript.
    "target": "esnext",

    // Search under node_modules for non-relative imports.
    "moduleResolution": "node",

    // Process & infer types from .js files.
    "allowJs": false,
    "jsx": "react",

    // Don't emit; allow Babel to transform files.
    "noEmit": true,

    // Enable strictest settings like strictNullChecks & noImplicitAny.
    "strict": true,

    // Disallow features that require cross-file information for emit.
    "isolatedModules": true,

    // Import non-ES modules as default imports.
    "esModuleInterop": true,

    "skipLibCheck": true,

    "baseUrl": ".",
    "paths": {
        /* my paths */
    }
  },
  "include": [
        /* my typescript folders */
  ],
  "exclude": [ "node_modules" ]
}

Note that I'm only using the package to type-check my files, the actual compilation is done using Babel.

Can you please help me understand why Visual studio adds these TypeScriptCompile Remove in my project? Am I doing something wrong?

1 Answers

The "remove" entry is added so that you don't get the nested filename.js and filename.js.map files appearing in your project folder structure. The instruction explicitly tells Visual Studio not to compile this file and instead allows you to use some other compiler (either the TSC that you downloaded via NPM or perhaps even the Angular compiler). Basically it tells VisualStudio to get out of the way.

Related