Skip to content

Required properties inside computed property name not detected #61731

Closed
@silverwind

Description

@silverwind

πŸ”Ž Search Terms

"computed property name", "required"

πŸ•— Version & Regression Information

  • This changed between versions 5.1.6 and 5.2.0
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about (nonexistant)

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250519#code/MYewdgzgLgBAZiEAuGAlApqATgEwDzRYCWYA5gDQwDeYAhgLboqEmkC+AfDALzUBQMGAG0ABghAiAuiiptyA4SIAkVAEQAjWllVspMuQtEqAylGJkAFBtoAvVQEpd06gbZA

πŸ’» Code

const foo: Record<string, {name: string}> = {
  [`foo`]: {},
  [`${"bar"}`]: {},
  [`${String("baz")}`]: {},
}

πŸ™ Actual behavior

The first and second properties are erroring as expected because of missing name property, but the third one does not, while it should.

πŸ™‚ Expected behavior

All three object properties should error because of missing name property.

Additional information about the issue

In 5.1, only the first property error was detected, since 5.2, it now detects the first two. Ideally it should detect all three cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions