TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.67k stars 692 forks source link

Error Initializers are not allowed in ambient contexts with typescript 3.1.1 and Angular 7 #862

Closed Ks89 closed 5 years ago

Ks89 commented 5 years ago

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?

legalbrickstechnology-dcm commented 5 years ago

Your compiler is still using 3.0.3 and not 3.1.1

aciccarello commented 5 years ago

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

btmurrell commented 5 years ago

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?

legalbrickstechnology-dcm commented 5 years ago

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.

aciccarello commented 5 years ago

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

btmurrell commented 5 years ago

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

Ks89 commented 5 years ago

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