mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-30 20:59:36 +02:00
refactor: move MaybePromise
type to src/types.ts
Suggested-by: https://github.com/mermaid-js/mermaid/pull/5974#discussion_r1810562136 Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Entries } from 'type-fest';
|
||||
import type { D3Selection } from '../../types.js';
|
||||
import type { D3Selection, MaybePromise } from '../../types.js';
|
||||
import type { Node, ShapeRenderOptions } from '../types.js';
|
||||
import { anchor } from './shapes/anchor.js';
|
||||
import { bowTieRect } from './shapes/bowTieRect.js';
|
||||
@@ -58,7 +58,6 @@ import { waveEdgedRectangle } from './shapes/waveEdgedRectangle.js';
|
||||
import { waveRectangle } from './shapes/waveRectangle.js';
|
||||
import { windowPane } from './shapes/windowPane.js';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type ShapeHandler = <T extends SVGGraphicsElement>(
|
||||
parent: D3Selection<T>,
|
||||
node: Node,
|
||||
|
@@ -94,3 +94,10 @@ export interface RenderResult {
|
||||
*/
|
||||
bindFunctions?: (element: Element) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be converted back to `T` by awaiting/`Awaited<T>`.
|
||||
*
|
||||
* This is useful for function types that may be either synchronous or asynchronous.
|
||||
*/
|
||||
export type MaybePromise<T> = T | Promise<T>;
|
||||
|
Reference in New Issue
Block a user