andrelmlins / svelte-dts

Typescript declaration generator for svelte with typescript
MIT License
28 stars 3 forks source link

The svelte-dts is duplicating types and properties #3

Closed silvioprog closed 3 years ago

silvioprog commented 3 years ago

Hi.

Supposing we run the svelte-dts in this small project, some generated types are duplicated, e.g:

import { SvelteComponentTyped } from "svelte";

declare module '@duallsistemas/duall-svelte-bootstrap5';

declare module '@duallsistemas/duall-svelte-bootstrap5/types.ts' {
    export type BackgroundColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'body' | 'white' | 'transparent';
    export type AlertType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
    export type ButtonType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
    export type ButtonSize = 'sm' | 'lg';
    export type ModalSize = 'sm' | 'lg' | 'xl' | 'fullscreen';
}

declare module '@duallsistemas/duall-svelte-bootstrap5';

declare module '@duallsistemas/duall-svelte-bootstrap5/utils.ts' {
    export function makeId(): string;
}

declare module '@duallsistemas/duall-svelte-bootstrap5/types.ts' {
    export type BackgroundColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'body' | 'white' | 'transparent';
    export type AlertType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
    export type ButtonType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
    export type ButtonSize = 'sm' | 'lg';
    export type ModalSize = 'sm' | 'lg' | 'xl' | 'fullscreen';
}

declare module '@duallsistemas/duall-svelte-bootstrap5/utils.ts' {
    export function makeId(): string;
}
...

and properties:

declare module '@duallsistemas/duall-svelte-bootstrap5/Button.svelte' {
    interface ButtonProps {
        ref?: HTMLButtonElement | HTMLAnchorElement;
        type?: ButtonType;
        title?: string;
        hint?: string;
        icon?: string;
        href?: string;
        disabled?: boolean;
        loading?: boolean;
        loadingMessage?: string;
        size?: ButtonSize;
        ref?: HTMLButtonElement | HTMLAnchorElement;
        type?: ButtonType;
        title?: string;
        hint?: string;
        icon?: string;
        href?: string;
        disabled?: boolean;
        loading?: boolean;
        loadingMessage?: string;
        size?: ButtonSize;
    }

I have been trying this configuration:

export default {
  input: pkg.svelte,
  plugins: [
    svelteDts({
      output: pkg.types
    }),
...

So, is there any option to avoid those duplications to generate a smaller .d.ts file?

TIA for any help!

silvioprog commented 3 years ago

Fixed by export default ["es", "umd"].map((format) => {.