Index type distributes over intersections too eagerly #61101
Labels
Help Wanted
You can do this
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
π Search Terms
index keyof indexed access deferred deferral instantiation
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250202#code/C4TwDgpgBAaghgGwK4QM4B4AqA+KBeKTAbQGsIQB7AM0IF0BuAKEYHoWpgAnOAO1SoqcAtqihVOFIVABEZEBAAmUCgCMAVhADGwKELhhpHClDhQkPAJYUejUJCgBRAB5c42hwDcIPYKgBiEkIACnAgCBRwCgCy+li4BPDIaOgA3oxQUEQA0lAWPFBy1HQAXITZtFAAZFApHOAQpTkAvkxN2Ey29Y48AI4oKADy6lrAWA5CFsDAip7eOhAu3gqitXYNUEESkJygWeRQbfg16VBsUJqcEHDTomASTiC6EMAAFhTLJxATwKVpGRnZXL5TDjSbTBSzHxEaRraS0WilAAUJ3+UDAoXCkVKA2+Y2+4MhOmqq3qjQOABoZLDsOSUVAAJT4XAeCgWBRMDItRhczr2ZxaPFgxRQBbTHjLGp1SClTYUba7faHAjIjLeHqlBy9foQIYabSCqaKGmMRl4Zms9nMBRaBBwS5iczaKz5C5XaYAZWAgggBvB2ER1qoeUmzt+n2+qDDqMBeQK5CKIPxigRUER6LCEQUpUTQoU5VN5rZHIOxYWWg1TgFzlc7i8Pn8gRCGciMTAvqN7W59NKvBAHVd1wgnu9iL+IojUf+eQHqEUSIA+r8zGAAEIgUo8JBCFQQTgHAs1Jq01HWmdz1OLyUKCgAdx4a43W53e6aB5SR5OH9Vlc0SLVb7pNUADovkmIDp0uOBZwUUc6QyJBV3XGQVDgAAvPIAHM4GkSkzleCxRFQN4kAQJRdwkTgAEI6VfDpUU0axUB0Kh8gIYDQOAcCeDPS1UTOf4AD0AH5mD49h8NEAioDUJAmJMc45UeIobxea5clEBQCLAW15CUKCoAAA3Y74uJ4gyAHJRDWOkGL4eYnDcYB3TgIQIEweoAEFUA8lQKC8JE4LRDFM2xXFAoyWoEIfKBN23XcDiqSU1lKaQIKuaDDCaRKSWlGQ0qgxRMuPVF-hheppEC41UQPFk2SORE3x5VEFkc5zXPcyAvJ8vyIFgkrl2i6QUPQngsJw05xJeKTrGgcjBFEBjOEubQEBAGj6WLD9aMYIA
π» Code
π Actual behavior
There is no error on the annotated call
π Expected behavior
It should error
Additional information about the issue
keyof (T & { type: K })
gets normalized tokeyof T & "type"
Exclude<X, "type">
(withinOmit
) is left asExclude<keyof T, "type">
.T
gets instantiated withExtractEventsFromPayloadMap<{ increased: { upBy: number; }; decreased: { downBy: number; }; }
keyof ...
returns only shared keys of this uniontype
so thisExclude
gets computed asnever
(Exclude<"type", "type">
)enq.emit.increased
gets computed as just{}
(from{ [K in never]: ... }
)The text was updated successfully, but these errors were encountered: