Skip to content

Same type evaluated differently when in a Tuple or by itselfΒ #47579

@188599

Description

@188599

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

Considering the following code:

type TypeWithoutTuple<T> = [T, Partial<T>];
type TypeWithTuple<T> = T | [T, Partial<T>];

interface A {
    a: number;
    b: string;
}

class A { }

const funcNotUsingTupleType = <
    T extends readonly unknown[]
    >(...args: [...{ [K in keyof T]: TypeWithoutTuple<T[K]> }]) => { }

const funcUsingTupleType = <
    T extends readonly unknown[]
    >(...args: [...{ [K in keyof T]: TypeWithTuple<T[K]> }]) => { }


funcNotUsingTupleType([new A(), {}]) // infers the typying <[A]>(things_0: ThingNoTuple<A>) => void

funcUsingTupleType([new A(), {}]) // infers the typying <[{}]>(things_0: TypeWithTuple<{}>) => void

πŸ™ Actual behavior

The same calls to funcNotUsingTupleType and funcUsingTupleType have different inferred typyings, even when they are evaluating the same thing.

πŸ™‚ Expected behavior

The same calls to funcNotUsingTupleType and funcUsingTupleType to have the same inferred typyings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions