-
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
TS2339: Property 'bar' does not exist on type 'never' (strictNullChecks) #41766
Comments
By what justification should this not be an error? This code doesn't make any sense. |
@RyanCavanaugh this is just a minimal reproducible example without any attached business logic to the code. The issue that typescript throws error when we handle null value.
does not throw error. In real world use case we use P.S. /**
* @type {{bar:string}|null}
*/
let foo = null;
setState();
console.log(foo?.bar);
function setState() {
foo = {bar: 'zoo'};
} This code still throw
|
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Seems like you're talking about #9998 then |
@RyanCavanaugh kind of... mostly about optional chaining |
Example code:
index.js
tsconfig.json
Command:
AR:
ER: No error
Typescript version 4.1.2
If change the code on:
All works fine
The text was updated successfully, but these errors were encountered: