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 assertion regression in TypeScript 5.7 · Issue #60573 · microsoft/TypeScript Closed Labels Milestone Description🔎 Search Terms"typescript 5.7", "type assertions", "casting", "regression", "zod", "tsc" 🕗 Version & Regression Information
⏯ Playground Link💻 Codetype Wrapper<T> = { _type: T } function stringWrapper(): Wrapper<string> { return { _type: "" } } function objWrapper<T extends Record<string, Wrapper<any>>>(obj: T): Wrapper<T> { return { _type: obj } } const value = objWrapper({ prop1: stringWrapper() as Wrapper<"hello"> }) type Unwrap<T extends Wrapper<any>> = T['_type'] extends Record<string, Wrapper<any>> ? { [Key in keyof T['_type']]: Unwrap<T['_type'][Key]> } : T['_type'] type Test = Unwrap<typeof value> 🙁 Actual behaviorThe type of This is wrong because the 🙂 Expected behaviorThe type of Additional information about the issueThis issue seems related to the inline type assertion on line 14. The inference is corrected if the type assertion happens on a separate line, such as: const strWrapper = stringWrapper() as Wrapper<"hello">; const value = objWrapper({ prop1: strWrapper }); type Test = Unwrap<typeof value> // ^? type Test = { prop1: "hello"; } This is a simplified version of an issue I'm seeing with some Zod schemas after upgrading to TypeScript 5.7. Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue 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. |