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

Typescript module declaration is missing.

Open jkourou opened this issue 2 years ago • 3 comments
trafficstars

Hey

Typescript projects getting missing declaration for your module when importing it. You should add a declaration so we do not have to do it manually. Thank you!

Error:

Could not find a declaration file for module 'vue-json-viewer'. 'my-project/node_modules/vue-json-viewer/vue-json-viewer.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/vue-json-viewer` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-json-viewer';`

jkourou avatar Jan 13 '23 09:01 jkourou

This maybe help: in src directory, create file vue-json-viewer.d.ts

declare module 'vue-json-viewer' {
    import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue'
    interface JsonViewerProps {
        value: Object | Array<any> | string | number | boolean;
        expanded: boolean;
        expandDepth: number;
        copyable: boolean | object;
        sort: boolean;
        boxed: boolean;
        theme: string;
        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
}

power721 avatar Jun 15 '23 09:06 power721

This maybe help: in src directory, create file vue-json-viewer.d.ts

declare module 'vue-json-viewer' {
    import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue'
    interface JsonViewerProps {
        value: Object | Array<any> | string | number | boolean;
        expanded: boolean;
        expandDepth: number;
        copyable: boolean | object;
        sort: boolean;
        boxed: boolean;
        theme: string;
        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
}

has this hint:

image

imvkmark avatar Jun 27 '23 23:06 imvkmark

I use vue-json-pretty instead

imvkmark avatar Jun 28 '23 01:06 imvkmark