Add Array support to functions

This commit is contained in:
K35
2022-01-02 20:51:45 +00:00
parent a8f49d117d
commit db21c1c42e
7 changed files with 143 additions and 40 deletions

View File

@ -42,4 +42,7 @@ service TestService {
@Description("Just sends an Event with a String")
@Param("param1", "Parameter with some string for event")
notification OnEvent(param1: string);
FunctionWithArrayAsParamAndReturn(values1: number[], values2: number[]): number[];
}

View File

@ -39,6 +39,10 @@ class TestService extends Server.TestService<undefined> {
OnEvent(param1: string, ctx: undefined): void {
console.log("Received notification", param1);
}
async FunctionWithArrayAsParamAndReturn(vals1, vals2) {
return [...vals1, ...vals2];
}
}
server.addService(new TestService());
@ -70,6 +74,22 @@ async function run() {
.catch((err) => {
console.log("Found expected error!", err.message);
});
console.log("Test with arrays:");
console.log(await test
//@ts-ignore
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,5,6]));
console.log("Let with Array fail!");
await test
//@ts-ignore
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,"asd",6])
.then(() => {
console.log("!!!!This should have failed!!!!");
})
.catch((err) => {
console.log("Found expected error!", err.message);
});
}
run();