Remove special any assignability for numeric index signatures (#41660)

* Only enable special assignability rule on string index signatures to 'any'.

* Accepted baselines.

* Added test.

* Accepted baselines.

* Renamed test files.

* Add non-erroring version of bclas'subClassThisTypeAssignable01.ts'

* Accepted baselines.

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
This commit is contained in:
Daniel RosenwasserandTypeScript Bot authored and GitHub committed 2021-02-25 17:36:09 -08:00
1 parent 2c5cee59f0
commit df5ffc0ea1
20 files changed
+392 -36

No files matched your search

+1 -1
View File
@@ -18948,7 +18948,7 @@ namespace ts {
return indexTypesIdenticalTo(source, target, kind);
}
const targetType = getIndexTypeOfType(target, kind);
if (!targetType || targetType.flags & TypeFlags.Any && !sourceIsPrimitive) {
if (!targetType || targetType.flags & TypeFlags.Any && !sourceIsPrimitive && kind === IndexKind.String) {
// Index signature of type any permits assignment from everything but primitives
return Ternary.True;
}