fix: Remove `ImperativeState` type restriction.

This commit is contained in:
Sidharth Vinod 2024-04-13 11:50:19 +05:30
parent 12bd301401
commit 866d9416b4
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 7 additions and 8 deletions

View File

@ -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<string, Actor>;
createdActors: Record<string, number>;
@ -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: {},

View File

@ -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<S extends Record<string, unknown>> {
export class ImperativeState<S> {
public records: S;
/**