File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,20 @@ type Narrow<A> = Cast<A,
21
21
| ( { [ K in keyof A ] : Narrow < A [ K ] > } )
22
22
>
23
23
24
+ // Prevent properties not in PluginDescriptor
25
+ // We need this because of the `extends` in the generic TDescriptor
26
+ type Exact < C , T > = {
27
+ [ K in keyof C ] : K extends keyof T ? T [ K ] : never
28
+ }
29
+
24
30
export type SetupFunction < TSettings = any > = ( api : DevtoolsPluginApi < TSettings > ) => void
25
31
26
32
export function setupDevtoolsPlugin <
27
- TDescriptor extends PluginDescriptor = PluginDescriptor ,
33
+ TDescriptor extends Exact < TDescriptor , PluginDescriptor > ,
34
+ // @ts -expect-error Type '"settings"' cannot be used to index type 'TDescriptor'.ts(2536)
28
35
TSettings = ExtractSettingsTypes < TDescriptor [ 'settings' ] > ,
29
36
> ( pluginDescriptor : Narrow < TDescriptor > , setupFn : SetupFunction < TSettings > ) {
30
- const descriptor = pluginDescriptor as TDescriptor
37
+ const descriptor = pluginDescriptor as unknown as PluginDescriptor
31
38
const target = getTarget ( )
32
39
const hook = getDevtoolsGlobalHook ( )
33
40
const enableProxy = isProxyAvailable && descriptor . enableEarlyProxy
You can’t perform that action at this time.
0 commit comments