Skip to content

fix(types): add type declarations for the rclnodejs/rosocket subpath#1533

Merged
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-rosocket-types
Jun 10, 2026
Merged

fix(types): add type declarations for the rclnodejs/rosocket subpath#1533
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-rosocket-types

Conversation

@minggangw

Copy link
Copy Markdown
Member

The ./rosocket subpath export shipped no type declarations, so under node16/nodenext module resolution:

  • import { startRosocket } from 'rclnodejs/rosocket' failed with TS7016 (the module implicitly had an any type).
  • @arethetypeswrong reported No types for the subpath across every resolution mode.

Changes

  • Add rosocket/index.d.ts — types the public entry point (startRosocket, StartRosocketOptions, RosocketServer), matched against rosocket/index.js (port=9000, host='0.0.0.0', required node, returns { wss, close, port }). wss is typed as its EventEmitter supertype to avoid a hard dependency on ws types.
  • Add rosocket/index.d.cts — a CommonJS-format companion (re-exporting the .d.ts) so the require condition resolves to a CJS type file and is not flagged as "Masquerading as ESM".
  • Wire per-condition types into the ./rosocket export in package.json (importindex.d.ts, requireindex.d.cts).

Fix: #1532

The ./rosocket subpath export shipped no type declarations, so under
node16/nodenext resolution `import { startRosocket } from 'rclnodejs/rosocket'`
failed with TS7016 (implicit any) and @arethetypeswrong reported 'No types'.

- add rosocket/index.d.ts typing the public entry point (startRosocket,
  StartRosocketOptions, RosocketServer), matching rosocket/index.js.
- add a rosocket/index.d.cts companion so the require condition resolves
  to a CommonJS-format type file (no 'Masquerading as ESM').
- wire per-condition types into the ./rosocket export.

attw now reports rclnodejs/rosocket green across node10, node16 (CJS+ESM)
and bundler; tsd passes and a nodenext+strict consumer resolves the
subpath without TS7016.
Copilot AI review requested due to automatic review settings June 10, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown

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 TypeScript declaration support for the rclnodejs/rosocket subpath export so that node16/nodenext consumers can import it without TS7016 and type tools detect the subpath as typed.

Changes:

  • Added rosocket/index.d.ts describing the public startRosocket() API and its option/return shapes.
  • Added rosocket/index.d.cts as a CommonJS-facing type entrypoint for the require export condition.
  • Updated package.json exports["./rosocket"] to provide per-condition types entries for both import and require.

Reviewed changes

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

File Description
rosocket/index.d.ts Adds ESM type declarations for the rclnodejs/rosocket public API.
rosocket/index.d.cts Adds CJS type entrypoint intended to satisfy the require export condition.
package.json Wires conditional types paths into the ./rosocket export map.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines 28 to +32
"./rosocket": {
"import": "./dist/rosocket.js",
"require": "./dist/rosocket.cjs",
"import": {
"types": "./rosocket/index.d.ts",
"default": "./dist/rosocket.js"
},
Comment thread rosocket/index.d.cts
Comment on lines +1 to +6
// CommonJS type entry for `require('rclnodejs/rosocket')`.
//
// Re-exports the ESM declarations so the `require` condition has a CommonJS
// (`.d.cts`) type file whose module format matches the CommonJS JavaScript
// served by the same condition.
export * from './index.js';
@coveralls

coveralls commented Jun 10, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 91.22%. remained the same — minggangw:fix-rosocket-types into RobotWebTools:develop

Address Copilot review on RobotWebTools#1533: add the standard Apache-2.0 license
header to rosocket/index.d.cts to match the other shipped type
entrypoints (web/index.d.ts, lib/runtime/index.d.ts, rosocket/index.d.ts).
@minggangw minggangw merged commit 01731e0 into RobotWebTools:develop Jun 10, 2026
19 checks passed
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 type declarations for the rclnodejs/rosocket

3 participants