Opening this issue to spawn a discussion about type-safety. Lucy offers a nice opportunity to increase TS type safety by statically analysing the machine. This is similar to, but much more reliable than, xstate-codegen. xstate-codegen pulls out machines from JS/TS, which is fraught with issues. Lucy could statically analyse files, free of side effects, and create 100% perfect types every time.
What do perfect types look like?
- All actions/guards/services know what events caused them to fire.
state.matches can be made type safe.
Because Lucy compiles to out.js files, an accompanying .d.ts file would be appropriate. Users could also pass it generics, such as TEvent and TContext, similar to xstate-codegen.
Interested to hear your thoughts.
Opening this issue to spawn a discussion about type-safety. Lucy offers a nice opportunity to increase TS type safety by statically analysing the machine. This is similar to, but much more reliable than, xstate-codegen.
xstate-codegenpulls out machines from JS/TS, which is fraught with issues. Lucy could statically analyse files, free of side effects, and create 100% perfect types every time.What do perfect types look like?
state.matchescan be made type safe.Because Lucy compiles to
out.jsfiles, an accompanying.d.tsfile would be appropriate. Users could also pass it generics, such asTEventandTContext, similar toxstate-codegen.Interested to hear your thoughts.