feat(core): add dynamic queries schematic (#32231)
Adds a schematic that will remove the explicit `static: false` flag from dynamic queries. E.g. ```ts import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core'; @Directive() export class MyDirective { @ViewChild('child', { static: false }) child: any; @ViewChild('secondChild', { read: ElementRef, static: false }) secondChild: ElementRef; @ContentChild('thirdChild', { static: false }) thirdChild: any; } ``` ```ts import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core'; @Directive() export class MyDirective { @ViewChild('child') child: any; @ViewChild('secondChild', { read: ElementRef }) secondChild: ElementRef; @ContentChild('thirdChild') thirdChild: any; } ``` PR Close #32231
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
## Dynamic queries migration
|
||||
|
||||
Automatically migrates dynamic queries to remove their `static` flag. This flag will no
|
||||
longer be necessary in version 9 for dynamic queries, as `false` is the default value.
|
||||
|
||||
#### Before
|
||||
```ts
|
||||
import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core';
|
||||
|
||||
@Directive()
|
||||
export class MyDirective {
|
||||
@ViewChild('child', { static: false }) child: any;
|
||||
@ViewChild('secondChild', { read: ElementRef, static: false }) secondChild: ElementRef;
|
||||
@ContentChild('thirdChild', { static: false }) thirdChild: any;
|
||||
}
|
||||
```
|
||||
|
||||
#### After
|
||||
```ts
|
||||
import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core';
|
||||
|
||||
@Directive()
|
||||
export class MyDirective {
|
||||
@ViewChild('child') child: any;
|
||||
@ViewChild('secondChild', { read: ElementRef }) secondChild: ElementRef;
|
||||
@ContentChild('thirdChild') thirdChild: any;
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user