fix: use `ParseErrorFunction` alias for mocks

This commit is contained in:
Basti Ortiz 2022-10-12 00:49:15 +08:00
parent 15f31f9d95
commit e8cd3c0baf
No known key found for this signature in database
GPG Key ID: 1402D5CB17F48E1B
2 changed files with 4 additions and 6 deletions

View File

@ -6,7 +6,7 @@
import * as configApi from '../config';
import { vi } from 'vitest';
import { addDiagrams } from '../diagram-api/diagram-orchestration';
import Diagram from '../Diagram';
import Diagram, { type ParseErrorFunction } from '../Diagram';
// Normally, we could just do the following to get the original `parse()`
// implementation, however, requireActual returns a promise and it's not documented how to use withing mock file.
@ -15,8 +15,7 @@ import Diagram from '../Diagram';
* @param text
* @param parseError
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function parse(text: string, parseError?: Function): boolean {
function parse(text: string, parseError?: ParseErrorFunction): boolean {
addDiagrams();
const diagram = new Diagram(text, parseError);
return diagram.parse(text, parseError);

View File

@ -22,7 +22,7 @@ import classDb from './diagrams/class/classDb';
import flowDb from './diagrams/flowchart/flowDb';
import flowRenderer from './diagrams/flowchart/flowRenderer';
import ganttDb from './diagrams/gantt/ganttDb';
import Diagram, { getDiagramFromText } from './Diagram';
import Diagram, { getDiagramFromText, type ParseErrorFunction } from './Diagram';
import errorRenderer from './diagrams/error/errorRenderer';
import { attachFunctions } from './interactionDb';
import { log, setLogLevel } from './logger';
@ -37,8 +37,7 @@ import { evaluate } from './diagrams/common/common';
* @param text
* @param parseError
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function parse(text: string, parseError?: Function): boolean {
function parse(text: string, parseError?: ParseErrorFunction): boolean {
addDiagrams();
const diagram = new Diagram(text, parseError);
return diagram.parse(text, parseError);