Skip to content
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

@class with mapped types can incorrectly handle properties #2842

Open
Gerrit0 opened this issue Feb 2, 2025 · 1 comment
Open

@class with mapped types can incorrectly handle properties #2842

Gerrit0 opened this issue Feb 2, 2025 · 1 comment
Milestone

Comments

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 2, 2025

Search terms

@class defineComponent

Expected Behavior

declare function defineComponent<
    T extends Record<string, () => any>,
    U extends Record<string, any>,
>(component: {
    computed: T;
    props: U;
}): new () => U & { [K in keyof T]: ReturnType<T[K]> };

/** @class */
export const ComputedClass = defineComponent({
    computed: {
        hello() {
            return "hello";
        },
    },
    props: {
        name: "world",
    },
});

Should produce a class with a hello property which has type string

Actual Behavior

TypeDoc makes a class with a hello property of type any

Environment

  • Typedoc version: 0.27.6
  • TypeScript version: 5.7.2
  • Node.js version: 20
  • OS: Fedora
@Gerrit0 Gerrit0 added the bug Functionality does not match expectation label Feb 2, 2025
@Gerrit0
Copy link
Collaborator Author

Gerrit0 commented Feb 2, 2025

I noticed this while working on typedoc-plugin-vue for #2841, there TypeDoc was behaving even more strangely, adding properties for each method on String to the resulting class, not sure why, but the same fix worked there.

@Gerrit0 Gerrit0 added this to the v0.27.7 milestone Feb 2, 2025
Gerrit0 added a commit that referenced this issue Feb 2, 2025
@Gerrit0 Gerrit0 removed the bug Functionality does not match expectation label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant