fix bad rpc finding for class member for real this time
This commit is contained in:
+8
-2
@@ -53,15 +53,21 @@ export class RPCServer<
|
||||
if(conf.connectionHandler) conf.connectionHandler(socket)
|
||||
}
|
||||
|
||||
exporters.forEach(U.fixNames)
|
||||
|
||||
let badRPC = exporters.flatMap(ex => ex.exportRPCs()).find(rpc => !rpc.name)
|
||||
if(badRPC)
|
||||
throw new Error(`
|
||||
if(badRPC){
|
||||
console.log(badRPC);
|
||||
|
||||
|
||||
throw new Error(`
|
||||
RPC did not provide a name.
|
||||
\nUse 'funtion name(..){ .. }' syntax instead.
|
||||
\n
|
||||
\n<------------OFFENDING RPC:
|
||||
\n`+badRPC.toString()+`
|
||||
\n>------------OFFENDING RPC`)
|
||||
}
|
||||
this.startWebsocket()
|
||||
}
|
||||
|
||||
|
||||
@@ -172,4 +172,20 @@ export function makeSesameFunction (sesame : T.SesameFunction | string) : T.Sesa
|
||||
|
||||
export function appendComma(s?:string):string{
|
||||
return s?`'${s}',`:""
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Typescript incorrectly omits the function.name attribute for MethodDeclaration.
|
||||
* This was supposedly fixed (https://github.com/microsoft/TypeScript/issues/5611) but it still is the case.
|
||||
* This function sets the name value for all object members that are functions.
|
||||
*/
|
||||
export function fixNames(o:Object):void{
|
||||
Object.keys(o).forEach(key => {
|
||||
if(typeof o[key] === 'function' && !o[key].name){
|
||||
Object.defineProperty(o[key], 'name', {
|
||||
value: key
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user