-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow auto accessor types to be inferred from their flow types in con…
…structors and static blocks (#59732) Co-authored-by: Ron Buckton <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,314 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/classAccessorInitializationInferenceWithElementAccess1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/compiler/classAccessorInitializationInferenceWithElementAccess1.ts] //// | ||
|
||
//// [classAccessorInitializationInferenceWithElementAccess1.ts] | ||
export class Cls { | ||
accessor x; | ||
accessor y; | ||
accessor z; | ||
|
||
accessor 0; | ||
|
||
constructor(seed: number) { | ||
this['x'] = [seed]; | ||
this['y'] = { seed }; | ||
this['z'] = `${seed}`; | ||
|
||
this[0] = [seed]; | ||
} | ||
} | ||
|
||
|
||
//// [classAccessorInitializationInferenceWithElementAccess1.js] | ||
export class Cls { | ||
accessor x; | ||
accessor y; | ||
accessor z; | ||
accessor 0; | ||
constructor(seed) { | ||
this['x'] = [seed]; | ||
this['y'] = { seed }; | ||
this['z'] = `${seed}`; | ||
this[0] = [seed]; | ||
} | ||
} | ||
|
||
|
||
//// [classAccessorInitializationInferenceWithElementAccess1.d.ts] | ||
export declare class Cls { | ||
accessor x: number[]; | ||
accessor y: { | ||
seed: number; | ||
}; | ||
accessor z: string; | ||
accessor 0: number[]; | ||
constructor(seed: number); | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/classAccessorInitializationInferenceWithElementAccess1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/classAccessorInitializationInferenceWithElementAccess1.ts] //// | ||
|
||
=== classAccessorInitializationInferenceWithElementAccess1.ts === | ||
export class Cls { | ||
>Cls : Symbol(Cls, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 0)) | ||
|
||
accessor x; | ||
>x : Symbol(Cls.x, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 18)) | ||
|
||
accessor y; | ||
>y : Symbol(Cls.y, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 1, 15)) | ||
|
||
accessor z; | ||
>z : Symbol(Cls.z, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 2, 15)) | ||
|
||
accessor 0; | ||
>0 : Symbol(Cls[0], Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 3, 15)) | ||
|
||
constructor(seed: number) { | ||
>seed : Symbol(seed, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 7, 16)) | ||
|
||
this['x'] = [seed]; | ||
>this : Symbol(Cls, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 0)) | ||
>'x' : Symbol(Cls.x, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 18)) | ||
>seed : Symbol(seed, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 7, 16)) | ||
|
||
this['y'] = { seed }; | ||
>this : Symbol(Cls, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 0)) | ||
>'y' : Symbol(Cls.y, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 1, 15)) | ||
>seed : Symbol(seed, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 9, 21)) | ||
|
||
this['z'] = `${seed}`; | ||
>this : Symbol(Cls, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 0)) | ||
>'z' : Symbol(Cls.z, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 2, 15)) | ||
>seed : Symbol(seed, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 7, 16)) | ||
|
||
this[0] = [seed]; | ||
>this : Symbol(Cls, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 0, 0)) | ||
>0 : Symbol(Cls[0], Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 3, 15)) | ||
>seed : Symbol(seed, Decl(classAccessorInitializationInferenceWithElementAccess1.ts, 7, 16)) | ||
} | ||
} | ||
|
85 changes: 85 additions & 0 deletions
85
tests/baselines/reference/classAccessorInitializationInferenceWithElementAccess1.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//// [tests/cases/compiler/classAccessorInitializationInferenceWithElementAccess1.ts] //// | ||
|
||
=== classAccessorInitializationInferenceWithElementAccess1.ts === | ||
export class Cls { | ||
>Cls : Cls | ||
> : ^^^ | ||
|
||
accessor x; | ||
>x : number[] | ||
> : ^^^^^^^^ | ||
|
||
accessor y; | ||
>y : { seed: number; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
accessor z; | ||
>z : string | ||
> : ^^^^^^ | ||
|
||
accessor 0; | ||
>0 : number[] | ||
> : ^^^^^^^^ | ||
|
||
constructor(seed: number) { | ||
>seed : number | ||
> : ^^^^^^ | ||
|
||
this['x'] = [seed]; | ||
>this['x'] = [seed] : number[] | ||
> : ^^^^^^^^ | ||
>this['x'] : number[] | ||
> : ^^^^^^^^ | ||
>this : this | ||
> : ^^^^ | ||
>'x' : "x" | ||
> : ^^^ | ||
>[seed] : number[] | ||
> : ^^^^^^^^ | ||
>seed : number | ||
> : ^^^^^^ | ||
|
||
this['y'] = { seed }; | ||
>this['y'] = { seed } : { seed: number; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>this['y'] : { seed: number; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>this : this | ||
> : ^^^^ | ||
>'y' : "y" | ||
> : ^^^ | ||
>{ seed } : { seed: number; } | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>seed : number | ||
> : ^^^^^^ | ||
|
||
this['z'] = `${seed}`; | ||
>this['z'] = `${seed}` : string | ||
> : ^^^^^^ | ||
>this['z'] : string | ||
> : ^^^^^^ | ||
>this : this | ||
> : ^^^^ | ||
>'z' : "z" | ||
> : ^^^ | ||
>`${seed}` : string | ||
> : ^^^^^^ | ||
>seed : number | ||
> : ^^^^^^ | ||
|
||
this[0] = [seed]; | ||
>this[0] = [seed] : number[] | ||
> : ^^^^^^^^ | ||
>this[0] : number[] | ||
> : ^^^^^^^^ | ||
>this : this | ||
> : ^^^^ | ||
>0 : 0 | ||
> : ^ | ||
>[seed] : number[] | ||
> : ^^^^^^^^ | ||
>seed : number | ||
> : ^^^^^^ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.