Skip to content

Specify whether generic is allowed to be infered as {} #15968

@NN---

Description

@NN---

I would like to specify that 'To' is not allowed to be inferred as '{}'.
Perhaps some compilation flag, --noInferObjectFromGeneric, or something else.

function convert<To, From>(from: From): To {
    return from as any as To; // doesn't really matter
}

var x = convert(1);  // To = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions