typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Inferred function return type is different from TS 5.9.3

Open In3luki opened this issue 1 month ago • 0 comments

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.

In3luki avatar Nov 27 '25 11:11 In3luki