Skip to content

Commit

Permalink
Directus extension SDK type fix (directus#23836)
Browse files Browse the repository at this point in the history
  • Loading branch information
br41nslug authored Oct 11, 2024
1 parent ad5361a commit 943da2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-trainers-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@directus/extensions": patch
---

Fixed extension-sdk defineHook and defineEndpoint types
12 changes: 4 additions & 8 deletions packages/extensions/src/shared/utils/define-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import type {
PanelConfig,
} from '../types/index.js';

type CustomConfig<T> = { [K in string]: K extends keyof T ? never : unknown };
type CustomConfig<T extends object> = { [K in string]: K extends keyof T ? never : unknown };

type ExtendedConfig<T, C> = Prettify<T & Omit<C, keyof T>>;
type ExtendedConfig<T extends object, C> = Prettify<T & Omit<C, keyof T>>;

export function defineInterface<Custom extends CustomConfig<InterfaceConfig>>(
config: ExtendedConfig<InterfaceConfig, Custom>,
Expand Down Expand Up @@ -45,15 +45,11 @@ export function definePanel<Custom extends CustomConfig<PanelConfig>>(
return config;
}

export function defineHook<Custom extends CustomConfig<HookConfig>>(
config: ExtendedConfig<HookConfig, Custom>,
): ExtendedConfig<HookConfig, Custom> {
export function defineHook(config: HookConfig): HookConfig {
return config;
}

export function defineEndpoint<Custom extends CustomConfig<EndpointConfig>>(
config: ExtendedConfig<EndpointConfig, Custom>,
): ExtendedConfig<EndpointConfig, Custom> {
export function defineEndpoint(config: EndpointConfig): EndpointConfig {
return config;
}

Expand Down

0 comments on commit 943da2a

Please sign in to comment.