Skip to content

Problem with .d.ts file generation for inner classes #59079

New issue

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

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

Already on GitHub? Sign in to your account

Closed
Velover opened this issue Jun 30, 2024 · 5 comments
Closed

Problem with .d.ts file generation for inner classes #59079

Velover opened this issue Jun 30, 2024 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@Velover
Copy link

Velover commented Jun 30, 2024

For the situations where the sub-class should return itself in the callback, it generates the wrong type.
It also generates a duplicate definition.

https://www.typescriptlang.org/play/?#code/MYGwhgzhAEAqCmEAu0DeAoaXrLEglsNAEICu+IAJvAE7QC80okMG27OSeh0AwjfDzwAFAEo0mDlIFJSNAHbR58AO7QkAC3wQxAbklSAvgY4AFGvnlIAEvBAgA9mIlTp8WQvVaI+19GMm7OaWSADiDg6UAEYAniLibH7YMnKKmtq+rsZ+oe4AcqQAtlG0zolJ0CmeAKyZRiaG+iYAsu4akQCMYuUcwA7yEA4g8AB0jgDmwgBEHVOidRxVad4N6C1tkQBM3YHYfQNDoxPTm3ML7EteGasmAGKW2ho7fpcAzAvGAQjII2QU1DQRvxBEh4iNglZbPYnKJwRYrOFIrEwbkkAViqV5kA

class Test {
    static Builder = class {
        static Create() {
            return new this();
        }
        PrintHello() {
            return this;
        }

        PrintGoodbye() {
            return this;
        }
        GetNumber() {
            return 5;
        }
    };

    Method1(){
        console.log("1");
        return this
    }
}

expected behaviour
generates .d.ts like/ or something like

declare class Anonymous1 {
    static Create(): Anonymous1
    PrintHello(): this;
    PrintGoodbye(): this;
    GetNumber(): number;
}
declare class Test {
    static Builder: Anonymous1;
    Method1(): this;
}

got

declare class Test {
    static Builder: {
        new (): {
            PrintHello(): any;
            PrintGoodbye(): any;
            GetNumber(): number;
        };
        Create(): {
            PrintHello(): any;
            PrintGoodbye(): any;
            GetNumber(): number;
        };
    };
    Method1(): this;
}

Some of the tooling relies on the type generation e.g. roblox-ts
and it causes some problems with the package Intellisense because any cannot be used for the generation of code like luau

@Velover Velover added the Duplicate An existing issue was already created label Jun 30, 2024
@Velover
Copy link
Author

Velover commented Jun 30, 2024

i didn't add the duplicate label, it happened automatically

there are no duplicates of this...

@fatcerberus
Copy link

It’s because you used the issue template for 9998 duplicates, this isn’t that (did the read the text in the template before you deleted it?). In fact there are no callback functions here

@fatcerberus
Copy link

#52415 is very similar but not an exact duplicate.
See also #41587 which is probably what's needed to fix this.

@Velover
Copy link
Author

Velover commented Jun 30, 2024

It’s because you used the issue template for 9998 duplicates, this isn’t that (did the read the text in the template before you deleted it?). In fact there are no callback functions here

Is that a problem? If so can I fix it?
I just got a little confused with these templates and picked the one that was the closest to the issue

@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" 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 Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants