@@ -1944,6 +1944,12 @@ func TestTSInstantiationExpression(t *testing.T) {
1944
1944
// Instantiation expression
1945
1945
expectPrintedTS (t , "const x1 = f<true>;\n (true);" , "const x1 = f;\n true;\n " )
1946
1946
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;\n 0;\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
+
1947
1953
expectPrintedTS (t , "f<number>?.();" , "f?.();\n " )
1948
1954
expectPrintedTS (t , "f?.<number>();" , "f?.();\n " )
1949
1955
expectPrintedTS (t , "f<<T>() => T>?.();" , "f?.();\n " )
@@ -2344,6 +2350,9 @@ func TestTSJSX(t *testing.T) {
2344
2350
expectPrintedTS (t , "const x = async <T extends X>(y, z) => {}" , "const x = async (y, z) => {\n };\n " )
2345
2351
expectPrintedTS (t , "const x = async <T extends X = Y>(y: T) => {}" , "const x = async (y) => {\n };\n " )
2346
2352
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 " )
2347
2356
expectParseErrorTS (t , "const x = async <T>(y: T)" , "<stdin>: ERROR: Unexpected \" :\" \n " )
2348
2357
expectParseErrorTS (t , "const x = async\n <T>() => {}" , "<stdin>: ERROR: Expected \" ;\" but found \" =>\" \n " )
2349
2358
expectParseErrorTS (t , "const x = async\n <T>(x) => {}" , "<stdin>: ERROR: Expected \" ;\" but found \" =>\" \n " )
0 commit comments