-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{ a: string } can not be assigned to Partial<Omit<P, "a"> & { a: string }> #43846
Comments
Reminds me of #28884, where the compiler doesn't currently perform the kind of analysis needed to verify such assignability for types depending on unresolved generics type parameters like |
Another issue with strange (but mostly explained?) |
The type system doesn't take |
Thanks for the explanation. Is that why I cannot "fill in" the omitted properties of For example: interface MyType {
path: string
params: Record<string, string>
}
function getMyTypeCreator<T extends MyType>(initial: Omit<T, 'params'>) {
return (params: T['params']): T => ({
...initial,
params,
})
// Error: Type 'Omit<T, "params"> & { params: T["params"]; }' is not assignable to type 'T'.
// 'Omit<T, "params"> & { params: T["params"]; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyType'.(2322)
} |
Exactly, yes |
Bug Report
π Search Terms
extends, Partial
π Version & Regression Information
4.2.4
β― Playground Link
Playground link with relevant code
π» Code
according #43125, { a: "string" } can not be assigned to Partial<P> which P extends { a: string } because P.a may extends from string. So I make 2 new version:
But still not work.
π Actual behavior
At least { a: string } should be assigned to Partial<Omit<P, "a"> & { a: string }>
π Expected behavior
It not work.
The text was updated successfully, but these errors were encountered: