Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const NODE_NAME = 'test_node';
const LIFECYCLE_NODE_NAME = 'lifecycle_test_node';
const TYPE_CLASS = 'std_msgs/msg/String';
const TOPIC = 'topic';
const SERVICE_NAME = 'service';
const MSG = rclnodejs.createMessageObject(TYPE_CLASS);
MSG.data = '';

Expand All @@ -27,6 +28,7 @@ expectType<string | undefined>(rclnodejs.DistroUtils.getDistroName(2105));

// ---- Context -----
expectType<rclnodejs.Context>(rclnodejs.Context.defaultContext());
expectType<number>(rclnodejs.Context.defaultContext().domainId());

// ---- NodeOptions ----
const nodeOptions = new rclnodejs.NodeOptions();
Expand Down Expand Up @@ -69,6 +71,8 @@ expectType<Array<object>>(node.getPublishersInfoByTopic('topic', false));
expectType<Array<object>>(node.getSubscriptionsInfoByTopic('topic', false));
expectType<number>(node.countPublishers(TOPIC));
expectType<number>(node.countSubscribers(TOPIC));
expectType<number>(node.countClients(SERVICE_NAME));
expectType<number>(node.countServices(SERVICE_NAME));
expectType<rclnodejs.Options<string | rclnodejs.QoS>>(
rclnodejs.Node.getDefaultOptions()
);
Expand Down Expand Up @@ -229,6 +233,9 @@ expectType<bigint>(timer.timeSinceLastCall());
expectType<bigint>(timer.timeUntilNextCall());
expectType<boolean>(timer.isCanceled());
expectType<void>(timer.cancel());
expectType<void>(timer.changeTimerPeriod(BigInt(100000)));
expectType<bigint>(timer.timerPeriod());
expectType<object>(timer.callTimerWithInfo());
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a more specific interface type for 'timer.callTimerWithInfo()' instead of the generic 'object', to enhance type safety and clarity.

Copilot uses AI. Check for mistakes.

// ---- Rate ----
const rate = await node.createRate(1);
Expand Down
6 changes: 6 additions & 0 deletions types/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,11 @@ declare module 'rclnodejs' {
* @returns The default Context
*/
static defaultContext(): Context;

/**
* Get the domain ID of this context.
* @returns domain ID of this context
*/
domainId(): number;
}
}
14 changes: 14 additions & 0 deletions types/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,5 +782,19 @@ declare module 'rclnodejs' {
* @returns Number of subscribers on the given topic.
*/
countSubscribers(topic: string): number;

/**
* Get the number of clients on a given service name.
* @param serviceName - The service name.
* @returns Number of clients.
*/
countClients(serviceName: string): number;

/**
* Get the number of services on a given service name.
* @param serviceName - The service name.
* @returns Number of services.
*/
countServices(serviceName: string): number;
}
}
6 changes: 6 additions & 0 deletions types/publisher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ declare module 'rclnodejs' {
* @param message - The message to be sent.
*/
publish(message: MessageType<T> | Buffer): void;

/**
* Get the number of subscriptions to this publisher.
* @returns The number of subscriptions
*/
subscriptionCount(): number;
}
}
6 changes: 6 additions & 0 deletions types/subscription.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,11 @@ declare module 'rclnodejs' {
* @returns True if successful; false otherwise
*/
clearContentFilter(): boolean;

/**
* Get the number of publishers to this subscription.
* @returns The number of publishers
*/
publisherCount(): number;
}
}
18 changes: 18 additions & 0 deletions types/timer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,23 @@ declare module 'rclnodejs' {
* @returns The interval value in nanoseconds
*/
timeUntilNextCall(): bigint;

/**
* Change the timer period.
* @param period - The new period in nanoseconds.
*/
changeTimerPeriod(period: bigint): void;

/**
* Get the timer period.
* @return The period in nanoseconds.
*/
timerPeriod(): bigint;

/**
* Call a timer and starts counting again, retrieves actual and expected call time.
* @return - The timer information.
*/
callTimerWithInfo(): object;
}
}
Loading