Skip to content

Typescript semantic error: A type predicate's type must be assignable to its parameter's type #3

Description

@SeanSobey

This comes from the index.d.ts, specifically these 3 functions:

function isNullOrEmpty<T>(seq: IEnumerable<T>): seq is (null | IEnumerable<T>);
function isUndefinedNullOrEmpty<T>(seq: IEnumerable<T>): seq is (undefined | null | IEnumerable<T>);
function isUndefinedOrEmpty<T>(seq: IEnumerable<T>): seq is (undefined | IEnumerable<T>);

I believe the correct semantics, also based on their names and what they should be able to accept as parameters is:

function isNullOrEmpty<T>(seq: null | IEnumerable<T>): seq is (null | IEnumerable<T>);
function isUndefinedNullOrEmpty<T>(seq: undefined | null | IEnumerable<T>): seq is (undefined | null | IEnumerable<T>);
function isUndefinedOrEmpty<T>(seq: undefined | IEnumerable<T>): seq is (undefined | IEnumerable<T>);

I am using typescript 2.7.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions