Skip to content

Commit

Permalink
fix: provideSharedConfig cant deep optional
Browse files Browse the repository at this point in the history
  • Loading branch information
chizukicn committed Oct 14, 2023
1 parent 7065bf6 commit f4958de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@vueuse/core": "^10.5.0",
"defu": "^6.1.2",
"maybe-types": "^0.1.0"
"maybe-types": "^0.1.0",
"type-fest": "^4.4.0"
}
}
5 changes: 3 additions & 2 deletions packages/shared/src/provides/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { InjectionKey } from "vue";
import { inject, provide } from "vue";
import defu from "defu";
import type { PartialDeep } from "type-fest";
import type { ActivateEvent } from "../types";

const SHARED_CONFIG_KEY: InjectionKey<Partial<SharedConfig>> = Symbol("SharedConfig");
const SHARED_CONFIG_KEY: InjectionKey<PartialDeep<SharedConfig>> = Symbol("SharedConfig");

export interface SharedConfig {
icon: {
Expand All @@ -21,7 +22,7 @@ export const DEFAULT_SHARED_CONFIG: SharedConfig = {
activateEvent: "dblclick"
};

export function provideSharedConfig(config: Partial<SharedConfig>) {
export function provideSharedConfig(config: PartialDeep<SharedConfig>) {
provide(SHARED_CONFIG_KEY, config);
}

Expand Down
3 changes: 1 addition & 2 deletions playground/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default defineComponent(() => {
provideSharedConfig({
icon: {
size: 96,
sizeUnit: "px"
size: 96
}
});
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4958de

Please sign in to comment.