json_typegen results
{
"states": {
"set": {
"on": {
"TOGGLE": "reset",
"RESET": "reset",
"OFF": "set"
}
},
"reset": {
"on": {
"TOGGLE": "set",
"SET": "set",
"DATA": "set"
}
}
}
}
json_typegen above.json -O typescript --name MachineConfig > below.ts
interface MachineConfig {
states: States;
}
interface States {
set: Set;
reset: Reset;
}
interface Set {
on: On;
}
interface On {
TOGGLE: string;
RESET: string;
OFF: string;
}
interface Reset {
on: On2;
}
interface On2 {
TOGGLE: string;
SET: string;
DATA: string;
}
Things to keep track
assess if serde typescript-definitions crates is suitablethe type must be determined before compilation so it can't generate n-number of possible types in a union type ❌interfaceand uniontypefor Stateinvestigate if serde typescript-definitions can generateit can generate type of plain object ✔️interface(or atleast plain objecttypecan be treated asinterfacein XState)json_typegenresults{ "states": { "set": { "on": { "TOGGLE": "reset", "RESET": "reset", "OFF": "set" } }, "reset": { "on": { "TOGGLE": "set", "SET": "set", "DATA": "set" } } } }json_typegen above.json -O typescript --name MachineConfig > below.tsThings to keep track