I built an application for Angular 2 alpha 45 and it worked wonderfully, but I had to 'mess' around a lot to get it to work. I understand Angular 2, but I don't understand how to get it to work to start actually using Angular 2.
I am trying a clean build of the 'Angular 2: 5 min Quickstart'. There are a number of issues, and I am going to be as specific as possible. I want to learn why these issues are occurring and hopefully how to fix them. Visual Studio 2015 Update 1, Typescript 1.7.
Typescript Configuration: the quickstart includes a tsconfig.json file.
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
I am not sure if this does anything though, as I had to edit the ProjectName.csproj file and add the line:
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
to get rid of the Experimental Decorators Error.
https://github.com/Microsoft/TypeScript/issues/3124 seems to suggest the tsconfig file needs to be in /Scripts to work, but that doesn't work for me either.
I would like to know either how to get this tsconfig file to work, or to edit the .csproj file to get the same compiler options. If you look in the Project Properties > Typescript Build. Are these what matter? Should the module system be: System?
My file structure is the same as the Quickstart.
app/
app.component.ts
boot.ts
node_modules/
blah
index.html
tsconfig.json
package.json
I used powershell to run npm install to get everything in the node_modules directory.
import {Component} from 'angular2/core';
displays an error. ../node_modules/angular2/core';
doesn't display the error, but then when you build the project, you get lots of build errors in files in node_moduels/angular2/src/*
. Now, I might be able to go in and manually fix these issues, but I feel like the configuration is wrong if these errors are appearing. The tsconfig seems to want to exclude node_modules
. Why am I not able to use 'angular2/core'
and instead must use a relative path to it? If I include the node_modules in the Visual Studio project, there are an insane amount of build errors in the node_modules
.
Separately:
I am doing this clean build because I couldn't work out how to update the project from alpha 45 to beta 0. Fixing bugs in my project from Angular 2 changes will be easy, but getting the app to load all the modules at the moment is impossible.
The next part is assuming I get past the build errors:
In index.html
there is the:
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
I have never gotten the System.import('app/boot')
to work without specifying the file extension. Is this a visual studio issue or is it a .NET MVC issue? If I specify the file extension in index.html
, then I get 404s with System.js trying to find the component files without a file extension (even though the config has defaultExtension: 'js'
. Is this because I need to include the js files in my project? Then if I get past that issue, I have to deal with
system.src.js:1049 GET http://localhost:63819/angular2/http 404 (Not Found)
I didn't have a single build error, but now System.js is not loading anything.
I feel like these are all issues that are created by different systems interpreting the typescript differently. I feel like I haven't been clear, but I don't know how to be clear about this issue. I would really appreciate any help and guidance you could bestow upon me. I feel like I have been searching for an answer to this for days now.