Skip to content

Commit

Permalink
fix ts-ignore errors refactored large functions to use helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Fulbright authored and Austin Fulbright committed Aug 8, 2024
1 parent 8fe0ed1 commit 00603e7
Show file tree
Hide file tree
Showing 9 changed files with 1,040 additions and 905 deletions.
3 changes: 1 addition & 2 deletions packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { parser } from './gitGraphParser.js';
import db from './gitGraphAst.js';
import { parse } from 'path';
import { db } from './gitGraphAst.js';

const parseInput = async (input: string) => {
await parser.parse(input);
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/git/gitGraph.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rejects } from 'assert';
import db from './gitGraphAst.js';
import { db } from './gitGraphAst.js';
import { parser } from './gitGraphParser.js';

describe('when parsing a gitGraph', function () {
Expand Down
7 changes: 3 additions & 4 deletions packages/mermaid/src/diagrams/git/gitGraphAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {
getDiagramTitle,
} from '../common/commonDb.js';
import defaultConfig from '../../defaultConfig.js';
import type { DiagramOrientation, Commit } from './gitGraphTypes.js';
import type { DiagramOrientation, Commit, GitGraphDB, CommitType } from './gitGraphTypes.js';
import { ImperativeState } from '../../utils/imperativeState.js';

interface GitGraphState {
commits: Map<string, Commit>;
head: Commit | null;
Expand Down Expand Up @@ -467,15 +466,15 @@ export const getHead = function () {
return state.records.head;
};

export const commitType = {
export const commitType: CommitType = {
NORMAL: 0,
REVERSE: 1,
HIGHLIGHT: 2,
MERGE: 3,
CHERRY_PICK: 4,
};

export default {
export const db: GitGraphDB = {
commitType,
getConfig: () => getConfig().gitGraph,
setDirection,
Expand Down
4 changes: 2 additions & 2 deletions packages/mermaid/src/diagrams/git/gitGraphDiagram.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @ts-ignore: JISON doesn't support types
import { parser } from './gitGraphParser.js';
import gitGraphDb from './gitGraphAst.js';
import { db } from './gitGraphAst.js';
import gitGraphRenderer from './gitGraphRenderer.js';
import gitGraphStyles from './styles.js';
import type { DiagramDefinition } from '../../diagram-api/types.js';

export const diagram: DiagramDefinition = {
parser: parser,
db: gitGraphDb,
db: db,
renderer: gitGraphRenderer,
styles: gitGraphStyles,
};
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/git/gitGraphParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parse } from '@mermaid-js/parser';
import type { ParserDefinition } from '../../diagram-api/types.js';
import { log } from '../../logger.js';
import { populateCommonDb } from '../common/populateCommonDb.js';
import db from './gitGraphAst.js';
import { db } from './gitGraphAst.js';
import { commitType } from './gitGraphAst.js';
import type {
CheckoutAst,
Expand Down
Loading

0 comments on commit 00603e7

Please sign in to comment.