Skip to content

Commit 3ada8f0

Browse files
committed
test coverage for async <A, B> in typescript
1 parent 8824778 commit 3ada8f0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/js_parser/ts_parser_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,12 @@ func TestTSInstantiationExpression(t *testing.T) {
19441944
// Instantiation expression
19451945
expectPrintedTS(t, "const x1 = f<true>;\n(true);", "const x1 = f;\ntrue;\n")
19461946

1947+
// Trailing commas are not allowed
1948+
expectPrintedTS(t, "const x = Array<number>\n(0);", "const x = Array(0);\n")
1949+
expectPrintedTS(t, "const x = Array<number>;\n(0);", "const x = Array;\n0;\n")
1950+
expectParseErrorTS(t, "const x = Array<number,>\n(0);", "<stdin>: ERROR: Expected identifier but found \">\"\n")
1951+
expectParseErrorTS(t, "const x = Array<number,>;\n(0);", "<stdin>: ERROR: Expected identifier but found \">\"\n")
1952+
19471953
expectPrintedTS(t, "f<number>?.();", "f?.();\n")
19481954
expectPrintedTS(t, "f?.<number>();", "f?.();\n")
19491955
expectPrintedTS(t, "f<<T>() => T>?.();", "f?.();\n")
@@ -2344,6 +2350,9 @@ func TestTSJSX(t *testing.T) {
23442350
expectPrintedTS(t, "const x = async <T extends X>(y, z) => {}", "const x = async (y, z) => {\n};\n")
23452351
expectPrintedTS(t, "const x = async <T extends X = Y>(y: T) => {}", "const x = async (y) => {\n};\n")
23462352
expectPrintedTS(t, "const x = async <T extends X = Y>(y, z) => {}", "const x = async (y, z) => {\n};\n")
2353+
expectPrintedTS(t, "const x = (async <T, X> y)", "const x = (async < T, X > y);\n")
2354+
expectPrintedTS(t, "const x = (async <T, X>(y))", "const x = async(y);\n")
2355+
expectPrintedTS(t, "const x = async <T,>(y)", "const x = async(y);\n")
23472356
expectParseErrorTS(t, "const x = async <T>(y: T)", "<stdin>: ERROR: Unexpected \":\"\n")
23482357
expectParseErrorTS(t, "const x = async\n<T>() => {}", "<stdin>: ERROR: Expected \";\" but found \"=>\"\n")
23492358
expectParseErrorTS(t, "const x = async\n<T>(x) => {}", "<stdin>: ERROR: Expected \";\" but found \"=>\"\n")

0 commit comments

Comments
 (0)