Skip to content

Commit 88f7d8b

Browse files
authored
Correct the parameter type of ActionServer constructor (#1210)
This PR corrects the parameter type of the ActionServer constructor by adding a missing `goalCallback` parameter to properly match the expected type signature. - Added `goalCallback` parameter to ActionServer constructor call - Implemented the `goalCallback` function with proper type annotations Fix: #1209
1 parent 605eb84 commit 88f7d8b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/types/index.test-d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ const actionServer = new rclnodejs.ActionServer(
390390
node,
391391
'example_interfaces/action/Fibonacci',
392392
'fibonacci',
393-
executeCallback
393+
executeCallback,
394+
goalCallback
394395
);
395396
expectType<rclnodejs.ActionServer<'example_interfaces/action/Fibonacci'>>(
396397
actionServer
@@ -403,6 +404,13 @@ expectType<void>(
403404
);
404405
expectType<void>(actionServer.destroy());
405406

407+
function goalCallback(
408+
goal: rclnodejs.ActionGoal<'example_interfaces/action/Fibonacci'>
409+
): rclnodejs.GoalResponse {
410+
expectType<number>(goal.order);
411+
return rclnodejs.GoalResponse.ACCEPT;
412+
}
413+
406414
function executeCallback(
407415
goalHandle: rclnodejs.ServerGoalHandle<'example_interfaces/action/Fibonacci'>
408416
) {

types/action_server.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ declare module 'rclnodejs' {
7878
goalHandle: ServerGoalHandle<T>
7979
) => Promise<ActionResult<T>> | ActionResult<T>;
8080
type GoalCallback<T extends TypeClass<ActionTypeClassName>> = (
81-
goalHandle: ServerGoalHandle<T>
81+
goal: ActionGoal<T>
8282
) => GoalResponse;
8383
type HandleAcceptedCallback<T extends TypeClass<ActionTypeClassName>> = (
8484
goalHandle: ServerGoalHandle<T>

0 commit comments

Comments
 (0)