How to get final state of a `state` type in typst v0.12?

In typst official documentation of state here for the .final() method, it says: “This argument is deprecated. It only exists for compatibility with Typst 0.10 and lower and shouldn’t be used anymore.”

So how can I visit the final state if I don’t use state.final() method?

1 Like

Hello @abcvav, the argument is deprecated. The function itself still exists.

1 Like

Get it now, I misunderstood the document :smile:. Thank you very much for your reply!

In new typst, the correct way to perform contextual queries is using context, such as context state.final(). This is equivalent to context state.final(here()), replacing locate(loc => state.final(loc)).

Each context expression has a unique here() location in the document and the location will be passed to contextual query functions implicitly, so you don’t have to pass them as arguments explicitly.

1 Like

Get it, thank you for your help! :smile:

To add to that: In the case of final(), it didn’t even make use of the location (in contrast to get) since it is not dependent on where it is called. It just needed to ensure that it’s only usable within a locate.