You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compilation fails when compiling with TypeScript v4.8.2
Error message:
node_modules/xstate/lib/interpreter.d.ts:181:122 - error TS2344: Type 'TChildStateSchema' does not satisfy the constraint 'StateSchema<any>'.
181 spawnMachine<TChildContext, TChildStateSchema, TChildEvent extends EventObject>(machine: StateMachine<TChildContext, TChildStateSchema, TChildEvent>, options?: {
~~~~~~~~~~~~~~~~~
node_modules/xstate/lib/interpreter.d.ts:181:33
181 spawnMachine<TChildContext, TChildStateSchema, TChildEvent extends EventObject>(machine: StateMachine<TChildContext, TChildStateSchema, TChildEvent>, options?: {
~~~~~~~~~~~~~~~~~
This type parameter might need an `extends StateSchema<any>` constraint.
node_modules/xstate/lib/types.d.ts:231:62 - error TS2344: Type 'TStateSchema["states"][K]' does not satisfy the constraint 'StateSchema<any>'.
Type 'TStateSchema["states"][keyof TStateSchema["states"]]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string] | TStateSchema["states"][number] | TStateSchema["states"][symbol]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string]' is not assignable to type 'StateSchema<any>'.
231 [K in keyof TStateSchema['states']]: StateNode<TContext, TStateSchema['states'][K], TEvent>;
~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/xstate/lib/types.d.ts:234:68 - error TS2344: Type 'TStateSchema["states"][K]' does not satisfy the constraint 'StateSchema<any>'.
Type 'TStateSchema["states"][keyof TStateSchema["states"]]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string] | TStateSchema["states"][number] | TStateSchema["states"][symbol]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string]' is not assignable to type 'StateSchema<any>'.
234 [K in keyof TStateSchema['states']]: StateNodeConfig<TContext, TStateSchema['states'][K], TEvent, TAction>;
~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/xstate/lib/types.d.ts:237:72 - error TS2344: Type 'TStateSchema["states"][K]' does not satisfy the constraint 'StateSchema<any>'.
Type 'TStateSchema["states"][keyof TStateSchema["states"]]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string] | TStateSchema["states"][number] | TStateSchema["states"][symbol]' is not assignable to type 'StateSchema<any>'.
Type 'TStateSchema["states"][string]' is not assignable to type 'StateSchema<any>'.
237 [K in keyof TStateSchema['states']]: StateNodeDefinition<TContext, TStateSchema['states'][K], TEvent>;
~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 errors in 2 files.
Errors Files
1 node_modules/xstate/lib/interpreter.d.ts:181
3 node_modules/xstate/lib/types.d.ts:231
Expected result
Application complies without error
Actual result
Compilation fails with the error noted above
Reproduction
Need to run tsc to see error
Additional context
Tried xstate 4.32.1 and 4.33.2, same result. This is our tsconfig:
I've created a PR to fix this in XState: #3559 . However, in the process, I've discovered a bug in TS that prevents me from applying a better fix (in my eyes). I've even managed to fix the said bug: microsoft/TypeScript#50540 so let's wait a couple of days to see what happens with this PR.
In the meantime, you should be able to use skipLibCheck: true in your tsconfig.json to work around this issue.
Description
Compilation fails when compiling with TypeScript v4.8.2
Error message:
Expected result
Application complies without error
Actual result
Compilation fails with the error noted above
Reproduction
Need to run tsc to see error
Additional context
Tried xstate 4.32.1 and 4.33.2, same result. This is our tsconfig:
The text was updated successfully, but these errors were encountered: