document tsconfig `lib`/`target` requirements
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
- #246 @ting-hong-shieh による — マージされずにクローズ
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- api
調査の方向性
まず、RpcStub 型の定義と、newWebSocketRpcSession および newHttpBatchRpcSession のジェネリック宣言を見つけます。TypeScript の例で問題を再現し、ApiMessage のようなオブジェクトの戻り値の型が保持され、無効なプロパティが型チェックによって拒否されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Description
When using newWebSocketRpcSession or newHttpBatchRpcSession with a TypeScript generic parameter, the RpcStub<T> type preserves primitive return types (string, number, boolean) but fails to preserve object/interface return types, returning any instead.
Minimal Reproducible Example
import { newWebSocketRpcSession, type RpcStub } from 'capnweb';
// Define types
type ApiMessage = { message: string; timestamp: string };
// Define API interface
interface MyApi {
getPrimitive(): Promise<string>; // Returns primitive
getObject(): Promise<ApiMessage>; // Returns object
hello(name: string): Promise<ApiMessage>; // Returns object
}
// Create client
const apiStub = newWebSocketRpcSession<MyApi>('wss://example.com/api');
// Primitives work correctly ✅
const primitive = await apiStub.getPrimitive();
// ^? Type is 'string' ✅
// Objects return 'any' ❌
const object = await apiStub.getObject();
// ^? Type is 'any' ❌
const helloResult = await apiStub.hello('world');
// ^? Type is 'any' ❌
Expected Behavior
All method return types should be preserved, regardless of whether they're primitives or objects:
const primitive = await apiStub.getPrimitive();
// ^? string ✅
const object = await apiStub.getObject();
// ^? Should be: ApiMessage
const helloResult = await apiStub.hello('world');
// ^? Should be: ApiMessage
Actual Behavior
Only primitive return types are preserved. Object/interface return types become any:
const apiStub: RpcStub<MyApi> = newWebSocketRpcSession<MyApi>('wss://example.com/api');
// ^? Correctly shows: RpcStub<MyApi>
const primitive = await apiStub.getPrimitive();
// ^? string ✅ Works!
const object = await apiStub.getObject();
// ^? any ❌ Should be ApiMessage
const helloResult = await apiStub.hello('world');
// ^? any ❌ Should be ApiMessage
// No type checking for objects
console.log(helloResult.anythingGoes); // No error
Root Cause
The RpcStub<T> type definition appears to handle primitives correctly but wraps object return types in complex proxy types (for promise pipelining support) that resolve to any instead of the original type.
Workaround
Manually cast each result:
const helloResult = await apiStub.hello('world') as ApiMessage;
// ^? Now correctly typed as: ApiMessage ✅
Environment
- capnweb version: 0.2.0
- TypeScript version: 5.8.3
- Node version: 22.15.1
- 主要言語
- TypeScript
- スター
- 4k
- フォーク
- 151
- 平均マージ
- 16時間 46分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloudflare/capnweb のほかの issue
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
cloudflare/capnweb#269 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
cloudflare/capnweb#260 ·
メンテナーはふだん 2 日以内に返信
-
onRpcBroken should return a Disposable so registrations can be undone再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
cloudflare/capnweb#234 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
support `Map` serialization type対応中かも @srikrsna が 93 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
cloudflare/capnweb#230 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cloudflare/capnweb#228 ·
メンテナーはふだん 2 日以内に返信
cloudflare/capnweb の issue をすべて見る
似ている issue
-
Add: ESP 2 ROオープンapproved check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
ipaas: Configure form shows "Deploy to apply." and "Overrides selected Link" when they don't apply対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
wso2/integration-control-plane#1118 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
UTDNebula/utd-notebook#311 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信