8000 Incorrect inferred return type for a function that returns a circular type referencing itself · Issue #11189 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Incorrect inferred return type for a function that returns a circular type referencing itself #11189
@guncha

Description

@guncha

TypeScript Version: master at a633652 (Sep 27, 2016)

Code

interface Fun<T> {
  (value: T)
}

function switcheroo<T>(component: Fun<T>): Fun<T> {
  return component
}

function MyComponent(value: string) {
  return {
    type: OtherComponent
  }
}

export const OtherComponent = switcheroo(MyComponent)

Expected behavior:

Expected type of MyComponent to be (value: string) => {type: Fun<string>} and type of OtherComponent to be Fun<string>

Actual behavior:
Both types are any.

This is likely related or caused by the same thing as #5487 but I thought I'd contribute another test case.

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

      0