Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

no-useless-constructor: Cannot read property 'body' of null #420

Closed
Labels
package: parserIssues related to @typescript-eslint/parserworking as intendedIssues that are closed as they are working as intended
@SebastiaanYN

Description

@SebastiaanYN

This seems to be the same issue as#15.


What code were you trying to parse?

// src/foo.tsclassFoo{constructor();constructor(obj:any);constructor(obj?:any){console.log(obj);}}

This also happens with both examples from the other issue,

declareclassFoo{constructor();}

and

classFoo{constructor();}

When the ESLintno-useless-constructor rule is disabled, the issue doesn't show.

What did you expect to happen?
ESLint sees the code as correct.

What actually happened?
ESLint gives an error, because the body of some constructors can't be found.

TypeError: Cannot read property 'body' of nullOccurred while linting /home/sebastiaanyn/Projects/Syntek/src/foo.ts:2    at checkForConstructor (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/rules/no-useless-constructor.js:169:42)    at listeners.(anonymous function).forEach.listener (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/util/safe-emitter.js:45:58)    at Array.forEach (<anonymous>)    at Object.emit (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/util/safe-emitter.js:45:38)    at NodeEventGenerator.applySelector (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/util/node-event-generator.js:251:26)    at NodeEventGenerator.applySelectors (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/util/node-event-generator.js:280:22)    at NodeEventGenerator.enterNode (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/util/node-event-generator.js:294:14)    at CodePathAnalyzer.enterNode (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)    at nodeQueue.forEach.traversalInfo (/home/sebastiaanyn/Projects/Syntek/node_modules/eslint/lib/linter.js:752:32)    at Array.forEach (<anonymous>)

Versions

packageversion
@typescript-eslint/eslint-plugin1.6.0
@typescript-eslint/parser1.6.0
TypeScript3.4.2
ESLint5.16.0
node11.8.0
npm6.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: parserIssues related to @typescript-eslint/parserworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp