Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve error location #6556

Merged
merged 12 commits into from Mar 6, 2023
Expand Up @@ -3,6 +3,6 @@
exports[`AST Fixtures declaration TSEnumDeclaration _error_ decorator TSESTree - Error 1`] = `
"TSError
> 1 | @decl enum Test {}
| ^^^^^^^^^^^^^^^^^^ Decorators are not valid here.
| ^^^^^ Decorators are not valid here.
2 |"
`;
Expand Up @@ -3,6 +3,6 @@
exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ decorator TSESTree - Error 1`] = `
"TSError
> 1 | @decl interface Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^ Decorators are not valid here.
| ^^^^^ Decorators are not valid here.
2 |"
`;
Expand Up @@ -3,6 +3,6 @@
exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ decorator TSESTree - Error 1`] = `
"TSError
> 1 | @decl type Test = {};
| ^^^^^^^^^^^^^^^^^^^^^ Decorators are not valid here.
| ^^^^^ Decorators are not valid here.
2 |"
`;
Expand Up @@ -3,6 +3,6 @@
exports[`AST Fixtures declaration VariableDeclaration _error_ decorator TSESTree - Error 1`] = `
"TSError
> 1 | @decl type Test = {};
| ^^^^^^^^^^^^^^^^^^^^^ Decorators are not valid here.
| ^^^^^ Decorators are not valid here.
2 |"
`;
Expand Up @@ -5,5 +5,5 @@ exports[`AST Fixtures legacy-fixtures errorRecovery _error_ decorator-on-enum-de
1 | // TODO: This fixture might be too large, and if so should be split up.
2 |
> 3 | @dec enum E {}
| ^^^^^^^^^^^^^^ Decorators are not valid here."
| ^^^^ Decorators are not valid here."
`;
Expand Up @@ -5,7 +5,6 @@ exports[`AST Fixtures legacy-fixtures errorRecovery _error_ decorator-on-interfa
1 | // TODO: This fixture might be too large, and if so should be split up.
2 |
> 3 | @deco()
| ^^^^^^^
> 4 | interface M {}
| ^^^^^^^^^^^^^^^ Decorators are not valid here."
| ^^^^^^^ Decorators are not valid here.
4 | interface M {}"
`;
Expand Up @@ -5,8 +5,7 @@ exports[`AST Fixtures legacy-fixtures errorRecovery _error_ decorator-on-variabl
1 | // TODO: This fixture might be too large, and if so should be split up.
2 |
> 3 | @deco()
| ^^^^^^^
> 4 | const a = 1
| ^^^^^^^^^^^^ Decorators are not valid here.
| ^^^^^^^ Decorators are not valid here.
4 | const a = 1
5 |"
`;
4 changes: 2 additions & 2 deletions packages/typescript-estree/src/convert.ts
Expand Up @@ -3033,8 +3033,8 @@ export class Converter {
#checkIllegalDecorators(node: ts.Node): void {
if (nodeHasIllegalDecorators(node)) {
this.#throwUnlessAllowInvalidAST(
// eslint-disable-next-line deprecation/deprecation
node.decorators?.[0] ?? node,
// @ts-expect-error -- this is safe as it's guarded
node.illegalDecorators?.[0] ?? node,
armano2 marked this conversation as resolved.
Show resolved Hide resolved
'Decorators are not valid here.',
);
}
Expand Down