embroider-build / content-tag

A rust program that uses my swc fork to parse GJS
MIT License
7 stars 7 forks source link

parse result should have more specific type #30

Closed NullVoxPopuli closed 6 months ago

NullVoxPopuli commented 9 months ago

right now the type is any. A better type might be something like:

interface ParseResult {
  type: "expression" | "class-member",
  tagName: "template",
  contents: string,
  range: {
    start: number,
    end: number,
  },
  contentRange: {
    start: number,
    end: number,
  },
  startRange: {
    end: number,
    start: number,
  },
  endRange: {
    start: number,
    end: number,
  },
}

// 
let result: ParseResult[] = p.parse(...);
ef4 commented 9 months ago

There's a merged but unreleased PR in wasm-bindgen that would let us return Result<Vec<Occurence>, JsValue> directly across the wasm boundary. That would probably cause wasm-bindgen to also generate this type better.

NullVoxPopuli commented 6 months ago

this is resolved as of 1.2.2