Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Decorators cause parsing errors #173

Closed
wesleycho opened this issue Feb 25, 2017 · 2 comments
Closed

Decorators cause parsing errors #173

wesleycho opened this issue Feb 25, 2017 · 2 comments
Labels

Comments

@wesleycho
Copy link

What version of TypeScript are you using?
2.2.1

What version of typescript-eslint-parser are you using?
2.0.0

What code were you trying to parse?

@Component({})
class FooComponent {}

What did you expect to happen?
I expected this to be linted properly

What happened?
eslint threw an error on this line: https://github.com/eslint/eslint/blob/4e52cfcf5314cac46e8d3688141a573016e7efb1/lib/rules/keyword-spacing.js#L276

The cause of this is that the token value of @ is not found.

This might require being allowed to use multiple parsers, i.e. specifying parsers like

{
  "parser": ["typescript-eslint-parser", "babel-eslint"]
}

so that Babel can properly handle converting the token to something eslint can read.

@soda0289
Copy link
Member

@wesleycho I believe this is a duplicate of #102.
We were able to get this fixed in eslint/master with this PR: eslint/eslint#8111

The problem with decorators was only with get, set or async class methods. The old logic would try and find the first keyword and not the first keyword that was get, set or async next to the class method identifier.

I don't believe there is a problem with the code you posted since the at (@) symbol is a Punctuator and not a Keyword token type. I might be missing something but if you want to give eslint master branch a try it should fix the problem.

@wesleycho
Copy link
Author

Yup, what I posted wasn't the root cause, but where the error was getting thrown.

Looks like you are correct - thanks for that information!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants