mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
Fix crash in JS when checking destructuring shorthand assignment (#25529)
This commit is contained in:
parent
b3b6c3bdbc
commit
60c0dfeb25
@ -21128,7 +21128,7 @@ namespace ts {
|
||||
getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], UnionReduction.Subtype) :
|
||||
leftType;
|
||||
case SyntaxKind.EqualsToken:
|
||||
const special = getSpecialPropertyAssignmentKind(left.parent as BinaryExpression);
|
||||
const special = isBinaryExpression(left.parent) ? getSpecialPropertyAssignmentKind(left.parent) : SpecialPropertyAssignmentKind.None;
|
||||
checkSpecialAssignment(special, right);
|
||||
if (isJSSpecialPropertyAssignment(special)) {
|
||||
return leftType;
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/bug25434.js(4,9): error TS2304: Cannot find name 'b'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/bug25434.js (1 errors) ====
|
||||
// should not crash while checking
|
||||
function Test({ b = '' } = {}) {}
|
||||
|
||||
Test(({ b = '5' } = {}));
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/bug25434.js ===
|
||||
// should not crash while checking
|
||||
function Test({ b = '' } = {}) {}
|
||||
>Test : Symbol(Test, Decl(bug25434.js, 0, 0))
|
||||
>b : Symbol(b, Decl(bug25434.js, 1, 15))
|
||||
|
||||
Test(({ b = '5' } = {}));
|
||||
>Test : Symbol(Test, Decl(bug25434.js, 0, 0))
|
||||
>b : Symbol(b, Decl(bug25434.js, 3, 7))
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/bug25434.js ===
|
||||
// should not crash while checking
|
||||
function Test({ b = '' } = {}) {}
|
||||
>Test : ({ b }?: { [x: string]: any; }) => void
|
||||
>b : string
|
||||
>'' : ""
|
||||
>{} : { b?: string; }
|
||||
|
||||
Test(({ b = '5' } = {}));
|
||||
>Test(({ b = '5' } = {})) : void
|
||||
>Test : ({ b }?: { [x: string]: any; }) => void
|
||||
>({ b = '5' } = {}) : { b?: any; }
|
||||
>{ b = '5' } = {} : { b?: any; }
|
||||
>{ b = '5' } : { [x: string]: any; b?: any; }
|
||||
>b : any
|
||||
>{} : { b?: any; }
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
// @allowjs: true
|
||||
// @checkjs: true
|
||||
// @noEmit: true
|
||||
// @Filename: bug25434.js
|
||||
// should not crash while checking
|
||||
function Test({ b = '' } = {}) {}
|
||||
|
||||
Test(({ b = '5' } = {}));
|
||||
Loading…
x
Reference in New Issue
Block a user