Skip to content

property in generic conditional type not narrowed in nested conditional typeΒ #46145

Closed
@DetachHead

Description

@DetachHead

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

4.5.0-dev.20210930

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

interface Foo {
  foo: string|undefined
}

type Str<T extends string> = T

type Bar<T> = 
  T extends Foo
    ? T['foo'] extends string
      // Type 'T["foo"]' does not satisfy the constraint 'string'.
      //  Type 'string | undefined' is not assignable to type 'string'.
      //   Type 'undefined' is not assignable to type 'string'.(2344)
      ? Str<T['foo']>
      : never
    :never

πŸ™ Actual behavior

T['foo'] is not being narrowed to string

πŸ™‚ Expected behavior

T['foo'] is narrowed to string

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions