File tree 4 files changed +31
-2
lines changed
4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -2975,6 +2975,11 @@ module ts {
2975
2975
return ! scanner . hasPrecedingLineBreak ( ) && isIdentifier ( )
2976
2976
}
2977
2977
2978
+ function netTokenIsIdentifierOrStartOfDestructuringOnTheSameLine ( ) {
2979
+ nextToken ( ) ;
2980
+ return ! scanner . hasPrecedingLineBreak ( ) && ( isIdentifier ( ) || token === SyntaxKind . OpenBraceToken || token === SyntaxKind . OpenBracketToken )
2981
+ }
2982
+
2978
2983
function parseYieldExpression ( ) : YieldExpression {
2979
2984
var node = < YieldExpression > createNode ( SyntaxKind . YieldExpression ) ;
2980
2985
@@ -4873,9 +4878,9 @@ module ts {
4873
4878
}
4874
4879
4875
4880
function isLetDeclaration ( ) {
4876
- // It is let declaration if in strict mode or next token is identifier on same line.
4881
+ // It is let declaration if in strict mode or next token is identifier\open brace\open curly on same line.
4877
4882
// otherwise it needs to be treated like identifier
4878
- return inStrictModeContext ( ) || lookAhead ( nextTokenIsIdentifierOnSameLine ) ;
4883
+ return inStrictModeContext ( ) || lookAhead ( netTokenIsIdentifierOrStartOfDestructuringOnTheSameLine ) ;
4879
4884
}
4880
4885
4881
4886
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