xstate: Bug: `AssignAction` type error when using `exactOptionalPropertyTypes: true`

XState version

XState version 5

Description

An assign action reports a type error when using exactOptionalPropertyTypes: true in tsconfig.json.

Expected result

It should be possible to use exactOptionalPropertyTypes: true with xstate.

Actual result

Reproduction

https://stackblitz.com/edit/vitejs-vite-lbw4wa?file=src%2Fmain.ts

Additional context

exactOptionalPropertyTypes allows for more type-safety. It is also recommended when using @effect/schema.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@Andarist is there any workaround for this?

I wasn’t yet able to figure out a workaround. It’s definitely possible to fix this on our side but it requires prioritization and time.

Do you know if it’s possible to disable exactOptionalPropertyTypes for a specific file?

No, it’s a global setting.

Also seeing this. Seems like only option is to disabled exactOptionalPropertyTypes for now which isn’t ideal but not the end of the world.

@davidkpiano it seems to be working now when only actions are defined.

When instead I add also actors (as I need in my codebase) the issue comes back: https://stackblitz.com/edit/vitejs-vite-aesqqz?file=package.json,src%2Fmain.ts