Skip to content

Type language as string, not a fixed union - #5

Merged
stromcom merged 2 commits into
masterfrom
docs/language-any-code
Aug 14, 2026
Merged

Type language as string, not a fixed union#5
stromcom merged 2 commits into
masterfrom
docs/language-any-code

Conversation

@stromcom

Copy link
Copy Markdown
Owner

Why

StromcomConfOptions.language is typed 'en' | 'cs' | 'sk' | null. The widget does not validate against that set — it resolves the language against the translation bundles it ships and uses English for anything else. So the union makes TypeScript reject values that work fine, and it needs editing every time a language is added.

What

  • language is string | null on StromcomConfOptions, with the fallback behaviour documented instead of encoded in the type. Same wording on StromcomProviderProps.language and in both README prop tables. No runtime change.
  • package.json bumped to 0.3.0. The 0.3.0 tag points at the merge of Add language prop to StromcomConf #4, but the version bump never landed — master still said 0.2.0. Worth a look: npm latest is still 0.1.0, so neither 0.2.0 nor 0.3.0 appears to have been published.

Tests

32 tests passing; lint and format:check clean.

stromek added 2 commits August 14, 2026 22:13
The widget resolves the language against the translations it ships and
uses English for anything else, so no code is invalid. The 'en'|'cs'|'sk'
union made TypeScript reject valid values and would need editing for
every language added.

Also bumps package.json to 0.3.0 — the 0.3.0 tag was cut without it.
Unknown language falls back to the browser language first, then English --
not straight to English.
@stromcom
stromcom merged commit 49ad9af into master Aug 14, 2026
3 checks passed
@stromcom stromcom mentioned this pull request Aug 14, 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