Does MSBuild need to translate .ts files in Angular2 dependencies (in node_modules) for Angular2?

Background

I have an ASP.NET MVC project integrated with Angular2. In Angular.io quick start guide - I created a folder in my solution file with the default Angular2 structure ...

├── app
|   └── ...
├── node_modules
|   └── ...
├── typings
|   └── ...
| systemjs.config.js
| tsconfig.json
| typings.json
| package.json

... and the package.jsondefault file :

"dependencies": {
  "@angular/common": "2.0.0",
  "@angular/compiler": "2.0.0",
  "@angular/core": "2.0.0",
  "@angular/forms": "2.0.0",
  "@angular/http": "2.0.0",
  "@angular/platform-browser": "2.0.0",
  "@angular/platform-browser-dynamic": "2.0.0",
  "@angular/router": "3.0.0",
  "@angular/upgrade": "2.0.0",
  "core-js": "^2.4.1",
  "reflect-metadata": "^0.1.3",
  "rxjs": "5.0.0-beta.12",
  "systemjs": "0.19.27",
  "zone.js": "^0.6.23",
  "angular2-in-memory-web-api": "0.0.20",
  "bootstrap": "^3.3.6"
},
"devDependencies": {
  "concurrently": "^2.2.0",
  "lite-server": "^2.2.2",
  "typescript": "^2.0.2",
  "typings":"^1.3.2"
}

Then I used the command npm installto install Angular2 dependencies in a folder node_modules.

Problem

The root of my problem is that MSBuild is trying to compile every .tsfile in the whole project. 1 They include the .tsfiles that it finds in the folder node_modules. This causes a lot of errors and prevents the solution from being built / published. 2

Question

, tsconfig.json, , . , MSBuild AngularJS node_modules.

? Angular2 , tsconfig.json , Typescript ? SystemJS Typescript?

1 Microsoft.Typescript.MSBuild NuGet .ts (tsc.exe v2.0.3) NodeJS v6.x.

2 , , Angular2 tsconfig.json , node_modules tsconfig.json - , \node_modules\browser-sync\node_modules\rx\ts\tsconfig.json.

+4
2

Angular2, tsconfig.json , Typescript ?

JS. . , Typescript , TypeScript ( .d.ts). , , (.ts). , Typescript .

, , JS- Typescript (.i.e. ). . , , Moment JS. npm install momemt, , . , Moment TypeScript, npm install @types/moment, Moment.

, Typescript, compilerOptions.declaration: true tsconfig.json. , , .

/ TypeScript. , , , tsconfig, , , . . , , , , .

+3

TypeScript node_modules. , , tsconfig :

"exclude": [
    "node_modules"
  ],

, TypeScript, - . TypeScript.

0

Source: https://habr.com/ru/post/1658738/


All Articles