# Bug Report <!-- Please fill in each section completely. Thank you! --> ### π Search Terms switch undefined <!-- What search terms did you use when trying to find an existing bug report? List them here so people in the future can find this one more easily. --> ### π Version & Regression Information 6.4 ~ 4.7.4 (latest) ### β― Playground Link <!-- A link to a TypeScript Playground "Share" link which shows this behavior The TypeScript Workbench can be used for more complex setups, try https://www.typescriptlang.org/dev/bug-workbench/ As a last resort, you can link to a repo, but these will be slower for us to investigate. --> [Playground link with relevant code](https://www.typescriptlang.org/play?#code/C4TwDgpgBAysCGxoF4oG8BQVtQGYHt8AuKAZ2ACcBLAOwHMMBfDDAGwmDISRLkWgA+UAK40AJhFy0IYgNwt2nChFLDWwEgCNC7eDSipc8VqQjyMVXFAAU5fgEp0LHF34A6AvgPJUAIlJiuGKkuL5YOKQA7lTAAMYAFjaUwhCOmOEu2LHwpq5IHoTeqADkSOTFRBmZ2bl2+Z5FUKUqwBVVmTjKquoGUMlm7R1QmsrwANbmQ1A10HUQBV4+JWWtlVMzefMNS00rbVMuXWqcqP3yBzgjEOOTQxtzUABkj5sLjc3la3c5s9xbhTsPqtBh0jj1ThQUucLsNRhNnN9an8oAB+V7bHy7FrFKAkIwmCBfDr3P5vQF7IkHMEnPqQgYw2HXeFVZhMDBAA) ### π» Code <!-- Please post the relevant code sample here as well--> ```ts type State = { foo: string } let state: State | undefined; let result: boolean = false; if (state) { state.foo === "sdfdsf" switch (true) { case state.foo === 'test': case state.foo === 'test': result = true; break; // Object is possibly 'undefined'.ts(2532) case state.foo === 'test': case state.foo === 'test': result = true; break; // Object is possibly 'undefined'.ts(2532) case state && state.foo === 'test': case state.foo === 'test': result = true; break; // Object is possibly 'undefined'.ts(2532) case state ? state.foo === 'test' : false: case state.foo === 'test': result = true; break; } } ``` ### π Actual behavior Error Object is possibly 'undefined'.ts(2532) ### π Expected behavior No error
Activity
MartinJohns commentedon Aug 21, 2022
Duplicate of #37178.
typescript-bot commentedon Aug 28, 2022
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.