Skip to content

ngtypecheck reference added in compiled TS files for libraries with multiple secondary entrypoints #57135

@davidlj95

Description

@davidlj95

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

compiler-cli

Is this a regression?

No

Description

See related issue

After upgrading to Angular v18.1.0, built Typescript definition files *.d.ts include a reference to ngtypecheck.d.ts files at the top of those. For instance:

/// <reference path="index.ngtypecheck.d.ts" />

Seems this only appears for secondary entrypoints of libraries though.

This is not an issue when building if you have skipLibCheck: true in tsconfig.json. Which was introduced in Angular CLI v17.1 AFAIK. However, those references point to missing files, so they're not valid anyway.

If coming from a workspace pre v17.1, that option isn't there and ng build fails (see below).

Please provide a link to a minimal reproduction of the bug

https://github.com/davidlj95/angular-18.1-typecheck-libs-error

Please provide the exception or error you saw

------------------------------------------------------------------------------
Building entry point 'example/tertiary-entrypoint'
------------------------------------------------------------------------------
✖ Compiling with Angular sources in Ivy partial compilation mode.
dist/example/secondary-entrypoint/index.d.ts:1:22 - error TS6053: File '/Users/davidlj95/Code/git/tmp/angular-18.1-typecheck-libs-error/dist/example/secondary-entrypoint/index.ngtypecheck.d.ts' not found.

1 /// <reference path="index.ngtypecheck.d.ts" />
                       ~~~~~~~~~~~~~~~~~~~~~~

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

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 18.1.2
Node: 20.12.0
Package Manager: pnpm 9.6.0
OS: darwin arm64

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

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

Anything else?

The fix for the related issue was shipped in Angular v18.1.1. Used that version to generate the minimal reproduction repository, but the issue is still there.

If upgrading Typescript to 5.5.x as mentioned in the related issue, the issue goes away (no reference in definition files).

If downgrading ng-packagr to 18.0.0, issue is still there

Metadata

Metadata

Assignees

Labels

area: compilerIssues related to `ngc`, Angular's template compilerregressionIndicates than the issue relates to something that worked in a previous versionstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions