Skip to content

Commit b62ea95

Browse files
committed
[Demo] Modernize TypeScript demos to NodeNext + ES2022
1 parent 01731e0 commit b62ea95

8 files changed

Lines changed: 26 additions & 36 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ TypeScript declaration files are included in the package and exposed through the
199199
```jsonc
200200
{
201201
"compilerOptions": {
202-
"module": "commonjs",
203-
"moduleResolution": "node",
204-
"target": "es2020",
202+
"module": "NodeNext",
203+
"moduleResolution": "NodeNext",
204+
"target": "es2022",
205205
},
206206
}
207207
```

demo/typescript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Asynchronous actions with progress feedback and cancellation
4242

4343
### Modern Development
4444

45-
- **ES2020+ syntax** with async/await patterns
45+
- **ES2022+ syntax** with async/await patterns
4646
- **Modular architecture** with clean separation of concerns
4747
- **Error boundaries** with comprehensive exception handling
4848
- **Graceful shutdown** handling for SIGINT/SIGTERM

demo/typescript/actions/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ demo/typescript/actions/
3636
├── src/
3737
│ ├── client.ts # Action client implementation
3838
│ └── server.ts # Action server implementation
39-
├── types/
40-
│ └── rclnodejs.d.ts # Type definitions
4139
├── package.json # Project configuration
4240
├── tsconfig.json # TypeScript configuration
4341
├── .gitignore # Git ignore rules

demo/typescript/actions/tsconfig.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "CommonJS",
5-
"lib": ["ES2020", "DOM"],
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"lib": ["ES2022", "DOM"],
67
"outDir": "./dist",
78
"rootDir": "./src",
89
"strict": true,
@@ -16,7 +17,7 @@
1617
"experimentalDecorators": true,
1718
"emitDecoratorMetadata": true,
1819
"types": ["node"],
19-
"typeRoots": ["./types", "./node_modules/@types"]
20+
"typeRoots": ["./node_modules/@types"]
2021
},
2122
"include": [
2223
"src/**/*"

demo/typescript/services/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Starting TypeScript Service Client Demo...
199199

200200
This demo includes:
201201

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

297297
### Debugging Tips
298298

demo/typescript/services/tsconfig.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "CommonJS",
5-
"lib": ["ES2020"],
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"lib": ["ES2022"],
67
"outDir": "./dist",
78
"rootDir": "./src",
89
"strict": true,
@@ -16,7 +17,7 @@
1617
"experimentalDecorators": true,
1718
"emitDecoratorMetadata": true,
1819
"types": ["node"],
19-
"typeRoots": ["./types", "./node_modules/@types"]
20+
"typeRoots": ["./node_modules/@types"]
2021
},
2122
"include": [
2223
"src/**/*",

demo/typescript/topics/README.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,21 @@ For development, you can run TypeScript files directly with ts-node:
105105

106106
## TypeScript Setup
107107

108-
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:
109-
110-
### Local Type Definitions
111-
112-
The `types/rclnodejs.d.ts` file provides basic TypeScript declarations for rclnodejs, enabling:
113-
114-
- ✅ TypeScript compilation without dependencies
115-
- ✅ Type checking and IntelliSense support
116-
- ✅ Proper interface definitions for common ROS2 operations
108+
This demo builds against the in-tree **rclnodejs** package
109+
(`"rclnodejs": "file:../../.."`), so it uses the package's own TypeScript
110+
declarations — there are no local stub types.
117111

118112
### TypeScript Configuration
119113

120114
The `tsconfig.json` is configured to:
121115

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

127-
### Development vs Runtime
128-
129-
- **Compilation**: Uses local type definitions (no rclnodejs dependency)
130-
- **Runtime**: Requires actual rclnodejs installation and ROS 2 environment
131-
132123
## Expected Output
133124

134125
### Publisher Output:

demo/typescript/topics/tsconfig.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
4-
"moduleResolution": "node",
5-
"target": "es2020",
3+
"module": "NodeNext",
4+
"moduleResolution": "NodeNext",
5+
"target": "es2022",
66
"outDir": "./dist",
77
"rootDir": "./src",
88
"strict": true,
@@ -12,9 +12,8 @@
1212
"declaration": true,
1313
"declarationMap": true,
1414
"sourceMap": true,
15-
"lib": ["es2020"],
15+
"lib": ["es2022"],
1616
"typeRoots": [
17-
"./types",
1817
"./node_modules/@types"
1918
]
2019
},

0 commit comments

Comments
 (0)