agiledigital-labs / agiledigital-labs/eslint-plugin-total-functions
[total-functions/no-unsafe-readonly-mutable-assignment] False positive?
- Ngôn ngữ chính
- TypeScript
- Star
- 92
- Fork
- 5
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Hi,
I'm getting the following error:
```
25:3 error Unsafe "Mutable" to "Mutable" assignment. Source: "{ c: number; } | {}", destination: "{ c: number; } | { c?: undefined; }" total-functions/no-unsafe-readonly-mutable-assignment
```
On the following code:
```
import merge from "lodash/merge";
export function mergeImmutable(v1: T1, v2: T2): T1 & T2;
export function mergeImmutable(
v1: T1,
v2: T2,
v3: T3,
): T1 & T2 & T3;
export function mergeImmutable(
v1: T1,
v2: T2,
v3: T3,
v4: T4,
): T1 & T2 & T3 & T4;
export function mergeImmutable[]>(
...args: Readonly
) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return merge({}, ...args);
}
const x = mergeImmutable(
{ a: 1 },
{ b: 2 },
Math.random() < 0.5 ? { c: 3 } : {},
);
```
I'm new to eslint-plugin-total-functions, but it seems to me that the error message doesn't make sense: it's complaining that a mutable value is being assigned to a mutable argument? Is this error being thrown incorrectly, or am I misunderstanding the message?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.