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

Typescript module declaration is missing. #103

Open
jkourou opened this issue Jan 13, 2023 · 3 comments
Open

Typescript module declaration is missing. #103

jkourou opened this issue Jan 13, 2023 · 3 comments

Comments

@jkourou
Copy link

jkourou commented Jan 13, 2023

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';`
@power721
Copy link

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
}

@imvkmark
Copy link

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
Copy link

I use vue-json-pretty instead

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

3 participants