mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-08 05:55:55 +08:00
feat: provide better types for injection keys
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { inject, unref, computed, Ref, watchEffect } from "vue-demi";
|
||||
import { inject, unref, computed, Ref, watchEffect, InjectionKey } from "vue-demi";
|
||||
import { EChartsType } from "../types";
|
||||
|
||||
export const LOADING_OPTIONS_KEY = "ecLoadingOptions";
|
||||
export const LOADING_OPTIONS_KEY = "ecLoadingOptions" as unknown as InjectionKey<UnknownRecord | Ref<UnknownRecord>>;
|
||||
|
||||
type UnknownRecord = Record<string, unknown>;
|
||||
|
||||
@ -10,9 +10,7 @@ export function useLoading(
|
||||
loading: Ref<boolean>,
|
||||
loadingOptions: Ref<UnknownRecord | undefined>
|
||||
): void {
|
||||
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {}) as
|
||||
| UnknownRecord
|
||||
| Ref<UnknownRecord>;
|
||||
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {})
|
||||
const realLoadingOptions = computed(() => ({
|
||||
...unref(defaultLoadingOptions),
|
||||
...loadingOptions?.value
|
||||
|
||||
Reference in New Issue
Block a user