There are similar questions with this same error message, but every one I found is a runtime error. For me, globalThis
does exist at runtime, but ESLint reports that it does not. How do I tell ESLint that globalThis
exists?
Note: I created this to answer it myself. I thought it should be documented outside of an obscure github issue.
2
Answers
@mdjermanovic documented the fix here:
Note that you can find older answers that suggest adding
globalThis
as an eslint "global" config, but the above solution is more modern.You can also tell ESLint that
globalThis
exists.Specify it in the ESLint configuration file by adding
globalThis
to theglobals
section.