Skip to content

Error typeof type guards #20613

Closed
Closed
@ghost

Description

export async function add(params: { [key: string]: string | string[] }): Promise<string> {
 if (!params.birthday || typeof params.birthday !== "string" || !Date.parse(params.birthday))
{
...
}
}

Get an Typscript Error on !Date.parse(params.birthday) because params.birthday can be a string or string []

Possible to make also object typeof recognize it as a type guard ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDuplicateAn existing issue was already createdFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions