I have a function called element
#element[name]
And I want to raise a warning when “name” is not present in the separately imported CSV file
I have a function called element
#element[name]
And I want to raise a warning when “name” is not present in the separately imported CSV file
Typst doesn’t have a built‑in warning function at the moment, but there is a workaround: you can force a warning by using a non‑existent font name. For a more convenient wrapper, you may want to use the uniwarn package.
Example:
#import "@preview/uniwarn:0.1.1": warning
#warning("name not in csv file")
This will produce an unknown font family warning. It’s not the most elegant solution, but it’s at least usable.
The font warning has caveats and not all caveats are documented in uniwarn’s README. See Pass things to stderr as errors or warnings | Tips on debugging Typst code, including the dark magic:
You can subscribe to Support for emitting custom warnings · Issue #1322 · typst/typst · GitHub to wait for the builtin support. There was an attempt in 2023 (https://github.com/typst/typst/pull/1872), but the PR was closed because more foundational design work was needed to be done at that time.
This pull request, #1872, aimed to add a warn function to Typst’s foundations, enabling script-generated warnings. Here is a summary.
The primary goal was to implement a solution for issues #1322 and #1276 by introducing a warn function that leverages the warning infrastructure from PR #1731.
The central debate revolved around warning suppression to prevent spam from third-party packages, which led to several design considerations:
key parameter for filtering.#suppressWarnings "packageName" or a #nowarn function).warn function showed the code snippet from the warn call itself, not the original cause, due to using Spanned.#nowarn function, as prototyped, could only suppress manual script warnings, not built-in Typst warnings, and was considered “impure” as it globally disabled warnings.Several specific code improvements were suggested and partially addressed:
warning! macro instead of manually constructing diagnostics.Due to the significant design work still required, the PR was closed on November 21, 2023, without being merged. The maintainer, @laurmaedje, acknowledged the effort but stated that PRs are not the ideal venue for such foundational design discussions. A new topic was opened in the contributors’ forum on Discord to continue the conversation.
The pull request is closed and unmerged. It has seen no activity since its closure, with users inquiring about progress as recently as May 2026, but it remains closed.