Skip to content

Generic component inheritance fails in AOT since v12 upgrade #43383

@jdussouillez

Description

@jdussouillez

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

core

Is this a regression?

Yes

Description

Since I upgraded to v12.2.4 (from 11.2.14), my build fails because of a generic abstract component who's inherited by 2 other components. The build fails with the error "Failed to find exported name of node" on one of my model class used in the generic.

I found a few different ways to make this compile without the error :

  • Remove the component inheritance or remove the generic in the CommonComponent
  • Disable the AOT mode in the angular.json configuration file
  • Disable the fullTemplateTypeCheck, strictInjectionParameters and strictTemplates options in the tsconfig.json configuration file

To reproduce the issue :

git clone https://github.com/jdussouillez/angular-test.git \
    && cd angular-test \
    && git checkout bugs/generic-component-inheritance-aot-v12 \
    && npm ci \
    && ng build

Please provide a link to a minimal reproduction of the bug

https://github.com/jdussouillez/angular-test/tree/bugs/generic-component-inheritance-aot-v12

Please provide the exception or error you saw

Compiling @angular/platform-browser-dynamic : es2015 as esm2015
(node:21312) UnhandledPromiseRejectionWarning: Error: Failed to find exported name of node (export class SyncableEntity extends com.github.jdussouillez.bean.Entity<string> {
        lastUpdate?: Date;
    }) in '/home/junior/test/angular-test/src/app/shared/models/model.ts'.
    at Object.findExportedNameOfNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/find_export.js:56:19)
    at RelativePathStrategy.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:286:38)
    at ReferenceEmitter.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:72:44)
    at TypeCheckFile.Environment.referenceType (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:133:42)
    at TypeEmitter.emitReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:97:63)
    at TypeEmitter.emitTypeReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:152:40)
    at visitNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:116:38)
    at Object.visitNode (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:83594:23)
    at /home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:133:52
    at transformation (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:102910:24)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21312) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21312) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
⠙ Generating browser application bundles (phase: building)...(node:21312) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
✔ Browser application bundle generation complete.

./node_modules/@angular-devkit/build-angular/src/webpack/es5-polyfills.js - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Failed to find exported name of node (export class SyncableEntity extends com.github.jdussouillez.bean.Entity<string> {
        lastUpdate?: Date;
    }) in '/home/junior/test/angular-test/src/app/shared/models/model.ts'.
    at Object.findExportedNameOfNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/find_export.js:56:19)
    at RelativePathStrategy.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:286:38)
    at ReferenceEmitter.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:72:44)
    at TypeCheckFile.Environment.referenceType (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:133:42)
    at TypeEmitter.emitReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:97:63)
    at TypeEmitter.emitTypeReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:152:40)
    at visitNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:116:38)
    at Object.visitNode (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:83594:23)
    at /home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:133:52
    at transformation (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:102910:24)

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Failed to find exported name of node (export class SyncableEntity extends com.github.jdussouillez.bean.Entity<string> {
        lastUpdate?: Date;
    }) in '/home/junior/test/angular-test/src/app/shared/models/model.ts'.
    at Object.findExportedNameOfNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/find_export.js:56:19)
    at RelativePathStrategy.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:286:38)
    at ReferenceEmitter.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:72:44)
    at TypeCheckFile.Environment.referenceType (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:133:42)
    at TypeEmitter.emitReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:97:63)
    at TypeEmitter.emitTypeReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:152:40)
    at visitNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:116:38)
    at Object.visitNode (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:83594:23)
    at /home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:133:52
    at transformation (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:102910:24)

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Failed to find exported name of node (export class SyncableEntity extends com.github.jdussouillez.bean.Entity<string> {
        lastUpdate?: Date;
    }) in '/home/junior/test/angular-test/src/app/shared/models/model.ts'.
    at Object.findExportedNameOfNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/find_export.js:56:19)
    at RelativePathStrategy.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:286:38)
    at ReferenceEmitter.emit (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:72:44)
    at TypeCheckFile.Environment.referenceType (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:133:42)
    at TypeEmitter.emitReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:97:63)
    at TypeEmitter.emitTypeReference (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:152:40)
    at visitNode (/home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:116:38)
    at Object.visitNode (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:83594:23)
    at /home/junior/test/angular-test/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:133:52
    at transformation (/home/junior/test/angular-test/node_modules/typescript/lib/typescript.js:102910:24)

Please provide the environment you discovered this bug in

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

Angular CLI: 12.2.4
Node: 14.17.1
Package Manager: npm 7.19.0
OS: linux x64

Angular: 12.2.4
... cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.4
@angular-devkit/build-angular   12.2.4
@angular-devkit/core            12.2.4
@angular-devkit/schematics      12.2.4
@schematics/angular             12.2.4
rxjs                            6.6.3
typescript                      4.3.5

Anything else?

I tried some other Angular versions but it doesn't work either (same error) :

  • 12.1.0
  • 13.0.0-next.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: 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