|
@@ -1,5 +1,6 @@
|
1
|
1
|
import { RPCServer, RPCSocket } from './Index'
|
2
|
2
|
import { RPCExporter } from './src/Interfaces'
|
|
3
|
+import { RPCInterface } from './src/Types'
|
3
|
4
|
|
4
|
5
|
// TL;DR
|
5
|
6
|
const echo = (text: string) => text
|
|
@@ -175,17 +176,16 @@ interface IMyImplementation {
|
175
|
176
|
getCallback: (callback:Function) => string
|
176
|
177
|
}
|
177
|
178
|
|
178
|
|
-type MyIfc = {
|
179
|
|
- MyRPCGroup1: {
|
180
|
|
- echo: IMyImplementation['echo']
|
181
|
|
- add: IMyImplementation['add']
|
182
|
|
- getAsync: IMyImplementation['getAsync']
|
183
|
|
- getCallback: IMyImplementation['getCallback']
|
|
179
|
+type IfcGenerator<Name extends string, Interface, keys extends keyof Interface = keyof Interface> = {
|
|
180
|
+ [name in Name]: {
|
|
181
|
+ [key in keys] : Interface[key]
|
184
|
182
|
}
|
185
|
183
|
}
|
186
|
184
|
|
|
185
|
+type MyIfc = IfcGenerator<"MyRPCGroup1", IMyImplementation>
|
|
186
|
+
|
187
|
187
|
class MyImplementation implements IMyImplementation, RPCExporter<MyIfc>{
|
188
|
|
- //"X" as "X" syntax is required to satisfy the type system (as it assumed string)
|
|
188
|
+ //"X" as "X" syntax is required to satisfy the type system (as it assumes string)
|
189
|
189
|
name = "MyRpcGroup11" as "MyRPCGroup1"
|
190
|
190
|
|
191
|
191
|
//List the functions you declared in MyIfc
|