This project was generated with Angular CLI version 18.1.1.
This repository is created in order to provide a minimal reproduction for an issue regarding Angular build
The following error appears when building (ng build
) Angular library projects after upgrading to Angular v18.1:
------------------------------------------------------------------------------
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" />
~~~~~~~~~~~~~~~~~~~~~~
ELIFECYCLE Command failed with exit code 1.
In order for the error to appear:
- There is more than 1 secondary entrypoint
- Angular workspace was created with Angular CLI v17.1.0 or below
- Typescript hasn't been upgraded yet to 5.5.x
In order to generate this repository (see commits):
-
Generate new application with using Angular CLI v18.1.0 (though see below)
pnpm dlx @angular/cli new --package-manager=pnpm \ --no-create-application angular-18.1-typecheck-libs-error
-
Add an
example
library to itpnpm ng g lib example
-
Add a secondary entrypoint as
ng-packagr
docs explain. And a third entrypoint that will use the former.- Using
index.ts
instead ofpublic-api.ts
in order to: - Configure path mappings via
tsconfig.json
for imports
- Using
-
Downgrade Typescript to 5.4 (as if you came from a previous Angular version without support for Typescript 5.5)
pnpm i -D typescript@5.4.x
-
Remove the recently added
skipLibCheck
set totrue
intsconfig.json
- There were no migration schematics for that. So existing projects around created before this change was introduced (
17.1.0
) will have that option enabled.
- There were no migration schematics for that. So existing projects around created before this change was introduced (
-
Run
ng build
. There you have your error 🎉
If you can. The error goes away 🎉 That's the best way to go
To tsconfig.json
. This is the new way to go for projects generated since Angular CLI v17.1.
Then, resulting files containing the invalid reference won't be checked hence the build command will succeed
/// <reference path="metadata-json-resolver.ngtypecheck.d.ts" />
Anyway that's an error, though with that option it's an error that you don't check for
One may be interested in checking those definition files anyway if using extra tooling to be sure shipped definitions are OK (and they aren't indeed due to the bug). For instance, one could want to verify definitions after rolling them up with
dts-bundle-generator
.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The application will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.