We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here's a named book
const NamedBook = Record({ name: String, title: String });
I want to create a type with the id in place of the name, so I can manually do this:
const Book = NamedBook.omit('name').extend({ id: String })
Q: Since I have 15+ runtypes, how can I write a generic function for that? I tried:
function extendWithId<T extends { name: typeof String }>(r: Record<T, false>) { return r.omit('name').extend({ id: String }); } const Book = extendWithId(NamedBook);
but I get:
Argument of type '["name"]' is not assignable to parameter of type '"name"[] extends (keyof T)[] ? (keyof T)[] & "name"[] : never[]'.ts(2345)
The text was updated successfully, but these errors were encountered:
Thanks for reporting, it seems like a limitation of TS's type inference but I'll try to seek for some solution.
Sorry, something went wrong.
No branches or pull requests
Minimal example
Here's a named book
I want to create a type with the id in place of the name, so I can manually do this:
Q: Since I have 15+ runtypes, how can I write a generic function for that? I tried:
but I get:
The text was updated successfully, but these errors were encountered: