microsoft / microsoft/TypeScript
Symbol properties should not be exempt from excess property checks in presence of a string index signature
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.