XState version
XState version 5
Description
TypesScript fails to emit declarations for the return type of setup().
Expected result
No TS error and successfully emitted declaration.
Actual result
Two kinds of errors are thrown:
The inferred type of 'machineSetup' cannot be named without a reference to '../node_modules/xstate/dist/declarations/src/guards'. This is likely not portable. A type annotation is necessary.(2742)
Exported variable 'machineSetup' has or is using name 'SpawnActionOptions' from external module "node_modules/xstate/dist/declarations/src/actions/spawnChild" but cannot be named.(4023)
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.(7056)
Reproduction
https://stackblitz.com/edit/typescript-node-njljw24f
Additional context
This is somehow related to module and moduleResolution tsconfig settings.
Explicitly typing the value could be a challenge due to the complexity of the type relying on inference and self referencing in some cases, e.g. self in the action params.
XState version
XState version 5
Description
TypesScript fails to emit declarations for the return type of
setup().Expected result
No TS error and successfully emitted declaration.
Actual result
Two kinds of errors are thrown:
Reproduction
https://stackblitz.com/edit/typescript-node-njljw24f
Additional context
This is somehow related to
moduleandmoduleResolutiontsconfig settings.Explicitly typing the value could be a challenge due to the complexity of the type relying on inference and self referencing in some cases, e.g.
selfin the action params.