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.

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?

@typescript-eslint/parser

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:closed
  • Created 4 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Sep 18, 2019

The project is actually using @typescript-eslint/require-await rule, not directly require-await. This rule internally uses the core require-await and also has some additional logic from the typing information (allows async functions without await 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 line AwaitExpression: rules.AwaitExpression in the distribution code is replaced with something like AwaitExpression(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 just FunctionExpression.

1reaction
kaicataldocommented, Sep 18, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

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