Skip to content

refactor: accept IDictionary for sysInputs - #3

Closed
msallin wants to merge 1 commit into
developfrom
claude/typstcompiler-idictionary-param-d9322f
Closed

refactor: accept IDictionary for sysInputs#3
msallin wants to merge 1 commit into
developfrom
claude/typstcompiler-idictionary-param-d9322f

Conversation

@msallin

@msallin msallin commented Sep 6, 2026

Copy link
Copy Markdown
Member

sysInputs on the TypstCompiler constructor, FromSource, FromFile, the static CompilePdf/CompileSvg/CompilePng helpers, and the argument of SetSysInputs were typed as Dictionary<string, string>. That forced callers holding a ReadOnlyDictionary<string, string>, ImmutableDictionary<string, string> or a custom implementation to copy into a concrete Dictionary first.

They now take IDictionary<string, string>. Widening a parameter type is source compatible, so every existing call passing a Dictionary<string, string> keeps compiling.

The JSON source generation context registers IDictionary<string, string> instead of Dictionary<string, string>; the generator emits CreateIDictionaryInfo metadata for it, so serialization stays source generated and trim/AOT friendly.

Added two tests that pass a ReadOnlyDictionary<string, string> through both the constructor parameter and SetSysInputs, and assert the value reaches sys.inputs in the rendered document.

Full suite: 47 passed, 0 failed.

Dictionary<string, string> forced callers to materialise a concrete
dictionary; a ReadOnlyDictionary or ImmutableDictionary could not be
passed. Widening the parameters to IDictionary<string, string> keeps
every existing call site compiling.
@msallin
msallin force-pushed the claude/typstcompiler-idictionary-param-d9322f branch from 4b6ed4f to 5635342 Compare September 6, 2026 17:44
@msallin msallin closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant