diff --git a/internal/js_parser/ts_parser_test.go b/internal/js_parser/ts_parser_test.go index 21cdb6cbf82..f28b12229a6 100644 --- a/internal/js_parser/ts_parser_test.go +++ b/internal/js_parser/ts_parser_test.go @@ -1944,6 +1944,12 @@ func TestTSInstantiationExpression(t *testing.T) { // Instantiation expression expectPrintedTS(t, "const x1 = f;\n(true);", "const x1 = f;\ntrue;\n") + // Trailing commas are not allowed + expectPrintedTS(t, "const x = Array\n(0);", "const x = Array(0);\n") + expectPrintedTS(t, "const x = Array;\n(0);", "const x = Array;\n0;\n") + expectParseErrorTS(t, "const x = Array\n(0);", ": ERROR: Expected identifier but found \">\"\n") + expectParseErrorTS(t, "const x = Array;\n(0);", ": ERROR: Expected identifier but found \">\"\n") + expectPrintedTS(t, "f?.();", "f?.();\n") expectPrintedTS(t, "f?.();", "f?.();\n") expectPrintedTS(t, "f<() => T>?.();", "f?.();\n") @@ -2344,6 +2350,9 @@ func TestTSJSX(t *testing.T) { expectPrintedTS(t, "const x = async (y, z) => {}", "const x = async (y, z) => {\n};\n") expectPrintedTS(t, "const x = async (y: T) => {}", "const x = async (y) => {\n};\n") expectPrintedTS(t, "const x = async (y, z) => {}", "const x = async (y, z) => {\n};\n") + expectPrintedTS(t, "const x = (async y)", "const x = (async < T, X > y);\n") + expectPrintedTS(t, "const x = (async (y))", "const x = async(y);\n") + expectPrintedTS(t, "const x = async (y)", "const x = async(y);\n") expectParseErrorTS(t, "const x = async (y: T)", ": ERROR: Unexpected \":\"\n") expectParseErrorTS(t, "const x = async\n() => {}", ": ERROR: Expected \";\" but found \"=>\"\n") expectParseErrorTS(t, "const x = async\n(x) => {}", ": ERROR: Expected \";\" but found \"=>\"\n")