question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lint ts report Cannot read property 'body' of null

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.15.0
  • Node Version: 8.11.0
  • npm Version: 5.6.0

What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser Please show your full configuration:

module.exports = {
  extends: [
    'react-app',
    'plugin:@typescript-eslint/recommended',
    'prettier/@typescript-eslint',
  ],
  rules: {
    strict: [0],
    'no-sequences': [0],
    'no-mixed-operators': [0],
    'react/react-in-jsx-scope': [0],
    'no-useless-escape': [0],
  },
};

Configuration

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

// AvatarItem.d.ts
import * as React from 'react';
export interface IAvatarItemProps {
  tips: React.ReactNode;
  src: string;
  style?: React.CSSProperties;
}

export default class AvatarItem extends React.Component<IAvatarItemProps, any> {
  constructor(props: IAvatarItemProps);
}
npx eslint --ext=ts AvatarItem.d.ts

What did you expect to happen? lint result

What actually happened? Please include the actual, raw output from ESLint.

Cannot read property 'body' of null

I have located the error location where in the no-useless-constructor.js, line 169

function checkForConstructor(node) {
            if (node.kind !== "constructor") {
                return;
            }

            const body = node.value.body.body;  // <---- here
            const ctorParams = node.value.params;
            const superClass = node.parent.parent.superClass;

Is there have a bug or our wrong code?

Are you willing to submit a pull request to fix this bug?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
paulmelnikowcommented, May 7, 2019

I wanted to note to others reading this that the related issue is typescript-eslint/typescript-eslint#420.

1reaction
platinumazurecommented, Apr 17, 2019

@ljharb Maybe, but this discussion should take place on the typescript-eslint project. Please file an issue there. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: TypeError: Cannot read property 'body' of null
You initialized post with null, which means it does not contains any value. When you are trying to access this.state.post.body this makes ...
Read more >
cannot read properties of null (reading 'matches') npm - You.com
If you are getting an error that reads "Cannot read properties of null (reading 'matches')" when running npm [1][2], it usually means that...
Read more >
TypeError: Cannot read property 'replace' of Undefined in JS
The "Cannot read property 'replace' of undefined" error occurs when calling the replace() method on a variable that stores an undefined value.
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
Read more >
Throwing an Error "cannot read property style of null" in ...
When we are trying to access one property i.e. either doesn't contain any value (not even defined properly) in it or it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found