Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

jquery tests failure on Definitely Typed #55583

Closed
navya9singh opened this issue Aug 31, 2023 · 7 comments
Closed

jquery tests failure on Definitely Typed #55583

navya9singh opened this issue Aug 31, 2023 · 7 comments
Assignees
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@navya9singh
Copy link
Member

navya9singh commented Aug 31, 2023

🔎 Search Terms

overloads, jquery

🕗 Version & Regression Information

This is a crash in jquery tests on Definitely Typed https://dev.azure.com/definitelytyped/DefinitelyTyped/_build/results?buildId=162795&view=logs&j=9d906afe-3eb5-5d79-316d-86f3f3fa360c&t=09716206-abc7-5ba2-2ea2-6c6fe97a3aad because of #54448

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.0-dev.20230831#code/JYOwLgpgTgZghgYwgAgFIEZkG9kGtQAmAXMgOQakDcyAvgFCiSyIqoBM2ehJ5bVtDcNHhI0AZk74QxMqjH96jYSzQAWSd1mqFgpiNYBWDdJ6oDOpc1GoAbMZnkbFoVdYB2e6bfO9K1AA5PWX8fZWsATiDycJ1dMJQAFQALCBA4ACMAGwgAHgSAPmQIAA9IaQBnZAAFKAB7AFtgcogAGWBcXILOejjXarrG5oAhOGa8gCUAGmQE1GmEgDlJumRVtdWAVSnkDbmdpZX1tYA1beO944OjtYBlbZu9m4XCrDpD67AUkByAQXGAEWQAF5kCAIAA3aDTH6oQEgsGQqDQhZw0EQqHva5rIYA4FoxHTIawvEIqHIIYoknopGYrHIADCuPh1Om9OJzIJDMpHIxdPW4yZ+LJ43ZQqRyHG3LFyz5az+ADEqZyYYqeeKfgtVdLaVicVrSeKifqWeTNUrebKGeNjZy2TayfSzWqZZaBfbxSL3dNJV6ddc-lVzerUIHncgNaHtZbyeNIwbCSGg4SFnGWX6jozU7bE2HHVmLbKBfmPTnpRKU0H8gAKdN0gi1MHy4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A9WnRtjSxmFcNYVDdg0L4asehSFELCLLLtA0LwBB0AQA2coYBkDCSIBwkhiioCgDEtMAAolAOo4p-b1HSGSDRWjphmJANo5A6Rai1GyHAEA0xHEAE9dHZHqKkMA0xpF4iwDQZAoxAkgBcSteRIBFHKPQKo7CxCcgYGmOwRJYhEmqESQYRJNhEluESf4RJ4RCggn8YEyoriwkKKUcJNgMS1YkKSeIVJ6TMnZNyfkxJ6BCnYACUEspciKnKLEDUyKdSUlqCaWgLJaAcloDyWgcI7TElsE6cUnpISVp9IiUosA0TPx8x-BgZZ3TSlrI2ZEsA1Tdn232UsvxRzgmhNOVswZlyX5yEOSU+56yYDdhAAgMAwAGzIFnvPAA+p-L2UAqwLleOsGFWJwmRIAI54mEiOOuVYoX6ThbKSSYBuxQBAMgbZ1csQ0GmJi4m2K+S4vxYS85JLrg0DnOmRFaKvgYrgBhF4Qk4DUAAPR8uQAAEh0cUYSEA-kJBceKtAmAPzsHTGS+SnKsU8v5YKkVYqJVgClTKg0NjuxKJpQS45LjFXkrgNMdI0wEBcuwGq5AArhWivFZK6VKADRCXSOq51Wq3V6upEJBAPrNWup1e6sUiq5wMoEDQIAA

💻 Code

interface J1 { kind: 'J1'; }
interface J2 { kind: 'J2'; }
interface J3 { kind: 'J3'; }
interface J4 { kind: 'J4'; }
interface J5 { kind: 'J5'; }
interface J6 { kind: 'J6'; }
interface J7 { kind: 'J7'; }
interface J8 { kind: 'J8'; }
interface J9 { kind: 'J9'; }

interface Thenable<T> extends PromiseLike<T> { }

interface PromiseBase<TR, TJ, TN,
        UR, UJ, UN,
        VR, VJ, VN,
        SR, SJ, SN> {

        then<ARD = never, AJD = never, AND = never,
            BRD = never, BJD = never, BND = never,
            CRD = never, CJD = never, CND = never,
            RRD = never, RJD = never, RND = never,
            ARF = never, AJF = never, ANF = never,
            BRF = never, BJF = never, BNF = never,
            CRF = never, CJF = never, CNF = never,
            RRF = never, RJF = never, RNF = never,
            ARP = never, AJP = never, ANP = never,
            BRP = never, BJP = never, BNP = never,
            CRP = never, CJP = never, CNP = never,
            RRP = never, RJP = never, RNP = never>(
                doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase<ARD, AJD, AND,
                    BRD, BJD, BND,
                    CRD, CJD, CND,
                    RRD, RJD, RND> | Thenable<ARD> | ARD,
                failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase<ARF, AJF, ANF,
                    BRF, BJF, BNF,
                    CRF, CJF, CNF,
                    RRF, RJF, RNF> | Thenable<ARF> | ARF,
                progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase<ARP, AJP, ANP,
                    BRP, BJP, BNP,
                    CRP, CJP, CNP,
                    RRP, RJP, RNP> | Thenable<ANP> | ANP): PromiseBase<ARD | ARF | ARP, AJD | AJF | AJP, AND | ANF | ANP,
            BRD | BRF | BRP, BJD | BJF | BJP, BND | BNF | BNP,
            CRD | CRF | CRP, CJD | CJF | CJP, CND | CNF | CNP,
            RRD | RRF | RRP, RJD | RJF | RJP, RND | RNF | RNP>;

        then<ARD = never, AJD = never, AND = never,
            BRD = never, BJD = never, BND = never,
            CRD = never, CJD = never, CND = never,
            RRD = never, RJD = never, RND = never,
            ARF = never, AJF = never, ANF = never,
            BRF = never, BJF = never, BNF = never,
            CRF = never, CJF = never, CNF = never,
            RRF = never, RJF = never, RNF = never>(
                doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase<ARD, AJD, AND,
                    BRD, BJD, BND,
                    CRD, CJD, CND,
                    RRD, RJD, RND> | Thenable<ARD> | ARD,
                failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase<ARF, AJF, ANF,
                    BRF, BJF, BNF,
                    CRF, CJF, CNF,
                    RRF, RJF, RNF> | Thenable<ARF> | ARF,
                progressFilter?: null): PromiseBase<ARD | ARF, AJD | AJF, AND | ANF,
            BRD | BRF, BJD | BJF, BND | BNF,
            CRD | CRF, CJD | CJF, CND | CNF,
            RRD | RRF, RJD | RJF, RND | RNF>;
        
        then<ARD = never, AJD = never, AND = never,
            BRD = never, BJD = never, BND = never,
            CRD = never, CJD = never, CND = never,
            RRD = never, RJD = never, RND = never>(
                doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase<ARD, AJD, AND,
                    BRD, BJD, BND,
                    CRD, CJD, CND,
                    RRD, RJD, RND> | Thenable<ARD> | ARD,
                failFilter?: null,
                progressFilter?: null): PromiseBase<ARD, AJD, AND,
            BRD, BJD, BND,
            CRD, CJD, CND,
            RRD, RJD, RND>;
}

interface Promise3<TR, TJ, TN,
    UR, UJ, UN,
    VR, VJ, VN> extends PromiseBase<TR, TJ, TN,
    UR, UJ, UN,
    VR, VJ, VN,
    never, never, never> { }

const p:Promise3<string, Error, number, string, string, boolean, any, Element, never> = {} as any;
const p1:Promise3<J1, J2, J3, J4, J5, J6, J7, J8, J9> = {} as any;
const p2:Promise3<J2, J3, J4, J5, J6, J7, J8, J9, J1> = {} as any;
const p3:Promise3<J3, J4, J5, J6, J7, J8, J9, J1, J2> = {} as any;

const t1: Thenable<J1> = {} as any;
const t2: Thenable<J2> = {} as any;
const t3: Thenable<J3> = {} as any;

function doneFilter_failFilter() {
    {
        const q = p.then(() => {
            return t1;
        }, () => {
            return t2;
        })
        q.then((a) => {
            a; // $ExpectType J1 | J2
        }, (a) => {
            a; // $ExpectType never but returns any
        }, (a, b, c) => {
            a; // $ExpectType never
            b; // $ExpectType never
            c; // $ExpectType never
        });
    }
}

🙁 Actual behavior

Type returned for a is any

🙂 Expected behavior

Type for a should be never

Additional information about the issue

No response

@Andarist
Copy link
Contributor

Seeing the list of these generic type params I’m suddenly feeling less bad about some of my signatures

@andrewbranch
Copy link
Member

Looks like this repro isn’t quite right, as the failing $ExpectType is failing in every TS version here. Something in the attempt to extract out the relevant bits of the jQuery typings left something important behind, apparently. @navya9singh said there are even more overloads and is starting to bring them back.

@navya9singh
Copy link
Member Author

Looks like this repro isn’t quite right, as the failing $ExpectType is failing in every TS version here. Something in the attempt to extract out the relevant bits of the jQuery typings left something important behind, apparently. @navya9singh said there are even more overloads and is starting to bring them back.

Updated the repro now.

@andrewbranch
Copy link
Member

I managed to trim it down quite a bit.

(I haven’t tried to validate whether the behavior is right or wrong, but this exhibits the same neverany change in nightly with less code.)

@andrewbranch
Copy link
Member

@navya9singh and @sandersn mentioned that this change was caused by #54448.

@sandersn sandersn added this to the TypeScript 5.3.0 milestone Sep 6, 2023
@sandersn sandersn added Bug A bug in TypeScript Recent Regression This is a new regression just found in the last major/minor version of TypeScript. labels Sep 6, 2023
@ahejlsberg
Copy link
Member

This is an intended change. In the example, we infer from a Thenable to a PromiseBase which in turn means inferring from the single then method in Thenable to the overloaded then method in PromiseBase. Previously, we'd only infer to the last overload, which never references the TJ type parameter, so we'd make no inferences and end up with the default type never. Now we infer to all signatures in the target, and therefore make an any inference for TJ. The change is described here. The new behavior is definitely more correct--after all, we don't know through which overload then will ultimately be invoked, so it makes no sense to ignore some of them.

@ahejlsberg ahejlsberg added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Bug A bug in TypeScript Recent Regression This is a new regression just found in the last major/minor version of TypeScript. labels Sep 10, 2023
@ahejlsberg ahejlsberg removed this from the TypeScript 5.3.0 milestone Sep 10, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

6 participants