File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,24 @@ function isAcornStyleParseError(
23
23
)
24
24
}
25
25
26
+ /**
27
+ * Check whether the given value is probably a TSError.
28
+ * @param x The value to check.
29
+ * @returns `true` if the given value is probably a TSError.
30
+ */
31
+ function isTSError (
32
+ x : any ,
33
+ ) : x is { message : string ; index : number ; lineNumber : number ; column : number } {
34
+ return (
35
+ ! ( x instanceof ParseError ) &&
36
+ typeof x . message === "string" &&
37
+ typeof x . index === "number" &&
38
+ typeof x . lineNumber === "number" &&
39
+ typeof x . column === "number" &&
40
+ x . name === "TSError"
41
+ )
42
+ }
43
+
26
44
/**
27
45
* HTML parse errors.
28
46
*/
@@ -53,6 +71,15 @@ export class ParseError extends SyntaxError {
53
71
* @param x The error object to normalize.
54
72
*/
55
73
public static normalize ( x : any ) : ParseError | null {
74
+ if ( isTSError ( x ) ) {
75
+ return new ParseError (
76
+ x . message ,
77
+ undefined ,
78
+ x . index ,
79
+ x . lineNumber ,
80
+ x . column ,
81
+ )
82
+ }
56
83
if ( ParseError . isParseError ( x ) ) {
57
84
return x
58
85
}
You can’t perform that action at this time.
0 commit comments