question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Library compilation fails with compiler-cli v12.2.7

See original GitHub issue

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

compiler-cli

Is this a regression?

Yes

Description

Some changes in v12.2.7 of compiler-cli (type-checker fix from PR #43511, I believe), make my library compilation fail with the “Unable to write a reference to <SomeTypeName>” error.

The error occurs during compilation time and only if there is at least one usage of some component with type parameters, from another library, exists. Those type parameters are custom ones — not the built-in TS types, which seem to work fine.

Rolling back compiler-cli package to v12.2.6 makes compilation to work again.


Example:

  • my-lib1
export type MyValue<T, K extends keyof T = keyof T> = T | T[K];
export type MyValueArray<T> = T | T[];

@Component({
  selector: 'my-comp',
  template: `
    {{ value }}
  `,
})
export class MyComponent<T = any, V extends MyValue<T> = any> {
  @Input() data: T[];
  @Input() value: V;
}
  • my-lib2
@Component({
  selector: 'some-comp',
  template: `
    <my-comp [data]="[]" [value]="null"></my-comp>
  `,
})
export class SomeComponent {
   // empty
}

Then compilation of my-lib2 fails with the message:

Unable to write a reference to MyValue in my-lib1/.../my-component.d.ts from my-lib/.../some-component.ngtypecheck.ts.

Please provide a link to a minimal reproduction of the bug

https://github.com/amariq/angular-pr43511-bug

Please provide the exception or error you saw

✖ Compiling with Angular sources in Ivy partial compilation mode.
Unable to write a reference to <SomeInterface> in <some-lib>/.../<some-component>.d.ts from <my-lib>/.../<my-component>.ngtypecheck.ts

Please provide the environment you discovered this bug in

Angular CLI: 12.2.7
Node: 16.10.0
Package Manager: 7.24.1
OS: Windows 10 x64

Angular: 12.2.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy: "partial"


Package                                             Version
---------------------------------------------------------
@angular-devkit/build-angular                       12.2.7
@angular/animations                                 12.2.7
@angular/cli                                        12.2.7
@angular/common                                     12.2.7
@angular/compiler-cli                               12.2.7
@angular/compiler                                   12.2.7
@angular/core                                       12.2.7
@angular/forms                                      12.2.7
@angular/platform-browser-dynamic                   12.2.7
@angular/platform-browser                           12.2.7
@angular/router                                     12.2.7
ng-packagr                                          12.2.2
rxjs                                    	    6.6.7
tslib                                               2.3.1
typescript                                  	    4.3.5
zone.js                                 	    0.11.4

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
JoostKcommented, Sep 28, 2021

I’m sorry I haven’t had time to look at your repro yet.

You should be able to workaround by using an import in the extends clause:

export class MyComponent<T = any, V extends import('./value-type-file').MyValue<T> = any>

If at least one of such import expressions is used, the compiler will not attempt to create any references at all.

0reactions
angular-automatic-lock-bot[bot]commented, Feb 6, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular 13 ng build library fails (ivy partial compilation mode)
I try ng build my-lib and get the below error. ✖ Compiling with Angular sources in Ivy partial compilation mode. Transform failed with ......
Read more >
Luminous - Ceph Documentation
build/ops: Boost system library is no longer required to compile and link example librados program (issue#25054, pr#23202, Nathan Cutler).
Read more >
CUDA Compiler Driver NVCC - NVIDIA Documentation Center
It allows running the compiled and linked executable without having to explicitly set the library path to the CUDA dynamic libraries. Unless a...
Read more >
User's Guide for Quantum ESPRESSO (v.6.1)
This guide gives a general overview of the contents and of the installation of Quantum. ESPRESSO (opEn-Source Package for Research in Electronic Structure, ......
Read more >
Spring Boot Reference Documentation
You can use Spring Boot in the same way as any standard Java library. ... name="spring-boot-starter" rev="${spring-boot.version}" conf="compile" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found