eslint-plugin-total-functions
eslint-plugin-total-functions copied to clipboard
[no-unsafe-readonly-mutable-assignment] false error with (mutable & readonly) type
This code throws an error when trying to assign (readonly & mutable) to readonly. I think there should be no error here.
type T_Mutable = { value : number[] | {a : number[]} };
type T_Readonly= { readonly value : readonly number[] | {readonly a : readonly number[]} };
declare const a : T_Mutable & T_Readonly;
const b : T_Readonly = a; // ESLint error: Using a readonly type to initialize a mutable type can lead to unexpected mutation in the readonly value.