From 3766be1bdee83b724eb070e7e17abfcf3eb0b54b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 6 Oct 2020 14:18:44 -0700 Subject: [PATCH] Test indexed access to `this` on intersections (#40967) * Added test. * Accepted baselines. --- .../indexedAccessToThisTypeOnIntersection01.js | 9 +++++++++ ...dexedAccessToThisTypeOnIntersection01.symbols | 16 ++++++++++++++++ ...indexedAccessToThisTypeOnIntersection01.types | 13 +++++++++++++ .../indexedAccessToThisTypeOnIntersection01.ts | 6 ++++++ 4 files changed, 44 insertions(+) create mode 100644 tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.js create mode 100644 tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.symbols create mode 100644 tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.types create mode 100644 tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts diff --git a/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.js b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.js new file mode 100644 index 00000000000..0e4408f69fd --- /dev/null +++ b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.js @@ -0,0 +1,9 @@ +//// [indexedAccessToThisTypeOnIntersection01.ts] +interface A { + a: string; + getA: this['a']; +} + +type T = (A & { a: number })['getA']; + +//// [indexedAccessToThisTypeOnIntersection01.js] diff --git a/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.symbols b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.symbols new file mode 100644 index 00000000000..b3af8d0c953 --- /dev/null +++ b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts === +interface A { +>A : Symbol(A, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 0)) + + a: string; +>a : Symbol(A.a, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 13)) + + getA: this['a']; +>getA : Symbol(A.getA, Decl(indexedAccessToThisTypeOnIntersection01.ts, 1, 12)) +} + +type T = (A & { a: number })['getA']; +>T : Symbol(T, Decl(indexedAccessToThisTypeOnIntersection01.ts, 3, 1)) +>A : Symbol(A, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 0)) +>a : Symbol(a, Decl(indexedAccessToThisTypeOnIntersection01.ts, 5, 15)) + diff --git a/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.types b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.types new file mode 100644 index 00000000000..60cabd1d77b --- /dev/null +++ b/tests/baselines/reference/indexedAccessToThisTypeOnIntersection01.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts === +interface A { + a: string; +>a : string + + getA: this['a']; +>getA : this["a"] +} + +type T = (A & { a: number })['getA']; +>T : never +>a : number + diff --git a/tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts b/tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts new file mode 100644 index 00000000000..63a4a9d37e5 --- /dev/null +++ b/tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts @@ -0,0 +1,6 @@ +interface A { + a: string; + getA: this['a']; +} + +type T = (A & { a: number })['getA']; \ No newline at end of file