vue3-json-viewer icon indicating copy to clipboard operation
vue3-json-viewer copied to clipboard

Is dist/bundle.d.ts missing?

Open sp00x opened this issue 1 year ago • 5 comments

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 avatar Feb 05 '23 11:02 sp00x

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 avatar Feb 05 '23 11:02 sp00x

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
}

qiuquanwu avatar Feb 14 '23 06:02 qiuquanwu

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;
}

re2005 avatar Mar 06 '23 12:03 re2005

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

b-maslennikov avatar Mar 15 '24 11:03 b-maslennikov

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

b-maslennikov avatar Mar 15 '24 11:03 b-maslennikov