-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Do you have a working compile-able example of the typescript interface? I attempted to implement the sample code like so:
import FurhatGUI, { Furhat } from "furhat-gui";
let furhat: Furhat;
function setupSubscriptions() {
furhat.subscribe("com.myapp.MyCustomEvent", (event) => {
console.log("received event: ", event.event_name);
});
}
FurhatGUI()
.then((connection) => {
furhat = connection;
furhat.onConnectionError((_connection: WebSocket, _ev: globalThis.Event) : any => {
console.error("Error occured while connecting to Furhat skill");
});
furhat.onConnectionClose(() => {
console.warn("Connection with Furhat skill has been closed");
});
setupSubscriptions();
})
.catch(console.error);
Typescript does not seem to like the callback signature, giving me the following error:
error TS2345: Argument of type '(_connection: WebSocket, _ev: globalThis.Event) => void' is not assignable to parameter of type '(this: WebSocket, ev: Event) => any'.
22 furhat.onConnectionError((_connection: WebSocket, _ev: globalThis.Event) => {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Of course I can remove the arguments and have a no-argument callback like with furhat.onConnectionClose, but I may need to use the event data. Any ideas why typescript is unhappy with this function signature?
Metadata
Metadata
Assignees
Labels
No labels