microsoft / microsoft/TypeScript

Symbol properties should not be exempt from excess property checks in presence of a string index signature

Open
#44,794 4 comments 2 reactions 1 assignee View on GitHub

@ahejlsberg is already working on this.

Since Jun 28, 2021.

Breaking Change Bug Domain: check: Excess Property Checking Rescheduled
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

In #44793, we found that a symbol index signature doesn't turn off excess property checks on symbols; however, a string index signature turns these excess property checks entirely.

interface A {
    a?: string
    b?: number
    [key: string]: unknown
}

const symbolKey = Symbol('key')

const a: A = {
    [symbolKey]: '123', // works!
}

It's likely that some users relied on this behavior; however, those users will be able to use symbol index signatures in TypeScript 4.4.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.