Skip to content

Since 18.1.0 ngtypecheck refrence is present in compiled ts files #56945

@rsi21

Description

@rsi21

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

compiler-cli

Is this a regression?

Yes

Description

Hi,

Today we are using Angular 18 along with cli & compiler in versions: 18.0.7 & 18.0.6 and no issues.
We have a project with several libraries and build is made without issues.

We updated to latest versions 18.1.0 and now builds of libraries react diferently, we have in some of them ngTypeCheck on top of compiled files, for example here in a public-api.dt.ts:

/// <reference path="public-api.ngtypecheck.d.ts" />

This add made other builds depending on this library to fail as the referenced file doesn't exist in the dist folder.

I reproduce that with a simple new angular project, and notice that it happens only in some use-cases:

  • Creating a new Angular project in 18 ng new test
  • Creating a library ng generate library lib
  • Building the library npm run build lib

The generated public-api.dt.ts contains as before 18.1.0:

export * from './lib/lib.service';
export * from './lib/lib.component';

Now if in the library, in the public-api.ts we remove only:

export * from './lib/lib.component';

and then rebuild the library: 'npm run build lib'

This time the generated public-api.dt.ts contains:

/// <reference path="public-api.ngtypecheck.d.ts" />
export * from './lib/lib.service';

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

When trying to use the compiled code / library then compiles fails with:

dist/my-lib/public-api.d.ts:1:22 - error TS6053: File 'C:/projects/angular-18/dist/my-lib/public-api.ngtypecheck.d.ts' not found.   

1 /// <reference path="public-api.ngtypecheck.d.ts" />

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

Angular CLI: 18.1.0
Node: 20.15.0
Package Manager: npm 10.7.0
OS: win32 x64

Angular: 18.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0
@angular-devkit/build-angular   18.1.0
@angular-devkit/core            18.1.0
@angular-devkit/schematics      18.1.0
@schematics/angular             18.1.0
ng-packagr                      18.1.0
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.7

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions