Skip to content

Function param with generic type are not recognized correctly #23705

Closed
@k8w

Description

@k8w

TypeScript Version: 2.7.0-dev.201xxxxx
2.8.3

Search Terms:

Code

class Protocol<T>{}

interface ReqTest {
    abcde: string;
}

const PtlTest = new Protocol<ReqTest>();

function request<T>(ptl: Protocol<T>, req: T) { }

request(PtlTest, {})

Expected behavior:
Compile error.
Because request(PtlTest, {}), param 2 {} not match ReqTest

Actual behavior:
Compile success

Playground Link:

Related Issues:

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