-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
TypeScript this
Type Information Dosen't Surface Properly in Editor
#10937
Comments
@thoughtentity thank you for the excellent bug report. One of the best explained and demonstrated I have seen 👍. I have reproduced. As this issue is a TypeScript language service issue I will migrate to their repo. |
This appears to be still an issue with:
Replicates as follows:
To elaborate on the last point. Assume the actual function() {
let that: SVGSVGElement | null = this; // works, although 'this' "appears" to be 'any'
// let that2: HTMLElement | null = this; // would fail, as expected
// let that3: SVGSVGElement= this; // would fail, as expected with strictNullChecks
return that? that.querySelectorAll('g') : []; // works as expected
// Alternatively, trying to use:
// return this? this.querySelectorAll('g') : []; // unexpectedly fails, with error `this` "could possibly be null"
} |
As of TS 2.2.0-dev.20161129 the issue with |
@tomwanzek Issue filed: #12587 |
Closing since the original issue is fixed. |
From @thoughtentity on September 14, 2016 15:57
TypeScript
this
Type Information Dosen't Surface Properly in EditorEnvironment Information
Problem
In TypeScript 2.0, the shape of
this
for functions can be described using type annotations. However, the VS Code TypeScript editor does not properly surface this information. Thethis
variable in the function gets typed asany
within the function but the editor still enforces that use ofthis
in the function conform to the type information used to describethis
for the function. This results in the odd issue of the editor not providing any intellisense for thethis
due to it being typed asany
but still expects it conform to the shape ofthis
described by thethis
type annotation for the function.Reproduction
The following minimum TypeScript file will reproduce the issue in VS Code.
Expected Result
The VS Code TypeScript editor should properly surface the type information for
this
in functions and not just type it asany
to provide proper intellisense.Copied from original issue: microsoft/vscode#12032
The text was updated successfully, but these errors were encountered: