eslint-plugin-total-functions icon indicating copy to clipboard operation
eslint-plugin-total-functions copied to clipboard

[no-unsafe-readonly-mutable-assignment] false error with (mutable & readonly) type

Open Perfectoff opened this issue 3 years ago • 0 comments

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.

Perfectoff avatar Apr 14 '22 15:04 Perfectoff