microsoft / microsoft/TypeScript

Broken assignability and quick info due to erroneously deferring keyof T since #51621

オープン
#63,786 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@gabritto がすでに取り組んでいます。

2026年4月30日 から。

Bug
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

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

https://www.typescriptlang.org/play/?ts=5.8.3#code/C4TwDgpgBAQghgZwJYGMDCB7AdgEycJbOAGwB4AVAPigF4oBrCEDAMynKggA9gJcEocLCABQUKAH4owAE4BXCGKgAuKCxIIIAbhEjQkKJiwskAc1pQA3lBkQAVhBTA0xDJtWyFUAL4790cggEYFolIxNzbl5+K28lcSlLePEU2wcnFzcIVXhkdGw8AiIycLNKHRSUuMrVLAgANwgZHT1waAAle0dnV00LQOCAbQAiNO7MzWGAXR0AelmUgD0pRmY2UsiePhwBIRBJaXloVXViTSA

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。