From 20d42dfaa3c23c1302dd3d5837ba6714dc891ac4 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 23 Aug 2023 17:22:54 -0700 Subject: Fix `() =>` (#4278) --- test/bundler/bundler_edgecase.test.ts | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'test') diff --git a/test/bundler/bundler_edgecase.test.ts b/test/bundler/bundler_edgecase.test.ts index 0cbb97b1e..59c013782 100644 --- a/test/bundler/bundler_edgecase.test.ts +++ b/test/bundler/bundler_edgecase.test.ts @@ -929,6 +929,76 @@ describe("bundler", () => { stdout: "pass", }, }); + itBundled("edgecase/TS_LessThanAmbiguity", { + files: { + "/entry.ts": ` + function expectArrow(item) { + if(typeof item !== 'function') { + throw new Error('Expected arrow function'); + } + } + function expectTypeCast(item) { + if(typeof item !== 'number') { + throw new Error('Expected arrow function'); + } + } + const x = 1; + expectTypeCast((x)); + expectTypeCast(<[]>(x)); + expectTypeCast((x)); + + expectArrow((x) => {}) + expectArrow((x) => {}) + expectArrow((x) => {}) + expectArrow((x) => {}) + expectArrow((x) => {}) + + console.log('pass'); + `, + }, + run: { + stdout: "pass", + }, + }); + itBundled("edgecase/TSX_LessThanAmbiguity", { + files: { + "/entry.tsx": ` + function expectJSX(item) { + if(typeof item !== 'object') { + throw new Error('Expected JSX'); + } + } + function expectArrow(item) { + if(typeof item !== 'function') { + throw new Error('Expected arrow function'); + } + } + + const A = 1; + expectJSX((x) ...); + expectJSX((x) ... ); + expectJSX((x) ... ); + expectJSX((x) ...); + expectJSX((x) ...); + expectJSX((x) ...); + expectJSX((x) ...); + + expectArrow((x) => {}); + expectArrow((x) => {}); + expectArrow((x) => {}); + + console.log('pass'); + `, + "/node_modules/react/jsx-dev-runtime.js": ` + export function jsxDEV(type, props, key, isStaticChildren, source, self) { + return {}; + } + `, + }, + run: { + stdout: "pass", + }, + }); itBundled("edgecase/IsBuffer2", { files: { "/entry.js": /* js */ ` -- cgit v1.2.3