Commit Graph

19282 Commits

Author SHA1 Message Date
dan
7e8a06cf4c [Fresh] Always reset useMemoCache on Fast Refresh (#30700)
Stacked on https://github.com/facebook/react/pull/30662.

Alternative to https://github.com/facebook/react/pull/30663 and
https://github.com/facebook/react/pull/30677.

During a Fast Refresh, we always want to evict the memo cache, same as
we do with normal `useMemo`. The mechanism used by `useMemo` and other
Hooks is this module-level variable:


fca5d655d7/packages/react-reconciler/src/ReactFiberHooks.js (L304-L307)

which has DEV-only behavior as if the dependencies are always different:


fca5d655d7/packages/react-reconciler/src/ReactFiberHooks.js (L451-L460)

The `useMemoCache` Hook doesn't use a dependency array but conceptually
I think we want the same behavior.

## Test Plan

The test passes.

---------

Co-authored-by: Lauren Tan <poteto@users.noreply.github.com>
2024-08-15 01:02:29 +01:00
Lauren Tan
d9eb1540e2 [fresh] Add failing test for useMemoCache reset case
During local development it's common to add or remove code which may
change the cache size between renders. Add a failing test to show that
currently (without the compiled fast refresh check) this issues a
warning and reuses the cache which may have stale values.

ghstack-source-id: efdcb017ba3bdadd88b1f8bb5523b1a9f6217eb5
Pull Request resolved: https://github.com/facebook/react/pull/30662
2024-08-14 17:45:47 -04:00
Sebastian Markbåge
fca5d655d7 [DevTools] Hide props section if it is null (#30696)
We use null as a marker that we don't know what the props are as opposed
to knowing that they're empty.
2024-08-14 15:48:05 -04:00
Mike Vitousek
dd8e0ba857 [compiler] Support for useTransition
Summary:
UseTransition is a builtin hook that returns a stable value, like useState. This PR represents that in Forget, and marks the startTransition function as stable.

ghstack-source-id: 0e76a64f2d0c86a4eb55c620922b4698250bb5c3
Pull Request resolved: https://github.com/facebook/react/pull/30681
2024-08-14 13:54:39 -04:00
Mike Vitousek
179197a22a [compiler] Allow different dependencies from explicit memoization when dependency is a ref
Summary:
In theory, as I understand it, the result of a useRef will never change between renders, because we'll always provide the same ref value consistently. That means that memoization that depends on a ref value will never re-compute, so I think we could not infer it as a dependency in Forget. This diff, however, doesn't do that: it instead allows the validatePreserveExistingMemoizationGuarantees analysis to admit mismatches between explicit dependencies and implicit ones when the implicit dependency is a ref that doesn't exist in source.

ghstack-source-id: 685d859d1eed5d1e19dbbbfadc75be3875ddb6ea
Pull Request resolved: https://github.com/facebook/react/pull/30679
2024-08-14 13:54:39 -04:00
Sebastian Silbermann
5c9243d153 Rename renderToMarkup to renderToHTML (#30689) 2024-08-14 19:35:16 +02:00
Sebastian Silbermann
e0a0e65412 Move react-html to react-markup (#30688) 2024-08-14 19:22:44 +02:00
Sebastian Markbåge
49496d4937 [DevTools] Support Server Components in Tree (#30684)
This adds VirtualInstances to the tree. Each Fiber has a list of its
parent Server Components in `_debugInfo`. The algorithm is that when we
enter a set of fibers, we actually traverse level 0 of all the
`_debugInfo` in each fiber. Then level 1 of each `_debugInfo` and so on.
It would be simpler if `_debugInfo` only contained Server Component
since then we could just look at the index in the array but it actually
contains other data as well which leads to multiple passes but we don't
expect it to have a lot of levels before hitting a reified fiber.
Finally when we hit the end a traverse the fiber itself.

This lets us match consecutive `ReactComponentInfo` that are all the
same at the same level. This creates a single VirtualInstance for each
sequence. This lets the same Server Component instance that's a parent
to multiple children appear as a single Instance instead of one per
Fiber.

Since a Server Component's result can be rendered in more than one place
there's not a 1:1 mapping though. If it is in different parents or if
the sequence is interrupted, then it gets split into two different
instances with the same `ReactComponentInfo` data.

The real interesting case is what happens during updates because this
algorithm means that a Fiber can become reparented during an update to
end up in a different VirtualInstance. The ideal would maybe be that the
frontend could deal with this reparenting but instead I basically just
unmount the previous instance (and its children) and mount a new
instance which leads to some interesting scenarios. This is inline with
the strategy I was intending to pursue anyway where instances are
reconciled against the previous children of the same parent instead of
the `fiberToFiberInstance` map - which would let us get rid of that map.
In that case the model is resilient to Fiber being in more than one
place at a time.

However this unmount/remount does mean that we can lose selection when
this happens. We could maybe do something like using the tracked path
like I did for component filters. Ideally it's a weird edge case though
because you'd typically not have it. The main case that it happens now
is for reorders of list of server components. In that case basically all
the children move between server components while the server components
themselves stay in place. We should really include the key in server
components so that we can reconcile them using the key to handle
reorders which would solve the common case anyway.

I convert the name to the `Env(Name)` pattern which allows the
Environment Name to be used as a badge.

<img width="1105" alt="Screenshot 2024-08-13 at 9 55 29 PM"
src="https://github.com/user-attachments/assets/323c20ba-b655-4ee8-84fa-8233f55d2999">

(Screenshot is with #30667. I haven't tried it with the alternative
fix.)

---------

Co-authored-by: Ruslan Lesiutin <rdlesyutin@gmail.com>
2024-08-14 11:16:51 -04:00
Jack Pope
0ad0fac1dc Fix unstable_useContextWithBailout dispatcher assignment (#30692)
One more copy pasta fix

Assignments are unique now
```
% cat packages/react-reconciler/src/ReactFiberHooks.js | grep .unstable_useContextWithBailout
function unstable_useContextWithBailout<T>(
  (ContextOnlyDispatcher: Dispatcher).unstable_useContextWithBailout =
  (HooksDispatcherOnMount: Dispatcher).unstable_useContextWithBailout =
    unstable_useContextWithBailout;
  (HooksDispatcherOnUpdate: Dispatcher).unstable_useContextWithBailout =
    unstable_useContextWithBailout;
  (HooksDispatcherOnRerender: Dispatcher).unstable_useContextWithBailout =
    unstable_useContextWithBailout;
    (HooksDispatcherOnMountInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (HooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (HooksDispatcherOnRerenderInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
    (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).unstable_useContextWithBailout =
        return unstable_useContextWithBailout(context, select);
```
2024-08-14 11:04:42 -04:00
Ruslan Lesiutin
fbfe08de61 fix[react-devtools/InspectedElement]: fixed border stylings when some of the panels are not rendered (#30676)
Alternative to https://github.com/facebook/react/pull/30667.

Basically wrap every section in a `div` with the same class, and only
apply `border-bottom` for every instance, except for the last child. We
are paying some cost by having more divs, but thats more explicit.
2024-08-14 13:35:06 +01:00
Josh Story
2a540194ad [Flight] do not emit error after abort (#30683)
When synchronously aborting in a non-async Function Component if you
throw after aborting the task would error rather than abort because
React never observed the AbortSignal.

Using a sigil to throw after aborting during render isn't effective b/c
the user code itself could throw so insteead we just read the request
status. This is ok b/c we don't expect any tasks to still be pending
after the currently running task finishes.

However I found one instance where that wasn't true related to
serializing thenables which I've fixed so we may find other cases. If we
do, though it's almost certainly a bug in our task bookkeeping so we
should just fix it if it comes up.

I also updated `abort` to not set the status to ABORTING unless the
status was OPEN. we don't want to ever leave CLOSED or CLOSING status
2024-08-13 20:59:45 -07:00
Mike Vitousek
8e60bacd08 [compiler] Reordering of logical expressions
ghstack-source-id: ad484f97451c65a2642618bfb9d540d6a53a19a6
Pull Request resolved: https://github.com/facebook/react/pull/30678
2024-08-13 16:57:45 -04:00
Josh Story
f6d1df6648 [Flight] erroring after abort should not result in unhandled rejection (#30675)
When I implemented the ability to abort synchronoulsy in flight I made
it possible for erroring async server components to cause an unhandled
rejection error. In the current implementation if you abort during the
synchronous phase of a Function Component and then throw an error in the
synchronous phase React will not attach any promise handlers because it
short circuits the thenable treatment and throws an AbortSigil instead.
This change updates the rendering logic to ignore the rejecting
component.
2024-08-13 13:42:10 -07:00
Mike Vitousek
a601d1da36 [compiler] Allow lets to be hoisted
ghstack-source-id: 02f4698bd98705a855deb0d4bc30b9829afdddc0
Pull Request resolved: https://github.com/facebook/react/pull/30674
2024-08-13 16:35:56 -04:00
Sebastian Markbåge
082a690cc3 [DevTools] Compute new reordered child set from the instance tree (#30668)
This is already filtered and simply just all the ids in the linked list.

Same principle as #30665.
2024-08-13 15:18:34 -04:00
Sebastian Markbåge
e865fe0722 [DevTools] Unmount instance by walking the instance tree instead of the fiber tree (#30665)
There was a comment that it's not safe to walk the unmounted fiber tree
which I'm not sure is correct or not but we need to walk the instance
tree to be able to clean up virtual instances anyway. We already walk
the instance tree to clean up "remaining instances".

This is also simpler because we don't need to special case Suspense
boundaries. We simply clean up whatever branch we had before.

The ultimate goal is to also walk the instance tree for updates so we
don't need a fiber to instance map.
2024-08-13 15:18:24 -04:00
Jack Pope
d48603a525 Fix unstable_useContextWithBailout incorrect dispatcher assignment (#30673)
Fixing a mistaken copy from another dispatcher property assignment
2024-08-13 11:31:44 -04:00
Timothy Yung
23830ea2a1 Unit Test for findNodeHandle Error Behavior (#30669)
## Summary

As promised on https://github.com/facebook/react/pull/29627, this
creates a unit test for the `findNodeHandle` error that prevents
developers from calling it within render methods.

## How did you test this change?

```
$ yarn test ReactFabric-test.internal.js
```
2024-08-12 16:32:40 -07:00
Mike Vitousek
0d7c12c779 [compiler][ez] Enable some sprout tests that no longer need to be disabled
Summary:
As title. Better support for flow typing, bugfixes, etc fixes these

ghstack-source-id: 6326653ce42b33b6c1c76a494434d133382ca80a
Pull Request resolved: https://github.com/facebook/react/pull/30591
2024-08-12 12:55:55 -07:00
Mike Vitousek
6532c41256 [compiler] Allow macro methods
Summary:
Builds support for macros that are invoked as methods rather than just function calls or jsx.

We now record macros as a schema that represents arbitrary member expressions including wildcards (so we can support, e.g., myMacro.*.foo.bar). When examining PropertyLoads in the macro memoization stage, we build up a map of partially-satisfied macro patterns until we determine that the pattern has been fully satisfied, at which point we treat the result of the PropertyLoad as a macro value.

ghstack-source-id: d78d9ba7041968c861ffa110fb7882b339a0e257
Pull Request resolved: https://github.com/facebook/react/pull/30589
2024-08-12 12:55:55 -07:00
Mike Vitousek
d50e024fd4 [compiler] Promote temporaries when necessary to prevent codegen reordering over side-effectful operations
ghstack-source-id: 639191e63a
Pull Request resolved: https://github.com/facebook/react/pull/30554
2024-08-12 12:36:49 -07:00
Lauren Tan
fbe81b214a [compiler] Publish to latest tag
> [!NOTE]
> The `latest` tag is published by default if no tag is specified, which
> is what we had done since the first release of the compiler

In my last PR to auto publish compiler releases I had added the
experimental tag to be used in publishing. However because we had
already previously published to the latest tag (which is non-removable)
this means that the `latest` tag is pinned to an old version. That makes
untagged installs of the compiler default to that old version instead of
whatever is the latest.

This changes the behavior back to what it was before. Since we are still
in the experimental release of the compiler anyway it seems fine to use
the latest tag. When we reach stable, we can update this to only push to
latest for stable releases.

ghstack-source-id: 1809481b45
Pull Request resolved: https://github.com/facebook/react/pull/30666
2024-08-12 14:41:11 -04:00
Sebastian Markbåge
25c584f567 [DevTools] Further Refactoring of Unmounts (#30658)
Stacked on #30625 and #30657.

This ensures that we only create instances during the commit
reconciliation and that we don't create unnecessary instances for things
that are filtered or not mounted. This ensures that we also can rely on
the reconciliation to do all the clean up. Now everything is created and
deleted as a pair in the same pass.

Previously we were including unfiltered components in the owner stack
which probably doesn't make sense since you're intending to filter them
everywhere presumably. However, it also means that those links were
broken since you can't link into owners that don't exist in the parent
tree.

The main complication is the component filters. It relied on not
unmounting the old instances. I had to update some tests that asserted
on ids that are now shifted.

For warnings/errors tracking I now restore them back into the pending
set when they unmount. Basically it puts them back into their
"pre-commit" state. That way when they remount they’re still there.

For restoring the current selection I use the tracked path mechanism
instead of relying on the id being unchanged. This is better anyway
because if you filter out the currently selected item it's better to
select the nearest match instead of just losing the selection.
2024-08-12 12:41:29 -04:00
Sebastian Markbåge
b4c38015d0 [DevTools] Remove lodash.throttle (#30657)
Same principle as #30555. We shouldn't be throttling the UI to make it
feel less snappy. Instead, we should use back-pressure to handle it.
Normally the browser handles it automatically with frame aligned events.
E.g. if the thread can't keep up with sync updates it doesn't send each
event but the next one. E.g. pointermove or resize.

However, it is possible that we end up queuing too many events if the
frontend can't keep up but the solution to this is the same as mentioned
in #30555. I.e. to track the last message and only send after we get a
response.

I still keep the throttle to persist the selection since that affects
the disk usage and doesn't have direct UX effects.

The main motivation for this change though is that lodash throttle
doesn't rely on timers but Date.now which makes it incompatible with
most jest helpers which means I can't write tests against these
functions properly.
2024-08-12 12:32:55 -04:00
Sebastian Markbåge
68dbd84b61 [DevTools] Unmount by walking previous nodes no longer in the new tree (#30644)
This no longer uses the handleCommitFiberUnmount hook to track unmounts.
Instead, we can just unmount the DevToolsInstances that we didn't reuse.
This doesn't account for cleaning up instances that were unnecessarily
created when they weren't in the tree. I have a separate follow up for
that.

This also removes the queuing of untracking. This was added in #21523
but I don't believe it has been needed for a while because the mentioned
flushPendingErrorsAndWarningsAfterDelay hasn't called untrackFiberID for
a while so the race condition doesn't exist. It's hard to tell though
because from the issues there weren't really any repros submitted.
2024-08-12 00:35:42 -04:00
Mofei Zhang
8d74e8c73a [compiler] Patch error reporting for blocklisted imports
ghstack-source-id: 614c1e9c04828bfa2da13a6abaeff7ce3e67cb9b
Pull Request resolved: https://github.com/facebook/react/pull/30652
2024-08-09 15:19:07 -07:00
hylinz
2504dbd669 Punctuation & correcting spelling mistakes (#30592) 2024-08-09 14:53:53 -07:00
Joe Savona
54a150dc6e [compiler][be] Remove completed todo comment
We made block types explicit a long time ago, this comment is super stale

ghstack-source-id: 810a34bb4c14a3f4541003db23ffb7ad91aecc8c
Pull Request resolved: https://github.com/facebook/react/pull/30633
2024-08-09 14:11:01 -07:00
Joe Savona
229038eab8 [compiler][be] Cleanup class naming in PromoteUsedTemporaries
I forgot to clean this up before landing #30573.

ghstack-source-id: 2141471912e410aa12545dcf7989f45447007ba9
Pull Request resolved: https://github.com/facebook/react/pull/30632
2024-08-09 14:11:01 -07:00
Jan Kassens
0e6d8c3d1a [ci] fix path in compiler_typescript.yml (#30651)
The path was incorrect, so the job didn\t run on changes to it.
2024-08-09 13:21:24 -04:00
Mofei Zhang
2d2cc042d7 [compiler][ez] Option to bail out on blocklisted imports
ghstack-source-id: 540d154b25e49a83683a05fc9326dbd0ad59a6bd
Pull Request resolved: https://github.com/facebook/react/pull/30643
2024-08-09 09:10:01 -07:00
Mofei Zhang
3871fdadaa [compiler][be] Clean up compilation skipping logic in Program
ghstack-source-id: fe2c81de9d4f41a787c690b722cbcff55eb18ac3
Pull Request resolved: https://github.com/facebook/react/pull/30642
2024-08-09 09:10:01 -07:00
Mofei Zhang
0fb03c4952 [compiler][ez] Add types for Math.min, recursive global
ghstack-source-id: 9940b8f96eec3fb2b411af8a7c92d93aae6da85e
Pull Request resolved: https://github.com/facebook/react/pull/30641
2024-08-09 09:10:01 -07:00
Sebastian Markbåge
587f03c922 [DevTools] Build up DevTools Instance Shadow Tree (#30625)
This is the beginning of a refactor of the DevTools Fiber backend. The
new approach is basically that we listen to each commit from Fiber and
traverse the tree - building up a filtered shadow tree. Then we send
diffs based on that tree and perform our own operations against that
instead of using Fibers as the source of truth.

Fiber diffs Elements -> Fibers. The backend diffs Fibers ->
DevToolsInstances as a side-effect it sends deltas to the front end.

This makes the algorithm resilient to a different Fiber implementation
that doesn't use pairs of Fibers (alternates) but instead stateless new
clones each time. In that world we can't treat Fibers as instances. They
can hold onto instances but they're not necessarily 1:1 themselves.

The same thing also applies to Server Components that don't have their
own instances.

The algorithm is more or less the same as React's reconciliation in
ReactChildFiber itself. However, we do a mutable update of the tree as
we go. We also cheat a bit here in the first version in that we still
have fiberToFiberInstance map and alternate which makes reorders easier.
Further down we could do the reorders by adding the previous set to a
temporary map like ChildFiber does but only if they're not already in
order.

This first bit is just about making sure that we produce correct trees.
We have fairly good test coverage already of that already.

In the next few follow ups I'll start simplifying the rest of the logic
by taking advantage of the new tree.
2024-08-08 12:44:35 -04:00
Jan Kassens
fb1c63fb76 [compiler] remove duplicate root files (#30639)
These files are duplicates from the root from a time when React Compiler
was in a different repo.
2024-08-08 12:42:45 -04:00
Sathya Gunsasekaran
9d2da5913a [compiler] Add context callee import if required
Previously the compiler would add an import for the specified context
callee even if the context access was not lowered, leading to unused
imports.

This PR tracks if lowering has happened and adds the import only when
necessary.

ghstack-source-id: 6ad794da41116e1034783b6c4a58fbfe7790343e
Pull Request resolved: https://github.com/facebook/react/pull/30628
2024-08-08 15:53:13 +01:00
Sathya Gunsasekaran
83cc13f746 [compiler] Rewrite useContext callee
If a value is specified for the LowerContextAccess environment config,
we rewrite the callee from 'useContext' to the specificed value.

This will allow us run an experiment internally.

ghstack-source-id: 00e161b988c8f8a1cf96efff8095f050cb534cc1
Pull Request resolved: https://github.com/facebook/react/pull/30612
2024-08-08 15:53:13 +01:00
Sol Lee
8b31835fc0 [compiler] Replace for...in with for...of for array of strings (#30631)
closes https://github.com/facebook/react/issues/30627

Thanks!
2024-08-07 22:07:04 -07:00
Mofei Zhang
a037dabd42 [compiler] Patch ValidatePreserveMemo to bailout correctly for refs
ghstack-source-id: b9c13bf5f8
Pull Request resolved: https://github.com/facebook/react/pull/30603
2024-08-07 18:57:57 -07:00
Mofei Zhang
53194c8792 [compiler] Remove transitive memo check in validatePreserveMemo
ghstack-source-id: 45521370e4
Pull Request resolved: https://github.com/facebook/react/pull/30630
2024-08-07 18:57:56 -07:00
Mofei Zhang
2f8ff3deb2 [compiler][repro] False positives for ValidatePreserveMemo
ghstack-source-id: 7fa94fea86
Pull Request resolved: https://github.com/facebook/react/pull/30629
2024-08-07 18:57:56 -07:00
Mofei Zhang
2bd415355e [compiler][repro] ValidatePreserveMemo x useRef bug
ghstack-source-id: 6ac5d58e97
Pull Request resolved: https://github.com/facebook/react/pull/30602
2024-08-07 18:57:56 -07:00
Mofei Zhang
e662b0a24b [compiler][be] Less ambiguous error messages for validateMemo bailout
ghstack-source-id: 312093ec74
Pull Request resolved: https://github.com/facebook/react/pull/30601
2024-08-07 18:57:56 -07:00
Sathya Gunsasekaran
e948a5ac68 [compiler] Add lowerContextAccess pass
*This is only for internal profiling, not intended to ship.*

This pass is intended to be used with https://github.com/facebook/react/pull/30407.

This pass synthesizes selector functions by collecting immediately
destructured context acesses. We bailout for other types of context
access.

This pass lowers context access to use a selector function by passing
the synthesized selector function as the second argument.

ghstack-source-id: 92d0f6ff2f
Pull Request resolved: https://github.com/facebook/react/pull/30548
2024-08-07 16:30:11 +01:00
Mike Vitousek
9eb288e657 [compiler][ez] Default to using flow suppressions
ghstack-source-id: b6592650e0
Pull Request resolved: https://github.com/facebook/react/pull/30622
2024-08-06 23:47:09 -07:00
Lauren Tan
838da52d67 [ci] Fix incorrect tags being pushed for compiler releases
ghstack-source-id: 812e49333c
Pull Request resolved: https://github.com/facebook/react/pull/30620
2024-08-06 17:27:27 -04:00
Lauren Tan
030d83bab4 [ci] Fix dist-tag command
ghstack-source-id: bdbcc12b28
Pull Request resolved: https://github.com/facebook/react/pull/30619
2024-08-06 15:35:38 -04:00
Lauren Tan
9f0508fcf4 [final] Actually publish packages to npm
ghstack-source-id: 78a358a81726f1e9898be7f46de23e80005b5bfd
Pull Request resolved: https://github.com/facebook/react/pull/30618
2024-08-06 15:12:03 -04:00
Joe Savona
3d61b9b4cd [compiler] Stay in SSA form through entire pipeline
This PR updates to use SSA form through the entire compilation pipeline. This means that in both HIR form and ReactiveFunction form, `Identifier` instances map 1:1 to `IdentifierId` values. If two identifiers have the same IdentifierId, they are the same instance. What this means is that all our passes can use this more precise information to determine if two particular identifiers are not just the same variable, but the same SSA "version" of that variable.

However, some parts of our analysis really care about program variables as opposed to SSA versions, and were relying on LeaveSSA to reset identifiers such that all Identifier instances for a particular program variable would have the same IdentifierId (though not necessarily the same Identifier instance). With LeaveSSA removed, those analysis passes can now use DeclarationId instead to uniquely identify a program variable.

Note that this PR surfaces some opportunties to improve edge-cases around reassigned values being declared/reassigned/depended-upon across multiple scopes. Several passes could/should use IdentifierId to more precisely identify exactly which values are accessed - for example, a scope that reassigns `x` but doesn't use `x` prior to reassignment doesn't have to take a dependency on `x`. But today we take a dependnecy.

My approach for these cases was to add a "TODO LeaveSSA" comment with notes and the name of the fixture demonstrating the difference, but to intentionally preserve the existing behavior (generally, switching to use DeclarationId when IdentifierId would have been more precise).

Beyond updating passes to use DeclarationId instead of Identifier/IdentifierId, the other change here is to extract out the remaining necessary bits of LeaveSSA into a new pass that rewrites InstructionKind (const/let/reassign/etc) based on whether a value is actually const or has reassignments and should be let.

ghstack-source-id: 69afdaee5fadf3fdc98ce97549da805f288218b4
Pull Request resolved: https://github.com/facebook/react/pull/30573
2024-08-06 12:02:50 -07:00
Joe Savona
22360089b5 [compiler] Add Identifier.declarationId
Adds `Identifier.declarationId` and the new `DeclarationId` (simulated) opaque type. DeclarationId allows uniquely identifying a variable in the original source, ie regardless of reassignments. This allows us to stay in SSA form throughout compilation (see next diff) while still being able to distinguish SSA versions (via IdentifierId) and non-SSA versions (DeclarationId).

ghstack-source-id: f2547a58aa7b30cea29fcfe23d5cb45583858a4e
Pull Request resolved: https://github.com/facebook/react/pull/30569
2024-08-06 12:02:50 -07:00