diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c69d5..476cf9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.3 + +* Improved typings for Vue 2 version. + ## 6.0.2 * Make `notMerge` option still respect `update-options`. diff --git a/package.json b/package.json index 0b91b19..04e73dc 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "vue-echarts", - "version": "6.0.2", + "version": "6.0.3", "description": "Vue.js component for Apache ECharts.", "author": "GU Yiling ", "scripts": { "serve": "vue-cli-service serve", - "build": "npm run docs && rimraf dist && rollup -c rollup.config.js && cp src/index.vue2.d.ts dist", + "build": "npm run docs && rimraf dist && rollup -c rollup.config.js", "lint": "vue-cli-service lint", "build:demo": "vue-cli-service build", "docs": "node -r esm ./scripts/docs.js", diff --git a/rollup.config.js b/rollup.config.js index e9432af..4887f0d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -97,6 +97,14 @@ const options = [ file: "dist/index.d.ts", format: "es" } + }, + { + input: "src/index.vue2.d.ts", + plugins: [dts()], + output: { + file: "dist/index.vue2.d.ts", + format: "es" + } } ]; diff --git a/src/index.vue2.d.ts b/src/index.vue2.d.ts index c15909f..5e52e26 100644 --- a/src/index.vue2.d.ts +++ b/src/index.vue2.d.ts @@ -1,10 +1,55 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/ban-types */ +import { DefineComponent } from "@vue/runtime-dom"; +import { Ref } from "@vue/composition-api"; +import { Option, InitOptions, UpdateOptions, EChartsType } from "./types"; + declare const LOADING_OPTIONS_KEY = "ecLoadingOptions"; declare const THEME_KEY = "ecTheme"; declare const INIT_OPTIONS_KEY = "ecInitOptions"; declare const UPDATE_OPTIONS_KEY = "ecUpdateOptions"; -declare const _default: any; +declare type ChartProps = { + loading?: boolean; + loadingOptions?: Record; + autoresize?: boolean; + option?: Option; + theme?: string | Record; + initOptions?: InitOptions; + updateOptions?: UpdateOptions; + group?: string; + manualUpdate?: boolean; +}; -export default _default; +type MethodNames = + | "getWidth" + | "getHeight" + | "getDom" + | "getOption" + | "resize" + | "dispatchAction" + | "convertToPixel" + | "convertFromPixel" + | "containPixel" + | "getDataURL" + | "getConnectedDataURL" + | "appendData" + | "clear" + | "isDisposed" + | "dispose" + | "setOption"; + +declare type ChartMethods = Pick; + +declare const Chart: DefineComponent< + ChartProps, + { + root: Ref; + chart: Ref; + }, + {}, + {}, + ChartMethods +>; + +export default Chart; export { INIT_OPTIONS_KEY, LOADING_OPTIONS_KEY, THEME_KEY, UPDATE_OPTIONS_KEY }; diff --git a/src/types.ts b/src/types.ts index 48b549a..fa1f027 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { init, SetOptionOpts } from "echarts/core"; import { Ref } from "vue";