Skip to content

TS/JS docs get lost when using $$restProps #1377

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

Open
mrtnbroder opened this issue Feb 8, 2022 · 2 comments
Open

TS/JS docs get lost when using $$restProps #1377

mrtnbroder opened this issue Feb 8, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@mrtnbroder
Copy link

mrtnbroder commented Feb 8, 2022

Describe the bug
When using {...$$restProps}, type infos are getting lost when running svelte-kit package

To Reproduce
repro to clone: https://github.com/mrtnbroder/svelte-lost-types

Expected behavior
Using $$restProps shouldn't mess up the types produced

When using $$restProps

import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
    props: {
        [x: string]: any;
        class?: string | null;
        disabled?: boolean | null;
    };
    events: {
        [evt: string]: CustomEvent<any>;
    };
    slots: {
        default: {};
    };
};
export declare type ButtonProps = typeof __propDef.props;
export declare type ButtonEvents = typeof __propDef.events;
export declare type ButtonSlots = typeof __propDef.slots;
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
}
export {};

vs

not using $$restProps

import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
    props: {
        /** CSS class for the element. */ class?: string | null;
        /** Whether the button is disabled. */ disabled?: boolean | null;
    };
    events: {
        [evt: string]: CustomEvent<any>;
    };
    slots: {
        default: {};
    };
};
export declare type ButtonProps = typeof __propDef.props;
export declare type ButtonEvents = typeof __propDef.events;
export declare type ButtonSlots = typeof __propDef.slots;
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
}
export {};
@mrtnbroder mrtnbroder added the bug Something isn't working label Feb 8, 2022
@dummdidumm
Copy link
Member

To me this looks as expected. You are using $$restProps which means you support passing other properties than the ones explicitly defined on the component. So the type definitions need to reflect that by also having an index signature on the props definition. Is it this what you think is wrong or is it something else?

@mrtnbroder
Copy link
Author

mrtnbroder commented Feb 8, 2022

@dummdidumm I'm talking about the comments here -> ** CSS class for the element. *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants