Microsoft/TypeScript

Index type for an intersected `NoInfer` can get sometimes incorrectly deferred

オープン

#61,091 opened on 2025/01/31

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (13,395 件のフォーク)batch import
Domain: Index TypesHelp WantedPossible Improvement

Repository metrics

Stars
 (108,860 個のスター)
PR merge metrics
 (PR metrics pending)

説明

🔎 Search Terms

noinfer intersection index type keyof deferred deferral

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250131#code/C4TwDgpgBAKhDOwoF4oGsIgPYDMoAoA5LASQDscIAnAHgG8ocssAuKRKgSzIHMoBfAHxQAZFDr8AlAG4AUAHp5UZQD0A-LNCRYCYACYU6TLgIMmrdsC68Bo8VLmLlUdbKA

💻 Code

type Test = keyof (NoInfer<{ foo: string }> & {});
//   ^? type Test = keyof (NoInfer<{ foo: string; }> & {})
type Test2 = keyof ({ foo: string } & {});
//   ^? type Test2 = "foo"

🙁 Actual behavior

Test is a deferred index type

🙂 Expected behavior

Test shouldn't be a deferred index type but a "foo" literal, just like Test2.

Additional information about the issue

No response

コントリビューターガイド