Rest parameter without type annotation in overload declaration cause null error
What version of TypeScript are you using? TypeScript 2.2
What version of typescript-eslint-parser are you using?
typescript-eslint-parser 2.1
What code were you trying to parse?
class World {
batman(...args);
batman(num: number) {}
}
// This also failed to parse
function batman(...args);
function batman(num: number) {}
What happened?
TypeError: Cannot read property 'type' of null
at Referencer.visitFunction (U:\Documents\batman\node_modules\escope\lib\referencer.js:258:26)
at Referencer.FunctionExpression (U:\Documents\batman\node_modules\escope\lib\referencer.js:569:18)
at Referencer.Visitor.visit (U:\Documents\batman\node_modules\esrecurse\esrecurse.js:122:34)
at Referencer.visitProperty (U:\Documents\batman\node_modules\escope\lib\referencer.js:297:18)
at Referencer.MethodDefinition (U:\Documents\batman\node_modules\escope\lib\referencer.js:452:18)
at Referencer.Visitor.visit (U:\Documents\batman\node_modules\esrecurse\esrecurse.js:122:34)
at Referencer.Visitor.visitChildren (U:\Documents\batman\node_modules\esrecurse\esrecurse.js:101:38)
at Referencer.Visitor.visit (U:\Documents\batman\node_modules\esrecurse\esrecurse.js:125:14)
at Referencer.visitClass (U:\Documents\batman\node_modules\escope\lib\referencer.js:281:18)
at Referencer.ClassDeclaration (U:\Documents\batman\node_modules\escope\lib\referencer.js:488:18)
Working code
The following code works:
class World {
batman(...args: any[]);
batman(num: number) {}
}
Appearantly, only batman(...args); (rest parameter without type annotation) cause the null error.
Thanks for the report.
This is a known issue. Unfortunately the scope anaylsis tool that eslint uses does not support empty body functions that can be found in typescript. This includes abstract methods, declared classes, and function overloads. This has since been fixed in ESLint v4 but there are still eslint rules that do not work with this syntax. We are working on getting this fixed as well.
More information can be found here: https://github.com/eslint/typescript-eslint-parser/issues/253
Closing the issue in favor of #253