Open sp00x opened 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
./src
of your project
declare module 'vue3-json-viewer' {
import { AllowedComponentProps, App, Component, ComponentCustomProps, VNodeProps } from 'vue'
interface JsonViewerProps {
value: Object | Array
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;
}
@qiuquanwu can you please add d.ts file to the package?
@re2005 good fix on value type
we can also change theme type to this:
theme: "dark" | "light"
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'smain.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.