@@ -384,3 +384,175 @@ function ff3(value: string | string[] | { [index: number]: boolean, length: numb
384
384
>value : Symbol(value, Decl(strictSubtypeAndNarrowing.ts, 153, 13))
385
385
}
386
386
387
+ // Repro from comment in #52984
388
+
389
+ type DistributedKeyOf<T> = T extends unknown ? keyof T : never;
390
+ >DistributedKeyOf : Symbol(DistributedKeyOf, Decl(strictSubtypeAndNarrowing.ts, 160, 1))
391
+ >T : Symbol(T, Decl(strictSubtypeAndNarrowing.ts, 164, 22))
392
+ >T : Symbol(T, Decl(strictSubtypeAndNarrowing.ts, 164, 22))
393
+ >T : Symbol(T, Decl(strictSubtypeAndNarrowing.ts, 164, 22))
394
+
395
+ type NarrowByKeyValue<ObjT, KeyT extends PropertyKey, ValueT> = ObjT extends unknown
396
+ >NarrowByKeyValue : Symbol(NarrowByKeyValue, Decl(strictSubtypeAndNarrowing.ts, 164, 63))
397
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 166, 22))
398
+ >KeyT : Symbol(KeyT, Decl(strictSubtypeAndNarrowing.ts, 166, 27))
399
+ >PropertyKey : Symbol(PropertyKey, Decl(lib.es5.d.ts, --, --))
400
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 166, 53))
401
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 166, 22))
402
+
403
+ ? KeyT extends keyof ObjT
404
+ >KeyT : Symbol(KeyT, Decl(strictSubtypeAndNarrowing.ts, 166, 27))
405
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 166, 22))
406
+
407
+ ? ValueT extends ObjT[KeyT]
408
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 166, 53))
409
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 166, 22))
410
+ >KeyT : Symbol(KeyT, Decl(strictSubtypeAndNarrowing.ts, 166, 27))
411
+
412
+ ? ObjT & Readonly<Record<KeyT, ValueT>>
413
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 166, 22))
414
+ >Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
415
+ >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
416
+ >KeyT : Symbol(KeyT, Decl(strictSubtypeAndNarrowing.ts, 166, 27))
417
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 166, 53))
418
+
419
+ : never
420
+ : never
421
+ : never;
422
+
423
+ type NarrowByDeepValue<ObjT, DeepPathT, ValueT> = DeepPathT extends readonly [
424
+ >NarrowByDeepValue : Symbol(NarrowByDeepValue, Decl(strictSubtypeAndNarrowing.ts, 172, 12))
425
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
426
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 174, 28))
427
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 174, 39))
428
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 174, 28))
429
+
430
+ infer Head extends DistributedKeyOf<ObjT>,
431
+ >Head : Symbol(Head, Decl(strictSubtypeAndNarrowing.ts, 175, 9))
432
+ >DistributedKeyOf : Symbol(DistributedKeyOf, Decl(strictSubtypeAndNarrowing.ts, 160, 1))
433
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
434
+
435
+ ]
436
+ ? NarrowByKeyValue<ObjT, Head, ValueT>
437
+ >NarrowByKeyValue : Symbol(NarrowByKeyValue, Decl(strictSubtypeAndNarrowing.ts, 164, 63))
438
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
439
+ >Head : Symbol(Head, Decl(strictSubtypeAndNarrowing.ts, 175, 9))
440
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 174, 39))
441
+
442
+ : DeepPathT extends readonly [infer Head extends DistributedKeyOf<ObjT>, ...infer Rest]
443
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 174, 28))
444
+ >Head : Symbol(Head, Decl(strictSubtypeAndNarrowing.ts, 178, 39))
445
+ >DistributedKeyOf : Symbol(DistributedKeyOf, Decl(strictSubtypeAndNarrowing.ts, 160, 1))
446
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
447
+ >Rest : Symbol(Rest, Decl(strictSubtypeAndNarrowing.ts, 178, 85))
448
+
449
+ ? NarrowByKeyValue<ObjT, Head, NarrowByDeepValue<NonNullable<ObjT[Head]>, Rest, ValueT>>
450
+ >NarrowByKeyValue : Symbol(NarrowByKeyValue, Decl(strictSubtypeAndNarrowing.ts, 164, 63))
451
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
452
+ >Head : Symbol(Head, Decl(strictSubtypeAndNarrowing.ts, 178, 39))
453
+ >NarrowByDeepValue : Symbol(NarrowByDeepValue, Decl(strictSubtypeAndNarrowing.ts, 172, 12))
454
+ >NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --))
455
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 174, 23))
456
+ >Head : Symbol(Head, Decl(strictSubtypeAndNarrowing.ts, 178, 39))
457
+ >Rest : Symbol(Rest, Decl(strictSubtypeAndNarrowing.ts, 178, 85))
458
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 174, 39))
459
+
460
+ : never;
461
+
462
+
463
+ declare function doesValueAtDeepPathSatisfy<
464
+ >doesValueAtDeepPathSatisfy : Symbol(doesValueAtDeepPathSatisfy, Decl(strictSubtypeAndNarrowing.ts, 180, 12))
465
+
466
+ ObjT extends object,
467
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 183, 44))
468
+
469
+ const DeepPathT extends ReadonlyArray<number | string>,
470
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 184, 24))
471
+ >ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --))
472
+
473
+ ValueT,
474
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 185, 59))
475
+
476
+ >(
477
+ obj: ObjT,
478
+ >obj : Symbol(obj, Decl(strictSubtypeAndNarrowing.ts, 187, 2))
479
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 183, 44))
480
+
481
+ deepPath: DeepPathT,
482
+ >deepPath : Symbol(deepPath, Decl(strictSubtypeAndNarrowing.ts, 188, 14))
483
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 184, 24))
484
+
485
+ predicate: (arg: unknown) => arg is ValueT,
486
+ >predicate : Symbol(predicate, Decl(strictSubtypeAndNarrowing.ts, 189, 24))
487
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 190, 16))
488
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 190, 16))
489
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 185, 59))
490
+
491
+ ): obj is NarrowByDeepValue<ObjT, DeepPathT, ValueT>;
492
+ >obj : Symbol(obj, Decl(strictSubtypeAndNarrowing.ts, 187, 2))
493
+ >NarrowByDeepValue : Symbol(NarrowByDeepValue, Decl(strictSubtypeAndNarrowing.ts, 172, 12))
494
+ >ObjT : Symbol(ObjT, Decl(strictSubtypeAndNarrowing.ts, 183, 44))
495
+ >DeepPathT : Symbol(DeepPathT, Decl(strictSubtypeAndNarrowing.ts, 184, 24))
496
+ >ValueT : Symbol(ValueT, Decl(strictSubtypeAndNarrowing.ts, 185, 59))
497
+
498
+
499
+ type Foo = {value: {type: 'A'}; a?: number} | {value: {type: 'B'}; b?: number};
500
+ >Foo : Symbol(Foo, Decl(strictSubtypeAndNarrowing.ts, 191, 53))
501
+ >value : Symbol(value, Decl(strictSubtypeAndNarrowing.ts, 194, 12))
502
+ >type : Symbol(type, Decl(strictSubtypeAndNarrowing.ts, 194, 20))
503
+ >a : Symbol(a, Decl(strictSubtypeAndNarrowing.ts, 194, 31))
504
+ >value : Symbol(value, Decl(strictSubtypeAndNarrowing.ts, 194, 47))
505
+ >type : Symbol(type, Decl(strictSubtypeAndNarrowing.ts, 194, 55))
506
+ >b : Symbol(b, Decl(strictSubtypeAndNarrowing.ts, 194, 66))
507
+
508
+ declare function isA(arg: unknown): arg is 'A';
509
+ >isA : Symbol(isA, Decl(strictSubtypeAndNarrowing.ts, 194, 79))
510
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 196, 21))
511
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 196, 21))
512
+
513
+ declare function isB(arg: unknown): arg is 'B';
514
+ >isB : Symbol(isB, Decl(strictSubtypeAndNarrowing.ts, 196, 47))
515
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 197, 21))
516
+ >arg : Symbol(arg, Decl(strictSubtypeAndNarrowing.ts, 197, 21))
517
+
518
+ declare function assert(condition: boolean): asserts condition;
519
+ >assert : Symbol(assert, Decl(strictSubtypeAndNarrowing.ts, 197, 47))
520
+ >condition : Symbol(condition, Decl(strictSubtypeAndNarrowing.ts, 199, 24))
521
+ >condition : Symbol(condition, Decl(strictSubtypeAndNarrowing.ts, 199, 24))
522
+
523
+ function test1(foo: Foo): {value: {type: 'A'}; a?: number} {
524
+ >test1 : Symbol(test1, Decl(strictSubtypeAndNarrowing.ts, 199, 63))
525
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 201, 15))
526
+ >Foo : Symbol(Foo, Decl(strictSubtypeAndNarrowing.ts, 191, 53))
527
+ >value : Symbol(value, Decl(strictSubtypeAndNarrowing.ts, 201, 27))
528
+ >type : Symbol(type, Decl(strictSubtypeAndNarrowing.ts, 201, 35))
529
+ >a : Symbol(a, Decl(strictSubtypeAndNarrowing.ts, 201, 46))
530
+
531
+ assert(doesValueAtDeepPathSatisfy(foo, ['value', 'type'], isA));
532
+ >assert : Symbol(assert, Decl(strictSubtypeAndNarrowing.ts, 197, 47))
533
+ >doesValueAtDeepPathSatisfy : Symbol(doesValueAtDeepPathSatisfy, Decl(strictSubtypeAndNarrowing.ts, 180, 12))
534
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 201, 15))
535
+ >isA : Symbol(isA, Decl(strictSubtypeAndNarrowing.ts, 194, 79))
536
+
537
+ return foo;
538
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 201, 15))
539
+ }
540
+
541
+ function test2(foo: Foo): {value: {type: 'A'}; a?: number} {
542
+ >test2 : Symbol(test2, Decl(strictSubtypeAndNarrowing.ts, 204, 1))
543
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 206, 15))
544
+ >Foo : Symbol(Foo, Decl(strictSubtypeAndNarrowing.ts, 191, 53))
545
+ >value : Symbol(value, Decl(strictSubtypeAndNarrowing.ts, 206, 27))
546
+ >type : Symbol(type, Decl(strictSubtypeAndNarrowing.ts, 206, 35))
547
+ >a : Symbol(a, Decl(strictSubtypeAndNarrowing.ts, 206, 46))
548
+
549
+ assert(!doesValueAtDeepPathSatisfy(foo, ['value', 'type'], isB));
550
+ >assert : Symbol(assert, Decl(strictSubtypeAndNarrowing.ts, 197, 47))
551
+ >doesValueAtDeepPathSatisfy : Symbol(doesValueAtDeepPathSatisfy, Decl(strictSubtypeAndNarrowing.ts, 180, 12))
552
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 206, 15))
553
+ >isB : Symbol(isB, Decl(strictSubtypeAndNarrowing.ts, 196, 47))
554
+
555
+ return foo;
556
+ >foo : Symbol(foo, Decl(strictSubtypeAndNarrowing.ts, 206, 15))
557
+ }
558
+
0 commit comments