8000 spread error when using tuples within overload signatures Β· Issue #54812 Β· microsoft/TypeScript Β· GitHub
[go: up one dir, main page]

Skip to content
spread error when using tuples within overload signaturesΒ #54812
Closed as not planned
@Enteleform

Description

@Enteleform

Bug Report

πŸ”Ž Search Terms

  • overload
  • spread

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type A = [number, number]
type B = [string, string]
type AB = A | B

function foo(...args:A): void /* works when removed */
function foo(...args:B): void /* works when removed */
function foo(...args:AB){}

const args = [1, 2] as AB

foo(...args)
// A spread argument must either have a tuple type or be passed to a rest parameter.(2556)

πŸ™ Actual behavior

Type Error:

A spread argument must either have a tuple type or be passed to a rest parameter.(2556)

πŸ™‚ Expected behavior

No type errors. All resolutions of the AB union are valid tuples and should be spreadable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0