From b6302f3c841d6a275fd73531a8ec24862e3c05c5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 16 Jul 2017 16:51:47 -1000 Subject: [PATCH] Add readonly type relationships --- src/compiler/checker.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 432e6721308..c928fdaff4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9265,6 +9265,13 @@ namespace ts { } } } + else if (target.flags & TypeFlags.Readonly) { + // A type S or readonly S is related to a readonly T if S is related to T. + const nonReadonlySource = source.flags & TypeFlags.Readonly ? (source).type : source; + if (result = isRelatedTo(nonReadonlySource, (target).type, reportErrors)) { + return result; + } + } else if (target.flags & TypeFlags.Index) { // A keyof S is related to a keyof T if T is related to S. if (source.flags & TypeFlags.Index) {