Open
Description
TypeScript Version: 3.7.5 and 3.9.0-dev.20200220
Search Terms: excess property, computed property, index signature
Code
interface Foo {
a: string;
}
const bar: Foo = {
a: "",
z: "" // error, excess prop
}
const baz: Foo = {
a: "",
["Z".toLowerCase()]: "" // this is okay I guess?
}
Expected behavior:
The computed property in the definition of baz
should maybe produce an excess property error, since Foo
has no string index signature and "Z".toLowerCase()
is only known to be a string
.
Actual behavior:
The computed property is allowed.
Playground Link: Here
Related Issues: #22427
This issue is a re-opening of #22427, which was marked as a bug and closed as "fixed", but I don't see an actual fix referenced anywhere in that issue and the behavior described in that issue persists. Any ideas? Thanks!
There's an SO question asking this, which brought me to #22427, which has me scratching my head 😕.