diff --git a/tests/hooks-support-IIFE.js b/tests/hooks-support-IIFE.js deleted file mode 100644 index 52a8df3..0000000 --- a/tests/hooks-support-IIFE.js +++ /dev/null @@ -1,6 +0,0 @@ -// ? works with IIFE -while (item) { - ;((item) => { - useFoo() - })(item) -} diff --git a/typescript/__snapshots__/hooks-support-IIFE.js b/typescript/__snapshots__/hooks-support-IIFE.js deleted file mode 100644 index 7d1277c..0000000 --- a/typescript/__snapshots__/hooks-support-IIFE.js +++ /dev/null @@ -1,10 +0,0 @@ -var _a; -_a = $RefreshSig$(); -// ? works with IIFE -while (item) { - ; - (_a((item) => { - _a(); - useFoo(); - }, "useFoo{}", true))(item); -} diff --git a/typescript/src/core.ts b/typescript/src/core.ts index 64d6e5c..c0c16b9 100644 --- a/typescript/src/core.ts +++ b/typescript/src/core.ts @@ -305,7 +305,6 @@ export default function (opts: Options = {}): TransformerFactory { node = newFunction // if it is an inner decl, we can update it safely if (findAncestor(oldNode.parent, ts.isFunctionLike)) node = wrapped - else if (isIIFEFunction(oldNode)) return wrapped } } return updateStatements(node, addSignatureReport) @@ -647,12 +646,6 @@ export default function (opts: Options = {}): TransformerFactory { if (['createElement', 'jsx', 'jsxs', 'jsxDEV'].includes(f)) return true return false } - function isIIFEFunction(f: HandledFunction): boolean { - let node: Node = f - while (ts.isParenthesizedExpression(node.parent)) node = node.parent - if (ts.isCallExpression(node.parent) && node.parent.expression === node) return true - return false - } } function startsWithLowerCase(str: string) {