Skip to content

Explicit spesifiying generic type parameters, while remain should be infer from function parameters #25603

Closed
@wesleyolis

Description

@wesleyolis

Expect that the remaining generic type parameters that are not explicitly set, should be inferred from the function parameters.

const testsCallBack = {
	test : function (callback : (err : any, result : string) => void)
}

function Prom<R extends any, M extends keyof O = any, O extends {} = any>(object : O, method : M) : void

const sftpWrapper = Prom<ssh2.SFTPWrapper>(testsCallBack, 'test'); // I would expect that the typing engine should infer the remain generics that are not explicitly set.

const sftpWrapper = Prom<ssh2.SFTPWrapper>(testsCallBack, 'tet');// Compiler Error
const sftpWrapper = Prom(ssh2, 'fastGet');// returns a good implementation of the types library

Also see post regarding top type unknown, which could also fix this problem, basically comes down to this being a type infer issues/bug in my opion.

#24439

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