document tsconfig `lib`/`target` requirements
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
- #246 của @ting-hong-shieh — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu bằng cách xác định định nghĩa kiểu RpcStub và các khai báo generic cho newWebSocketRpcSession và newHttpBatchRpcSession. Tái hiện vấn đề bằng ví dụ TypeScript, sau đó xác minh rằng các kiểu trả về của đối tượng như ApiMessage được giữ nguyên và các thuộc tính không hợp lệ bị trình kiểm tra kiểu từ chối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 4k
- Fork
- 151
- Merge trung bình
- 16 giờ 46 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudflare/capnweb
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
cloudflare/capnweb#269 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
cloudflare/capnweb#260 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
onRpcBroken should return a Disposable so registrations can be undoneCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
cloudflare/capnweb#234 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
support `Map` serialization typeCó thể đã có người làm @srikrsna đã nhận 93 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
cloudflare/capnweb#230 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
cloudflare/capnweb#228 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của cloudflare/capnweb
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation easy good first issue help wanted
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Billion-context documentation addendum: nudge is independent of window occupancy. | billion-context 文档补充:nudge 与窗口占用无关Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
ranxianglei/billion-context#5893 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
microsoft/monaco-editor#5575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100