From b9cba1ad4dc90090fe42755ad479fefd5ee8b17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 21 Apr 2022 15:56:34 +0900 Subject: [PATCH] test(es/parser): Add a test for a fixed issue (#4388) --- .../issues-4xxx/issue-4296/1/input/.swcrc | 14 +++++++++ .../issues-4xxx/issue-4296/1/input/index.tsx | 29 +++++++++++++++++++ .../issues-4xxx/issue-4296/1/output/index.tsx | 14 +++++++++ 3 files changed, 57 insertions(+) create mode 100644 crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/index.tsx create mode 100644 crates/swc/tests/fixture/issues-4xxx/issue-4296/1/output/index.tsx diff --git a/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/.swcrc b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/.swcrc new file mode 100644 index 00000000000..c69c5a2267e --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/.swcrc @@ -0,0 +1,14 @@ +{ + "jsc": { + "transform": { + "hidden": { + "jest": true + } + }, + "target": "es2022", + "parser": { + "syntax": "typescript", + "tsx": true + } + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/index.tsx b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/index.tsx new file mode 100644 index 00000000000..c98cb113271 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/input/index.tsx @@ -0,0 +1,29 @@ +import React from "react"; + +interface ListProps { + callback: () => void; +} + +const SomeList = ({ callback }: ListProps) => { + callback(); + + return
; +}; + +const list = [0]; + +const MyComponent = (): JSX.Element => { + return ( +
+ {list.map(() => + true ? ( + console.log("do something")} + /> + ) : ( +
+ ) + )} +
+ ); +}; diff --git a/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/output/index.tsx b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/output/index.tsx new file mode 100644 index 00000000000..461c35242b0 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/issue-4296/1/output/index.tsx @@ -0,0 +1,14 @@ +import React from "react"; +const SomeList = ({ callback })=>{ + callback(); + return /*#__PURE__*/ React.createElement("div", null); +}; +const list = [ + 0 +]; +const MyComponent = ()=>{ + return /*#__PURE__*/ React.createElement("div", null, list.map(()=>true ? /*#__PURE__*/ React.createElement(SomeList, { + callback: ()=>console.log("do something") + }) : /*#__PURE__*/ React.createElement("div", null) + )); +};