TypeScript
TypeScript copied to clipboard
Don't generalize when assigment target is never (fix: #41707)
Fixes #41707
Added a condition that when the expected type is "never," the checker should not generalize the literal type. It might not be the best solution, but it's definitely the easiest one. Another idea that I've considered was to check if the "source" type is narrowed and skip generalization for narrowed types, but I'm not sure how to do it properly and if it OK solution.
@microsoft-github-policy-service agree
I think this is a good fix; un-narrowing the source is going to make things more confusing. I can't commit the suggestion to the PR branch for some reason - please merge it in. Behavior changes LGTM.
This was merged skipping checks; not sure that was intended.
@hyzyla I would recommend sending PRs from branches on your fork rather than main; that's why we couldn't modify it.