Skip to content

Boolean properties are treated differently in conditional types (functions/methods) #48696

Description

@bluebarcode

Bug Report

Comparing conditional types containing boolean properties behave dififferent to other property types. But this only occures when the comparison takes place in a function/method.

🔎 Search Terms

conditional types, boolean, method, function

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ

⏯ Playground Link

Playground link with relevant code

💻 Code

typeFailsType={foo: boolean;};typeWorksType={foo: string};classTestClass<Param>{testFunc: <TextendsPartial<Param>>(param: T)=>{testProp?:ParamextendsPartial<T> ? 'yes' : 'no'}=(param)=>({});}typeinlineTest=FailsTypeextendsPartial<FailsType> ? 'yes' : 'no';constinlineTestValue:inlineTest='yes';// Here i use the Works TypeconsttestClassWorks=newTestClass<WorksType>();constresultWorks=testClassWorks.testFunc({foo: 'works'});resultWorks.testProp='yes';// Here i use the Fails TypeconsttestClassFails=newTestClass<FailsType>();constresultFails=testClassFails.testFunc({foo: false});resultFails.testProp='yes';

🙁 Actual behavior

The type of resultFails.testProp is not 'yes'

🙂 Expected behavior

The type of resultFails.testProp should be 'yes'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions