Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,7 @@ namespace ts {
return finishNode(node);
}

const startPos = scanner.getStartPos();
node.decorators = parseDecorators();
node.modifiers = parseModifiers();
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
Expand All @@ -2237,14 +2238,13 @@ namespace ts {
node.type = parseParameterType();
node.initializer = parseBindingElementInitializer(/*inParameter*/ true);

// Do not check for initializers in an ambient context for parameters. This is not
// a grammar error because the grammar allows arbitrary call signatures in
// an ambient context.
// It is actually not necessary for this to be an error at all. The reason is that
// function/constructor implementations are syntactically disallowed in ambient
// contexts. In addition, parameter initializers are semantically disallowed in
// overload signatures. So parameter initializers are transitively disallowed in
// ambient contexts.
if (startPos === scanner.getStartPos()) {
// What we're parsing isn't actually remotely recognizable as a parameter and we've consumed no tokens whatsoever
// Consume a token to advance the parser in some way and avoid an infinite loop in `parseDelimitedList`
// This can happen when we're speculatively parsing parenthesized expressions which we think may be arrow functions,
// or when a modifier keyword which is disallowed as a parameter name (ie, `static` in strict mode) is supplied
nextToken();
}

return addJSDocComment(finishNode(node));
}
Expand Down
14 changes: 14 additions & 0 deletions tests/baselines/reference/parseCommaSeperatedNewlineNew.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests/cases/compiler/parseCommaSeperatedNewlineNew.ts(1,2): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parseCommaSeperatedNewlineNew.ts(1,2): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/parseCommaSeperatedNewlineNew.ts(2,4): error TS1109: Expression expected.


==== tests/cases/compiler/parseCommaSeperatedNewlineNew.ts (3 errors) ====
(a,
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
new)
~
!!! error TS1109: Expression expected.
7 changes: 7 additions & 0 deletions tests/baselines/reference/parseCommaSeperatedNewlineNew.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//// [parseCommaSeperatedNewlineNew.ts]
(a,
new)

//// [parseCommaSeperatedNewlineNew.js]
(a,
new );
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/parseCommaSeperatedNewlineNumber.ts(1,2): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parseCommaSeperatedNewlineNumber.ts(1,2): error TS2695: Left side of comma operator is unused and has no side effects.


==== tests/cases/compiler/parseCommaSeperatedNewlineNumber.ts (2 errors) ====
(a,
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
1)
7 changes: 7 additions & 0 deletions tests/baselines/reference/parseCommaSeperatedNewlineNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//// [parseCommaSeperatedNewlineNumber.ts]
(a,
1)

//// [parseCommaSeperatedNewlineNumber.js]
(a,
1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/parseCommaSeperatedNewlineString.ts(1,2): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parseCommaSeperatedNewlineString.ts(1,2): error TS2695: Left side of comma operator is unused and has no side effects.


==== tests/cases/compiler/parseCommaSeperatedNewlineString.ts (2 errors) ====
(a,
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
'')
7 changes: 7 additions & 0 deletions tests/baselines/reference/parseCommaSeperatedNewlineString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//// [parseCommaSeperatedNewlineString.ts]
(a,
'')

//// [parseCommaSeperatedNewlineString.js]
(a,
'');
2 changes: 2 additions & 0 deletions tests/cases/compiler/parseCommaSeperatedNewlineNew.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(a,
new)
2 changes: 2 additions & 0 deletions tests/cases/compiler/parseCommaSeperatedNewlineNumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(a,
1)
2 changes: 2 additions & 0 deletions tests/cases/compiler/parseCommaSeperatedNewlineString.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(a,
'')