Skip to content

Primitive type boolean does not work with conditional typesΒ #44663

Closed
@benkeil

Description

@benkeil

Bug Report

πŸ”Ž Search Terms

conditional type extends boolean

πŸ•— Version & Regression Information

4.3.2

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type TestFunction<I, O> = I extends void ? () => O : (result: I) => O;

const numberFunction: TestFunction<number, void> = () => {};
numberFunction(1);
const booleanFunction1: TestFunction<boolean, void> = () => {};
booleanFunction1(true);
const booleanFunction2: TestFunction<Boolean, void> = () => {};
booleanFunction2(true);

πŸ™ Actual behavior

Looks like the keyword extends does not work with primitive type boolean but with Class Boolean and also with primitive type number.

TS2345: Argument of type 'boolean' is not assignable to parameter of type 'never'.

πŸ™‚ Expected behavior

booleanFunction2 should act like booleanFunction1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions