From 731a20a3c2c8cc805294f738b6a6c60877bdf06e Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 7 Jul 2020 15:37:00 -0700 Subject: [PATCH] Revert "Cherry-pick PR #38653 into release-3.9 (#38687)" This reverts commit 9ec5fc5f35d9262be46d7b7f21ad5d6b8cc16ad5. --- src/compiler/checker.ts | 6 +-- .../reference/circularContextualMappedType.js | 32 ------------ .../circularContextualMappedType.symbols | 51 ------------------- .../circularContextualMappedType.types | 50 ------------------ .../compiler/circularContextualMappedType.ts | 20 -------- 5 files changed, 1 insertion(+), 158 deletions(-) delete mode 100644 tests/baselines/reference/circularContextualMappedType.js delete mode 100644 tests/baselines/reference/circularContextualMappedType.symbols delete mode 100644 tests/baselines/reference/circularContextualMappedType.types delete mode 100644 tests/cases/compiler/circularContextualMappedType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18611a9f68780..f669ac4e4683d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22402,10 +22402,6 @@ namespace ts { } } - function isCircularMappedProperty(symbol: Symbol) { - return !!(getCheckFlags(symbol) & CheckFlags.Mapped && !(symbol).type && findResolutionCycleStartIndex(symbol, TypeSystemPropertyName.Type) >= 0); - } - function getTypeOfPropertyOfContextualType(type: Type, name: __String) { return mapType(type, t => { if (isGenericMappedType(t)) { @@ -22419,7 +22415,7 @@ namespace ts { else if (t.flags & TypeFlags.StructuredType) { const prop = getPropertyOfType(t, name); if (prop) { - return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); + return getTypeOfSymbol(prop); } if (isTupleType(t)) { const restType = getRestTypeOfTupleType(t); diff --git a/tests/baselines/reference/circularContextualMappedType.js b/tests/baselines/reference/circularContextualMappedType.js deleted file mode 100644 index 7bd989c843a80..0000000000000 --- a/tests/baselines/reference/circularContextualMappedType.js +++ /dev/null @@ -1,32 +0,0 @@ -//// [circularContextualMappedType.ts] -type Func = () => T; - -type Mapped = { [K in keyof T]: Func }; - -declare function reproduce(options: number): void; -declare function reproduce(options: Mapped): T - -reproduce({ - name: () => { return 123 } -}); - -reproduce({ - name() { return 123 } -}); - -reproduce({ - name: function () { return 123 } -}); - - -//// [circularContextualMappedType.js] -"use strict"; -reproduce({ - name: function () { return 123; } -}); -reproduce({ - name: function () { return 123; } -}); -reproduce({ - name: function () { return 123; } -}); diff --git a/tests/baselines/reference/circularContextualMappedType.symbols b/tests/baselines/reference/circularContextualMappedType.symbols deleted file mode 100644 index 445906d48c1c7..0000000000000 --- a/tests/baselines/reference/circularContextualMappedType.symbols +++ /dev/null @@ -1,51 +0,0 @@ -=== tests/cases/compiler/circularContextualMappedType.ts === -type Func = () => T; ->Func : Symbol(Func, Decl(circularContextualMappedType.ts, 0, 0)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 0, 10)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 0, 10)) - -type Mapped = { [K in keyof T]: Func }; ->Mapped : Symbol(Mapped, Decl(circularContextualMappedType.ts, 0, 23)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12)) ->K : Symbol(K, Decl(circularContextualMappedType.ts, 2, 20)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12)) ->Func : Symbol(Func, Decl(circularContextualMappedType.ts, 0, 0)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 2, 12)) ->K : Symbol(K, Decl(circularContextualMappedType.ts, 2, 20)) - -declare function reproduce(options: number): void; ->reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50)) ->options : Symbol(options, Decl(circularContextualMappedType.ts, 4, 27)) - -declare function reproduce(options: Mapped): T ->reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27)) ->options : Symbol(options, Decl(circularContextualMappedType.ts, 5, 30)) ->Mapped : Symbol(Mapped, Decl(circularContextualMappedType.ts, 0, 23)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27)) ->T : Symbol(T, Decl(circularContextualMappedType.ts, 5, 27)) - -reproduce({ ->reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50)) - - name: () => { return 123 } ->name : Symbol(name, Decl(circularContextualMappedType.ts, 7, 11)) - -}); - -reproduce({ ->reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50)) - - name() { return 123 } ->name : Symbol(name, Decl(circularContextualMappedType.ts, 11, 11)) - -}); - -reproduce({ ->reproduce : Symbol(reproduce, Decl(circularContextualMappedType.ts, 2, 48), Decl(circularContextualMappedType.ts, 4, 50)) - - name: function () { return 123 } ->name : Symbol(name, Decl(circularContextualMappedType.ts, 15, 11)) - -}); - diff --git a/tests/baselines/reference/circularContextualMappedType.types b/tests/baselines/reference/circularContextualMappedType.types deleted file mode 100644 index d9439215d280e..0000000000000 --- a/tests/baselines/reference/circularContextualMappedType.types +++ /dev/null @@ -1,50 +0,0 @@ -=== tests/cases/compiler/circularContextualMappedType.ts === -type Func = () => T; ->Func : Func - -type Mapped = { [K in keyof T]: Func }; ->Mapped : Mapped - -declare function reproduce(options: number): void; ->reproduce : { (options: number): void; (options: Mapped): T; } ->options : number - -declare function reproduce(options: Mapped): T ->reproduce : { (options: number): void; (options: Mapped): T; } ->options : Mapped - -reproduce({ ->reproduce({ name: () => { return 123 }}) : { name: number; } ->reproduce : { (options: number): void; (options: Mapped): T; } ->{ name: () => { return 123 }} : { name: () => number; } - - name: () => { return 123 } ->name : () => number ->() => { return 123 } : () => number ->123 : 123 - -}); - -reproduce({ ->reproduce({ name() { return 123 }}) : { name: number; } ->reproduce : { (options: number): void; (options: Mapped): T; } ->{ name() { return 123 }} : { name(): number; } - - name() { return 123 } ->name : () => number ->123 : 123 - -}); - -reproduce({ ->reproduce({ name: function () { return 123 }}) : { name: number; } ->reproduce : { (options: number): void; (options: Mapped): T; } ->{ name: function () { return 123 }} : { name: () => number; } - - name: function () { return 123 } ->name : () => number ->function () { return 123 } : () => number ->123 : 123 - -}); - diff --git a/tests/cases/compiler/circularContextualMappedType.ts b/tests/cases/compiler/circularContextualMappedType.ts deleted file mode 100644 index 4c982cd6fca1f..0000000000000 --- a/tests/cases/compiler/circularContextualMappedType.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @strict: true - -type Func = () => T; - -type Mapped = { [K in keyof T]: Func }; - -declare function reproduce(options: number): void; -declare function reproduce(options: Mapped): T - -reproduce({ - name: () => { return 123 } -}); - -reproduce({ - name() { return 123 } -}); - -reproduce({ - name: function () { return 123 } -});