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
check more case for empty binding patten #25263
Merged
RyanCavanaugh
merged 7 commits into
microsoft:master
from
Kingwl:Destructuring_assignment_assignability_check
Apr 26, 2019
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1302133
check more case for empty binding patten
Kingwl af362cc
refactor binding pattern checking getWidenedType
Kingwl c8a3ae3
Merge branch 'master' into Destructuring_assignment_assignability_check
Kingwl 9eb45ea
fix spelling
Kingwl d88c01e
Merge branch 'master' into Destructuring_assignment_assignability_check
Kingwl a7beca3
Merge branch 'master' into Destructuring_assignment_assignability_check
Kingwl bd46038
fix merge and rebase
Kingwl File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/destructuringAssignabilityCheck.errors.txt
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/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(1,7): error TS2461: Type '{}' is not an array type. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(2,7): error TS2532: Object is possibly 'undefined'. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(3,3): error TS2461: Type '{}' is not an array type. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(4,3): error TS2532: Object is possibly 'undefined'. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(6,14): error TS2532: Object is possibly 'undefined'. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(9,14): error TS2461: Type '{}' is not an array type. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(13,7): error TS2532: Object is possibly 'undefined'. | ||
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts(15,7): error TS2461: Type '{}' is not an array type. | ||
|
||
|
||
==== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts (8 errors) ==== | ||
const [] = {}; // should be error | ||
~~ | ||
!!! error TS2461: Type '{}' is not an array type. | ||
const {} = undefined; // error correctly | ||
~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
(([]) => 0)({}); // should be error | ||
~~ | ||
!!! error TS2461: Type '{}' is not an array type. | ||
(({}) => 0)(undefined); // should be error | ||
~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
|
||
function foo({}: undefined) { | ||
~~~~~~~~~~~~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
return 0 | ||
} | ||
function bar([]: {}) { | ||
~~~~~~ | ||
!!! error TS2461: Type '{}' is not an array type. | ||
return 0 | ||
} | ||
|
||
const { }: undefined = 1 | ||
~~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
|
||
const []: {} = {} | ||
~~ | ||
!!! error TS2461: Type '{}' is not an array type. | ||
|
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/destructuringAssignabilityCheck.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,32 @@ | ||
//// [destructuringAssignabilityCheck.ts] | ||
const [] = {}; // should be error | ||
const {} = undefined; // error correctly | ||
(([]) => 0)({}); // should be error | ||
(({}) => 0)(undefined); // should be error | ||
|
||
function foo({}: undefined) { | ||
return 0 | ||
} | ||
function bar([]: {}) { | ||
return 0 | ||
} | ||
|
||
const { }: undefined = 1 | ||
|
||
const []: {} = {} | ||
|
||
|
||
//// [destructuringAssignabilityCheck.js] | ||
"use strict"; | ||
var _a = {}; // should be error | ||
var _b = undefined; // error correctly | ||
(function (_a) { return 0; })({}); // should be error | ||
(function (_a) { return 0; })(undefined); // should be error | ||
function foo(_a) { | ||
return 0; | ||
} | ||
function bar(_a) { | ||
return 0; | ||
} | ||
var _c = 1; | ||
var _d = {}; |
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/destructuringAssignabilityCheck.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,24 @@ | ||
=== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts === | ||
const [] = {}; // should be error | ||
const {} = undefined; // error correctly | ||
>undefined : Symbol(undefined) | ||
|
||
(([]) => 0)({}); // should be error | ||
(({}) => 0)(undefined); // should be error | ||
>undefined : Symbol(undefined) | ||
|
||
function foo({}: undefined) { | ||
>foo : Symbol(foo, Decl(destructuringAssignabilityCheck.ts, 3, 23)) | ||
|
||
return 0 | ||
} | ||
function bar([]: {}) { | ||
>bar : Symbol(bar, Decl(destructuringAssignabilityCheck.ts, 7, 1)) | ||
|
||
return 0 | ||
} | ||
|
||
const { }: undefined = 1 | ||
|
||
const []: {} = {} | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/destructuringAssignabilityCheck.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,40 @@ | ||
=== tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.ts === | ||
const [] = {}; // should be error | ||
>{} : {} | ||
|
||
const {} = undefined; // error correctly | ||
>undefined : undefined | ||
|
||
(([]) => 0)({}); // should be error | ||
>(([]) => 0)({}) : number | ||
>(([]) => 0) : ([]: {}) => number | ||
>([]) => 0 : ([]: {}) => number | ||
>0 : 0 | ||
>{} : {} | ||
|
||
(({}) => 0)(undefined); // should be error | ||
>(({}) => 0)(undefined) : number | ||
>(({}) => 0) : ({}: undefined) => number | ||
>({}) => 0 : ({}: undefined) => number | ||
>0 : 0 | ||
>undefined : undefined | ||
|
||
function foo({}: undefined) { | ||
>foo : ({}: undefined) => number | ||
|
||
return 0 | ||
>0 : 0 | ||
} | ||
function bar([]: {}) { | ||
>bar : ([]: {}) => number | ||
|
||
return 0 | ||
>0 : 0 | ||
} | ||
|
||
const { }: undefined = 1 | ||
>1 : 1 | ||
|
||
const []: {} = {} | ||
>{} : {} | ||
|
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
17 changes: 17 additions & 0 deletions
17
tests/cases/conformance/es6/destructuring/destructuringAssignabilityCheck.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,17 @@ | ||
// @strict: true | ||
|
||
const [] = {}; // should be error | ||
const {} = undefined; // error correctly | ||
(([]) => 0)({}); // should be error | ||
(({}) => 0)(undefined); // should be error | ||
|
||
function foo({}: undefined) { | ||
return 0 | ||
} | ||
function bar([]: {}) { | ||
return 0 | ||
} | ||
|
||
const { }: undefined = 1 | ||
|
||
const []: {} = {} |
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.
Spelling