Skip to content

Commit

Permalink
Remove Readonly<any> -> any callout
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Apr 29, 2019
1 parent b646f28 commit 18e5656
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/compiler/checker.ts
Expand Up @@ -11205,11 +11205,7 @@ namespace ts {
return mapType(mappedTypeVariable, t => {
if (t.flags & (TypeFlags.AnyOrUnknown | TypeFlags.InstantiableNonPrimitive | TypeFlags.Object | TypeFlags.Intersection) && t !== wildcardType && t !== errorType) {
const replacementMapper = createReplacementMapper(typeVariable, t, mapper);
// The first rule exists such that `Readonly<any>` is simply `any`, which is what most people think it will resolve to.
// Without the extra special callout, it actually instantiates to `{readonly [index: string]: any}` which has a bunch of
// assignability quirks to do with index signatures - most notably it no longer provides _every possible explicit property_.
return isTypeAny(t) && getTemplateTypeFromMappedType(type) === getIndexedAccessType(typeVariable, getTypeParameterFromMappedType(type)) ? t :
isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) :
instantiateAnonymousType(type, replacementMapper);
}
Expand Down

0 comments on commit 18e5656

Please sign in to comment.