-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use global this when noImplicitThis
is enabled.
#15613
Comments
The intention here was to not allow use of |
From my response in #3576 which was adapted from this Stack Overflow answer, you could just use |
Ugh. Can TypeScript start taking a serious look at the |
It appears a variable name was chosen (globalThis) and has successfully shipped in Chrome 71 stable channel. https://www.chromestatus.com/features/6571514765770752 |
Fixed by #29332 |
When
noImplicitThis
is turned on, you are unable to reference the globalthis
(which may be window, or global, or other value in various runtime environments).I'm not sure if there is a recommended way around this, but currently there does not appear to be a way to get the "global"
this
without an error'this' implicitly has type 'any' because it does not have a type annotation.
This may be something I'm just not seeing. I tried to defineglobal
but that wasn't much help.TypeScript Version: 2.3.x
Code
Expected behavior:
Be able to use the global
this
without error.Actual behavior:
Compiler error
'this' implicitly has type 'any' because it does not have a type annotation.
when usingthis
globally.cc @benlesh
The text was updated successfully, but these errors were encountered: