Currently, I have a basic function that my client uses to communicate with my server. In order to maintain flexibility, I have implemented the following:
public call(method: string, ...parameters: any[]) {}
On the server side, I organize all methods together like this:
MethodManager.methods({
findOne: {
function: function(collection: string, query: Object) {
return model(collection).findOne(query).exec();
}
},
find: {
function: function(collection: string, query: Object, sortQuery: Object = {}) {
return model(collection).find(query).sort(sortQuery).exec();
}
}
}
Each method has different parameters. Unfortunately, using 'any' as parameter type limits the use of Typescript in the client-side code.
Is there a way to configure Visual Studio Code to provide suggestions based on the specific method being called? For example, when typing:
this.socketManager.call('findOne',
I would like it to suggest the following:
(method: 'findOne', collection: string, query: Object)
And for:
this.socketManager.call('find',
The suggestion should be:
(method: 'find', collection: string, query: Object, sortQuery: Object = {})
Instead of the generic:
(method: string, ...parameters: any[])
This enhancement would greatly improve the development process.