Skip to content

Commit 4fa7eac

Browse files
committed
Accept new baselines
1 parent fe31e70 commit 4fa7eac

8 files changed

Lines changed: 840 additions & 16 deletions

tests/baselines/reference/inKeywordTypeguard(strict=false).errors.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,70 @@ tests/cases/compiler/inKeywordTypeguard.ts(186,21): error TS2322: Type 'T' is no
350350
}
351351
}
352352

353+
function f10(x: { a: unknown }) {
354+
if ("a" in x) {
355+
x;
356+
}
357+
else {
358+
x;
359+
}
360+
}
361+
362+
function f11(x: { a: any }) {
363+
if ("a" in x) {
364+
x;
365+
}
366+
else {
367+
x;
368+
}
369+
}
370+
371+
function f12(x: { a: string }) {
372+
if ("a" in x) {
373+
x;
374+
}
375+
else {
376+
x;
377+
}
378+
}
379+
380+
function f13(x: { a?: string }) {
381+
if ("a" in x) {
382+
x;
383+
}
384+
else {
385+
x;
386+
}
387+
}
388+
389+
function f14(x: { a: string | undefined }) {
390+
if ("a" in x) {
391+
x;
392+
}
393+
else {
394+
x;
395+
}
396+
}
397+
398+
function f15(x: { a?: string | undefined }) {
399+
if ("a" in x) {
400+
x;
401+
}
402+
else {
403+
x;
404+
}
405+
}
406+
353407
// Repro from #50639
354408

355409
function foo<A>(value: A) {
356410
if (typeof value === "object" && value !== null && "prop" in value) {
357411
value; // A & object & Record<"prop", unknown>
358412
}
359413
}
414+
415+
// Repro from #50954
416+
417+
const checkIsTouchDevice = () =>
418+
"ontouchstart" in window || "msMaxTouchPoints" in window.navigator;
360419

tests/baselines/reference/inKeywordTypeguard(strict=false).js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,72 @@ function f9(x: object) {
271271
}
272272
}
273273

274+
function f10(x: { a: unknown }) {
275+
if ("a" in x) {
276+
x;
277+
}
278+
else {
279+
x;
280+
}
281+
}
282+
283+
function f11(x: { a: any }) {
284+
if ("a" in x) {
285+
x;
286+
}
287+
else {
288+
x;
289+
}
290+
}
291+
292+
function f12(x: { a: string }) {
293+
if ("a" in x) {
294+
x;
295+
}
296+
else {
297+
x;
298+
}
299+
}
300+
301+
function f13(x: { a?: string }) {
302+
if ("a" in x) {
303+
x;
304+
}
305+
else {
306+
x;
307+
}
308+
}
309+
310+
function f14(x: { a: string | undefined }) {
311+
if ("a" in x) {
312+
x;
313+
}
314+
else {
315+
x;
316+
}
317+
}
318+
319+
function f15(x: { a?: string | undefined }) {
320+
if ("a" in x) {
321+
x;
322+
}
323+
else {
324+
x;
325+
}
326+
}
327+
274328
// Repro from #50639
275329

276330
function foo<A>(value: A) {
277331
if (typeof value === "object" && value !== null && "prop" in value) {
278332
value; // A & object & Record<"prop", unknown>
279333
}
280334
}
335+
336+
// Repro from #50954
337+
338+
const checkIsTouchDevice = () =>
339+
"ontouchstart" in window || "msMaxTouchPoints" in window.navigator;
281340

282341

283342
//// [inKeywordTypeguard.js]
@@ -533,9 +592,59 @@ function f9(x) {
533592
x[sym];
534593
}
535594
}
595+
function f10(x) {
596+
if ("a" in x) {
597+
x;
598+
}
599+
else {
600+
x;
601+
}
602+
}
603+
function f11(x) {
604+
if ("a" in x) {
605+
x;
606+
}
607+
else {
608+
x;
609+
}
610+
}
611+
function f12(x) {
612+
if ("a" in x) {
613+
x;
614+
}
615+
else {
616+
x;
617+
}
618+
}
619+
function f13(x) {
620+
if ("a" in x) {
621+
x;
622+
}
623+
else {
624+
x;
625+
}
626+
}
627+
function f14(x) {
628+
if ("a" in x) {
629+
x;
630+
}
631+
else {
632+
x;
633+
}
634+
}
635+
function f15(x) {
636+
if ("a" in x) {
637+
x;
638+
}
639+
else {
640+
x;
641+
}
642+
}
536643
// Repro from #50639
537644
function foo(value) {
538645
if (typeof value === "object" && value !== null && "prop" in value) {
539646
value; // A & object & Record<"prop", unknown>
540647
}
541648
}
649+
// Repro from #50954
650+
const checkIsTouchDevice = () => "ontouchstart" in window || "msMaxTouchPoints" in window.navigator;

tests/baselines/reference/inKeywordTypeguard(strict=false).symbols

Lines changed: 121 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,21 +709,134 @@ function f9(x: object) {
709709
}
710710
}
711711

712+
function f10(x: { a: unknown }) {
713+
>f10 : Symbol(f10, Decl(inKeywordTypeguard.ts, 270, 1))
714+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 272, 13))
715+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 272, 17))
716+
717+
if ("a" in x) {
718+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 272, 13))
719+
720+
x;
721+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 272, 13))
722+
}
723+
else {
724+
x;
725+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 272, 13))
726+
}
727+
}
728+
729+
function f11(x: { a: any }) {
730+
>f11 : Symbol(f11, Decl(inKeywordTypeguard.ts, 279, 1))
731+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 281, 13))
732+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 281, 17))
733+
734+
if ("a" in x) {
735+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 281, 13))
736+
737+
x;
738+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 281, 13))
739+
}
740+
else {
741+
x;
742+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 281, 13))
743+
}
744+
}
745+
746+
function f12(x: { a: string }) {
747+
>f12 : Symbol(f12, Decl(inKeywordTypeguard.ts, 288, 1))
748+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 290, 13))
749+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 290, 17))
750+
751+
if ("a" in x) {
752+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 290, 13))
753+
754+
x;
755+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 290, 13))
756+
}
757+
else {
758+
x;
759+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 290, 13))
760+
}
761+
}
762+
763+
function f13(x: { a?: string }) {
764+
>f13 : Symbol(f13, Decl(inKeywordTypeguard.ts, 297, 1))
765+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 299, 13))
766+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 299, 17))
767+
768+
if ("a" in x) {
769+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 299, 13))
770+
771+
x;
772+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 299, 13))
773+
}
774+
else {
775+
x;
776+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 299, 13))
777+
}
778+
}
779+
780+
function f14(x: { a: string | undefined }) {
781+
>f14 : Symbol(f14, Decl(inKeywordTypeguard.ts, 306, 1))
782+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 308, 13))
783+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 308, 17))
784+
785+
if ("a" in x) {
786+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 308, 13))
787+
788+
x;
789+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 308, 13))
790+
}
791+
else {
792+
x;
793+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 308, 13))
794+
}
795+
}
796+
797+
function f15(x: { a?: string | undefined }) {
798+
>f15 : Symbol(f15, Decl(inKeywordTypeguard.ts, 315, 1))
799+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 317, 13))
800+
>a : Symbol(a, Decl(inKeywordTypeguard.ts, 317, 17))
801+
802+
if ("a" in x) {
803+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 317, 13))
804+
805+
x;
806+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 317, 13))
807+
}
808+
else {
809+
x;
810+
>x : Symbol(x, Decl(inKeywordTypeguard.ts, 317, 13))
811+
}
812+
}
813+
712814
// Repro from #50639
713815

714816
function foo<A>(value: A) {
715-
>foo : Symbol(foo, Decl(inKeywordTypeguard.ts, 270, 1))
716-
>A : Symbol(A, Decl(inKeywordTypeguard.ts, 274, 13))
717-
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 274, 16))
718-
>A : Symbol(A, Decl(inKeywordTypeguard.ts, 274, 13))
817+
>foo : Symbol(foo, Decl(inKeywordTypeguard.ts, 324, 1))
818+
>A : Symbol(A, Decl(inKeywordTypeguard.ts, 328, 13))
819+
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 328, 16))
820+
>A : Symbol(A, Decl(inKeywordTypeguard.ts, 328, 13))
719821

720822
if (typeof value === "object" && value !== null && "prop" in value) {
721-
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 274, 16))
722-
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 274, 16))
723-
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 274, 16))
823+
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 328, 16))
824+
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 328, 16))
825+
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 328, 16))
724826

725827
value; // A & object & Record<"prop", unknown>
726-
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 274, 16))
828+
>value : Symbol(value, Decl(inKeywordTypeguard.ts, 328, 16))
727829
}
728830
}
729831

832+
// Repro from #50954
833+
834+
const checkIsTouchDevice = () =>
835+
>checkIsTouchDevice : Symbol(checkIsTouchDevice, Decl(inKeywordTypeguard.ts, 336, 5))
836+
837+
"ontouchstart" in window || "msMaxTouchPoints" in window.navigator;
838+
>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
839+
>window.navigator : Symbol(navigator, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
840+
>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
841+
>navigator : Symbol(navigator, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
842+

0 commit comments

Comments
 (0)