Equivalent arguments typed with tuples aren't assignable to the same functions with overloads when the same function is recursively referenced
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
Bắt đầu với bản tái hiện trên TypeScript Playground được liên kết trong issue và kiểm tra hành vi có thể gán đệ quy giữa các hàm có đối số tuple và các hàm nạp chồng. Công việc hoàn tất khi phép gán được minh họa thành công mà không có lỗi, đồng thời vẫn duy trì việc kiểm tra chính xác các chữ ký đệ quy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
🔎 Search Terms
arguments, overloads, function, tuple
🕗 Version & Regression Information
All versions with support for tuple arguments (upto v4.5.0-dev.20210815).
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about function overloading (there is nothing in the FAQ about tuples)
⏯ Playground Link
Playground link with relevant code
💻 Code
type START = 0
type DATA = 1
type Args<In, Out> =
| [t: START, other: FnWithArgs<Out, In>]
| [t: DATA]
type FnWithArgs<In, Out> = (...args: Args<In, Out>) => void
interface FnWithOverloads<In, Out> {
(t: START, other: FnWithOverloads<Out, In>): void;
(t: DATA): void;
}
declare const withArgs: FnWithArgs<1, 2>
// these should be assignable to one another, but aren't:
const assertion: FnWithOverloads<1, 2> = withArgs
🙁 Actual behavior
Two types that should be functionally equivalent aren't assignable to one another:
Type 'FnWithArgs<1, 2>' is not assignable to type 'FnWithOverloads<1, 2>'.
Types of parameters 'args' and 't' are incompatible.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type 'Args<1, 2>'.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type '[t: 0, other: FnWithArgs<2, 1>]'.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'FnWithOverloads<2, 1>' is not assignable to type 'FnWithArgs<2, 1>'.
Types of parameters 't' and 'args' are incompatible.
Type 'Args<2, 1>' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Type '[t: 1]' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Source has 1 element(s) but target requires 2.
I've tried simplifying the example, and this issue doesn't seem to occur when the parameters of the function don't reference themselves in their signature.
🙂 Expected behavior
No error, types should be assignable to one another.
Related issues
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
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 microsoft/TypeScript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64322 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Possible Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64278 · 1 bình luận · 1 reaction ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/TypeScript#64118 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64094 ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#63959 · 5 bình luận ·
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
kubernetes-sigs/prow#953 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
caddyserver/caddy#8046 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
L1 recommended for recruits
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
area/entangle bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100