Open pauldesmondparker opened 2 weeks ago
Short term remediation:
// @ts-expect-error exactOptionalPropertyTypes
Second remediation:
onDone: {
actions: ({ event }) => assign({
user: event.output, // Strongly typed as User
}),
},
Making actions an anonymous function, either returning a single action or an array of actions works fine.
XState version
XState version 5
Description
Reproduction on typescritplang.org.
typescript: v5.6.3 xstate: 5.18.2
Code is the same as the #invoke-and-typescript example with a few tweaks.
Navigate to
TS Config
and setexactOptionalPropertyTypes
.The resulting error on
onDone
will be:Expected result
No typescript error.
Actual result
Reproduction
https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true&ts=5.6.3#code/JYWwDg9gTgLgBAbzgQwM6uAcwHYBo4BmUEIACsSMKgKb40wCuYcAvoRXAOQAeqMyMapwDccOAHpxcGAE8w1VAC44AVgB0ARgAcagEwAoQ8GyCoBZAGNqcAKo0oifWOAATZdgYgARtSjCncNjIINTKfFDGmP4shtTckLBwFhDYfHAglgAWxtYAvHD0TAAUCAGy8kqOYmLJJnEwyghsaFXVYgz2AJJugZ4+fgFtHb4A-Mp2vv5tLLgBMwGWMNCVpW0E1DAWmRNQykQk5CRU1AA8O-hIw1Dd7n2+rAB8RWgy2BZwJXDGYAzwLACUcFyD1abVqaSgCkgqTyKAA7shgPBDpQaGpIagIAAbABu1BKgzaXx631+aiu3VmROqQRCyk4AAkGJgIJwqUSAVMiZDGFBsHAMdCaFyxAD2fMAWoLJCBNQALJZHIEsSSOBqdUBWqCbgNUFwCk9AAsunF7OMSOAyCx9NcWKE7L4spWhNtoT1YhSjUJbWoLiROwAIhtEViVtJkFBMBt6ViIMg-dhMDtOKx2dM06nCbH45Edl7qcYcRAANZu1bUgpQCz09abbb2Nne6qk3WfLX1ViA4EfcsV-VdHrtnXkgf4VUAFTk1mo2AI0CsLmkEDgPgKMAiiabov+GbaKQDKTLW+qi2AKUqaAwOGVfeqV2Un2oeJMnaBIKfM5gaggvx+MDHUgAMrrikmBYjI0hTouLQ7Me267tU8zUkhiGmvonJAA
Additional context
No response