Skip to content

5.6 regression: Incorrect param type inference for type with all optional props #59656

Description

🔎 Search Terms

inference, param

🕗 Version & Regression Information

  • This changed between versions 5.5.4 and 5.6.0

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240816#code/JYOwLgpgTgZghgYwgAgMoHsC2EAqBPABxQG8AoZC5AeiuQHkRkBWAOgDYWAGAGmQgA8iUYNnDIARnmSY4Aa1ABzZGAAWwAM7ICUdAWRQIARwCuwAwBMW5SsZDATEAAo6CAfgBcydWGEgFAblIAX1JScwgEABs4A2QEdBBvZHRxdU86VOgANzhxSIgAHgxsfCIAPkDSGFsEMGAE5BiFAHEIMHUAdR0-UogACgBKdMyoHLzC4iCy5DJKfTbjKEYU9RYCYCI+sDgCPqbkAF5p2bnKJsDTyhoAPVdrS5pkAFFBCMhzT2LcQhRQZhZWAAWe6nR4AQVqxjgkU8FEmyD+WVYHE4AFpxG04Mp0P8UajwlkWAAmThEwGcAAcAEY2Mg9mBkPk4N4BiCggMBoEQlUanUGk1Wu0AMLoKAGWq9QYzEEGMCLZapNYbfrbXb7I7Sy4Uc4guY3O5a6i0MGRADucDwmniYrebI5XNCoEgsEQKAy6myuXyBRwxxB6yIBTBZT6unSQjgYFFADFefUQD7eMGhvQRmNvcGHU7oPAkMgAKogGJ4WMgWrxxPIABKxzp6nQiyQnhwKar-mQIWzLrzdAjUagpfLCUrNb4-EgIHMmkLxcHfIT7s94x9ZV4i9GXsKNdrnfAOddyAAsgl0L1e9BIzG48PfWOJ1P6H2r2X55Xb8QO2EItFYtUX-HlB2Fc+hAAQwE8PockiYwIGbAZDmmLJ0GAcwU2PEBTx+c8oEvAdrwTX1AiAA

💻 Code

interfaceSomeType{// On 5.6.0, experiment by making this prop required.uniqueProp?: string;}declareconstobs: Observable<SomeType>;functionargGetsWrongType(): Observable<{}>{returnobs.pipe(tap(arg=>{arg;//^?// Expected: SomeType in 5.5.4// Actual: {} in v5.6.0-beta to 5.6.0-dev.20240816 (at least)}));}functionargGetsCorrectType(){returnobs.pipe(tap(arg=>{arg;//^?// Always correct}));}interfaceObservable<T>{pipe<A>(op: OperatorFunction<T,A>): Observable<A>;}interfaceUnaryFunction<T,R>{(source: T): R;}interfaceOperatorFunction<T,R>extendsUnaryFunction<Observable<T>,Observable<R>>{}interfaceMonoTypeOperatorFunction<T>extendsOperatorFunction<T,T>{}declarefunctiontap<T>(next: (value: T)=>void): MonoTypeOperatorFunction<T>;

🙁 Actual behavior

arg is inferred as {}

🙂 Expected behavior

arg is inferred as SomeType as was consistent in v5.5.4

Additional information about the issue

(Google note: See http://cl/664889390 for local workaround)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions