mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[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:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user