Microsoft/TypeScript

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

Open

#61.091 aberto em 31 de jan. de 2025

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (6.726 forks)batch import
Domain: Index TypesHelp WantedPossible Improvement

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

Description

🔎 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

Guia do colaborador