Cannot set property 'hasAwait' of null
See original GitHub issue- ESLint Version: v6.4.0
- Node Version: v12.10.0
- npm Version: 6.10.3
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration: eslintrc
$ eslint --ext .ts --ext .tsx src/
TypeError: Cannot set property 'hasAwait' of null
Occurred while linting /home/mha/Projects/chat/src/components/ChatMessage.tsx:127
at AwaitExpression (/home/mha/Projects/chat/node_modules/eslint/lib/rules/require-await.js:95:36)
at /home/mha/Projects/chat/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/mha/Projects/chat/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/mha/Projects/chat/node_modules/eslint/lib/linter/node-event-generator.js:253:26)
at NodeEventGenerator.applySelectors (/home/mha/Projects/chat/node_modules/eslint/lib/linter/node-event-generator.js:282:22)
at NodeEventGenerator.enterNode (/home/mha/Projects/chat/node_modules/eslint/lib/linter/node-event-generator.js:296:14)
at CodePathAnalyzer.enterNode (/home/mha/Projects/chat/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:646:23)
at /home/mha/Projects/chat/node_modules/eslint/lib/linter/linter.js:936:32
at Array.forEach (<anonymous>)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Cannot set property of null - javascript - Stack Overflow
Cannot set property 'actualLocation' of null; I tried declaring all the variables globally so I can use the later but I don't know...
Read more >Fix Cannot Set Property of Null Error in JavaScript - YouTube
Check us out at https://www.skillforge.com The " cannot set property of null " error is a very common JavaScript issue that you may...
Read more >HTML : Uncaught TypeError: Cannot set property 'onclick' of null
HTML : Uncaught TypeError: Cannot set property 'onclick' of null [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] HTML ...
Read more >Code coverage report for compiler-sfc/src/compileScript.ts
Expression isConst: boolean } > = Object.create(null) // magic-string state const ... cannot accept both type and non-type arguments ` + `at the...
Read more >mozilla-central: changeset 539276 ...
"function") return null; var cache = new WeakMap(); ... throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed ...
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
The project is actually using
@typescript-eslint/require-await
rule, not directlyrequire-await
. This rule internally uses the corerequire-await
and also has some additional logic from the typing information (allowsasync
functions withoutawait
in some cases).Docs: @typescript-eslint/require-await.md
Source code: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/rules/require-await.ts
It doesn’t appear in the stack trace because it just returns a reference to
AwaitExpression
. When the lineAwaitExpression: rules.AwaitExpression
in the distribution code is replaced with something likeAwaitExpression(node){ rules.AwaitExpression(node); }
, it does appear in the stack trace.While the core rule doesn’t crash on this code, the
@typescript-eslint
wrapper does, because it has a bit different selectors -FunctionExpression[async = true]
instead of justFunctionExpression
.This isn’t currently handled by the rule because this is a parser error in the default parser and in Babel’s parser (see demo). I don’t think it would be a bad thing to update the rule to not crash here, but I think the real fix should be that @typescript-eslint/parser should throw a parser error here.