Directives/components with generic type parameters may always be considered affected, even when not changed
See original GitHub issueπ Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
Is this a regression?
Yes, the previous version in which this bug was not present was: ....Description
I've created empty angular app with two lazy loaded modules, first module (M1) has one component with no dependencies second one (M2) imports our (quite big) UI libraryimport { Component, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
@Component({
template: `M1`,
})
export class M1Component {}
@NgModule({
declarations: [M1Component],
imports: [RouterModule.forChild([{ path: '', component: M1Component }])],
})
export class M1Module {
constructor() {
console.log(2);
}
}
import { Component, NgModule } from "@angular/core";
import { RouterModule } from "@angular/router";
import { ButtonModule } from "@xyz/user-interface"; <--- this is path mapped in tsconfig to TS files
@Component({
template: `M2`
})
export class M2Component {}
@NgModule({
declarations: [M2Component],
imports: [
ButtonModule,
RouterModule.forChild([
{path: '', component: M2Component}
])
]
})
export class M2Module {}
After changing console.log(x)
to console.log(y)
in M1Module IncrementalCompilation
marks this files as physicallyChangedTsFiles
apps/build-test/src/app/m1.module.ts
libs/user-interface/src/lib/forms/select/select.component.ts
libs/user-interface/src/lib/data-table/data-table/data-table.component.ts
then this is marked as logicallyChangedTsFiles
apps/build-test/src/app/m1.module.ts
libs/user-interface/src/lib/forms/select/select.module.ts
libs/user-interface/src/lib/data-table/data-table.module.ts
libs/user-interface/src/lib/forms/select/select.component.ts
libs/user-interface/src/lib/data-table/data-table/data-table.component.ts
and then in AngularWebpackPlugin.updateAotProgram
I have affectedFiles
apps/build-test/src/app/m1.module.ts
libs/user-interface/src/lib/core/overlay/generic-component-type.ts
libs/user-interface/src/lib/core/overlay/position/position-strategy.ts
libs/user-interface/src/lib/core/overlay/scroll/interface.ts
libs/user-interface/src/lib/icons-container/icons.type.ts
libs/user-interface/src/lib/common/avatar/avatar.types.ts
libs/worker/src/lib/helpers.ts
libs/worker/src/lib/interfaces.ts
libs/worker/src/lib/common.worker.ts
libs/worker/src/index.ts
libs/user-interface/src/lib/dialog/dialog.component.ts
libs/user-interface/src/lib/pdf-viewer/pdf-viewer.types.ts
libs/user-interface/src/lib/forms/file-upload/attachment-item/attachment-item.types.ts
libs/user-interface/src/lib/forms/file-upload/attachment-placeloader/attachment-placeloader.types.ts
libs/user-interface/src/lib/forms/select/select.component.ts
libs/user-interface/src/lib/forms/select/select.module.ts
libs/user-interface/src/lib/data-table/data-table/data-table.component.ts
libs/user-interface/src/lib/data-table/data-table.module.ts
In this compilation typescript state.changedFilesSet
has only one entry which is
apps/build-test/src/app/m1.module.ts
π¬ Minimal Reproduction
π₯ Exception or Error
π Your Environment
Angular CLI: 12.0.3
Node: 14.16.1
Package Manager: yarn 1.21.1
OS: darwin x64
Angular: 12.0.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1200.3
@angular-devkit/build-angular 12.0.3
@angular-devkit/build-optimizer 0.1200.3
@angular-devkit/build-webpack 0.1200.3
@angular-devkit/core 12.0.3
@angular-devkit/schematics 12.0.3
@angular/benchpress 0.2.1
@ngtools/webpack 12.0.3
@schematics/angular 12.0.3
ng-packagr 12.0.3
rxjs 6.6.3
typescript 4.2.4
Anything else relevant? Same thing happens on 11.2 exactly the same files are marked as affected, I guess it will be hard to debug without reproduce, maybe you can tell what might be the cause of this behaviour? Is there anything that I should check?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Does Angular Support Generic Component Types?
You make a component generic by providing a generic type parameter within angle brackets as part of the class declaration: GridComponent<TData>Β ...
Read more >Restrictions on Generics (The Javaβ’ Tutorials > Learning the ...
Cannot Instantiate Generic Types with Primitive Types; Cannot Create Instances of Type Parameters; Cannot Declare Static Fields Whose Types are Type ...
Read more >Functional React components with generic props in TypeScript
In this article, we explore writing functional React components with TypeScript using generic props. By doing so, we can create reusable andΒ ...
Read more >Breaking Changes Β· microsoft/TypeScript Wiki - GitHub
Generic type parameters are now narrowed. Recommendation Either declare your locals to be a specific type and not the generic type parameter,Β ...
Read more >Documentation - Generics - TypeScript
Generic classes are only generic over their instance side rather than their static side, so when working with classes, static members can not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, so what is happening here is that the generic type refers to the
SomeInterface
type, which is not exported. Consequently, the template type checker generates the type constructor forSomeRandomComponent
in the original source file. Then, the next incremental compilation detects that the original source file is not the same as the prior one as that one had been augmented with the type constructor.Iβm marking this as P4 given that itβs not a correctness issue.
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.