Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implicitly inferred type from another entry point generates wrong import pathes in compiled library #2403

@paulheising

Description

@paulheising

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

Setup:

  • Library with at least two entry points, call them "entry2" and "entry3"
  • entry3 exports an interface
  • entry2 uses that interface (imports explicitly) in any file
  • Another file in entry2 references a value typed from the interface in entry3. Thanks to TypeScript type infering, the interface does not need to be imported in that file, as TypeScript can automatically infer the type from the assignment.
  • However what looks right and compiles fine leads to incorrect pathes in the compiled library: The d.ts file of the file containing the implicit reference to the interface looks something like this: "dist/entry2/interface"
  • This is a problem when publishing the library, because you won't have the library in that path when you installed it. This will lead to build errors in the consuming application

This appears to be a new problem in Angular 14 / ng-packagr 14

We used to have a setup like this for months now, and recently tried to upgrade to ng 14, which we can't until that bug is fixed or a workaround is found

How To Reproduce

See this demo repository, that contains a minimal reproduction example for the issue. You can find a setup similar to the one described above, only entry points "entry2" and "entry3" are relevant, just ignore the app and the main entry point of the lib

Expected Behaviour

The compiled library should always import from the public import path, like it used to did prior to ng 14

Version Information

ng-packagr:            14.1.0
@angular/compiler:     14.1.2
rollup:                2.78.0
typescript:            4.7.4
node: v16.16.0
npm: 8.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions