Skip to content

Regression for omitted lambda parameter with tuple args #30301

Description

@ulrichb

TypeScript Version: 3.4.0-dev.20190309

Search Terms: 3.4 tuple lambda

Code

The following snippet compiles fine in TS 3.3 whereas it emits an error in TS 3.4.

type MyTupleItem = {};
type MyTuple = [MyTupleItem, ...MyTupleItem[]];

type GenericFunction<T extends MyTuple> = (...fromArgs: T) => void;

class GenericClass<T extends MyTuple> {
    from: T | undefined;
}

function createClass<T extends MyTuple>(f: GenericFunction<T>): GenericClass<T> {
    return new GenericClass<T>(/* ... use f */);
}

function consumeClass(c: GenericClass<[string, boolean]>) { }

// ERROR:
consumeClass(createClass(str => console.log(str.length)));

// WORKS:
consumeClass(createClass((str, _unused_num) => console.log(str.length)));

Expected behavior:

No compile error.

Actual behavior:

>npx tsc TypeScriptIssueNext.ts
TypeScriptIssueNext.ts:18:14 - error TS2345: Argument of type 'GenericClass<[string]>' is not assignable to parameter of type 'GenericClass<[string, boolean]>'.
  Property '1' is missing in type '[string]' but required in type '[string, boolean]'.

18 consumeClass(createClass(str => console.log(str.length)));
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Playground Link: Link

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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