Skip to content

Type narrowing for generic types #1726

Description

Hi,

Type narrowing not working in the following situation (maybe caused by generic type?):

interfaceOptions<T>{opt: T|(()=>T);}functionMyFunc<T>(options: Options<T>){varopt=options.opt;if(typeofopt==="function"){vark=opt;// k is "T | (() => T)" but should be "() => T"}}///////////////////////////////////varoptions: Options<number>;varopt=options.opt;if(typeofopt==="function"){vark=opt;// k is "() => number", it is OK}

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions