You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionaddressOrThrow(value: unknown){if(typeofvalue!=="object"||value==null)thrownewTypeError();if(!("street"invalue)||typeofvalue.street!=="string")thrownewTypeError();if(!("houseNumber"invalue)||typeofvalue.houseNumber!=="number")thrownewTypeError();returnvalue;}functionaddressOrThrowTG(value: unknown): value is Address{addressOrThrow(value);returntrue;}functionpersonOrThrow(value: unknown){if(typeofvalue!=="object"||value==null)thrownewTypeError();if(!("firstName"invalue)||typeofvalue.firstName!=="string")thrownewTypeError();if(!("lastName"invalue)||typeofvalue.lastName!=="string")thrownewTypeError();if("middleName"invalue&&typeofvalue.middleName!=="string")thrownewTypeError();if(!("addresses"invalue)||!Array.isArray(value.addresses))thrownewTypeError();if(!value.addresses.every(addressOrThrowTG))thrownewTypeError();returnvalue;}typeAddress=ReturnType<typeofaddressOrThrow>;typePerson=ReturnType<typeofpersonOrThrow>;
π Actual behavior
type Address = object & Record<"street", unknown> & Record<"houseNumber", unknown> type Person = object & Record<"firstName", unknown> & Record<"lastName", unknown> & Record<"addresses", unknown>
π Expected behavior
type Address = object & Record<"street", string> & Record<"houseNumber", number> type Person = object & Record<"firstName", string> & Partial<Record<"middleName", string>> & Record<"lastName", string> & Record<"addresses", Address[]>
Activity
RyanCavanaugh commentedon Oct 28, 2022
Anders Hejlsberg (@ahejlsberg) any easy way to make this happen?
arahansen commentedon Nov 29, 2022
Also just ran into this. Here is a playground reproducing the issue.
The above errors in version 4.9.3 but no error in 4.8.4