diff --git a/src/parser.ts b/src/parser.ts index e0d61fa581..0cd9b9243e 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -2169,7 +2169,7 @@ export class Parser extends DiagnosticEmitter { tn.range() ); } - returnType = this.parseType(tn, name.kind == NodeKind.CONSTRUCTOR || isSetter); + returnType = this.parseType(tn, isSetter || name.kind == NodeKind.CONSTRUCTOR); if (!returnType) return null; } else { returnType = Node.createOmittedType(tn.range(tn.pos)); @@ -2209,7 +2209,7 @@ export class Parser extends DiagnosticEmitter { } body = this.parseBlockStatement(tn, false); if (!body) return null; - } else if (!(flags & (CommonFlags.AMBIENT | CommonFlags.ABSTRACT)) && !isInterface) { + } else if (!isInterface && !(flags & (CommonFlags.AMBIENT | CommonFlags.ABSTRACT))) { this.error( DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration, tn.range() @@ -2225,7 +2225,9 @@ export class Parser extends DiagnosticEmitter { body, tn.range(startPos, tn.pos) ); - tn.skip(Token.SEMICOLON); + if (!(isInterface && tn.skip(Token.COMMA))) { + tn.skip(Token.SEMICOLON); + } return retMethod; } else if (isConstructor) { @@ -2288,7 +2290,10 @@ export class Parser extends DiagnosticEmitter { if (!initializer) return null; } let range = tn.range(startPos, tn.pos); - if ((flags & CommonFlags.DEFINITELY_ASSIGNED) != 0 && ((flags & CommonFlags.STATIC) != 0 || isInterface || initializer !== null)) { + if ( + (flags & CommonFlags.DEFINITELY_ASSIGNED) != 0 && + (isInterface || initializer !== null || (flags & CommonFlags.STATIC) != 0) + ) { this.error( DiagnosticCode.A_definite_assignment_assertion_is_not_permitted_in_this_context, range @@ -2302,7 +2307,9 @@ export class Parser extends DiagnosticEmitter { initializer, range ); - tn.skip(Token.SEMICOLON); + if (!(isInterface && tn.skip(Token.COMMA))) { + tn.skip(Token.SEMICOLON); + } return retField; } return null; diff --git a/tests/parser/interface.ts b/tests/parser/interface.ts index f65fbcd714..db94e6119e 100644 --- a/tests/parser/interface.ts +++ b/tests/parser/interface.ts @@ -3,3 +3,9 @@ interface Foo { baz: i32; readonly baz2: f64; } + +interface Boo { + bar(): void, + baz: i32, + readonly baz2: f64, +} diff --git a/tests/parser/interface.ts.fixture.ts b/tests/parser/interface.ts.fixture.ts index f65fbcd714..aacb138d03 100644 --- a/tests/parser/interface.ts.fixture.ts +++ b/tests/parser/interface.ts.fixture.ts @@ -3,3 +3,8 @@ interface Foo { baz: i32; readonly baz2: f64; } +interface Boo { + bar(): void; + baz: i32; + readonly baz2: f64; +}