-
Notifications
You must be signed in to change notification settings - Fork 12.8k
No error accessing non-existent method on string with strictNullChecks on #26426
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
Comments
I believe this is because of this line in If |
That PR didn't fix this, the line I pointed out still exists. I would leave this issue open since there's still the possibility for confusing differences between services and the compiler. |
But I see error reported by running tsc as well as from language service so its fixed? |
@sheetalkamat You probably don't have |
Duplicate of #19686 . |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.0.1
Search Terms: strictNullChecks, inferred any, no error, parameter, argument, implicit any, property does not exist
Code
Expected behavior:
Expected to get error
Property 'foo' does not exist on type 'string'
on the last line.Actual behavior:
No error on the last line.
With all the strict settings on, there's a different error on the argument to the
getString
call, but that should not affect the return type offunctionThatReturnsAString
. The function could be in a completely separate part of the codebase. Inspecting that should not be required when trying to debug thes.foo()
call.Playground Link: https://www.typescriptlang.org/play/#src=function%20getString(required%3A%20%7B%7D)%20%7B%0D%0A%20%20return%20''%3B%0D%0A%7D%0D%0A%0D%0Afunction%20functionThatReturnsAString()%20%7B%0D%0A%20%20const%20optional%3A%20%7B%7D%20%7C%20null%20%3D%20null%3B%0D%0A%20%20return%20getString(optional)%3B%0D%0A%7D%0D%0A%0D%0Aconst%20s%20%3D%20functionThatReturnsAString()%3B%0D%0As.foo()%3B%0D%0A
Tested with all strict options on. (Note that Playground has been finnicky today.)
Related Issues:
The text was updated successfully, but these errors were encountered: