Skip to content

Commit b9fe996

Browse files
authored
Change isStartOfParameter to be more general (#17431)
1 parent fdb4465 commit b9fe996

File tree

5 files changed

+17
-32
lines changed

5 files changed

+17
-32
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,8 +2237,7 @@ namespace ts {
22372237
return token() === SyntaxKind.DotDotDotToken ||
22382238
isIdentifierOrPattern() ||
22392239
isModifierKind(token()) ||
2240-
token() === SyntaxKind.AtToken || token() === SyntaxKind.ThisKeyword || token() === SyntaxKind.NewKeyword ||
2241-
token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral;
2240+
token() === SyntaxKind.AtToken || isStartOfType();
22422241
}
22432242

22442243
function parseParameter(): ParameterDeclaration {

tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2304: Cannot find name 'a'.
2-
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2695: Left side of comma operator is unused and has no side effects.
1+
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,15): error TS1003: Identifier expected.
32
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2304: Cannot find name 'b'.
43
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2695: Left side of comma operator is unused and has no side effects.
54
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,19): error TS2304: Cannot find name 'c'.
6-
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,23): error TS1005: ';' expected.
7-
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,26): error TS2304: Cannot find name 'a'.
85
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,28): error TS2304: Cannot find name 'b'.
96
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,30): error TS2304: Cannot find name 'c'.
107
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(2,12): error TS2695: Left side of comma operator is unused and has no side effects.
@@ -21,22 +18,16 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,17): error TS1005
2118
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,20): error TS2304: Cannot find name 'a'.
2219

2320

24-
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (21 errors) ====
21+
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (18 errors) ====
2522
var tt1 = (a, (b, c)) => a+b+c;
26-
~
27-
!!! error TS2304: Cannot find name 'a'.
28-
~
29-
!!! error TS2695: Left side of comma operator is unused and has no side effects.
23+
~
24+
!!! error TS1003: Identifier expected.
3025
~
3126
!!! error TS2304: Cannot find name 'b'.
3227
~
3328
!!! error TS2695: Left side of comma operator is unused and has no side effects.
3429
~
3530
!!! error TS2304: Cannot find name 'c'.
36-
~~
37-
!!! error TS1005: ';' expected.
38-
~
39-
!!! error TS2304: Cannot find name 'a'.
4031
~
4132
!!! error TS2304: Cannot find name 'b'.
4233
~

tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ var tt2 = ((a), b, c) => a+b+c;
55
var tt3 = ((a)) => a;
66

77
//// [fatarrowfunctionsOptionalArgsErrors2.js]
8-
var tt1 = (a, (b, c));
9-
a + b + c;
8+
var tt1 = function (a, ) {
9+
if ( === void 0) { = (b, c); }
10+
return a + b + c;
11+
};
1012
var tt2 = ((a), b, c);
1113
a + b + c;
1214
var tt3 = ((a));

tests/baselines/reference/parser512325.errors.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2304: Cannot find name 'a'.
2-
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2695: Left side of comma operator is unused and has no side effects.
1+
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,14): error TS1003: Identifier expected.
32
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2304: Cannot find name 'b'.
43
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2695: Left side of comma operator is unused and has no side effects.
54
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,18): error TS2304: Cannot find name 'c'.
6-
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,22): error TS1005: ';' expected.
7-
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,25): error TS2304: Cannot find name 'a'.
85
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,27): error TS2304: Cannot find name 'b'.
96
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,29): error TS2304: Cannot find name 'c'.
107

118

12-
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (9 errors) ====
9+
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (6 errors) ====
1310
var tt = (a, (b, c)) => a+b+c;
14-
~
15-
!!! error TS2304: Cannot find name 'a'.
16-
~
17-
!!! error TS2695: Left side of comma operator is unused and has no side effects.
11+
~
12+
!!! error TS1003: Identifier expected.
1813
~
1914
!!! error TS2304: Cannot find name 'b'.
2015
~
2116
!!! error TS2695: Left side of comma operator is unused and has no side effects.
2217
~
2318
!!! error TS2304: Cannot find name 'c'.
24-
~~
25-
!!! error TS1005: ';' expected.
26-
~
27-
!!! error TS2304: Cannot find name 'a'.
2819
~
2920
!!! error TS2304: Cannot find name 'b'.
3021
~

tests/baselines/reference/parser512325.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
var tt = (a, (b, c)) => a+b+c;
33

44
//// [parser512325.js]
5-
var tt = (a, (b, c));
6-
a + b + c;
5+
var tt = function (a, ) {
6+
if ( === void 0) { = (b, c); }
7+
return a + b + c;
8+
};

0 commit comments

Comments
 (0)