You are reading a single comment by @luwar and its replies. Click here to read the full conversation.
  • I use Espruino with TypeScript and was a bit disappointed at the time that the Typescript goal of the last campaign was not reached.

    So I tried to generated a file espruino.d.ts by myself but gave up. It's seems not possible to generate good TypeScript definitions from the other type files (e.g. espruino.json). There are more informations required than available:

    // This class should be automatically generated.
    class I2C {
            // ...
            readFrom( address: number | { address: number, stop: boolean }, quantity: number ): Uint8Array;

    But the corresponding jswrap comment is

      "type" : "method",
      "class" : "I2C",
      "name" : "readFrom",
      "generate" : "jswrap_i2c_readFrom",
      "params" : [
        ["address","JsVar","The 7 bit address of the device to request bytes from, or an object of the form `{address:12, stop:false}` to send this data without a STOP signal."],
        ["quantity","int32","The number of bytes to request"]
      "return" : ["JsVar","The data that was returned - as a Uint8Array"],
      "return_object" : "Uint8Array"
    Request bytes from the given slave device, and return them as a Uint8Array (packed array of bytes). This is like using Arduino Wire's requestFrom, available and read functions.  Sends a STOP

    The important information of parameter address is only in the description. :-(

    Currently it is required to write the TypeScript type definition by hand but there is always the risk that the type file will become outdated.

    @Gordon: Do you have an idea how it can go on in the long term?


Avatar for luwar @luwar started