DrSensor / scdlang

(status: soon revived as different project) Statechart Description Language (just an experiment, need to be rewritten)
Universal Permissive License v1.0
101 stars 2 forks source link

Generate typescript declaration for XState #17

Open DrSensor opened 5 years ago

DrSensor commented 5 years ago
{
  "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

DrSensor commented 5 years ago

This is just a temporary hack, in the future find a way to use and contribute to swc_ecma_codegen typescript implementation. (hint: fork then include that as a git-submodule)

beware: this might need more RAM since Rust langserver doesn't have a mode to conserve memory. So delay this until I can buy better laptop 😢