[compiler] Handle TSInstantiationExpression in lowerExpression (#32302)

Fix #31745
This commit is contained in:
inottn 2025-02-04 00:41:04 +08:00 committed by GitHub
parent a4b2d0d518
commit 10a4c88f58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 58 additions and 0 deletions

View File

@ -2528,6 +2528,7 @@ function lowerExpression(
loc: expr.node.loc ?? GeneratedSource,
};
}
case 'TSInstantiationExpression':
case 'TSNonNullExpression': {
let expr = exprPath as NodePath<t.TSNonNullExpression>;
return lowerExpression(builder, expr.get('expression'));

View File

@ -0,0 +1,46 @@
## Input
```javascript
import {identity, invoke} from 'shared-runtime';
function Test() {
const str = invoke(identity<string>, '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"

View File

@ -0,0 +1,11 @@
import {identity, invoke} from 'shared-runtime';
function Test() {
const str = invoke(identity<string>, 'test');
return str;
}
export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [],
};