Skip to content

Commit

Permalink
fix: Remove ImperativeState type restriction.
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Apr 13, 2024
1 parent 12bd301 commit 866d941
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions packages/mermaid/src/diagrams/sequence/sequenceDb.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<string, Actor>;
createdActors: Record<string, number>;
Expand All @@ -27,9 +26,9 @@ type State = {
currentBox?: Box;
lastCreated?: Actor;
lastDestroyed?: Actor;
};
}

const state = new ImperativeState<State>(() => ({
const state = new ImperativeState<SequenceState>(() => ({
prevActor: undefined,
actors: {},
createdActors: {},
Expand Down
6 changes: 3 additions & 3 deletions packages/mermaid/src/utils/imperativeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -21,7 +21,7 @@
* // }
* ```
*/
export class ImperativeState<S extends Record<string, unknown>> {
export class ImperativeState<S> {
public records: S;

/**
Expand Down

0 comments on commit 866d941

Please sign in to comment.