Skip to content

Inferred return type for function that return type assertion should be is [type] #14891

@mohsen1

Description

@mohsen1

TypeScript Version: 2.2.1

Code

function isString(x: any) {
    return typeof x === 'string';
}

Expected behavior:

Inferred type of foo is function isString(x: any): boolean

Actual behavior:

Inferred type should be function isString(x: any): x is string

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions