Skip to content

Commit 301dceb

Browse files
committed
refactor: update type definitions for ParsingResult and related functions
1 parent a6ce81e commit 301dceb

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/pages/playgroud/compiler.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// REF: https://chat.openai.com/c/828fa9d6-981d-404a-8ef8-46e8140111ba
22
//
3-
import type { Definitions } from "internet-object";
4-
import { parse } from "internet-object"
5-
import { parseDefinitions } from 'internet-object';
6-
import { InternetObjectError } from 'internet-object';
7-
import { InternetObjectSyntaxError } from 'internet-object';
8-
import { InternetObjectValidationError } from 'internet-object';
3+
import type { IODefinitions } from "internet-object";
4+
import { parse } from "internet-object"
5+
import { parseDefinitions } from 'internet-object';
6+
import { IOError } from 'internet-object';
7+
import { IOSyntaxError } from 'internet-object';
8+
import { IOValidationError } from 'internet-object';
99

1010

1111
/**
@@ -25,7 +25,7 @@ export interface ErrorMarker {
2525
*/
2626
export interface ParsingResult {
2727
errorMessage: string | null;
28-
defs: Definitions | null;
28+
defs: IODefinitions | null;
2929
output: any | null;
3030
defsMarkers: ErrorMarker[];
3131
docMarkers: ErrorMarker[];
@@ -52,7 +52,7 @@ function tryParse<T>(input: string, fn: (input: string, defs?: any) => T, isDefs
5252
const result = fn(input, null);
5353
return {
5454
errorMessage: null,
55-
defs: isDefs ? result as Definitions : null,
55+
defs: isDefs ? result as IODefinitions : null,
5656
output: isDefs ? null : (result as any).toJSON(),
5757
defsMarkers: [],
5858
docMarkers: [],
@@ -74,22 +74,22 @@ function tryParse<T>(input: string, fn: (input: string, defs?: any) => T, isDefs
7474

7575

7676

77-
function parseDoc(doc: string, defs: Definitions | null = null): ParsingResult {
77+
function parseDoc(doc: string, defs: IODefinitions | null = null): ParsingResult {
7878
return tryParse(doc, (d) => parse(d, defs));
7979
}
8080

8181

8282

8383
function getErrorMessage(e: any): string {
84-
if (e instanceof InternetObjectSyntaxError) return 'SYNTAX_ERROR: ' + (e?.message || String(e));
85-
if (e instanceof InternetObjectValidationError) return 'VALIDATION_ERROR: ' + (e?.message || String(e));
84+
if (e instanceof IOSyntaxError) return 'SYNTAX_ERROR: ' + (e?.message || String(e));
85+
if (e instanceof IOValidationError) return 'VALIDATION_ERROR: ' + (e?.message || String(e));
8686
return 'ERROR: ' + (e?.message || String(e));
8787
}
8888

8989

9090

9191
function getErrorMarkers(e: any): ErrorMarker[] {
92-
if (!(e instanceof InternetObjectError)) return [];
92+
if (!(e instanceof IOError)) return [];
9393
const startPos: any = e.positionRange?.getStartPos();
9494
const endPos: any = e.positionRange?.getEndPos();
9595
if (!startPos && !endPos) return [];

0 commit comments

Comments
 (0)