Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trailing comma in function types #2608

Merged
merged 3 commits into from
Jan 6, 2023
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
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ export class Parser extends DiagnosticEmitter {
}
} else {
if (isSignature) {
if (tn.peek() == Token.CloseParen) break; // allow trailing comma
this.error(
DiagnosticCode.Identifier_expected,
tn.range()
Expand Down
1 change: 1 addition & 0 deletions tests/parser/function-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ var b: (a: i32, b: i32) => void;
var c: (a: i32, b: i32) => (a: i32, b: i32) => void;
var d: (a: i32, a: i32) => void; // NOTE: duplicates in type signatures doesn't in TypeScript
var e: (a) => void; // TS1110
var f: (a: i32, b: i32,) => (a: i32, b: i32,) => void;
1 change: 1 addition & 0 deletions tests/parser/function-type.ts.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ var b: (a: i32, b: i32) => void;
var c: (a: i32, b: i32) => (a: i32, b: i32) => void;
var d: (a: i32, a: i32) => void;
var e: (a) => void;
var f: (a: i32, b: i32) => (a: i32, b: i32) => void;
// ERROR 1110: "Type expected." in function-type.ts(5,10+0)