Skip to content

Commit 6f32900

Browse files
committed
add descriptor interface tsd tests
1 parent 903cff3 commit 6f32900

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/types/index.test-d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,48 @@ param.value.integer_value = BigInt(123);
390390
expectType<bigint>(param.value.integer_value);
391391
param.value.byte_array_value = [1, 2, 3];
392392
expectType<number[]>(param.value.byte_array_value);
393+
394+
// ---- Descriptors -----
395+
// Note: All fields are of type string exactly equal to the type of interface.
396+
// built-in msg
397+
const duration = rclnodejs.createMessageObject(
398+
'builtin_interfaces/msg/descriptor/Duration'
399+
);
400+
expectType<rclnodejs.builtin_interfaces.msg.descriptor.Duration>(duration);
401+
expectType<'int32'>(duration.sec);
402+
expectType<'uint32'>(duration.nanosec);
403+
// msg containing complex types
404+
const poseStampedDescriptor = rclnodejs.createMessageObject(
405+
'geometry_msgs/msg/descriptor/PoseStamped'
406+
);
407+
expectType<rclnodejs.geometry_msgs.msg.descriptor.PoseStamped>(
408+
poseStampedDescriptor
409+
);
410+
expectType<'std_msgs/msg/Header'>(poseStampedDescriptor.header);
411+
expectType<'geometry_msgs/msg/Pose'>(poseStampedDescriptor.pose);
412+
// action interface
413+
const navigateToPoseFeedbackDescriptor = rclnodejs.createMessageObject(
414+
'nav2_msgs/action/descriptor/NavigateToPose_Feedback'
415+
);
416+
expectType<rclnodejs.nav2_msgs.action.descriptor.NavigateToPose_Feedback>(
417+
navigateToPoseFeedbackDescriptor
418+
);
419+
expectType<'geometry_msgs/msg/PoseStamped'>(
420+
navigateToPoseFeedbackDescriptor.current_pose
421+
);
422+
expectType<'float32'>(navigateToPoseFeedbackDescriptor.distance_remaining);
423+
expectType<'builtin_interfaces/msg/Duration'>(
424+
navigateToPoseFeedbackDescriptor.estimated_time_remaining
425+
);
426+
expectType<'builtin_interfaces/msg/Duration'>(
427+
navigateToPoseFeedbackDescriptor.navigation_time
428+
);
429+
expectType<'int16'>(navigateToPoseFeedbackDescriptor.number_of_recoveries);
430+
// srv interface
431+
const cancelGoalRequestDescriptor = rclnodejs.createMessageObject(
432+
'action_msgs/srv/descriptor/CancelGoal_Request'
433+
);
434+
expectType<rclnodejs.action_msgs.srv.descriptor.CancelGoal_Request>(
435+
cancelGoalRequestDescriptor
436+
);
437+
expectType<'action_msgs/msg/GoalInfo'>(cancelGoalRequestDescriptor.goal_info);

0 commit comments

Comments
 (0)