0

I'm trying to compile my ionic 2 rc app using ngc with typescript@next:

[ben@ben app2] $ ./node_modules/.bin/ngc -p tsconfig.json 
Error: Metadata emit requires the sourceFiles are passed to WriteFileCallback. Update to TypeScript ^1.9.0-dev
    at MetadataWriterHost.writeFile (/home/ben/blindmate/app2/node_modules/@angular/tsc-wrapped/src/compiler_host.js:97:23)
    at Object.writeFile (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:58205:132)
    at Object.writeFile (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:8508:14)
    at printFile (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:55459:16)
    at emitFile (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:55409:21)
    at onSingleFileEmit (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:8415:13)
    at Object.forEachTransformedEmitFile (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:8392:21)
    at Object.emitFiles (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:55392:12)
    at emitWorker (/home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:58256:33)
    at /home/ben/blindmate/app2/node_modules/typescript/lib/typescript.js:58219:66

I cannot change my typescript version (@next), because I need support for async / await. Is there any way to fix this error without installing typescript@1.9.0 as the error message suggests?

My tsconfig looks like this:

{


"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "target": "es5"
  },
  "exclude": [
    "node_modules",
    ".tmp",
    "src/app/main.prod.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}
highwaychile
  • 755
  • 1
  • 6
  • 18

1 Answers1

1

I've been exploring the same thing, and it seems as though the Angular 2 AOT Compiler, at least the version used by Ionic 2 RC0, isn't exactly compatible with pre-release builds of TypeScript 2.1 at this point.

If you revert to TypeScript 2.0, which is the version used by Ionic 2 RC0, it will work. You'll have to forgo async/await, but you don't really need async/await as you can effectively write the same code by creating and consuming Promises explicitly. It's just not nearly as concise or expressive. :) That said, I want async/await probably as much as you do and would also be interested in getting this to work as soon as possible.