Skip to content

Commit 3766be1

Browse files
Test indexed access to this on intersections (#40967)
* Added test. * Accepted baselines.
1 parent 692502e commit 3766be1

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [indexedAccessToThisTypeOnIntersection01.ts]
2+
interface A {
3+
a: string;
4+
getA: this['a'];
5+
}
6+
7+
type T = (A & { a: number })['getA'];
8+
9+
//// [indexedAccessToThisTypeOnIntersection01.js]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts ===
2+
interface A {
3+
>A : Symbol(A, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 0))
4+
5+
a: string;
6+
>a : Symbol(A.a, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 13))
7+
8+
getA: this['a'];
9+
>getA : Symbol(A.getA, Decl(indexedAccessToThisTypeOnIntersection01.ts, 1, 12))
10+
}
11+
12+
type T = (A & { a: number })['getA'];
13+
>T : Symbol(T, Decl(indexedAccessToThisTypeOnIntersection01.ts, 3, 1))
14+
>A : Symbol(A, Decl(indexedAccessToThisTypeOnIntersection01.ts, 0, 0))
15+
>a : Symbol(a, Decl(indexedAccessToThisTypeOnIntersection01.ts, 5, 15))
16+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/indexedAccessToThisTypeOnIntersection01.ts ===
2+
interface A {
3+
a: string;
4+
>a : string
5+
6+
getA: this['a'];
7+
>getA : this["a"]
8+
}
9+
10+
type T = (A & { a: number })['getA'];
11+
>T : never
12+
>a : number
13+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface A {
2+
a: string;
3+
getA: this['a'];
4+
}
5+
6+
type T = (A & { a: number })['getA'];

0 commit comments

Comments
 (0)