Bug: react-hooks/exhaustive-deps reports a dependency if typeof
TypeScript operator is used in a function.
#27548
Labels
Resolution: Stale
Automatically closed due to inactivity
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
These issues linked below are closely related, but I believe the problem was only fixed if you use
typeof
TypeScript operator inside theuseEffect
callback.#19327
#18828
However, if you call a function from the
useEffect
callback and that function usestypeof
in a type context, exhaustive-deps reports a problem.React version: 18.2.0
"eslint-plugin-react-hooks": "^4.6.0"
Steps To Reproduce
typeof
to define the type of a parameter.Link to code example:
I hope this sample is enough, let me know if it would be useful to have a whole cloneable repository for reproduction.
The current behavior
The above code reports the following problem.
The expected behavior
typeof
operator in the type context does not affect the compiled JavaScript and should not be reported byexhaustive-deps
.For reference, the following does not report an error even though it's functionally the exact same as the code example above:
The text was updated successfully, but these errors were encountered: