lint ts report Cannot read property 'body' of null
See original GitHub issueTell 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:
- Created 5 years ago
- Reactions:3
- Comments:10 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wanted to note to others reading this that the related issue is typescript-eslint/typescript-eslint#420.
@ljharb Maybe, but this discussion should take place on the typescript-eslint project. Please file an issue there. Thanks!