Skip to content

Commit

Permalink
change defaultConfig type to RequiredDeep and use it in pieDb
Browse files Browse the repository at this point in the history
  • Loading branch information
Yokozuna59 committed Aug 16, 2023
1 parent 744cc79 commit defe406
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/config/setup/modules/defaultConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

#### Defined in

[defaultConfig.ts:266](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L266)
[defaultConfig.ts:267](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L267)

---

### default

`Const` **default**: `Partial`<`MermaidConfig`>
`Const` **default**: `RequiredDeep`<`MermaidConfig`>

Default mermaid configuration options.

Expand All @@ -30,4 +30,4 @@ Non-JSON JS default values are listed in this file, e.g. functions, or

#### Defined in

[defaultConfig.ts:16](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L16)
[defaultConfig.ts:17](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L17)
8 changes: 5 additions & 3 deletions packages/mermaid/src/defaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { RequiredDeep } from 'type-fest';

import theme from './themes/index.js';
import { type MermaidConfig } from './config.type.js';
import type { MermaidConfig } from './config.type.js';

// Uses our custom Vite jsonSchemaPlugin to load only the default values from
// our JSON Schema
Expand All @@ -13,7 +15,7 @@ import defaultConfigJson from './schemas/config.schema.yaml?only-defaults=true';
* Non-JSON JS default values are listed in this file, e.g. functions, or
* `undefined` (explicitly set so that `configKeys` finds them).
*/
const config: Partial<MermaidConfig> = {
const config: RequiredDeep<MermaidConfig> = {
...defaultConfigJson,
// Set, even though they're `undefined` so that `configKeys` finds these keys
// TODO: Should we replace these with `null` so that they can go in the JSON Schema?
Expand Down Expand Up @@ -232,7 +234,7 @@ const config: Partial<MermaidConfig> = {
},
pie: {
...defaultConfigJson.pie,
useWidth: undefined,
useWidth: 984,
},
requirement: {
...defaultConfigJson.requirement,
Expand Down
7 changes: 2 additions & 5 deletions packages/mermaid/src/diagrams/pie/pieDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ import type { ParseDirectiveDefinition } from '../../diagram-api/types.js';
import type { PieFields, PieDB, Sections } from './pieTypes.js';
import type { RequiredDeep } from 'type-fest';
import type { PieDiagramConfig } from '../../config.type.js';
import DEFAULT_CONFIG from '../../defaultConfig.js';

export const DEFAULT_PIE_CONFIG: Required<PieDiagramConfig> = {
useMaxWidth: true,
useWidth: 984,
textPosition: 0.75,
} as const;
export const DEFAULT_PIE_CONFIG: Required<PieDiagramConfig> = DEFAULT_CONFIG.pie;

export const DEFAULT_PIE_DB: RequiredDeep<PieFields> = {
sections: {},
Expand Down

0 comments on commit defe406

Please sign in to comment.