From 866d9416b449376fe0e53be4c976ea9f745fb39f Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 13 Apr 2024 11:50:19 +0530 Subject: [PATCH] fix: Remove `ImperativeState` type restriction. --- packages/mermaid/src/diagrams/sequence/sequenceDb.ts | 9 ++++----- packages/mermaid/src/utils/imperativeState.ts | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts index 5d844904bc..03d3210aa9 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts @@ -1,5 +1,6 @@ import { getConfig } from '../../diagram-api/diagramAPI.js'; import { log } from '../../logger.js'; +import { ImperativeState } from '../../utils/imperativeState.js'; import { sanitizeText } from '../common/common.js'; import { clear as commonClear, @@ -10,11 +11,9 @@ import { setAccTitle, setDiagramTitle, } from '../common/commonDb.js'; -import { ImperativeState } from '../../utils/imperativeState.js'; import type { Actor, AddMessageParams, Box, Message, Note } from './types.js'; -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -type State = { +interface SequenceState { prevActor?: string; actors: Record; createdActors: Record; @@ -27,9 +26,9 @@ type State = { currentBox?: Box; lastCreated?: Actor; lastDestroyed?: Actor; -}; +} -const state = new ImperativeState(() => ({ +const state = new ImperativeState(() => ({ prevActor: undefined, actors: {}, createdActors: {}, diff --git a/packages/mermaid/src/utils/imperativeState.ts b/packages/mermaid/src/utils/imperativeState.ts index dcadeee1fd..1661e356c4 100644 --- a/packages/mermaid/src/utils/imperativeState.ts +++ b/packages/mermaid/src/utils/imperativeState.ts @@ -2,11 +2,11 @@ * Resettable state storage. * @example * ``` - * const state = new ImperativeState(() => { + * const state = new ImperativeState(() => ({ * foo: undefined as string | undefined, * bar: [] as number[], * baz: 1 as number | undefined, - * }); + * })); * * state.records.foo = "hi"; * console.log(state.records.foo); // prints "hi"; @@ -21,7 +21,7 @@ * // } * ``` */ -export class ImperativeState> { +export class ImperativeState { public records: S; /**