[compiler] Make compiler aware of whether a local binding is constlike or not

Summary:
Minor change which supports the changeDetection work later on. We can know whether an individual local binding is const or constlike.

[ghstack-poisoned]
This commit is contained in:
Mike Vitousek
2024-07-18 09:17:57 -07:00
parent 26a95b10a1
commit ffd72dde5f
2 changed files with 6 additions and 1 deletions
@@ -1168,7 +1168,7 @@ export type NonLocalBinding =
imported: string;
}
// let, const, function, etc declared in the module but outside the current component/hook
| { kind: "ModuleLocal"; name: string }
| { kind: "ModuleLocal"; name: string; immutable: boolean }
// an unresolved binding
| { kind: "Global"; name: string };
@@ -271,9 +271,14 @@ export default class HIRBuilder {
module: importDeclaration.node.source.value,
};
} else {
const immutable =
(path.isVariableDeclaration() && path.node.kind === "const") ||
path.isClassDeclaration() ||
path.isClassExpression();
return {
kind: "ModuleLocal",
name: originalName,
immutable,
};
}
}