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; /**