File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -2975,6 +2975,12 @@ module ts {
29752975 return ! scanner . hasPrecedingLineBreak ( ) && isIdentifier ( )
29762976 }
29772977
2978+ function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine ( ) {
2979+ nextToken ( ) ;
2980+ return ! scanner . hasPrecedingLineBreak ( ) &&
2981+ ( isIdentifier ( ) || token === SyntaxKind . OpenBraceToken || token === SyntaxKind . OpenBracketToken ) ;
2982+ }
2983+
29782984 function parseYieldExpression ( ) : YieldExpression {
29792985 var node = < YieldExpression > createNode ( SyntaxKind . YieldExpression ) ;
29802986
@@ -4873,9 +4879,9 @@ module ts {
48734879 }
48744880
48754881 function isLetDeclaration ( ) {
4876- // It is let declaration if in strict mode or next token is identifier on same line.
4882+ // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line.
48774883 // otherwise it needs to be treated like identifier
4878- return inStrictModeContext ( ) || lookAhead ( nextTokenIsIdentifierOnSameLine ) ;
4884+ return inStrictModeContext ( ) || lookAhead ( nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine ) ;
48794885 }
48804886
48814887 function isDeclarationStart ( ) : boolean {
Original file line number Diff line number Diff line change 1+ //// [letInNonStrictMode.ts]
2+ let [ x ] = [ 1 ] ;
3+ let { a : y } = { a : 1 } ;
4+
5+ //// [letInNonStrictMode.js]
6+ var x = ( [
7+ 1
8+ ] ) [ 0 ] ;
9+ var y = ( {
10+ a : 1
11+ } ) . a ;
Original file line number Diff line number Diff line change 1+ === tests/cases/compiler/letInNonStrictMode.ts ===
2+ let [x] = [1];
3+ >x : number
4+ >[1] : [number]
5+
6+ let {a: y} = {a: 1};
7+ >a : unknown
8+ >y : number
9+ >{a: 1} : { a: number; }
10+ >a : number
11+
Original file line number Diff line number Diff line change 1+ let [ x ] = [ 1 ] ;
2+ let { a : y } = { a : 1 } ;
You can’t perform that action at this time.
0 commit comments