diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 24bf24b60a20c..43297244e1ad5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14826,11 +14826,16 @@ namespace ts { } function getNormalizedType(type: Type, writing: boolean): Type { - return isFreshLiteralType(type) ? (type).regularType : - getObjectFlags(type) & ObjectFlags.Reference && (type).node ? createTypeReference((type).target, getTypeArguments(type)) : - type.flags & TypeFlags.Substitution ? writing ? (type).typeVariable : (type).substitute : - type.flags & TypeFlags.Simplifiable ? getSimplifiedType(type, writing) : - type; + do { + const t = isFreshLiteralType(type) ? (type).regularType : + getObjectFlags(type) & ObjectFlags.Reference && (type).node ? createTypeReference((type).target, getTypeArguments(type)) : + type.flags & TypeFlags.Substitution ? writing ? (type).typeVariable : (type).substitute : + type.flags & TypeFlags.Simplifiable ? getSimplifiedType(type, writing) : + type; + if (t === type) break; + type = t; + } while (true); + return type; } /** diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js new file mode 100644 index 0000000000000..2ff1261fd794c --- /dev/null +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js @@ -0,0 +1,50 @@ +//// [indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts] +type AnyFunction = (...args: any[]) => any; +type Params = Parameters>; + +interface Wrapper { + call(event: K, ...args: Params): void; +} + +interface AWrapped { + foo(): void; +} + +class A { + foo: Wrapper; +} + +interface BWrapped extends AWrapped { + bar(): void; +} + +class B extends A { + foo: Wrapper; +} + +//// [indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + return B; +}(A)); diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols new file mode 100644 index 0000000000000..41f6b4a5ebceb --- /dev/null +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols @@ -0,0 +1,62 @@ +=== tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts === +type AnyFunction = (...args: any[]) => any; +>AnyFunction : Symbol(AnyFunction, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) +>args : Symbol(args, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 20)) + +type Params = Parameters>; +>Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 43)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 12)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 12)) +>AnyFunction : Symbol(AnyFunction, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) + +interface Wrapper { +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) + + call(event: K, ...args: Params): void; +>call : Symbol(Wrapper.call, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 22)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) +>event : Symbol(event, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 25)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) +>args : Symbol(args, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 34)) +>Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 43)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) +} + +interface AWrapped { +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) + + foo(): void; +>foo : Symbol(AWrapped.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 7, 20)) +} + +class A { +>A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 9, 1)) + + foo: Wrapper; +>foo : Symbol(A.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 11, 9)) +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) +} + +interface BWrapped extends AWrapped { +>BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 13, 1)) +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) + + bar(): void; +>bar : Symbol(BWrapped.bar, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 15, 37)) +} + +class B extends A { +>B : Symbol(B, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 17, 1)) +>A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 9, 1)) + + foo: Wrapper; +>foo : Symbol(B.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 19, 19)) +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) +>BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 13, 1)) +} diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types new file mode 100644 index 0000000000000..2c57c390ddc53 --- /dev/null +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts === +type AnyFunction = (...args: any[]) => any; +>AnyFunction : AnyFunction +>args : any[] + +type Params = Parameters>; +>Params : Parameters> + +interface Wrapper { + call(event: K, ...args: Params): void; +>call : (event: K, ...args: Parameters>) => void +>event : K +>args : Parameters> +} + +interface AWrapped { + foo(): void; +>foo : () => void +} + +class A { +>A : A + + foo: Wrapper; +>foo : Wrapper +} + +interface BWrapped extends AWrapped { + bar(): void; +>bar : () => void +} + +class B extends A { +>B : B +>A : A + + foo: Wrapper; +>foo : Wrapper +} diff --git a/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts b/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts new file mode 100644 index 0000000000000..a68ea9beee6d2 --- /dev/null +++ b/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts @@ -0,0 +1,22 @@ +type AnyFunction = (...args: any[]) => any; +type Params = Parameters>; + +interface Wrapper { + call(event: K, ...args: Params): void; +} + +interface AWrapped { + foo(): void; +} + +class A { + foo: Wrapper; +} + +interface BWrapped extends AWrapped { + bar(): void; +} + +class B extends A { + foo: Wrapper; +} \ No newline at end of file