We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
generic partial
4.2.2
Playground Link
type FunctionType<T> = { func(arg: Partial<T>): any; }; type StringType = { str: string; }; function example<T extends StringType>(ft: FunctionType<T>) { ft.func({ str: "" }); }
The code doesn't compile because ft.func({ str: "" }) gives the following error
ft.func({ str: "" })
Argument of type '{ str: ""; }' is not assignable to parameter of type 'Partial<T>'.
I would expect the code to compile
The text was updated successfully, but these errors were encountered:
The type "abc" extends the type string. The type { str: "abc" } extends the type { str: string }. "" is not a valid value for the type "abc".
"abc"
string
{ str: "abc" }
{ str: string }
""
This is unrelated to Partial<T>. It's due to your misunderstanding of generics.
Partial<T>
Here's a simplified example of the problem at hand:
function example<T extends string>(): T { return ""; } example<"abc">();
Sorry, something went wrong.
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
π Search Terms
generic partial
π Version & Regression Information
4.2.2
β― Playground Link
Playground Link
π» Code
π Actual behavior
The code doesn't compile because
ft.func({ str: "" })
gives the following errorπ Expected behavior
I would expect the code to compile
The text was updated successfully, but these errors were encountered: