Skip to content

Commit 1d78a83

Browse files
committed
fix(compiler): unwrap TS wrappers on method-call receiver and computed key in dep collection
staticDepMemberName and the CallExpression handler in collectDepPaths did not peel TSAsExpression, TSNonNullExpression, TSSatisfiesExpression, TSTypeAssertion, or ParenthesizedExpression from the receiver object or computed property key. Spellings such as props!.load(id), (props as T).load(id), or props['load' as const](id) fell through to the fallback walk and recorded the whole receiver as a free identifier instead of emitting the guarded __methodDep probe. Apply unwrapTsExpr to callee.object in the CallExpression handler and to member.property in staticDepMemberName, matching the unwrapValue already used by staticMemberInfo in hook-deps.js.
1 parent 0f03a0d commit 1d78a83

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎packages/octane/src/compiler/compile.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18077,12 +18077,9 @@ function staticDepMemberName(node) {
1807718077
const member = depPathMember(node);
1807818078
if (member === null) return null;
1807918079
if (!member.computed && member.property.type === 'Identifier') return member.property.name;
18080-
if (
18081-
member.computed &&
18082-
member.property.type === 'Literal' &&
18083-
typeof member.property.value === 'string'
18084-
) {
18085-
return member.property.value;
18080+
if (member.computed) {
18081+
const prop = unwrapTsExpr(member.property);
18082+
if (prop?.type === 'Literal' && typeof prop.value === 'string') return prop.value;
1808618083
}
1808718084
return null;
1808818085
}
@@ -18342,10 +18339,11 @@ export function collectDepPaths(expr, coarsenDepRoots, isModuleBound, methodDep)
1834218339
case 'CallExpression': {
1834318340
const callee = depPathMember(unwrapTsExpr(n.callee));
1834418341
const name = staticDepMemberName(callee);
18345-
if (callee?.object.type === 'Identifier' && name !== null) {
18346-
if (isFree(callee.object, callee, 'object') && !deferredAmbient(callee.object.name)) {
18342+
const obj = callee ? unwrapTsExpr(callee.object) : undefined;
18343+
if (obj?.type === 'Identifier' && name !== null) {
18344+
if (isFree(obj, callee, 'object') && !deferredAmbient(obj.name)) {
1834718345
const member = b.member(
18348-
b.id(callee.object.name),
18346+
b.id(obj.name),
1834918347
callee.computed ? b.literal(name, JSON.stringify(name)) : b.id(name),
1835018348
callee.computed,
1835118349
);

0 commit comments

Comments
 (0)