8000 fix: "has only a getter" error (#210) · vuejs/vue-eslint-parser@4cd70e6 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cd70e6

Browse files
authored
fix: "has only a getter" error (#210)
1 parent 7fd3735 commit 4cd70e6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ast/errors.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ function isAcornStyleParseError(
2323
)
2424
}
2525

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+
2644
/**
2745
* HTML parse errors.
2846
*/
@@ -53,6 +71,15 @@ export class ParseError extends SyntaxError {
5371
* @param x The error object to normalize.
5472
*/
5573
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+
}
5683
if (ParseError.isParseError(x)) {
5784
return x
5885
}

0 commit comments

Comments
 (0)
0