Repository navigation
Conversation
e3f08d7 to
55aee27
Compare
17dac6f to
35cf94d
Compare
petebacondarwin
left a comment
There was a problem hiding this comment.
Brilliant work @crisbeto - I made a lot of comments but then there were a LOT of changes.
The main comment appears to be that you have a stylistic approach to asserting that something is not null by casting it:
function foo(): string|null {}
// I know foo will be non-null
const v: string = foo() as string;
I don't like to use this approach for two reasons:
- It is more verbose.
- We already know what the non-null/undefined type is, so this is making the code more brittle to changes to the type, since the type will no longer flow naturally and have to be updated wherever these casts are.
I prefer to simply assert that they are well defined.
function foo(): string|null {}
// I know foo will be non-null
const v: string = foo()!;
There was a problem hiding this comment.
I think the only change needed here is form!:
| @Input() questions: QuestionBase<string>[] | null = []; | |
| form!: FormGroup; | |
| payLoad = ''; | |
| constructor(private qcs: QuestionControlService) { } | |
| constructor(private qcs: QuestionControlService) {} | |
| ngOnInit() { | |
| this.form = this.qcs.toFormGroup(this.questions); | |
| this.form = this.qcs.toFormGroup(this.questions as QuestionBase<string>[]); | |
| @Input() questions: QuestionBase<string>[] = []; | |
| form!: FormGroup; | |
| payLoad = ''; | |
| constructor(private qcs: QuestionControlService) {} | |
| ngOnInit() { | |
| this.form = this.qcs.toFormGroup(this.questions); |
There was a problem hiding this comment.
Hmm, I left a comment on this yesterday but it got lost somehow 🤔. The reason I changed questions to | null is because the example passes them in with an async pipe in one of the templates. The async pipe starts off with a null value.
There was a problem hiding this comment.
In which case we should not be casting it to QuestionBase<string>[] on line 22, right?
|
Regarding the non-null assertions: that's actually what I prefer as well, but there's a lint rule that doesn't allow them. I believe it's one that is turned on by default in the CLI. |
What 😱 ??? That is a bad lint rule. Since tslint is deprecated in v12, we should not be using it for our examples anyway :-) So I would recommend deleting the |
jelbourn
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-for: public-api
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
|
@crisbeto it looks like this PR has all the necessary approvals now :) |
Turns on the `strict` compiler flag and resolves the compilation errors in the various AIO examples. PR Close #41999
This commit aligns the code in `product-alerts.component.ts` with [product-alerts.component.1.ts][1], since both files are supposed to represent the same component in different points in time. It also makes the necessary changes in the respective templates. This is a follow-up to angular#41999. [1]: https://github.com/angular/angular/blob/e86a1d3441b30776e28c0216f00610d6787de297/aio/content/examples/getting-started/src/app/product-alerts/product-alerts.component.1.ts#L18
This commit aligns the code in `product-alerts.component.ts` with [product-alerts.component.1.ts][1], since both files are supposed to represent the same component in different points in time. It also makes the necessary changes in the respective templates. This is a follow-up to #41999. [1]: https://github.com/angular/angular/blob/e86a1d3441b30776e28c0216f00610d6787de297/aio/content/examples/getting-started/src/app/product-alerts/product-alerts.component.1.ts#L18 PR Close #42155
This commit aligns the code in `product-alerts.component.ts` with [product-alerts.component.1.ts][1], since both files are supposed to represent the same component in different points in time. It also makes the necessary changes in the respective templates. This is a follow-up to #41999. [1]: https://github.com/angular/angular/blob/e86a1d3441b30776e28c0216f00610d6787de297/aio/content/examples/getting-started/src/app/product-alerts/product-alerts.component.1.ts#L18 PR Close #42155
…2155) This commit aligns the code in `product-alerts.component.ts` with [product-alerts.component.1.ts][1], since both files are supposed to represent the same component in different points in time. It also makes the necessary changes in the respective templates. This is a follow-up to angular#41999. [1]: https://github.com/angular/angular/blob/e86a1d3441b30776e28c0216f00610d6787de297/aio/content/examples/getting-started/src/app/product-alerts/product-alerts.component.1.ts#L18 PR Close angular#42155
…2155) This commit aligns the code in `product-alerts.component.ts` with [product-alerts.component.1.ts][1], since both files are supposed to represent the same component in different points in time. It also makes the necessary changes in the respective templates. This is a follow-up to angular#41999. [1]: https://github.com/angular/angular/blob/e86a1d3441b30776e28c0216f00610d6787de297/aio/content/examples/getting-started/src/app/product-alerts/product-alerts.component.1.ts#L18 PR Close angular#42155
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Turns on the
strictcompiler flag and resolves the compilation errors in the various AIO examples.Closes #42107