Skip to content

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

Closed
@bluebarcode

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

type FailsType = {
  foo: boolean;
};
type WorksType = { 
  foo: string
};
class TestClass<Param> {
  testFunc: <T extends Partial<Param>>(
    param: T
  ) => {testProp?:Param extends Partial<T> ? 'yes' : 'no'} = (param)=>({});
}
type inlineTest = FailsType extends Partial<FailsType> ? 'yes' : 'no';
const inlineTestValue:inlineTest = 'yes';

// Here i use the Works Type
const testClassWorks = new TestClass<WorksType>();
const resultWorks = testClassWorks.testFunc({ foo: 'works' });
resultWorks.testProp='yes';

// Here i use the Fails Type
const testClassFails = new TestClass<FailsType>();
const resultFails = 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