forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elt access assignment uses declared, not narrowed type (microsoft#27574)
I forgot to do this in microsoft#26424. Fixes microsoft#27557 Fixes microsoft#27412
- Loading branch information
Showing
8 changed files
with
108 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//// [controlFlowElementAccess.ts] | ||
let x: { o: boolean } = { o: false } | ||
if (x['o'] === false) { | ||
x['o'] = true | ||
} | ||
|
||
const y: [number, number] = [0, 0]; | ||
if (y[0] === 0) { | ||
y[0] = -1; | ||
} | ||
|
||
|
||
//// [controlFlowElementAccess.js] | ||
var x = { o: false }; | ||
if (x['o'] === false) { | ||
x['o'] = true; | ||
} | ||
var y = [0, 0]; | ||
if (y[0] === 0) { | ||
y[0] = -1; | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/controlFlowElementAccess.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,27 @@ | ||
=== tests/cases/conformance/controlFlow/controlFlowElementAccess.ts === | ||
let x: { o: boolean } = { o: false } | ||
>x : Symbol(x, Decl(controlFlowElementAccess.ts, 0, 3)) | ||
>o : Symbol(o, Decl(controlFlowElementAccess.ts, 0, 8)) | ||
>o : Symbol(o, Decl(controlFlowElementAccess.ts, 0, 25)) | ||
|
||
if (x['o'] === false) { | ||
>x : Symbol(x, Decl(controlFlowElementAccess.ts, 0, 3)) | ||
>'o' : Symbol(o, Decl(controlFlowElementAccess.ts, 0, 8)) | ||
|
||
x['o'] = true | ||
>x : Symbol(x, Decl(controlFlowElementAccess.ts, 0, 3)) | ||
>'o' : Symbol(o, Decl(controlFlowElementAccess.ts, 0, 8)) | ||
} | ||
|
||
const y: [number, number] = [0, 0]; | ||
>y : Symbol(y, Decl(controlFlowElementAccess.ts, 5, 5)) | ||
|
||
if (y[0] === 0) { | ||
>y : Symbol(y, Decl(controlFlowElementAccess.ts, 5, 5)) | ||
>0 : Symbol(0) | ||
|
||
y[0] = -1; | ||
>y : Symbol(y, Decl(controlFlowElementAccess.ts, 5, 5)) | ||
>0 : Symbol(0) | ||
} | ||
|
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/conformance/controlFlow/controlFlowElementAccess.ts === | ||
let x: { o: boolean } = { o: false } | ||
>x : { o: boolean; } | ||
>o : boolean | ||
>{ o: false } : { o: false; } | ||
>o : false | ||
>false : false | ||
|
||
if (x['o'] === false) { | ||
>x['o'] === false : boolean | ||
>x['o'] : boolean | ||
>x : { o: boolean; } | ||
>'o' : "o" | ||
>false : false | ||
|
||
x['o'] = true | ||
>x['o'] = true : true | ||
>x['o'] : boolean | ||
>x : { o: boolean; } | ||
>'o' : "o" | ||
>true : true | ||
} | ||
|
||
const y: [number, number] = [0, 0]; | ||
>y : [number, number] | ||
>[0, 0] : [number, number] | ||
>0 : 0 | ||
>0 : 0 | ||
|
||
if (y[0] === 0) { | ||
>y[0] === 0 : boolean | ||
>y[0] : number | ||
>y : [number, number] | ||
>0 : 0 | ||
>0 : 0 | ||
|
||
y[0] = -1; | ||
>y[0] = -1 : -1 | ||
>y[0] : number | ||
>y : [number, number] | ||
>0 : 0 | ||
>-1 : -1 | ||
>1 : 1 | ||
} | ||
|
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
9 changes: 9 additions & 0 deletions
9
tests/cases/conformance/controlFlow/controlFlowElementAccess.ts
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,9 @@ | ||
let x: { o: boolean } = { o: false } | ||
if (x['o'] === false) { | ||
x['o'] = true | ||
} | ||
|
||
const y: [number, number] = [0, 0]; | ||
if (y[0] === 0) { | ||
y[0] = -1; | ||
} |