Skip to content

Empty tuple not inferred from rest parameters of a generic array type #38770

Closed
@fasttime

Description

@fasttime

TypeScript Version: 3.9.3

Search Terms: generic rest parameters empty tuple

Code

declare function requireAtLeast1Arg<T extends any[]>(...args: T extends [] ? never : T);

requireAtLeast1Arg();

Expected behavior: The code above should trigger the infamous compiler error 2345 as it used to do in TypeScript <= 3.8.

Actual behavior: The code compiles in current TypeScript 3.9.3.

I couldn't find a release note about the new behavior, so I'm assuming this was a kind of unintended breaking change.

Playground Link:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions