-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[v11] Limit MermaidConfig
enum TypesScript types to certain values
#4803
[v11] Limit MermaidConfig
enum TypesScript types to certain values
#4803
Conversation
We're planning on limiting some of MermaidConfig's types to specific values (e.g. `0 | 1` instead of `number`).
Currently (in Mermaid v10), pretty much all enum types in the MermaidConfig have generic `string` or `number` fallbacks, for backwards compatibility. This commit drops this. The MermaidConfig TypeScript types now expects a limited amount of values. BREAKING-CHANGE: Remove `MermaidConfig` generic type fallbacks for enum values.
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #4803 +/- ##
===========================================
- Coverage 77.08% 46.57% -30.51%
===========================================
Files 146 55 -91
Lines 14573 6819 -7754
Branches 592 36 -556
===========================================
- Hits 11233 3176 -8057
- Misses 3221 3642 +421
+ Partials 119 1 -118
Flags with carried forward coverage won't be shown. Click here to find out more. |
Hmmmm, weird, I keep getting the following error in the
It's in the |
@aloisklink It may have happened after updating the |
📑 Summary
When implementing #4112, we skipped adding proper TypeScript types for
MermaidConfig
values that wereenums
, as in they could only be certain specific values. This is because we didn't want to cause a breaking change for any users of our Typescript types.In the next MAJOR release of Mermaid, we should remove these types.
For example,
const config: MermaidConfig = {flowchart: {defaultRenderer: "this-renderer-does-not-exist"}};
will now throw a TypeScript error, when currently it's okay.THIS PR IS A BREAKING CHANGE to TypeScript types.
📏 Design Decisions
I had to slightly modify some test files to make TypeScript happy, e.g. by adding
as const
.Technically, users can just
// @ts-ignore
any TypeScript errors, or they might just not use TypeScript, so we can't fully trust that every value is valid, though. This will need to wait until we implement #3397, which will actually validate the config at run-time in JavaScript, instead of at build-time with TypeScript.📋 Tasks
Make sure you
📖 have read the contribution guidelines
💻 have added necessary unit/e2e tests.
📓 have added documentation. Make sure
MERMAID_RELEASE_VERSION
is used for all new features.**enum**: the value of this property must be equal to one of the following values: [..]
, seeflowchart.defaultRenderer
docs for an exampleSee screenshot
🔖 targeted
develop
branchnext
branch instead.