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

Is dist/bundle.d.ts missing? #16

Open
sp00x opened this issue Feb 5, 2023 · 5 comments
Open

Is dist/bundle.d.ts missing? #16

sp00x opened this issue Feb 5, 2023 · 5 comments

Comments

@sp00x
Copy link

sp00x commented Feb 5, 2023

The package.json has "types": "dist/bundle.d.ts", line but that referred file is not included in the npm installed files, leading to trying to include this project from a TypeScript project's main.ts resulting in a missing type declarations error.

I had to add one manually in my typings/ dir and then it worked...

Checked 2.2.0 and 2.1.0 and it's not there either. Not sure for earlier versions.

@sp00x
Copy link
Author

sp00x commented Feb 5, 2023

FWIW, if anyone else runs into it: I added a vue3-json-viewer.d.ts file in my custom typings/ dir set up in tsconfig.json like this:

declare module 'vue3-json-viewer' {
  import { Plugin } from 'vue';
  const plugin: Plugin;
  export default plugin;
}

Not even sure if this is the correct syntax, but it worked :p

@sp00x sp00x changed the title Is dist/bundle.d.ts missing in 2.2.2 ? Is dist/bundle.d.ts missing? Feb 5, 2023
@qiuquanwu
Copy link
Owner

Typescript Support

  • create vue3-json-viewer.d.ts in ./src of your project
declare module 'vue3-json-viewer' {
    import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue'
    interface JsonViewerProps {
        value: Object | Array<any> | string | number | boolean; //对象
        expanded: boolean; //Auto expand?
        expandDepth: number; //Expand Levels
        copyable: boolean | object; //copiable
        sort: boolean;
        boxed: boolean;
        theme: string;//"dark" | "light"
        previewMode: boolean;
        timeformat: (value: any) => string
    }
    type JsonViewerType = JsonViewerProps & VNodeProps & AllowedComponentProps & ComponentCustomProps
    const JsonViewer: Component<JsonViewerType>
    export { JsonViewer }
    const def: { install: (app: App) => void }
    export default def
}

@re2005
Copy link

re2005 commented Mar 6, 2023

declare module 'vue3-json-viewer' {
    import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue';

    interface JsonViewerProps {
        value: Record<string, unknown> | Array<any> | string | number | boolean;
        expanded: boolean;
        expandDepth: number;
        copyable: boolean | object;
        sort: boolean;
        boxed: boolean;
        theme: string; //"dark" | "light"
        previewMode: boolean;
        timeformat: (value: any) => string;
    }

    type JsonViewerType = JsonViewerProps & VNodeProps & AllowedComponentProps & ComponentCustomProps;
    const JsonViewer: Component<JsonViewerType>;
    export { JsonViewer };
    const def: { install: (app: App) => void };
    export default def;
}

@b-maslennikov
Copy link

@qiuquanwu can you please add d.ts file to the package?

@b-maslennikov
Copy link

@re2005 good fix on value type
we can also change theme type to this:
theme: "dark" | "light"

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

4 participants