Generic type on a method is throwing a parsing error #497
Description
Hello,
I'm migrating my code base to the new vue-cli tooling, and I encountered an issue when running ESLint on TypeScript code that use a generic type. 😞
If it can help, I'm using @vue/cli-plugin-eslint
and @vue/eslint-config-typescript
.
Here is my .eslintrc.js
:
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/recommended',
'@vue/prettier',
'@vue/typescript',
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'on' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'on' : 'off',
}
};
What version of TypeScript are you using?
Version 2.9.2 and 3+
What version of typescript-eslint-parser
are you using?
Version 16.0.1
What code were you trying to parse?
export const decorateRequest = <T>(request: Promise<T>, bag: RequestBag): Promise<T> => {
Object.assign(bag, makeRequestBag());
return new Promise<T>(resolve => {
// ...
});
};
What did you expect to happen?
No errors
For having this result, I changed my code to:
-export const decorateRequest = <T>(request: Promise<T>, bag: RequestBag): Promise<T> => {
+export const decorateRequest = (request: Promise<any>, bag: RequestBag): Promise<any> => {
Object.assign(bag, makeRequestBag());
return new Promise<T>(resolve => {
// ...
});
};
What happened?
When using AST explorer with typescript-eslint-parser
, my code is not parsed: https://astexplorer.net/#/gist/c19d736c02a606dc437892e2ba502ab6/2cf1e76e411f75f6aa7c94328724b8e7fa504611
But when I change to typescript
, it's working: http://astexplorer.net/#/gist/c19d736c02a606dc437892e2ba502ab6/fde12f491295d79d28c9d05e02486734932fb3a0
Tell me if you need more info, I will be glad to help you to solve this bug 👍
Thanks