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
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)});
Bug Report
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
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
(see comment below for a simpler repro: #47865 (comment))
🙁 Actual behavior
Using object spread in a function parameter produces an unusable type in TS 4.6.1-rc.
The type of
slugs
in the first example is:in TypeScript 4.6.0-beta but:
in TypeScript 4.6.1-rc.
These are both the same (assuming
T = "/path/:foo/to/:bar"
) but the latter doesn't let me read any properties off of it.🙂 Expected behavior
I should be able to read
bar
off ofslugs
.The text was updated successfully, but these errors were encountered: