File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,14 +37,27 @@ declare module 'rclnodejs/web' {
3737 * string `"<n>n"` so they survive `JSON.stringify`. Everything else
3838 * passes through unchanged.
3939 *
40+ * Cases (checked in order):
41+ * - `bigint` → {@link Int64Wire} (the `"<n>n"` string)
42+ * - `ReadonlyArray<U>` → `WireType<U>[]` (recurse per element)
43+ * - `Date` → `string` (ISO string on the wire)
44+ * - `object` → field-wise recursion
45+ * - everything else → passes through unchanged
46+ *
4047 * @experimental — exposed for advanced consumers that want to derive
4148 * wire shapes by hand. Most users should rely on the type-name
4249 * generics on {@link RosClient.call} / `subscribe` / etc., which
4350 * apply this mapping internally.
4451 */
45- export type WireType < T > = [ T ] extends [ bigint ]
46- ? Int64Wire
47- : T extends ReadonlyArray < infer U >
52+ // The bigint check uses `[T] extends [bigint]` (tuple wrapper) instead
53+ // of bare `T extends bigint` so the conditional doesn't distribute
54+ // across union members like `bigint | string` (which would map only
55+ // the bigint half and silently drop the rest).
56+ export type WireType < T > = [ T ] extends [ bigint ] ? Int64Wire : _WireRecurse < T > ;
57+
58+ /** Recursion step for {@link WireType}; pulled out to keep the cascade flat. */
59+ type _WireRecurse < T > =
60+ T extends ReadonlyArray < infer U >
4861 ? WireType < U > [ ]
4962 : T extends Date
5063 ? string
You can’t perform that action at this time.
0 commit comments