Why is Typst Preview working, while typst compile fails?

Hi,

I’m using neovim (AstroNvim) for Typst, Typst Language Pack. It works, my preview looks like I expect. When I try to generate a PDF from the same typ file, I get an error:

master ~/spaces/text/wei> typst compile the-hundred-squares-ru.typ hunnerd.pdf
error: entry does not have field "page"
   ┌─ robinson-toc.typ:67:48
   │
67 │         #subcnt #box(width: 1fr, repeat[.]) #it.page
   │                                                 ^^^^

exit 1
master ~/spaces/text/wei>

I understand that my info is insufficient; what data should I supply? Nevertheless, it looks like the CLI typst lacks some environment that the Preview has. What could that be?

I assume the offending code is part of a show rule for an outline entry.

As the field it.page has been replaced with a function it.page() starting with Typst v0.13, it seems to me that you have the 0.13 release candidate installed. This version of Typst is then used when you run typst compile, whereas typst-preview likely ships its own compiler, which still uses version 0.12.

Exactly! I downgraded typst with

cargo binstall typst-cli --force

and the error’s gone. Now it’s

~> typst --version
typst 0.12.0 (737895d7)
~>

Release on GitHub 737895d. So I shouldn’t use any release candidate in a normal workflow.

Besides, can I be sure that the tinymist language server uses the same version of the language?

Tinymist uses even patch releases (e.g. 0.12.18) for regular releases – this would be equivalent to Typst 0.12 – and odd releases (e.g. 0.12.21) for pre-releases – this specific one uses 0.13 (or a Typst commit very close to it) but isn’t considered stable enough for Tinymist 0.13.0 yet.

So while Tinymist (necessarily) uses a fork of the Typst compiler to support its features, using a stable (even) release ensures you’re using the released version of Typst.


btw, I updated the title to bring it in line with the question guidelines:

Good titles are questions you would ask your friend about Typst.

I also added tags, as it makes your question easier to find.

Finally, if Eric’s response answered your initial question, marking it with a checkmark :ballot_box_with_check: would help others find the answer more easily. Cheers! :slight_smile:

Right now Typst 0.13.0 is released, Tinymist and Typs Preview updated (?), to what versions I’m not sure, and not working any more. That is, I have gray space instead of preview while typst compile works (with breaking changes corrected).

The other way around :blush:

I’m on Tinymist 0.12.21 (latest VS Code extension) and compiling and preview works fine, so we’d need more details to figure this out.

My typst-cli:

~> typst --version
typst 0.13.0 (8dce676d)

Tinymist 0.12.20, which may be critical, if I understand you correctly. So far it refuses to update, and for good reason, apparently. The latest release is still 0.12.20: Tinymist

I use AstroNvim pack

UPD

Just tried VScodium, Tinymist plugin. Exactly the same situation: gray preview, and Tinymist version 0.12.20.

UPD2

Oh, pre-release 0.12.21, sixteen hours ago :blush: . Probably, I just have to wait a bit… Or do I have to wait for 0.12.22?

On even patches, tinymist 0.x is equivalent to Typst 0.x. So if your goal is working with 0.13 and tinymist is still on 0.12,you definitely want an odd patch version.

There was also 0.12.19, you can try to “downgrade” to that if 0.12.21 is not ready yet for your editor.

My latest news :grin: :

  1. The long term Tinymist release is there and installable.
  2. With it I can see the preview, but no forward/inverse search for me. Is there anything to check?

UPD

With VSCodium forward/inverse search is working. Neovim problem :(