Typedoc: Error Initializers are not allowed in ambient contexts with typescript 3.1.1 and Angular 7

Created on 30 Sep 2018  路  7Comments  路  Source: TypeStrong/typedoc

I'm using typedoc 0.12.0, typescript 3.1.1 with Angular 7.0.0 rc.0 and angular-cli 7.0.0-beta.4

I have an Angular library built with the standard method using angular-cli library features.

I want to generare the doc of my lib running:
typedoc --out ./docs/typedoc --mode file --target ES6 --exclude **/*.spec.ts ./projects/ks89/angular-modal-gallery

but I receive this error:

> typedoc --out ./docs/typedoc --mode file --target ES6 --exclude **/*.spec.ts ./projects/ks89/angular-modal-gallery


Using TypeScript 3.0.3 from /Users/ks89/git/angular-modal-gallery/node_modules/typedoc/node_modules/typescript/lib
Error: /Users/ks89/git/angular-modal-gallery/node_modules/@angular/core/src/application_init.d.ts(21)
 Initializers are not allowed in ambient contexts.
Error: /Users/ks89/git/angular-modal-gallery/node_modules/@angular/core/src/ivy_switch/compiler/ivy_switch_on.d.ts(11)
 A 'const' initializer in an ambient context must be a string or numeric literal.
Error: /Users/ks89/git/angular-modal-gallery/node_modules/@angular/core/src/ivy_switch/compiler/legacy.d.ts(18)
 A 'const' initializer in an ambient context must be a string or numeric literal.
Error: /Users/ks89/git/angular-modal-gallery/node_modules/@angular/core/src/linker/query_list.d.ts(33)
 Initializers are not allowed in ambient contexts.

Do you have any suggestions?

Most helpful comment

Your compiler is still using 3.0.3 and not 3.1.1

All 7 comments

Your compiler is still using 3.0.3 and not 3.1.1

Yes as @legalbrickstechnology-dcm noted, TypeDoc is using its own version of TypeScript. This is because it uses some internal TypeScript apis that aren't guaranteed to be stable. This should be fixed by #863

I am hitting this too, also triggered by typedoc. i took a look at @angular/core/src/application_init.d.ts(21) -- not claiming any TS expertise, but lines 21 and 22 do this:

    readonly donePromise: Promise<any>;
    readonly done = false;

by typing and assigning values in those two lines, it seems to violate TS's ambient context rule for declaration files. if i edit this file to just have properties like so:

    readonly donePromise;
    readonly done;

I get past this error (but there are more in the error stack).

should this be reported to Angular team?

Potentially could be raised to angular, seems they have created an issue where rc0 (as far as i can see) is reliant on the 3.1.1 TypeScript compiler which they haven't stated as a breaking change.

It is angular7-rc.0 adding support for TypeScript 3.1.1 that seems to be the issue .. Should work fine with angular7-beta7.

Typedoc has been updated to TypeScript 3.1.x which I believe should resolve this issue when Angular supports TypeScript 3.1

You can try this out at typedoc@next

I will confirm 0.13.0-0 allows for a successful typedoc on my angular project. Thanks!

  • angular 7.0.0-rc.0
  • typescript 3.1.1
  • typedoc 0.13.0-0

thank u for the support. It's working. Issue closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcmath picture mcmath  路  3Comments

rbuckton picture rbuckton  路  3Comments

topherfangio picture topherfangio  路  3Comments

lsagetlethias picture lsagetlethias  路  3Comments

cfischer picture cfischer  路  4Comments