Bug Report
text[key] on left infer to never ??? but why text[key] on right infer to string | number?
🔎 Search Terms
🕗 Version & Regression Information
typescript - 4.5.0
⏯ Playground Link
link
💻 Code
interface Item {
id: number;
name: string;
age: number;
}
const form: Item = {
id: 99,
name: 'k',
age: 99,
};
const text: Item = {
id: 1,
name: '张三',
age: 18,
};
(['id','name','age'] as const).forEach(key => {
text[key] = text[key];
});
// Type 'string | number' is not assignable to type 'never'.
// Type 'string' is not assignable to type 'never'.
🙁 Actual behavior
bug occured
🙂 Expected behavior
no bug
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
typescript - 4.5.0⏯ Playground Link
link
💻 Code
🙁 Actual behavior
bug occured
🙂 Expected behavior
no bug