Add Array support to functions
This commit is contained in:
@ -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[];
|
||||
}
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user