fix: update types

This commit is contained in:
Qiuxia Fan 2022-01-10 20:09:40 +08:00
parent 2fb39ca82f
commit a836ae20e9
2 changed files with 15 additions and 22 deletions

View File

@ -14,12 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BarSeriesOption, LineSeriesOption } from "echarts/charts";
import {
BarSeriesOption,
LineSeriesOption,
HeatmapSeriesOption,
PieSeriesOption,
} from "echarts/charts";
import {
TitleComponentOption,
TooltipComponentOption,
GridComponentOption,
DatasetComponentOption,
LegendComponentOption,
} from "echarts/components";
import type { Ref } from "vue";
import { useTimeoutFn } from "./useTimeout";
@ -37,6 +43,9 @@ export type ECOption = echarts.ComposeOption<
| TooltipComponentOption
| GridComponentOption
| DatasetComponentOption
| LegendComponentOption
| HeatmapSeriesOption
| PieSeriesOption
>;
export function useECharts(
@ -46,7 +55,7 @@ export function useECharts(
const getDarkMode = computed(() => {
return theme === "default" ? "light" : theme;
});
let chartInstance: echarts.ECharts | null = null;
let chartInstance: Nullable<echarts.ECharts> = null;
let resizeFn: Fn = resize;
const cacheOptions = ref({}) as Ref<ECOption>;
let removeResizeFn: Fn = () => ({});
@ -128,7 +137,7 @@ export function useECharts(
chartInstance = null;
});
function getInstance(): echarts.ECharts | null {
function getInstance(): Nullable<echarts.ECharts> {
if (!chartInstance) {
initCharts(getDarkMode.value as "default");
}

View File

@ -32,22 +32,6 @@ export function isObject(val: unknown): val is Record<any, any> {
return val !== null && is(val, "Object");
}
export function isEmpty<T = unknown>(val: any): val is T {
if (isArray(val) || isString(val)) {
return val.length === 0;
}
if (val instanceof Map || val instanceof Set) {
return val.size === 0;
}
if (isObject(val)) {
return Object.keys(val).length === 0;
}
return false;
}
export function isDate(val: unknown): val is Date {
return is(val, "Date");
}
@ -81,7 +65,7 @@ export function isString(val: unknown): val is string {
return is(val, "String");
}
export function isFunction(val: unknown): boolean {
export function isFunction(val: unknown): val is () => unknown {
return typeof val === "function";
}
@ -93,8 +77,8 @@ export function isRegExp(val: unknown): val is RegExp {
return is(val, "RegExp");
}
export function isArray(val: any): boolean {
return val && Array.isArray(val);
export function isArray(val: unknown): boolean {
return Array.isArray(val);
}
export function isWindow(val: unknown): val is Window {