microsoft / microsoft/TypeScript
Broken assignability and quick info due to erroneously deferring keyof T since #51621
@gabritto đang làm issue này rồi.
Từ ngày 30/4/2026.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
Note: This is a refiling of #61728 due to being closed due to being related to quick info display (see #62827).
Version & Regression Information
This changed in PR https://github.com/microsoft/TypeScript/pull/51621
Playground Link
Code:
Poor quick info:
type BasicConditional<T> = keyof T extends any
? true
: false;
type Config = { rejectClose: true };
type Test =
Config extends {}
? {
rejectClose: BasicConditional<Config>;
}
: never;
type RejectClose = Test["rejectClose"];
// ^? keyof Config extends any ? true : false
Broken assignability (found by @Andarist, see https://github.com/microsoft/TypeScript/issues/61728#issuecomment-2891710775)
type BasicConditional<T> = keyof T extends infer R ? R : never;
type Config = { rejectClose: true };
type Test = Config extends {}
? {
rejectClose: BasicConditional<Config>;
}
: never;
const test: Test["rejectClose"] = "rejectClose";
// ^ Type 'string' is not assignable to type 'BasicConditional<Config>'.
const ok: BasicConditional<Config> = "rejectClose"; // No error
Actual behavior
RejectClose's quick info is keyof Config extends any ? true : false which is un-simplified and rather ugly. In addition in the second snippet const test: Test["rejectClose"] = "rejectClose"; fails.
Expected behavior
The quick info should look nice and const test: Test["rejectClose"] = "rejectClose"; should succeed.
See https://github.com/microsoft/TypeScript/pull/61999 for a TS-JS based fix.
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.
Đánh giá
Issue này chưa được đánh giá.