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
{{ message }}
Repository navigation
Unable to read properties off object spread in generic function parameter (regression with 4.6.1-rc) #47865
I noticed a regression between TypeScript 4.6.0-beta and 4.6.1-rc in my repo where parameters to generic functions that use object spread sometimes get an unusable type.
🔎 Search Terms
object spread
4.6.1-rc
🕗 Version & Regression Information
This changed between versions 4.6.0-beta and 4.6.1-rc.
Here's a simpler repro that doesn't involve template literal types. This (correctly) passes the type checker with TS 4.5.5 but raises a spurious error with 4.6.1-rc.
interfaceSlugs{foo: string;bar: string;}functioncall<Textendsobject>(obj: T,cb: (val: T)=>void){cb(obj);}declareletobj: Slugs;call(obj,({foo, ...rest})=>{console.log(rest.bar);// ~~~ Property 'bar' does not exist on type 'Omit<T, "foo">'. ts(2339)});
Activity
danvk commentedon Feb 14, 2022
Here's a simpler repro that doesn't involve template literal types. This (correctly) passes the type checker with TS 4.5.5 but raises a spurious error with 4.6.1-rc.
RyanCavanaugh commentedon Feb 14, 2022
Bisected to #47337
RyanCavanaugh commentedon Feb 14, 2022
Gabriela Araujo Britto (@gabritto) seems like we're failing to assign the inferred type to
resthere;Tshouldn't be appearing at all