Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ff71e5

Browse files
authored
fix: Support trailing comma in function type parameters (#2608)
1 parent 4b3b390 commit 1ff71e5

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

‎src/parser.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ export class Parser extends DiagnosticEmitter {
797797
}
798798
} else {
799799
if (isSignature) {
800+
if (tn.peek() == Token.CloseParen) break; // allow trailing comma
800801
this.error(
801802
DiagnosticCode.Identifier_expected,
802803
tn.range()

‎tests/parser/function-type.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ var b: (a: i32, b: i32) => void;
33
var c: (a: i32, b: i32) => (a: i32, b: i32) => void;
44
var d: (a: i32, a: i32) => void; // NOTE: duplicates in type signatures doesn't in TypeScript
55
var e: (a) => void; // TS1110
6+
var f: (a: i32, b: i32,) => (a: i32, b: i32,) => void;

‎tests/parser/function-type.ts.fixture.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ var b: (a: i32, b: i32) => void;
33
var c: (a: i32, b: i32) => (a: i32, b: i32) => void;
44
var d: (a: i32, a: i32) => void;
55
var e: (a) => void;
6+
var f: (a: i32, b: i32) => (a: i32, b: i32) => void;
67
// ERROR 1110: "Type expected." in function-type.ts(5,10+0)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /