xstate
xstate copied to clipboard
Bug: Circular type reference in Machine Definition resolves as Actor<any>
XState version
XState version 5
Description
If i add types for ActorRefFrom to Child and Parent I get a Error: // Type error:
'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.(7022)
Expected result
Expected o circular types to work.
Actual result
Resolves as Actor<any>
Reproduction
https://stackblitz.com/edit/github-7zo8fh?file=src%2Fmain.ts
Additional context
Discord Thread: https://discord.com/channels/795785288994652170/1192785773079052298
This isn't fixable since this relationship is, indeed, circular and TypeScript has to resolve it eagerly. One side has to be typed here without the typeof query to avoid this circularity
Is there a recommended way of assigning a type here without typeof?