@@ -1867,11 +1867,11 @@ func TestTSInstantiationExpression(t *testing.T) {
1867
1867
expectPrintedTS (t , "f['g']<number>" , "f[\" g\" ];\n " )
1868
1868
expectPrintedTS (t , "(f<number>)<number>" , "f;\n " )
1869
1869
1870
- // function call
1870
+ // Function call
1871
1871
expectPrintedTS (t , "const x1 = f<true>\n (true);" , "const x1 = f(true);\n " )
1872
- // relational expression
1872
+ // Relational expression
1873
1873
expectPrintedTS (t , "const x1 = f<true>\n true;" , "const x1 = f < true > true;\n " )
1874
- // instantiation expression
1874
+ // Instantiation expression
1875
1875
expectPrintedTS (t , "const x1 = f<true>;\n (true);" , "const x1 = f;\n true;\n " )
1876
1876
1877
1877
expectPrintedTS (t , "f<number>?.();" , "f?.();\n " )
@@ -1882,20 +1882,32 @@ func TestTSInstantiationExpression(t *testing.T) {
1882
1882
expectPrintedTS (t , "type T21 = typeof Array<string>; f();" , "f();\n " )
1883
1883
expectPrintedTS (t , "type T22 = typeof Array<string, number>; f();" , "f();\n " )
1884
1884
1885
+ // This behavior matches TypeScript 4.7.0 nightly (specifically "[email protected] ")
1886
+ // after various fixes from Microsoft that landed after the TypeScript 4.7.0 beta
1885
1887
expectPrintedTS (t , "f<x>, g<y>;" , "f, g;\n " )
1888
+ expectPrintedTS (t , "f<x>g<y>;" , "f < x > g;\n " )
1889
+ expectPrintedTS (t , "f<x>=g<y>;" , "f = g;\n " )
1890
+ expectPrintedTS (t , "f<x>>g<y>;" , "f < x >> g;\n " )
1891
+ expectPrintedTS (t , "f<x>>>g<y>;" , "f < x >>> g;\n " )
1892
+ expectParseErrorTS (t , "f<x>>=g<y>;" , "<stdin>: ERROR: Invalid assignment target\n " )
1893
+ expectParseErrorTS (t , "f<x>>>=g<y>;" , "<stdin>: ERROR: Invalid assignment target\n " )
1894
+ expectPrintedTS (t , "f<x> = g<y>;" , "f = g;\n " )
1895
+ expectParseErrorTS (t , "f<x> > g<y>;" , "<stdin>: ERROR: Unexpected \" >\" \n " )
1896
+ expectParseErrorTS (t , "f<x> >> g<y>;" , "<stdin>: ERROR: Unexpected \" >>\" \n " )
1897
+ expectParseErrorTS (t , "f<x> >>> g<y>;" , "<stdin>: ERROR: Unexpected \" >>>\" \n " )
1898
+ expectParseErrorTS (t , "f<x> >= g<y>;" , "<stdin>: ERROR: Unexpected \" >=\" \n " )
1899
+ expectParseErrorTS (t , "f<x> >>= g<y>;" , "<stdin>: ERROR: Unexpected \" >>=\" \n " )
1900
+ expectParseErrorTS (t , "f<x> >>>= g<y>;" , "<stdin>: ERROR: Unexpected \" >>>=\" \n " )
1886
1901
expectPrintedTS (t , "[f<x>];" , "[f];\n " )
1887
1902
expectPrintedTS (t , "f<x> ? g<y> : h<z>;" , "f ? g : h;\n " )
1888
- expectPrintedTS (t , "f<x> ^ g<y>;" , "f ^ g;\n " )
1889
- expectPrintedTS (t , "f<x> & g<y>;" , "f & g;\n " )
1890
- expectPrintedTS (t , "f<x> | g<y>;" , "f | g;\n " )
1891
- expectPrintedTS (t , "f<x> && g<y>;" , "f && g;\n " )
1892
- expectPrintedTS (t , "f<x> || g<y>;" , "f || g;\n " )
1893
- expectPrintedTS (t , "f<x> ?? g<y>;" , "f ?? g;\n " )
1894
1903
expectPrintedTS (t , "{ f<x> }" , "{\n f;\n }\n " )
1895
- expectPrintedTS (t , "f<x> == g<y>;" , "f == g;\n " )
1896
- expectPrintedTS (t , "f<x> === g<y>;" , "f === g;\n " )
1897
- expectPrintedTS (t , "f<x> != g<y>;" , "f != g;\n " )
1898
- expectPrintedTS (t , "f<x> !== g<y>;" , "f !== g;\n " )
1904
+ expectPrintedTS (t , "f<x> + g<y>;" , "f < x > +g;\n " )
1905
+ expectPrintedTS (t , "f<x> - g<y>;" , "f < x > -g;\n " )
1906
+ expectParseErrorTS (t , "f<x> * g<y>;" , "<stdin>: ERROR: Unexpected \" *\" \n " )
1907
+ expectParseErrorTS (t , "f<x> == g<y>;" , "<stdin>: ERROR: Unexpected \" ==\" \n " )
1908
+ expectParseErrorTS (t , "f<x> ?? g<y>;" , "<stdin>: ERROR: Unexpected \" ??\" \n " )
1909
+ expectParseErrorTS (t , "f<x> in g<y>;" , "<stdin>: ERROR: Unexpected \" in\" \n " )
1910
+ expectParseErrorTS (t , "f<x> instanceof g<y>;" , "<stdin>: ERROR: Unexpected \" instanceof\" \n " )
1899
1911
1900
1912
expectParseErrorTS (t , "const a8 = f<number><number>;" , "<stdin>: ERROR: Unexpected \" ;\" \n " )
1901
1913
expectParseErrorTS (t , "const b1 = f?.<number>;" , "<stdin>: ERROR: Expected \" (\" but found \" ;\" \n " )
@@ -1929,6 +1941,31 @@ func TestTSInstantiationExpression(t *testing.T) {
1929
1941
// See: https://github.com/microsoft/TypeScript/issues/48759
1930
1942
expectParseErrorTS (t , "x<true>\n import<T>('y')" , "<stdin>: ERROR: Expected \" (\" but found \" <\" \n " )
1931
1943
expectParseErrorTS (t , "new x<true>\n import<T>('y')" , "<stdin>: ERROR: Expected \" (\" but found \" <\" \n " )
1944
+
1945
+ // See: https://github.com/evanw/esbuild/issues/2201
1946
+ expectParseErrorTS (t , "return Array < ;" , "<stdin>: ERROR: Unexpected \" ;\" \n " )
1947
+ expectParseErrorTS (t , "return Array < > ;" , "<stdin>: ERROR: Unexpected \" >\" \n " )
1948
+ expectParseErrorTS (t , "return Array < , > ;" , "<stdin>: ERROR: Unexpected \" ,\" \n " )
1949
+ expectPrintedTS (t , "return Array < number > ;" , "return Array;\n " )
1950
+ expectPrintedTS (t , "return Array < number > 1;" , "return Array < number > 1;\n " )
1951
+ expectPrintedTS (t , "return Array < number > +1;" , "return Array < number > 1;\n " )
1952
+ expectPrintedTS (t , "return Array < number > (1);" , "return Array(1);\n " )
1953
+ expectPrintedTS (t , "return Array < number >> 1;" , "return Array < number >> 1;\n " )
1954
+ expectPrintedTS (t , "return Array < number >>> 1;" , "return Array < number >>> 1;\n " )
1955
+ expectPrintedTS (t , "return Array < Array < number >> ;" , "return Array;\n " )
1956
+ expectPrintedTS (t , "return Array < Array < number > > ;" , "return Array;\n " )
1957
+ expectParseErrorTS (t , "return Array < Array < number > > 1;" , "<stdin>: ERROR: Unexpected \" >\" \n " )
1958
+ expectPrintedTS (t , "return Array < Array < number >> 1;" , "return Array < Array < number >> 1;\n " )
1959
+ expectParseErrorTS (t , "return Array < Array < number > > +1;" , "<stdin>: ERROR: Unexpected \" >\" \n " )
1960
+ expectPrintedTS (t , "return Array < Array < number >> +1;" , "return Array < Array < number >> 1;\n " )
1961
+ expectPrintedTS (t , "return Array < Array < number >> (1);" , "return Array(1);\n " )
1962
+ expectPrintedTS (t , "return Array < Array < number > > (1);" , "return Array(1);\n " )
1963
+ expectParseErrorTS (t , "return Array < number > in x;" , "<stdin>: ERROR: Unexpected \" in\" \n " )
1964
+ expectParseErrorTS (t , "return Array < Array < number >> in x;" , "<stdin>: ERROR: Unexpected \" in\" \n " )
1965
+ expectParseErrorTS (t , "return Array < Array < number > > in x;" , "<stdin>: ERROR: Unexpected \" >\" \n " )
1966
+ expectPrintedTS (t , "for (var x = Array < number > in y) ;" , "x = Array;\n for (var x in y)\n ;\n " )
1967
+ expectPrintedTS (t , "for (var x = Array < Array < number >> in y) ;" , "x = Array;\n for (var x in y)\n ;\n " )
1968
+ expectPrintedTS (t , "for (var x = Array < Array < number > > in y) ;" , "x = Array;\n for (var x in y)\n ;\n " )
1932
1969
}
1933
1970
1934
1971
func TestTSExponentiation (t * testing.T ) {
0 commit comments