Skip to content

Commit 4ce494a

Browse files
committed
Accept new baselines
1 parent a439e62 commit 4ce494a

File tree

3 files changed

+460
-36
lines changed

3 files changed

+460
-36
lines changed

tests/baselines/reference/keyofAndIndexedAccess.js

+84
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,46 @@ function f40(c: C) {
181181
let z: Z = c["z"];
182182
}
183183

184+
function f50<T>(k: keyof T, s: string, n: number) {
185+
const x1 = s as keyof T;
186+
const x2 = n as keyof T;
187+
const x3 = k as string;
188+
const x4 = k as number;
189+
const x5 = k as string | number;
190+
}
191+
192+
function f51<T, K extends keyof T>(k: K, s: string, n: number) {
193+
const x1 = s as keyof T;
194+
const x2 = n as keyof T;
195+
const x3 = k as string;
196+
const x4 = k as number;
197+
const x5 = k as string | number;
198+
}
199+
200+
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
201+
const x1 = obj[s];
202+
const x2 = obj[n];
203+
const x3 = obj[k];
204+
}
205+
206+
function f53<T, K extends keyof T>(obj: { [x: string]: boolean }, k: K, s: string, n: number) {
207+
const x1 = obj[s];
208+
const x2 = obj[n];
209+
const x3 = obj[k];
210+
}
211+
212+
function f54<T>(obj: T, key: keyof T) {
213+
for (let s in obj[key]) {
214+
}
215+
const b = "foo" in obj[key];
216+
}
217+
218+
function f55<T, K extends keyof T>(obj: T, key: K) {
219+
for (let s in obj[key]) {
220+
}
221+
const b = "foo" in obj[key];
222+
}
223+
184224
// Repros from #12011
185225

186226
class Base {
@@ -329,6 +369,40 @@ function f40(c) {
329369
var y = c["y"];
330370
var z = c["z"];
331371
}
372+
function f50(k, s, n) {
373+
var x1 = s;
374+
var x2 = n;
375+
var x3 = k;
376+
var x4 = k;
377+
var x5 = k;
378+
}
379+
function f51(k, s, n) {
380+
var x1 = s;
381+
var x2 = n;
382+
var x3 = k;
383+
var x4 = k;
384+
var x5 = k;
385+
}
386+
function f52(obj, k, s, n) {
387+
var x1 = obj[s];
388+
var x2 = obj[n];
389+
var x3 = obj[k];
390+
}
391+
function f53(obj, k, s, n) {
392+
var x1 = obj[s];
393+
var x2 = obj[n];
394+
var x3 = obj[k];
395+
}
396+
function f54(obj, key) {
397+
for (var s in obj[key]) {
398+
}
399+
var b = "foo" in obj[key];
400+
}
401+
function f55(obj, key) {
402+
for (var s in obj[key]) {
403+
}
404+
var b = "foo" in obj[key];
405+
}
332406
// Repros from #12011
333407
var Base = (function () {
334408
function Base() {
@@ -454,6 +528,16 @@ declare class C {
454528
private z;
455529
}
456530
declare function f40(c: C): void;
531+
declare function f50<T>(k: keyof T, s: string, n: number): void;
532+
declare function f51<T, K extends keyof T>(k: K, s: string, n: number): void;
533+
declare function f52<T>(obj: {
534+
[x: string]: boolean;
535+
}, k: keyof T, s: string, n: number): void;
536+
declare function f53<T, K extends keyof T>(obj: {
537+
[x: string]: boolean;
538+
}, k: K, s: string, n: number): void;
539+
declare function f54<T>(obj: T, key: keyof T): void;
540+
declare function f55<T, K extends keyof T>(obj: T, key: K): void;
457541
declare class Base {
458542
get<K extends keyof this>(prop: K): this[K];
459543
set<K extends keyof this>(prop: K, value: this[K]): void;

tests/baselines/reference/keyofAndIndexedAccess.symbols

+194-36
Original file line numberDiff line numberDiff line change
@@ -626,84 +626,242 @@ function f40(c: C) {
626626
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 167, 24))
627627
}
628628

629+
function f50<T>(k: keyof T, s: string, n: number) {
630+
>f50 : Symbol(f50, Decl(keyofAndIndexedAccess.ts, 180, 1))
631+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 182, 13))
632+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 182, 16))
633+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 182, 13))
634+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 182, 27))
635+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 182, 38))
636+
637+
const x1 = s as keyof T;
638+
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 183, 9))
639+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 182, 27))
640+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 182, 13))
641+
642+
const x2 = n as keyof T;
643+
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 184, 9))
644+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 182, 38))
645+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 182, 13))
646+
647+
const x3 = k as string;
648+
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 185, 9))
649+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 182, 16))
650+
651+
const x4 = k as number;
652+
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 186, 9))
653+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 182, 16))
654+
655+
const x5 = k as string | number;
656+
>x5 : Symbol(x5, Decl(keyofAndIndexedAccess.ts, 187, 9))
657+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 182, 16))
658+
}
659+
660+
function f51<T, K extends keyof T>(k: K, s: string, n: number) {
661+
>f51 : Symbol(f51, Decl(keyofAndIndexedAccess.ts, 188, 1))
662+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 190, 13))
663+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 190, 15))
664+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 190, 13))
665+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 190, 35))
666+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 190, 15))
667+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 190, 40))
668+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 190, 51))
669+
670+
const x1 = s as keyof T;
671+
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 191, 9))
672+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 190, 40))
673+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 190, 13))
674+
675+
const x2 = n as keyof T;
676+
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 192, 9))
677+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 190, 51))
678+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 190, 13))
679+
680+
const x3 = k as string;
681+
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 193, 9))
682+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 190, 35))
683+
684+
const x4 = k as number;
685+
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 194, 9))
686+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 190, 35))
687+
688+
const x5 = k as string | number;
689+
>x5 : Symbol(x5, Decl(keyofAndIndexedAccess.ts, 195, 9))
690+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 190, 35))
691+
}
692+
693+
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
694+
>f52 : Symbol(f52, Decl(keyofAndIndexedAccess.ts, 196, 1))
695+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 198, 13))
696+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 198, 16))
697+
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 198, 24))
698+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 198, 46))
699+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 198, 13))
700+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 198, 58))
701+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 198, 69))
702+
703+
const x1 = obj[s];
704+
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 199, 9))
705+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 198, 16))
706+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 198, 58))
707+
708+
const x2 = obj[n];
709+
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 200, 9))
710+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 198, 16))
711+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 198, 69))
712+
713+
const x3 = obj[k];
714+
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 201, 9))
715+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 198, 16))
716+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 198, 46))
717+
}
718+
719+
function f53<T, K extends keyof T>(obj: { [x: string]: boolean }, k: K, s: string, n: number) {
720+
>f53 : Symbol(f53, Decl(keyofAndIndexedAccess.ts, 202, 1))
721+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 204, 13))
722+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 204, 15))
723+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 204, 13))
724+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 204, 35))
725+
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 204, 43))
726+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 204, 65))
727+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 204, 15))
728+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 204, 71))
729+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 204, 82))
730+
731+
const x1 = obj[s];
732+
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 205, 9))
733+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 204, 35))
734+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 204, 71))
735+
736+
const x2 = obj[n];
737+
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 206, 9))
738+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 204, 35))
739+
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 204, 82))
740+
741+
const x3 = obj[k];
742+
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 207, 9))
743+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 204, 35))
744+
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 204, 65))
745+
}
746+
747+
function f54<T>(obj: T, key: keyof T) {
748+
>f54 : Symbol(f54, Decl(keyofAndIndexedAccess.ts, 208, 1))
749+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 210, 13))
750+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 210, 16))
751+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 210, 13))
752+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 210, 23))
753+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 210, 13))
754+
755+
for (let s in obj[key]) {
756+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 211, 12))
757+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 210, 16))
758+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 210, 23))
759+
}
760+
const b = "foo" in obj[key];
761+
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 213, 9))
762+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 210, 16))
763+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 210, 23))
764+
}
765+
766+
function f55<T, K extends keyof T>(obj: T, key: K) {
767+
>f55 : Symbol(f55, Decl(keyofAndIndexedAccess.ts, 214, 1))
768+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 216, 13))
769+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 216, 15))
770+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 216, 13))
771+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 216, 35))
772+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 216, 13))
773+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 216, 42))
774+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 216, 15))
775+
776+
for (let s in obj[key]) {
777+
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 217, 12))
778+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 216, 35))
779+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 216, 42))
780+
}
781+
const b = "foo" in obj[key];
782+
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 219, 9))
783+
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 216, 35))
784+
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 216, 42))
785+
}
786+
629787
// Repros from #12011
630788

631789
class Base {
632-
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
790+
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 220, 1))
633791

634792
get<K extends keyof this>(prop: K) {
635-
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
636-
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
637-
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
638-
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
793+
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 224, 12))
794+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 225, 8))
795+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 225, 30))
796+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 225, 8))
639797

640798
return this[prop];
641-
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
642-
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
799+
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 220, 1))
800+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 225, 30))
643801
}
644802
set<K extends keyof this>(prop: K, value: this[K]) {
645-
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
646-
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
647-
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
648-
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
649-
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
650-
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
803+
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 227, 5))
804+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 228, 8))
805+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 228, 30))
806+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 228, 8))
807+
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 228, 38))
808+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 228, 8))
651809

652810
this[prop] = value;
653-
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
654-
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
655-
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
811+
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 220, 1))
812+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 228, 30))
813+
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 228, 38))
656814
}
657815
}
658816

659817
class Person extends Base {
660-
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
661-
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
818+
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 231, 1))
819+
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 220, 1))
662820

663821
parts: number;
664-
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 193, 27))
822+
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 233, 27))
665823

666824
constructor(parts: number) {
667-
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
825+
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 235, 16))
668826

669827
super();
670-
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
828+
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 220, 1))
671829

672830
this.set("parts", parts);
673-
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
674-
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
675-
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
676-
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
831+
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 227, 5))
832+
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 231, 1))
833+
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 227, 5))
834+
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 235, 16))
677835
}
678836
getParts() {
679-
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 198, 5))
837+
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 238, 5))
680838

681839
return this.get("parts")
682-
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
683-
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
684-
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
840+
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 224, 12))
841+
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 231, 1))
842+
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 224, 12))
685843
}
686844
}
687845

688846
class OtherPerson {
689-
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
847+
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 242, 1))
690848

691849
parts: number;
692-
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 204, 19))
850+
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 244, 19))
693851

694852
constructor(parts: number) {
695-
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
853+
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 246, 16))
696854

697855
setProperty(this, "parts", parts);
698856
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
699-
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
700-
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
857+
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 242, 1))
858+
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 246, 16))
701859
}
702860
getParts() {
703-
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 208, 5))
861+
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 248, 5))
704862

705863
return getProperty(this, "parts")
706864
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
707-
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
865+
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 242, 1))
708866
}
709867
}

0 commit comments

Comments
 (0)