qiuquanwu / vue3-json-viewer

Simple JSON viewer component, for Vue.js 3.x
https://vjv-doc-qiuquanwu.vercel.app/
MIT License
103 stars 15 forks source link

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

Open sp00x opened 1 year ago

sp00x commented 1 year ago

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 commented 1 year ago

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

qiuquanwu commented 1 year ago

Typescript Support

declare module 'vue3-json-viewer' { import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue' interface JsonViewerProps { value: Object | Array | 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 export { JsonViewer } const def: { install: (app: App) => void } export default def }

re2005 commented 1 year ago
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 commented 8 months ago

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

b-maslennikov commented 8 months ago

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