Repository navigation
Resolve # targets by exact id only - #5814
Conversation
🦋 Changeset detectedLatest commit: cff1d05 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…larify route id docs
Rule
#xis an exact id lookup. The text after#is matched against state ids as a whole and is never split into a path. It matches a state's explicitidor its implicit id (path from the root joined by., prefixed by the machine id when set; escaped key segments keep\.). Explicit ids are opaque strings: dots need no escaping. Applies to transition targets,initial: { target: '#…' },snapshot.matches('#…'),@xstate.stateInandgetStateNodeById. Combining an id with a relative path (#someId.foo.bar) is no longer supported. Prior art: CSS#id, SCXML id-only targets.Before / after
Error suggestion
When a prefix of the id is a state id and the rest resolves beneath it as a relative path, the error names the target's actual id (
Use "#bee".when the target has an explicit id). Otherwise:No state has id "…".Duplicate ids still throw.Changes
getStateNodeByIddoes oneidMaplookup; removed the first-segment+path resolution, the implicit-id fallback, the\.unescaping for ids, and the#branches ingetStateNodeByPath/getStateNode.@xstate/testcoverage target resolution no longer falls back to path parsing for#strings.createMachine#targets andsetup()id targets accept only whole ids (explicit ids unescaped; implicit ids forcreateMachine). Removed#id.pathcomposition types.report-id-path-targetstransform; flags#a.btargets (target,initial, bareon/aftervalues, arrays) andmatches/stateInarguments (string or static template literals) that are not whole state ids of the enclosingcreateMachine/createStateConfigconfig; references outside a config are always reported. Included in the manual-migration section.machineFromJSONand@xstate/testpropertyTestalready did exact lookups;@xstate/scxmlemits#idwith.sanitized to$(unaffected); graph utilities do not parse#targets.Verification
pnpm install --frozen-lockfile,pnpm build,pnpm test(264 files, 4448 passed / 32 skipped / 3 todo),pnpm typecheck,pnpm typecheck:examples,pnpm lint,pnpm format:check,pnpm check:exports,pnpm check:packed,pnpm knip,pnpm bench:type-errors --check(snapshot unchanged) all pass. Lockfile unchanged.