mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(migrations): handle safe property reads in signal input migration (#57318)
As of this commit, the migration will also inspect safe property reads and migrate them, if they reference an input that is being migrated. PR Close #57318
This commit is contained in:
committed by
Andrew Kushnir
parent
6b7b44db98
commit
52673e6420
+6
-2
@@ -17,6 +17,7 @@ import {
|
||||
PropertyRead,
|
||||
PropertyWrite,
|
||||
RecursiveAstVisitor,
|
||||
SafePropertyRead,
|
||||
ThisReceiver,
|
||||
TmplAstBoundAttribute,
|
||||
TmplAstBoundEvent,
|
||||
@@ -274,12 +275,15 @@ export class TemplateExpressionReferenceVisitor<ExprContext> extends RecursiveAs
|
||||
super.visitLiteralMap(ast, context);
|
||||
}
|
||||
|
||||
// TODO: Consider safe property reads/writes.
|
||||
|
||||
override visitPropertyRead(ast: PropertyRead) {
|
||||
this._inspectPropertyAccess(ast);
|
||||
super.visitPropertyRead(ast, null);
|
||||
}
|
||||
override visitSafePropertyRead(ast: SafePropertyRead) {
|
||||
this._inspectPropertyAccess(ast);
|
||||
super.visitPropertyRead(ast, null);
|
||||
}
|
||||
|
||||
override visitPropertyWrite(ast: PropertyWrite) {
|
||||
this._inspectPropertyAccess(ast);
|
||||
super.visitPropertyWrite(ast, null);
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// tslint:disable
|
||||
|
||||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
{{bla?.myInput}}
|
||||
`,
|
||||
})
|
||||
class WithSafePropertyReads {
|
||||
@Input() myInput = 0;
|
||||
|
||||
bla: this | undefined = this;
|
||||
}
|
||||
@@ -751,6 +751,30 @@ import { input } from '@angular/core';
|
||||
class Required {
|
||||
simpleInput = input.required<string>();
|
||||
}
|
||||
@@@@@@ safe_property_reads.ts @@@@@@
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// tslint:disable
|
||||
|
||||
import { Component, input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
{{bla?.myInput()}}
|
||||
`,
|
||||
})
|
||||
class WithSafePropertyReads {
|
||||
myInput = input(0);
|
||||
|
||||
bla: this | undefined = this;
|
||||
}
|
||||
@@@@@@ scope_sharing.ts @@@@@@
|
||||
|
||||
// tslint:disable
|
||||
|
||||
@@ -751,6 +751,30 @@ import { input } from '@angular/core';
|
||||
class Required {
|
||||
simpleInput = input.required<string>();
|
||||
}
|
||||
@@@@@@ safe_property_reads.ts @@@@@@
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// tslint:disable
|
||||
|
||||
import { Component, input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
{{bla?.myInput()}}
|
||||
`,
|
||||
})
|
||||
class WithSafePropertyReads {
|
||||
myInput = input(0);
|
||||
|
||||
bla: this | undefined = this;
|
||||
}
|
||||
@@@@@@ scope_sharing.ts @@@@@@
|
||||
|
||||
// tslint:disable
|
||||
|
||||
Reference in New Issue
Block a user