From 65a08efa00e3366acdd61669669595037e50caec Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 28 Nov 2023 00:31:05 +0530 Subject: [PATCH] chore: Cleanup types --- .../mermaid/src/diagrams/flowchart/flowDb.ts | 13 ++++----- .../mermaid/src/diagrams/flowchart/types.ts | 29 ++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index 41a367289..96ac418a3 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -20,7 +20,7 @@ const MERMAID_DOM_ID_PREFIX = 'flowchart-'; let vertexCounter = 0; let config = getConfig(); let vertices: Record = {}; -let edges: any[] & { defaultInterpolate?: string; defaultStyle?: string } = []; +let edges: FlowEdge[] & { defaultInterpolate?: string; defaultStyle?: string[] } = []; let classes: Record = {}; let subGraphs: FlowSubGraph[] = []; let subGraphLookup: Record = {}; @@ -59,8 +59,8 @@ export const addVertex = function ( _id: string, textObj: FlowText, type: 'group', - style: any[], - classes: any[], + style: string[], + classes: string[], dir: string, props = {} ) { @@ -128,9 +128,6 @@ export const addVertex = function ( export const addSingleLink = function (_start: string, _end: string, type: any) { const start = _start; const end = _end; - // if (start[0].match(/\d/)) start = MERMAID_DOM_ID_PREFIX + start; - // if (end[0].match(/\d/)) end = MERMAID_DOM_ID_PREFIX + end; - // log.info('Got edge...', start, end); const edge: FlowEdge = { start: start, end: end, type: undefined, text: '', labelType: 'text' }; log.info('abc78 Got edge...', edge); @@ -160,7 +157,7 @@ export const addSingleLink = function (_start: string, _end: string, type: any) edges.push(edge); }; -export const addLink = function (_start: string[], _end: string[], type: any) { +export const addLink = function (_start: string[], _end: string[], type: unknown) { log.info('addLink', _start, _end, type); for (const start of _start) { for (const end of _end) { @@ -190,7 +187,7 @@ export const updateLinkInterpolate = function ( * Updates a link with a style * */ -export const updateLink = function (positions: ('default' | number)[], style: any) { +export const updateLink = function (positions: ('default' | number)[], style: string[]) { positions.forEach(function (pos) { if (typeof pos === 'number' && pos >= edges.length) { throw new Error( diff --git a/packages/mermaid/src/diagrams/flowchart/types.ts b/packages/mermaid/src/diagrams/flowchart/types.ts index 4261f51b9..954759f39 100644 --- a/packages/mermaid/src/diagrams/flowchart/types.ts +++ b/packages/mermaid/src/diagrams/flowchart/types.ts @@ -1,16 +1,16 @@ export interface FlowVertex { + classes: string[]; + dir?: string; + domId: string; + haveCallback?: boolean; id: string; labelType: 'text'; - dir?: string; - props?: any; - type?: string; - text?: string; link?: string; linkTarget?: string; - haveCallback?: boolean; - domId: string; - styles: any[]; - classes: any[]; + props?: any; + styles: string[]; + text?: string; + type?: string; } export interface FlowText { @@ -21,8 +21,10 @@ export interface FlowText { export interface FlowEdge { start: string; end: string; + interpolate?: string; type?: string; stroke?: string; + style?: string[]; length?: number; text: string; labelType: 'text'; @@ -35,16 +37,17 @@ export interface FlowClass { } export interface FlowSubGraph { - id: string; - nodes: string[]; - title: string; classes: string[]; dir?: string; + id: string; labelType: string; + nodes: string[]; + title: string; } export interface FlowLink { - type: string; - stroke: string; length?: number; + stroke: string; + type: string; + text?: string; }