Myriad-Dreamin/tinymist

Missing Line Number Information in Typst Error Span

josercarmo opened this issue · 1 comments

Hi,
When compiling Typst code via window.$typst.svg(),web assembly, the error message provides an internal Span identifier (e.g., Span(902576878445443)) but no human-readable line/column location. This makes debugging difficult, especially for larger documents. How to use this Span?

[SourceDiagnostic {
  severity: Error,
  span: Span(902576878445443),
  message: "unknown variable: lor2em",
  trace: [],
  hints: []
}]

Please check the option of the underlying compiler, which decodes span information: https://github.com/Myriad-Dreamin/typst.ts/blob/9226ed644fd305acb896ad3932d91f17f2b0250f/packages/typst.ts/src/compiler.mts#L106-L112

The $typst (TypstSnippet) doesn't provide convenient apis about diagnostics for simplicity. PS: I have explored API design in the node compiler, and may expose more functionality to $typst about compile function in short future.