Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ TypeScript declaration files are included in the package and exposed through the
```jsonc
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "es2022",
},
}
```
Expand Down
2 changes: 1 addition & 1 deletion demo/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Asynchronous actions with progress feedback and cancellation

### Modern Development

- **ES2020+ syntax** with async/await patterns
- **ES2022+ syntax** with async/await patterns
- **Modular architecture** with clean separation of concerns
- **Error boundaries** with comprehensive exception handling
- **Graceful shutdown** handling for SIGINT/SIGTERM
Expand Down
2 changes: 0 additions & 2 deletions demo/typescript/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ demo/typescript/actions/
├── src/
│ ├── client.ts # Action client implementation
│ └── server.ts # Action server implementation
├── types/
│ └── rclnodejs.d.ts # Type definitions
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
├── .gitignore # Git ignore rules
Expand Down
9 changes: 5 additions & 4 deletions demo/typescript/actions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020", "DOM"],
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022", "DOM"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
Expand All @@ -16,7 +17,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["node"],
"typeRoots": ["./types", "./node_modules/@types"]
"typeRoots": ["./node_modules/@types"]
},
"include": [
"src/**/*"
Expand Down
4 changes: 2 additions & 2 deletions demo/typescript/services/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Starting TypeScript Service Client Demo...

This demo includes:

- **Local Type Definitions**: Custom TypeScript definitions for rclnodejs in `types/rclnodejs.d.ts`
- **Package Type Definitions**: Uses the in-tree rclnodejs TypeScript declarations (no local stub types)
- **Service Types**: Type definitions for `example_interfaces/srv/AddTwoInts`
- **Strict Type Checking**: Full TypeScript strict mode enabled
- **Build Pipeline**: Automated compilation with shebang fixing for executable JavaScript
Expand Down Expand Up @@ -292,7 +292,7 @@ Modify the service callback to implement your own business logic:
```
Type errors in service definitions
```
**Solution**: Check the type definitions in `types/rclnodejs.d.ts` match your usage.
**Solution**: Ensure the in-tree rclnodejs package is built so its TypeScript declarations are available.

### Debugging Tips

Expand Down
9 changes: 5 additions & 4 deletions demo/typescript/services/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020"],
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
Expand All @@ -16,7 +17,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["node"],
"typeRoots": ["./types", "./node_modules/@types"]
"typeRoots": ["./node_modules/@types"]
},
"include": [
"src/**/*",
Expand Down
21 changes: 6 additions & 15 deletions demo/typescript/topics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,21 @@ For development, you can run TypeScript files directly with ts-node:

## TypeScript Setup

This demo includes a self-contained TypeScript configuration that allows compilation without requiring the full rclnodejs installation to be built first. The key components are:

### Local Type Definitions

The `types/rclnodejs.d.ts` file provides basic TypeScript declarations for rclnodejs, enabling:

- ✅ TypeScript compilation without dependencies
- ✅ Type checking and IntelliSense support
- ✅ Proper interface definitions for common ROS2 operations
This demo builds against the in-tree **rclnodejs** package
(`"rclnodejs": "file:../../.."`), so it uses the package's own TypeScript
declarations — there are no local stub types.

### TypeScript Configuration

The `tsconfig.json` is configured to:

- Use local type definitions from the `types/` directory
- Use modern `NodeNext` module resolution, matching how Node.js resolves the
package's `exports` map
- Target `ES2022`, consistent with the rclnodejs package itself
- Compile TypeScript to JavaScript in the `dist/` directory
- Generate source maps and declaration files
- Enable strict type checking

### Development vs Runtime

- **Compilation**: Uses local type definitions (no rclnodejs dependency)
- **Runtime**: Requires actual rclnodejs installation and ROS 2 environment

## Expected Output

### Publisher Output:
Expand Down
9 changes: 4 additions & 5 deletions demo/typescript/topics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "es2022",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
Expand All @@ -12,9 +12,8 @@
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"lib": ["es2020"],
"lib": ["es2022"],
"typeRoots": [
"./types",
"./node_modules/@types"
]
},
Comment on lines 16 to 19
Expand Down
Loading