chore: Cleanup types

This commit is contained in:
Sidharth Vinod 2023-11-28 00:31:05 +05:30
parent 60266289e0
commit 65a08efa00
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 21 additions and 21 deletions

View File

@ -20,7 +20,7 @@ const MERMAID_DOM_ID_PREFIX = 'flowchart-';
let vertexCounter = 0;
let config = getConfig();
let vertices: Record<string, FlowVertex> = {};
let edges: any[] & { defaultInterpolate?: string; defaultStyle?: string } = [];
let edges: FlowEdge[] & { defaultInterpolate?: string; defaultStyle?: string[] } = [];
let classes: Record<string, FlowClass> = {};
let subGraphs: FlowSubGraph[] = [];
let subGraphLookup: Record<string, FlowSubGraph> = {};
@ -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(

View File

@ -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;
}