0
votes

I'm developing in Atom with atom-typescript a small test app using Angular2. My initial set up for angular2.d.ts used alpha.28 and router.d.ts used alpha.31. I have updated my index.html to alpha.46

<script src="https://code.angularjs.org/2.0.0-alpha.46/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.46/router.dev.js"></script>

Now when I import things like ROUTE_PROVIDERS, atom-typescript gives me a not found error. I also get router.d.ts cannot find name 'Opaque Token'.

I think I need d.ts files that match alpha.46. After a couple hours of searching and trying things, I can't make this happen. I tried npm install angular2 with the command line cursor on typings/angular2 and I got an error log with 12,031 lines in it, but no new d.ts files. Among many things, I have also tried Chrome's empty cache and hard reload.

How can I get d.ts files that match the angular2 version? Is it possible to automate the update so it always matches the angular2 version in index.html?

If its helpful, here is my tsconfig.json file

{
  "compilerOptions": {
    "charset": " UTF-8",
    "declaration": false,
    "diagnostics": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "listFiles": true,
    "module": "commonjs",
    "noImplicitAny": false,
    "noLib": false,
    "outDir": "dist/js/cjs",
    "rootDir": "src",
    "removeComments": true,
    "sourceMap": true,
    "target": "es5",
    "version": true
  },
  "filesGlob": [
    "./**/*.ts",
    "!node_modules/**"
  ],
  "exclude": [
    "node_modules"
  ],
  "files": [
    "./app.ts",
    "./src/components/navigation/home.ts",
    "./src/components/navigation/postApartment4Rent.ts",
    "./typings/angular2/angular2.d.ts",
    "./typings/angular2/router.d.ts",
    "./typings/es6-promise/es6-promise.d.ts",
    "./typings/rx/rx-lite.d.ts",
    "./typings/rx/rx.d.ts",
    "./typings/tsd.d.ts"
  ],
  "atom": {
    "rewriteTsconfig": true
  },
  "buildOnSave": true,
  "compileOnSave ": true
}
1
Check this issue - Eric Martinez
Eric, thanks. I posted a description of errors I receive on the issues page you sent me to. I may be messed up, but I think the angular2 team has some work to do to get typescript working in IDEs for the recent alpha releases. - Mike_Laird
The problems I posted were mine. I fixed them and npm installed alpha.47 into my project code. atom-typescript still does not find new entities like ROUTE_PROVIDERS. I may have to wait until more angular2 documentation comes out. - Mike_Laird

1 Answers

0
votes

I have seen an interesting solution here which I have adopted for development code at least while the ng2 version keeps changing:

1) In the gulp file:

gulp.src('node_modules/angular2/bundles/angular2.dev.js').pipe(gulp.dest(dest_lib));
gulp.src('node_modules/angular2/bundles/router.dev.js').pipe(gulp.dest(dest_lib));
gulp.src('node_modules/systemjs/dist/system.src.js').pipe(gulp.dest(dest_lib));

2) In your index.html file

<script src="lib/system.src.js"></script>
<script src="lib/angular2.dev.js"></script>
<script src="lib/router.dev.js"></script>