mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
* Fix inferFromUsage on index signatures 1. Check the argumentExpression to determine the index signature type. Previously, the code mistakenly checked the type of the element access itself, which never returned a good type. 2. If inference for the index signature type fails, substitute anyType. Previously, the code would create a bad index signature with an undefined type. 3. Add tests. Previously, there were no tests. * Fixing (1) means that number index signatures are now created. Previously, only string index signatures would be created. * Fixing (2) means that index signatures will be inferred from single usage like `return a[0]`. Previously, the refactoring would fail, perhaps because of a check when stringifying the index signature (I haven't tracked down why.) * Update fourslash test with improved inference