Description
TypeScript Version: 4.1.2, 4.0.5 (worked better in 3.9.7)
Search Terms: "string is not assignable to type never" (all 15 issues I found look slightly different I think)
Code
function assertUnreachable(_: never): void {}
type ActionTypes = 'a' | 'b'
function reducer(state: {}, action: {type: ActionTypes}) {
switch(action.type) {
case 'a':
return state
default: {
assertUnreachable(action.type) // <-- incorrect widening on this line
return state
}
}
}
Expected behavior: like in 3.9.7, the error message should be Argument of type '"b"' is not assignable to parameter of type 'never'
Actual behavior: Argument of type 'string' is not assignable to parameter of type 'never'
- which is too wide to be actually helpful :(
Playground Link: https://www.typescriptlang.org/play?ts=4.1.2#code/GYVwdgxgLglg9mABAQwM6oKYCcoFUxYbIQAWyARgDYYAUA+gFyJgYBu2AlE63DACaIA3gF8AUKID0ExCFTIA5hlFQAngAcMiAILR4YACrqMqRAF5EAcmQXEAH0vkL40JFgJEhPiAjYaqKMhQGEwiADQougghqhpMOm4GRqjCHEKiiIioAO4wUKQ0xAkAdDEYqYLpGYgQaJpWFgyVVR4YUCBYSP6BSs18GMDIIJRQIU1VaJg4+ITEZFS0hXolRhxjGYRtHZkBQWNiGWJiohAIqHDURZRw8jSe3r5hQqVMFo4pHEA (change the version number to see the previous error)
Related Issues: ?