Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: AssignAction type error when using exactOptionalPropertyTypes: true #4613

Open
SandroMaglione opened this issue Dec 22, 2023 · 4 comments
Assignees
Labels

Comments

@SandroMaglione
Copy link

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.

@SandroMaglione
Copy link
Author

@Andarist is there any workaround for this? Do you know if it's possible to disable exactOptionalPropertyTypes for a specific file?

@davidkpiano
Copy link
Member

@Andarist is there any workaround for this? Do you know if it's possible to disable exactOptionalPropertyTypes for a specific file?

I updated XState and TypeScript in this codebase and it seems to work fine: https://stackblitz.com/edit/vitejs-vite-lbw4wa?file=package.json,src%2Fmain.ts

Can you double-check that everything's working on your end?

@SandroMaglione
Copy link
Author

@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

@Andarist
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants