Add static index signature by Kingwl · Pull Request #37797 · microsoft/TypeScript (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good, but I'd love to see some more tests (you should consider placing them in a subfolder of the conformance
directory instead of compiler
, since it's a "new" language feature). Specifically, I'm thinking of tests showing:
- Class static inheritance both inheriting and overriding index signatures (and issuing errors if you override with an incompatible type)
- Assignability of class static sides to one another when index signatures are in place (readonly and not readonly)
- Assignability between class static sides and equivalent interfaces describing them
- Assignability between class static sides with generic static index signatures (this likely requires defining classes within a closure with generic parameters) to have some sanity checks on the behavior of variance digests with these
- Some usages with indexed access types, eg
(typeof Cls)[string]
- Some usages with
keyof
, egkeyof typeof Cls
- Some usages with homomorphic mapped types, eg
Extract<typeof Cls, string>
More would also be welcome, ofc, if you can think of any other possible edge cases.