Closed
Description
TypeScript Version: 3.5.1
Search Terms:
- Type 'any' is not assignable to type 'never'
Code
interface T {
str: string;
bool: boolean;
}
const initState: T = {
str: 'date',
bool: true,
};
let k: keyof T;
initState[k] = 'test' as any;
// ~~~~~~~~~~~~ Type 'any' is not assignable to type 'never'.ts(2322)
This seems to happen specifically with boolean
properties. If I get rid of the boolean
-valued property from the interface it works fine. If I have a larger interface and select non-boolean
properties, it also works fine. But boolean
and another type produces this error.
This error happens with TS 3.5 but not 3.4 (see playground link).
Expected behavior:
No error.
Actual behavior:
Type 'any' is not assignable to type 'never'
Playground Link: link
Related Issues: