Skip to content

The generic type cannot be successfully inferred.Β #57185

Closed as not planned
Closed as not planned
@LiST-GIT

Description

@LiST-GIT

πŸ”Ž Search Terms

The generic type cannot be successfully inferred.

πŸ•— Version & Regression Information

5.3

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBMEM7APoCMA8AVANFAwugGgHxQC8U6UEAHrAHYAmcUA3gL5QD8LUA2gNJQAlrSgBrCCAD2AM3IBdAFzl+cyjQgMmACgDGwKkoCGtENklhgcIyewA6e4YBOAcytDa0iI6gAFAJSkxMKe3gBKnFC6+kp4+GYWbsxioqJKtACuALbIXlCsdg4ubv6BUOFpEABuuexKAEwA3ABQ0um0eoKSIoY9hqgAItjohFrASkn0HEqDUNJT5FAAPjDwSGhY3HBbaVk53qzErAFJrE29hlrMTVA3UAD0d1D041BbbgCMdQDMedgPuJJMpkNMBhM4YAALQRMAA2wmgknSwCgAHdBDCYVAQIIIDD6E9BNIQiCoI54OkYZZbNdbtJxjTbrcLnoqPFLNhescGYyeSzbG9uYz8oLbsgoqyoOZ2VBOSwRTyoHyBQqbsKVYrxWy4Byelz1YylVt5b9jW8lAByAACCCcwHNmG5wqOQA

πŸ’» Code

type test_b<T, CTX> = T extends {} ? { [K in keyof T]: T[K] extends (ctx: any, opts: any, ...args: infer P) => infer R ? (ctx: CTX, opts: { kkk: number }, ...args: P) => R : never } : 2;
function aaaa<D, T>(t: { d?: D, f?: T | test_b<T, { sss: number }> }) { }
aaaa({
    // d: { sss: 123 }, // Commenting this line out will yield different results.
    f: {
        a(ctx, opts, aaa) {
            ctx.sss
        },
        b(ctx, opts, aaa) {
            ctx.sss
        },
        c(ctx, opts, aaa) {
            ctx.sss
        },
        sss: '@start',
    },
})

πŸ™ Actual behavior

The error occurred after set d.

πŸ™‚ Expected behavior

It should always converge successfully.

Additional information about the issue

No response

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