Closed
Description
Bug Report
π Search Terms
extends, Partial
π Version & Regression Information
4.2.4
β― Playground Link
Playground link with relevant code
π» Code
// We can quickly address your report if:
// - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
// - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
// - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
// - We have to pare too much extraneous code.
// - We have to clone a large repo and validate that the problem isn't elsewhere.
// - The sample is confusing or doesn't clearly demonstrate what's wrong.
type FunctionType<T> = {
func(arg: Partial<T>): any;
};
type StringType = {
str: string;
};
type T = { str: "abc" }
type A = T & StringType;
type B = Omit<T, "str"> & StringType;
const a: Partial<A> = { str: "" }; // not ok.
const b: Partial<B> = { str: "" }; // ok.
function example<T extends Record<string, any>>(ft: FunctionType<Omit<T, "str"> & StringType>) {
ft.func({ str: "" }); // not ok.
}
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:
- T & { a: string }
- Omit<T, "a"> & { a: string }.
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.