Skip to content

Commit d21e4ca

Browse files
authored
Enhance Stubify and Unstubify for tuple types (#117)
* Enhance Stubify and Unstubify for tuple types fixes #116 * Add changeset for "Enhance Stubify and Unstubify for tuple types"
1 parent 8a47045 commit d21e4ca

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/rich-mangos-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"capnweb": patch
3+
---
4+
5+
Enhance Stubify and Unstubify for tuple types

src/types.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export type Stubify<T> =
9292
: T extends StubBase<any> ? T
9393
: T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>>
9494
: T extends Set<infer V> ? Set<Stubify<V>>
95+
: T extends [] ? []
96+
: T extends [infer Head, ...infer Tail] ? [Stubify<Head>, ...Stubify<Tail>]
97+
: T extends readonly [] ? readonly []
98+
: T extends readonly [infer Head, ...infer Tail] ? readonly [Stubify<Head>, ...Stubify<Tail>]
9599
: T extends Array<infer V> ? Array<Stubify<V>>
96100
: T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>>
97101
: T extends BaseType ? T
@@ -107,6 +111,10 @@ type UnstubifyInner<T> =
107111
T extends StubBase<infer V> ? (T | V) // can provide either stub or local RpcTarget
108112
: T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>>
109113
: T extends Set<infer V> ? Set<Unstubify<V>>
114+
: T extends [] ? []
115+
: T extends [infer Head, ...infer Tail] ? [Unstubify<Head>, ...Unstubify<Tail>]
116+
: T extends readonly [] ? readonly []
117+
: T extends readonly [infer Head, ...infer Tail] ? readonly [Unstubify<Head>, ...Unstubify<Tail>]
110118
: T extends Array<infer V> ? Array<Unstubify<V>>
111119
: T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>>
112120
: T extends BaseType ? T

0 commit comments

Comments
 (0)