Skip to content

Commit c20f682

Browse files
committed
Adding SyntaxKind.BindingElement case
1 parent a826215 commit c20f682

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/compiler/utilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,10 @@ namespace ts {
12011201
return parent.kind === SyntaxKind.TypeQuery;
12021202
}
12031203
return false;
1204+
case SyntaxKind.BindingElement:
12041205
case SyntaxKind.ImportSpecifier:
1205-
// Name on left hand of 'as' in import specifier
1206-
return (<ImportSpecifier>parent).propertyName === node;
1206+
// Property name in binding element or import specifier
1207+
return (<BindingElement | ImportSpecifier>parent).propertyName === node;
12071208
case SyntaxKind.ExportSpecifier:
12081209
// Any name in an export specifier
12091210
return true;

tests/baselines/reference/strictModeReservedWordInDestructuring.errors.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ tests/cases/compiler/strictModeReservedWordInDestructuring.ts(3,10): error TS121
33
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(4,7): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
44
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,15): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
55
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,38): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
6-
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,6): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
7-
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,14): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
6+
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,7): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
7+
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,15): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
88

99

1010
==== tests/cases/compiler/strictModeReservedWordInDestructuring.ts (7 errors) ====
@@ -18,13 +18,15 @@ tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,14): error TS121
1818
var [[private]] = [["hello"]];
1919
~~~~~~~
2020
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
21-
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
21+
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
2222
~~~~~~
2323
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
2424
~~~~~~~
2525
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
26-
var {public, protected} = { public: 1, protected: 2 };
27-
~~~~~~
26+
var { public, protected } = { public: 1, protected: 2 };
27+
~~~~~~
2828
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
29-
~~~~~~~~~
30-
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
29+
~~~~~~~~~
30+
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
31+
var { public: a, protected: b } = { public: 1, protected: 2 };
32+

tests/baselines/reference/strictModeReservedWordInDestructuring.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
var [public] = [1];
44
var { x: public } = { x: 1 };
55
var [[private]] = [["hello"]];
6-
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
7-
var {public, protected} = { public: 1, protected: 2 };
6+
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
7+
var { public, protected } = { public: 1, protected: 2 };
8+
var { public: a, protected: b } = { public: 1, protected: 2 };
9+
810

911
//// [strictModeReservedWordInDestructuring.js]
1012
"use strict";
@@ -13,3 +15,4 @@ var public = { x: 1 }.x;
1315
var private = [["hello"]][0][0];
1416
var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p;
1517
var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected;
18+
var _c = { public: 1, protected: 2 }, a = _c.public, b = _c.protected;

tests/cases/compiler/strictModeReservedWordInDestructuring.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
var [public] = [1];
33
var { x: public } = { x: 1 };
44
var [[private]] = [["hello"]];
5-
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
6-
var {public, protected} = { public: 1, protected: 2 };
5+
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
6+
var { public, protected } = { public: 1, protected: 2 };
7+
var { public: a, protected: b } = { public: 1, protected: 2 };

0 commit comments

Comments
 (0)