-
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
"Property does not exist on type 'never'" with optional chaining #58733
Comments
Variables are narrowed on assignment/initialization. TS knows |
@fatcerberus maybe it does, but not the case in my code. I have some code that fetches project data and assigns the data to the |
Here is the full code for the page:
|
@fatcerberus Ok, thank you very much! |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
optional chaining, null, undefined, property does not exist on type never
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBACgTgewFYQMbCgXigbwFBRQCWAJgFxQB2ArgLYBGEcBUwRwANhBQM7BxFKAcwA0LDoIDWvfoNEsSEHqgFg2CSjIHC8AXzx4uGMIhToK8ZGgwAfKtQ4cs9xwG4DqDTwRcAdBwQhAAoTK3QAfl82TggASnc8IA
💻 Code
🙁 Actual behavior
TypeScript is not recognizing that
project
can be of typeProject
, giving a type error:🙂 Expected behavior
I would expect for TypeScript to accept
Project
as a possible type for the variable.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: