Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add dynamic queries schematic #32231

Closed
wants to merge 2 commits into from

Conversation

@crisbeto
Copy link
Member

commented Aug 21, 2019

Adds a schematic that will remove the explicit static: false flag from dynamic queries. E.g.

Before

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

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;
}
@googlebot googlebot added the cla: yes label Aug 21, 2019
@crisbeto crisbeto force-pushed the crisbeto:FW-1512/dynamic-queries branch from fea5add to 740e617 Aug 21, 2019
@crisbeto crisbeto marked this pull request as ready for review Aug 21, 2019
@crisbeto crisbeto requested a review from angular/fw-core as a code owner Aug 21, 2019
@ngbot ngbot bot added this to the needsTriage milestone Aug 21, 2019
Copy link
Member

left a comment

LGTM 🎉

Just to mention one edge case: If someone has the query options set through a variable declaration, the migration will currently do nothing. It could show a message though that the given query should be checked manually. Just mentioning this as it could make the migration more robust.

Not saying we should do it; just bringing this up for awareness; we only saw these type of queries rarely in the static-query migration.

@crisbeto crisbeto force-pushed the crisbeto:FW-1512/dynamic-queries branch from 740e617 to 66d2474 Aug 28, 2019
@crisbeto crisbeto removed their assignment Aug 28, 2019
@crisbeto

This comment has been minimized.

Copy link
Member Author

commented Aug 28, 2019

The feedback has been addressed @kara.

@kara
kara approved these changes Sep 4, 2019
Copy link
Contributor

left a comment

LGTM, once last comment is addressed

crisbeto added 2 commits Aug 21, 2019
Adds a schematic that will remove the explicit `static: false` flag from dynamic queries. E.g.

#### 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;
}
```
@crisbeto crisbeto force-pushed the crisbeto:FW-1512/dynamic-queries branch from 66d2474 to dd749d2 Sep 4, 2019
@crisbeto

This comment has been minimized.

Copy link
Member Author

commented Sep 4, 2019

Rebased and addressed the last comment @kara.

@crisbeto crisbeto removed their assignment Sep 4, 2019
@kara kara removed the PR action: review label Sep 10, 2019
@kara

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2019

@matsko matsko closed this in f5982fd Sep 11, 2019
arnehoek added a commit to arnehoek/angular that referenced this pull request Sep 26, 2019
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 angular#32231
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

commented Oct 12, 2019

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.