scdlang icon indicating copy to clipboard operation
scdlang copied to clipboard

Generate typescript declaration for XState

Open DrSensor opened this issue 5 years ago • 1 comments

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

  • https://github.com/arabidopsis/typescript-definitions/issues/2
  • https://github.com/evestera/json_typegen/issues/10

DrSensor avatar Jun 08 '19 09:06 DrSensor

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 😢

DrSensor avatar Jul 14 '19 20:07 DrSensor