Skip to content

Inferred function return type is different from TS 5.9.3 #2161

@In3luki

Description

@In3luki

Steps to reproduce

This is a contrived reproduction from a larger codebase. It looks like the error happens on line 24 where the inferred type of getItem(options.uuid) is always the same type as options.item as far as I can tell.

https://www.typescriptlang.org/play/?#code/MYGwhgzhAEDiCmA7eAnAlsAkgF3gW2gG8AoaM6RMPeaAXmgCIBzJVDBgbmIF9jjRIMAMoAHeMDQAzDDnzR4AD1yIAJjATJ0WXARLloAewBuqdCpqVqdRhDETpwTjz6SAromDY0BxNBbZZPAAeABUAEQNgV2pEbHklJDU4Vi1AgD4AClJyAH1XVzQVAC5oCGx0RCYAGmIAShLwyOikOIAfClcQECJsshR4bFcUX0IKKngS5hT2aG5oSGhGqJjsLl5iNw8vHz8B0XEpGR0M+uh9+yO5PXJ+weGiMepJ2wOHBlm1vmAfMsMRbcQEBK1zI+UKAH4SmUKkwuPo0DpIWc7IdtHJ2ohOiA1tZCNwuPwfnEEXJ6AZ-t5AQA6EkEcHg6AZckAiBUsEqaAM-yBJkUn5sgoqWrQEr+c6onm1WoEqSMgCEGVp0DQgOwYA88AMkmSmkueClPX02AAFigDAB3aAAURQZpQGQYADkDHF1cqdHKGNKePIQBAaLKMgqlSqyurgJrteKHIEDSDoN9AQYQPAqeawMNFToqZZ4N7eEA

Behavior with [email protected]

The type of item is correctly narrowed to GenericItem at the end of the if block and no errors are shown.

Behavior with tsgo

The type of item becomes never and the error Property 'name' does not exist on type 'never' is shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions