Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@bluebarcode

Description

@bluebarcode
Issue body actions

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'

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.