Skip to content

bug(typings): typescript isolatedModules option not working anymore with 14.0.0 #46240

@nicolashenry

Description

@nicolashenry

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

Previouly I could use "isolatedModules" flag to true in tsconfig without any issue:

"isolatedModules": true,

Now I have those errors coming when I use ng serve:
image

Note that it fails also on cdk/material stuff

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-9sbnod?file=tsconfig.json

Please provide the exception or error you saw

Error: node_modules/@angular/router/index.d.ts:183:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

183     readonly type = EventType.ActivationEnd;
                        ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:201:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

201     readonly type = EventType.ActivationStart;
                        ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:592:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

592     readonly type = EventType.ChildActivationEnd;
                        ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:6100m:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

610     readonly type = EventType.ChildActivationStart;
                        ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:998:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

998     readonly type = EventType.GuardsCheckEnd;
                        ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1025:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1025     readonly type = EventType.GuardsCheckStart;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1311:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1311     readonly type = EventType.NavigationCancel;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1335:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1335     readonly type = EventType.NavigationEnd;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1359:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1359     readonly type = EventType.NavigationError;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1396:21 - merror TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1396     readonly type = EventType.NavigationStart;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1745:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1745     readonly type = EventType.ResolveEnd;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:1773:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1773     readonly type = EventType.ResolveStart;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:2146:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

2146     readonly type = EventType.RouteConfigLoadEnd;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:2163:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

2163     readonly type = EventType.RouteConfigLoadStart;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:3423:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

3423     readonly type = EventType.RoutesRecognized;
                         ~~~~~~~~~


Error: node_modules/@angular/router/index.d.ts:3458:21 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

3458     readonly type = EventType.Scroll;
                         ~~~~~~~~~

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.0.0
Node: 16.15.0
Package Manager: npm 8.5.5
OS: Windows 10 (WSL 2 on Ubuntu)

Angular: 14.0.0
- router
(- cdk/material also)
Typescript: 4.6.3

Anything else?

I think It can be reproduced on any project using router (or cdk/material) by putting "isolatedModules": true, in compilerOptions in tsconfig.

It was working perfectly fine previously on Angular 13.3.1.

I know that it was not said in documentation that it should work with this flag activated but there was previously not any contraindication as far as I know so it would be nice if it can continue to work with this flag.

Note that, as a workaround, I can set "skipLibCheck": true, in compilerOptions but I would prefer that it work without this flag if possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions