Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Jul 16, 2025

This PR adds a comprehensive TypeScript demo for rclnodejs, demonstrating how to create ROS2 service servers and clients using TypeScript. The demo includes a complete project structure with proper TypeScript configuration, build scripts, and detailed documentation.

Key changes:

  • Adds a complete TypeScript service demo with client and server implementations
  • Implements AddTwoInts service with proper type handling and error management
  • Updates main README to include reference to the new TypeScript demo

Fix: #1193

@minggangw minggangw requested a review from Copilot July 16, 2025 06:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive TypeScript demo for rclnodejs, demonstrating how to create ROS2 service servers and clients using TypeScript. The demo includes a complete project structure with proper TypeScript configuration, build scripts, and detailed documentation.

Key changes:

  • Adds a complete TypeScript service demo with client and server implementations
  • Implements AddTwoInts service with proper type handling and error management
  • Updates main README to include reference to the new TypeScript demo

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ts_demo/services/tsconfig.json TypeScript compiler configuration with strict settings and proper output structure
ts_demo/services/src/server.ts Service server implementation that provides AddTwoInts service with logging and error handling
ts_demo/services/src/client.ts Service client implementation that calls AddTwoInts service at regular intervals
ts_demo/services/package.json Package configuration with build scripts, dependencies, and development tools
ts_demo/services/README.md Comprehensive documentation with usage instructions, examples, and troubleshooting
README.md Updated main README to reference the new TypeScript demo

const service = node.createService(
'example_interfaces/srv/AddTwoInts',
SERVICE_NAME,
(request: any, response: any) => {
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Using 'any' type defeats the purpose of TypeScript's type safety. Consider defining proper interfaces for the request and response types or using the appropriate rclnodejs types.

Suggested change
(request: any, response: any) => {
(request: AddTwoIntsRequest, response: AddTwoIntsResponse) => {

Copilot uses AI. Check for mistakes.
console.log(` Timestamp: ${new Date().toISOString()}`);

// Send the request and wait for response
client.sendRequest(request, (response: any) => {
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Using 'any' type for response parameter removes type safety benefits. Consider defining proper interface for the AddTwoInts response type.

Suggested change
client.sendRequest(request, (response: any) => {
client.sendRequest(request, (response: AddTwoIntsResponse) => {

Copilot uses AI. Check for mistakes.
import * as rclnodejs from 'rclnodejs';

const SERVICE_NAME = 'add_two_ints';
const REQUEST_INTERVAL = 3000000000n; // 3 seconds in nanoseconds
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The magic number 3000000000n is not immediately clear. Consider defining a constant with a more descriptive calculation like 3 * 1000 * 1000 * 1000 or using a conversion function.

Suggested change
const REQUEST_INTERVAL = 3000000000n; // 3 seconds in nanoseconds
const REQUEST_INTERVAL = 3n * 1000n * 1000n * 1000n; // 3 seconds in nanoseconds

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

coveralls commented Jul 16, 2025

Coverage Status

coverage: 84.526%. remained the same
when pulling e9c86b0 on minggangw:fix-1193
into ccb9c21 on RobotWebTools:develop.

@minggangw minggangw merged commit 9d338bb into RobotWebTools:develop Jul 16, 2025
21 of 22 checks passed
minggangw added a commit that referenced this pull request Jul 16, 2025
This PR adds a comprehensive TypeScript demo for rclnodejs, demonstrating how to create ROS2 service servers and clients using TypeScript. The demo includes a complete project structure with proper TypeScript configuration, build scripts, and detailed documentation.

Key changes:
- Adds a complete TypeScript service demo with client and server implementations
- Implements AddTwoInts service with proper type handling and error management
- Updates main README to include reference to the new TypeScript demo

Fix: #1193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a demo for client/service using typescript

2 participants