diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts index 4d9ce6becc1..d5c3ea6a492 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts @@ -2528,6 +2528,7 @@ function lowerExpression( loc: expr.node.loc ?? GeneratedSource, }; } + case 'TSInstantiationExpression': case 'TSNonNullExpression': { let expr = exprPath as NodePath; return lowerExpression(builder, expr.get('expression')); diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.expect.md new file mode 100644 index 00000000000..8400a135b6f --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.expect.md @@ -0,0 +1,46 @@ + +## Input + +```javascript +import {identity, invoke} from 'shared-runtime'; + +function Test() { + const str = invoke(identity, 'test'); + return str; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Test, + params: [], +}; + +``` + +## Code + +```javascript +import { c as _c } from "react/compiler-runtime"; +import { identity, invoke } from "shared-runtime"; + +function Test() { + const $ = _c(1); + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t0 = invoke(identity, "test"); + $[0] = t0; + } else { + t0 = $[0]; + } + const str = t0; + return str; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Test, + params: [], +}; + +``` + +### Eval output +(kind: ok) "test" \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.tsx b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.tsx new file mode 100644 index 00000000000..373d0057476 --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-expression.tsx @@ -0,0 +1,11 @@ +import {identity, invoke} from 'shared-runtime'; + +function Test() { + const str = invoke(identity, 'test'); + return str; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Test, + params: [], +};