简体   繁体   English

为什么 Visual Studio 2019 增加了<typescriptcompile Remove />在我的项目中?

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

I have an asp.net core 2.2 project running on .net 4.7.2, which includes the Microsoft.TypeScript.MSBuild nuget package. 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:每次我将新的 typescript(.ts 或 .tsx)文件添加到我的项目时,Visual Studio 都会自动添加:

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

line into my project.csproj file.进入我的 project.csproj 文件。

Here is my tsconfig file:这是我的 tsconfig 文件:

{
  "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.请注意,我只使用 package 对我的文件进行类型检查,实际编译是使用 Babel 完成的。

Can you please help me understand why Visual studio adds these TypeScriptCompile Remove in my project?你能帮我理解为什么 Visual Studio 在我的项目中添加这些 TypeScriptCompile Remove 吗? Am I doing something wrong?难道我做错了什么?

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.添加了“删除”条目,这样您就不会在项目文件夹结构中看到嵌套的 filename.js 和 filename.js.map 文件。 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).该指令明确告诉 Visual Studio 不要编译此文件,而是允许您使用其他一些编译器(您通过 NPM 下载的 TSC,甚至可能是 Angular 编译器)。 Basically it tells VisualStudio to get out of the way.基本上它告诉 VisualStudio 让开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio Community 2019 中创建 TypeScript 项目 - Create a TypeScript project in Visual Studio Community 2019 是否可以在Visual Studio 2019中使用TypeScript创建用于开发javascript库的项目? - Is it possible to create project for developing javascript library with TypeScript in Visual Studio 2019? 如何将 javascript 文件添加到 Visual Studio Community 2019 typescript 项目 - How add javascript files to Visual Studio Community 2019 typescript project Visual Studio 2019 的 React Redux 项目模板,JavaScript 问题 - React Redux Project template by Visual Studio 2019, JavaScript question Visual Studio 2019 无法识别 tsconfig.json - Visual Studio 2019 does not recognize tsconfig.json 在 Visual Studio 2019 中调试 React App 不起作用 - Debugging React App in Visual Studio 2019 does not work TypeScriptCompileBlocked 被 Visual Studio 2019 忽略 - TypeScriptCompileBlocked Ignored by Visual Studio 2019 无法在 Visual Studio 2019 ASP.Net Core 3.1 Angular 项目中调试 Typescript - Unable to debug Typescript in Visual Studio 2019 ASP.Net Core 3.1 Angular project 如何在 Visual Studio 2019 ASP.NET 核心项目中对 TypeScript 进行单元测试? - How to do unit-testing of TypeScript in a Visual Studio 2019 ASP.NET Core project? 在Visual Studio 2019中将TS编译为JS时如何从JS文件中删除导入指令 - How can remove import directives from JS file when compiling TS to JS in Visual Studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM