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

Class constructor overloads throws TypeError: Cannot read property 'type' of null #222

Closed
unlight opened this issue Apr 18, 2017 · 1 comment

Comments

@unlight
Copy link

unlight commented Apr 18, 2017

What version of TypeScript are you using?
[email protected]

What version of typescript-eslint-parser are you using?
[email protected]

What code were you trying to parse?

export class Book {

    constructor(fields: Partial<Book>);
  
    constructor(data: any = null) {
    }

}

What did you expect to happen?
No errors

What happened?

Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at Referencer.visitFunction (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:258:26)
    at Referencer.FunctionExpression (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:569:18)
    at Referencer.Visitor.visit (d:\Dev\koa-boilerplate\node_modules\esrecurse\esrecurse.js:122:34)
    at Referencer.visitProperty (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:297:18)
    at Referencer.MethodDefinition (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:452:18)
    at Referencer.Visitor.visit (d:\Dev\koa-boilerplate\node_modules\esrecurse\esrecurse.js:122:34)
    at Referencer.Visitor.visitChildren (d:\Dev\koa-boilerplate\node_modules\esrecurse\esrecurse.js:101:38)
    at Referencer.Visitor.visit (d:\Dev\koa-boilerplate\node_modules\esrecurse\esrecurse.js:125:14)
    at Referencer.visitClass (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:281:18)
    at Referencer.ClassDeclaration (d:\Dev\koa-boilerplate\node_modules\escope\lib\referencer.js:488:18)
@soda0289
Copy link
Member

This is a duplicate of this issue:
#92

The problem was that escope did not know how to handle functions with empty bodies. We have since forked escope and will release it with eslint v4. There are still some rules that will crash when they see empty body functions but we are working to correct them.

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

No branches or pull requests

3 participants