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
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/js/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl<'a> ParserImpl<'a> {
};
self.ctx =
self.ctx.and_in(ctx.has_in()).and_await(ctx.has_await()).and_yield(ctx.has_yield());
if !self.is_ts && body.is_none() {
if (!self.is_ts || matches!(func_kind, FunctionKind::ObjectMethod)) && body.is_none() {
return self.fatal_error(diagnostics::expect_function_body(self.end_span(span)));
}
let function_type = match func_kind {
Expand Down
33 changes: 20 additions & 13 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit: b78f0899
parser_typescript Summary:
AST Parsed : 9839/9840 (99.99%)
Positive Passed: 9830/9840 (99.90%)
Negative Passed: 1492/2549 (58.53%)
Negative Passed: 1493/2549 (58.57%)
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration3.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration4.ts
Expand Down Expand Up @@ -716,8 +716,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/nullKeyword.

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/omitTypeTestErrors01.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/omittedExpressionForOfLoop.ts
Expand Down Expand Up @@ -2653,17 +2651,19 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
4 │ }
╰────

× Getters and setters must have an implementation.
╭─[typescript/tests/cases/compiler/accessorWithoutBody1.ts:1:15]
× Expected function body
╭─[typescript/tests/cases/compiler/accessorWithoutBody1.ts:1:18]
1 │ var v = { get foo() }
· ──
· ──
╰────
help: Add a function body (`{}`).

× Getters and setters must have an implementation.
╭─[typescript/tests/cases/compiler/accessorWithoutBody2.ts:1:15]
× Expected function body
╭─[typescript/tests/cases/compiler/accessorWithoutBody2.ts:1:18]
1 │ var v = { set foo(a) }
· ───
· ───
╰────
help: Add a function body (`{}`).

× Unexpected token
╭─[typescript/tests/cases/compiler/aliasErrors.ts:13:12]
Expand Down Expand Up @@ -8818,6 +8818,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
· ╰── Opened here
╰────

× Expected function body
╭─[typescript/tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts:1:14]
1 │ var v = { foo(); }
· ──
╰────
help: Add a function body (`{}`).

× Expected `,` or `}` but found `;`
╭─[typescript/tests/cases/compiler/objectLiteralWithSemicolons1.ts:1:12]
1 │ var v = { a; b; c }
Expand Down Expand Up @@ -26061,14 +26068,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
38 │ }
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[typescript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts:20:15]
× Expected function body
╭─[typescript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts:20:8]
19 │ var b = {
20 │ foo(x = 1), // error
·
· ───────
21 │ foo(x = 1) { }, // error
╰────
help: Try inserting a semicolon here
help: Add a function body (`{}`).

× TS(1090): 'public' modifier cannot appear on a parameter.
╭─[typescript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters.ts:16:10]
Expand Down
Loading