GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Type inference on tuple intersection types broken · Issue #59521 · microsoft/TypeScript Open Labels Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases Milestone Description🔎 Search Termsinfer tuple intersection 🕗 Version & Regression Information
⏯ Playground Link💻 Codetype Target = [number, string, boolean] & { att: string; }; type A = Readonly<Target>; // wishful thinking type Head1 = Target extends [infer H, ...infer Tail] ? H : never; // doesn't work type Head2 = Target extends [infer H, ...any[]] ? H : never; // works type Tail1 = Target extends [infer H, ...infer Tail] ? Tail : never; // doesn't work type Tail2 = Target extends [any, ...infer Tail] ? Tail : never; // doesn't work type ReverseHead1 = Target extends [...infer RTail, infer RH] ? RH : never; // doesn't work type ReverseHead2 = Target extends [...any[], infer RH] ? RH : never; // doesn't work type ReverseTail1 = Target extends [...infer RTail, infer RH] ? RTail : never; // doesn't work type ReverseTail2 = Target extends [...infer RTail, any] ? RTail : never; // doesn't work 🙁 Actual behaviorDoesn't work 🙂 Expected behaviorWorks Additional information about the issueI would expect In any case, I thought, whatever, I'll do it myself with some infers... but it looks like I won't be able to do the general case because infers break on tuple types that are intersected. So, just letting you know in case you care... here are some unexpected behaviors ✌️ Activity
MetadataMetadataAssigneesLabelsDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |