-
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
Omit properties from generic type which set by default and have extend #33484
Comments
Operations like |
@RyanCavanaugh Maybe you should indicate this in the documentation so as not to mislead beginners like me? I expected that TypeScript would understand that a universal type expanding by a certain interface would be able to get keys from it. Expected behavior was that omit will get all keys from Bar because T is extending him |
@RyanCavanaugh I just want to note that if you extend a given class with a subclass of some kind and pass in a prepared object that is expanded by the Bar interface, then it begins to understand which keys need to be sorted out. That is, this problem can be fixed with a crutch by increasing the chain of inheritance by 1. You can see that in file index2.ts https://stackblitz.com/edit/typescript-8zyjig |
Which documentation pages had you referred to before logging this? I'm trying to figure out which one to potentially add the information to. |
@RyanCavanaugh what does |
Something seems a little fishy here, because it seems TypeScript is able to properly build a list of a generic type's properties with See for example this example from https://stackoverflow.com/questions/64920228/using-typescript-exclude-with-generic-type |
TypeScript Version: 3.6.3
Omit extended generic type, type has no properties in common with type Pick Exclude
Expected behavior:
exclude the "type" property, and get in the available properties for the parameter "param" id and the rest that will be present in the interface because Bar is default param for T
Actual behavior:
Error "Type 'type' has no properties in common with type Pick <T, Exclude , 'type'>"
Playground Link:
https://stackblitz.com/edit/typescript-8zyjig
Related Issues: #24791
The text was updated successfully, but these errors were encountered: