-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Do not report errors of implicit any during contexual type checking of binding pattern element #8241
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
Merged
Merged
Do not report errors of implicit any during contexual type checking of binding pattern element #8241
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dfee3de
Add test case for #8229
sheetalkamat 90d347e
Do not report errors during contextual typecheck
sheetalkamat 34f7f2c
Handle the scenario when let [a=undefined]=[]
sheetalkamat 02f908a
Merge branch 'master' into noImplicitAnyDestructuring
sheetalkamat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js
This file contains hidden or 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,25 @@ | ||
//// [noImplicitAnyDestructuringVarDeclaration2.ts] | ||
let [a, b, c] = [1, 2, 3]; // no error | ||
let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error | ||
let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error | ||
let [a3 = <any>undefined, b3 = <any>null, c3 = <any>undefined] = [1, 2, 3]; // no error | ||
let [a4] = [<any>undefined], [b4] = [<any>null], c4 = <any>undefined, d4 = <any>null; // no error | ||
|
||
let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error | ||
let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error | ||
let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error | ||
let {x3 = <any>undefined, y3 = <any>null, z3 = <any>undefined} = { x3: 1, y3: 2, z3: 3 }; // no error | ||
let {x4} = { x4: <any>undefined }, {y4} = { y4: <any>null }; // no error | ||
|
||
|
||
//// [noImplicitAnyDestructuringVarDeclaration2.js] | ||
var _a = [1, 2, 3], a = _a[0], b = _a[1], c = _a[2]; // no error | ||
var _b = [1, 2, 3], _c = _b[0], a1 = _c === void 0 ? 10 : _c, _d = _b[1], b1 = _d === void 0 ? 10 : _d, _e = _b[2], c1 = _e === void 0 ? 10 : _e; // no error | ||
var _f = [1, 2, 3], _g = _f[0], a2 = _g === void 0 ? undefined : _g, _h = _f[1], b2 = _h === void 0 ? undefined : _h, _j = _f[2], c2 = _j === void 0 ? undefined : _j; // no error | ||
var _k = [1, 2, 3], _l = _k[0], a3 = _l === void 0 ? undefined : _l, _m = _k[1], b3 = _m === void 0 ? null : _m, _o = _k[2], c3 = _o === void 0 ? undefined : _o; // no error | ||
var a4 = [undefined][0], b4 = [null][0], c4 = undefined, d4 = null; // no error | ||
var _p = { x: 1, y: 2, z: 3 }, x = _p.x, y = _p.y, z = _p.z; // no error | ||
var _q = { x1: 1, y1: 2, z1: 3 }, _r = _q.x1, x1 = _r === void 0 ? 10 : _r, _s = _q.y1, y1 = _s === void 0 ? 10 : _s, _t = _q.z1, z1 = _t === void 0 ? 10 : _t; // no error | ||
var _u = { x2: 1, y2: 2, z2: 3 }, _v = _u.x2, x2 = _v === void 0 ? undefined : _v, _w = _u.y2, y2 = _w === void 0 ? undefined : _w, _x = _u.z2, z2 = _x === void 0 ? undefined : _x; // no error | ||
var _y = { x3: 1, y3: 2, z3: 3 }, _z = _y.x3, x3 = _z === void 0 ? undefined : _z, _0 = _y.y3, y3 = _0 === void 0 ? null : _0, _1 = _y.z3, z3 = _1 === void 0 ? undefined : _1; // no error | ||
var x4 = { x4: undefined }.x4, y4 = { y4: null }.y4; // no error |
78 changes: 78 additions & 0 deletions
78
tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols
This file contains hidden or 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,78 @@ | ||
=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === | ||
let [a, b, c] = [1, 2, 3]; // no error | ||
>a : Symbol(a, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 5)) | ||
>b : Symbol(b, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 7)) | ||
>c : Symbol(c, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 10)) | ||
|
||
let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error | ||
>a1 : Symbol(a1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 5)) | ||
>b1 : Symbol(b1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 13)) | ||
>c1 : Symbol(c1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 22)) | ||
|
||
let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error | ||
>a2 : Symbol(a2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 5)) | ||
>undefined : Symbol(undefined) | ||
>b2 : Symbol(b2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 20)) | ||
>undefined : Symbol(undefined) | ||
>c2 : Symbol(c2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 36)) | ||
>undefined : Symbol(undefined) | ||
|
||
let [a3 = <any>undefined, b3 = <any>null, c3 = <any>undefined] = [1, 2, 3]; // no error | ||
>a3 : Symbol(a3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 5)) | ||
>undefined : Symbol(undefined) | ||
>b3 : Symbol(b3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 25)) | ||
>c3 : Symbol(c3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 41)) | ||
>undefined : Symbol(undefined) | ||
|
||
let [a4] = [<any>undefined], [b4] = [<any>null], c4 = <any>undefined, d4 = <any>null; // no error | ||
>a4 : Symbol(a4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 5)) | ||
>undefined : Symbol(undefined) | ||
>b4 : Symbol(b4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 30)) | ||
>c4 : Symbol(c4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 48)) | ||
>undefined : Symbol(undefined) | ||
>d4 : Symbol(d4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 69)) | ||
|
||
let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error | ||
>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 5)) | ||
>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 7)) | ||
>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 10)) | ||
>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 17)) | ||
>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 23)) | ||
>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 29)) | ||
|
||
let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error | ||
>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 5)) | ||
>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 13)) | ||
>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 22)) | ||
>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 35)) | ||
>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 42)) | ||
>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 49)) | ||
|
||
let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error | ||
>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 5)) | ||
>undefined : Symbol(undefined) | ||
>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 20)) | ||
>undefined : Symbol(undefined) | ||
>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 36)) | ||
>undefined : Symbol(undefined) | ||
>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 56)) | ||
>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 63)) | ||
>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 70)) | ||
|
||
let {x3 = <any>undefined, y3 = <any>null, z3 = <any>undefined} = { x3: 1, y3: 2, z3: 3 }; // no error | ||
>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 5)) | ||
>undefined : Symbol(undefined) | ||
>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 25)) | ||
>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 41)) | ||
>undefined : Symbol(undefined) | ||
>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 66)) | ||
>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 73)) | ||
>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 80)) | ||
|
||
let {x4} = { x4: <any>undefined }, {y4} = { y4: <any>null }; // no error | ||
>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 5)) | ||
>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 12)) | ||
>undefined : Symbol(undefined) | ||
>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 36)) | ||
>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 43)) | ||
|
137 changes: 137 additions & 0 deletions
137
tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types
This file contains hidden or 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,137 @@ | ||
=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === | ||
let [a, b, c] = [1, 2, 3]; // no error | ||
>a : number | ||
>b : number | ||
>c : number | ||
>[1, 2, 3] : [number, number, number] | ||
>1 : number | ||
>2 : number | ||
>3 : number | ||
|
||
let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error | ||
>a1 : number | ||
>10 : number | ||
>b1 : number | ||
>10 : number | ||
>c1 : number | ||
>10 : number | ||
>[1, 2, 3] : [number, number, number] | ||
>1 : number | ||
>2 : number | ||
>3 : number | ||
|
||
let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error | ||
>a2 : number | ||
>undefined : undefined | ||
>b2 : number | ||
>undefined : undefined | ||
>c2 : number | ||
>undefined : undefined | ||
>[1, 2, 3] : [number, number, number] | ||
>1 : number | ||
>2 : number | ||
>3 : number | ||
|
||
let [a3 = <any>undefined, b3 = <any>null, c3 = <any>undefined] = [1, 2, 3]; // no error | ||
>a3 : number | ||
><any>undefined : any | ||
>undefined : undefined | ||
>b3 : number | ||
><any>null : any | ||
>null : null | ||
>c3 : number | ||
><any>undefined : any | ||
>undefined : undefined | ||
>[1, 2, 3] : [number, number, number] | ||
>1 : number | ||
>2 : number | ||
>3 : number | ||
|
||
let [a4] = [<any>undefined], [b4] = [<any>null], c4 = <any>undefined, d4 = <any>null; // no error | ||
>a4 : any | ||
>[<any>undefined] : [any] | ||
><any>undefined : any | ||
>undefined : undefined | ||
>b4 : any | ||
>[<any>null] : [any] | ||
><any>null : any | ||
>null : null | ||
>c4 : any | ||
><any>undefined : any | ||
>undefined : undefined | ||
>d4 : any | ||
><any>null : any | ||
>null : null | ||
|
||
let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error | ||
>x : number | ||
>y : number | ||
>z : number | ||
>{ x: 1, y: 2, z: 3 } : { x: number; y: number; z: number; } | ||
>x : number | ||
>1 : number | ||
>y : number | ||
>2 : number | ||
>z : number | ||
>3 : number | ||
|
||
let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error | ||
>x1 : number | ||
>10 : number | ||
>y1 : number | ||
>10 : number | ||
>z1 : number | ||
>10 : number | ||
>{ x1: 1, y1: 2, z1: 3 } : { x1?: number; y1?: number; z1?: number; } | ||
>x1 : number | ||
>1 : number | ||
>y1 : number | ||
>2 : number | ||
>z1 : number | ||
>3 : number | ||
|
||
let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error | ||
>x2 : number | ||
>undefined : undefined | ||
>y2 : number | ||
>undefined : undefined | ||
>z2 : number | ||
>undefined : undefined | ||
>{ x2: 1, y2: 2, z2: 3 } : { x2?: number; y2?: number; z2?: number; } | ||
>x2 : number | ||
>1 : number | ||
>y2 : number | ||
>2 : number | ||
>z2 : number | ||
>3 : number | ||
|
||
let {x3 = <any>undefined, y3 = <any>null, z3 = <any>undefined} = { x3: 1, y3: 2, z3: 3 }; // no error | ||
>x3 : number | ||
><any>undefined : any | ||
>undefined : undefined | ||
>y3 : number | ||
><any>null : any | ||
>null : null | ||
>z3 : number | ||
><any>undefined : any | ||
>undefined : undefined | ||
>{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; } | ||
>x3 : number | ||
>1 : number | ||
>y3 : number | ||
>2 : number | ||
>z3 : number | ||
>3 : number | ||
|
||
let {x4} = { x4: <any>undefined }, {y4} = { y4: <any>null }; // no error | ||
>x4 : any | ||
>{ x4: <any>undefined } : { x4: any; } | ||
>x4 : any | ||
><any>undefined : any | ||
>undefined : undefined | ||
>y4 : any | ||
>{ y4: <any>null } : { y4: any; } | ||
>y4 : any | ||
><any>null : any | ||
>null : null | ||
|
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that new
c4
andd4
error correctly