@@ -22,9 +22,13 @@ export interface InPageChannelProtocol {
2222 sharedStates ?: Record < string , object >
2323}
2424
25- type SideFunctions < S > = S extends Record < string , ( ...args : any [ ] ) => any > ? S : Record < string , never >
26- type PageScriptFunctions < P extends InPageChannelProtocol > = SideFunctions < NonNullable < P [ 'pageScript' ] > >
27- type PanelFunctions < P extends InPageChannelProtocol > = SideFunctions < NonNullable < P [ 'panel' ] > >
25+ type SideFunctions < P , S > = InPageChannelProtocol extends P
26+ ? Record < string , ( ...args : any [ ] ) => any >
27+ : S extends Record < string , ( ...args : any [ ] ) => any >
28+ ? string extends keyof S ? Record < never , never > : S
29+ : Record < never , never >
30+ type PageScriptFunctions < P extends InPageChannelProtocol > = SideFunctions < P , NonNullable < P [ 'pageScript' ] > >
31+ type PanelFunctions < P extends InPageChannelProtocol > = SideFunctions < P , NonNullable < P [ 'panel' ] > >
2832type SharedStates < P extends InPageChannelProtocol >
2933 = P [ 'sharedStates' ] extends Record < string , object > ? P [ 'sharedStates' ] : Record < string , never >
3034
@@ -113,7 +117,9 @@ interface InPageFunctionOption<F> {
113117 */
114118type CreatePageScriptChannelOptionsFunctions < P extends InPageChannelProtocol > = {
115119 [ NAME in keyof PageScriptFunctions < P > & string ] : InPageFunctionOption < PageScriptFunctions < P > [ NAME ] >
116- }
120+ } extends infer FUNCTIONS
121+ ? keyof FUNCTIONS extends never ? Record < string , never > : FUNCTIONS
122+ : never
117123
118124/**
119125 * Functions implemented by {@link connectPanelChannel}.
@@ -122,7 +128,9 @@ type CreatePageScriptChannelOptionsFunctions<P extends InPageChannelProtocol> =
122128 */
123129type ConnectPanelChannelOptionsFunctions < P extends InPageChannelProtocol > = {
124130 [ NAME in keyof PanelFunctions < P > & string ] : InPageFunctionOption < PanelFunctions < P > [ NAME ] >
125- }
131+ } extends infer FUNCTIONS
132+ ? keyof FUNCTIONS extends never ? Record < string , never > : FUNCTIONS
133+ : never
126134
127135/**
128136 * Connection lifecycle of a panel endpoint: `connecting` (handshake retry
0 commit comments