Skip to content

Incorrect types for readonly arrays #22

@russelldavis

Description

@russelldavis

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

N/A

Plugin version

No response

Node.js version

N/A

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

N/A

Description

The return value of deepmerge is incorrect when the inputs contain a readonly array.

Steps to Reproduce

import makeDeepmerge from "@fastify/deepmerge";
const deepmerge = makeDeepmerge();
const a1 = ['a', 'b'] as const;
const a2 = ['c'] as const;
const m = deepmerge(a1, a2);

The type of m is readonly ["c"] which is incorrect.

Expected Behavior

The type of m should be ["a" | "b" | "c"] (or even better, ["a", "b", "c"] in this case since the inputs are tuples).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions