-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Cannot extract/filter property keys from this. #29413
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
Comments
That step of logic isn't correct. class Example2 extends Example {
a: 10;
b: number;
} which means |
@RyanCavanaugh Correct. That's the desired behavior I'm looking for when extending the base class. Still, the type seems unable to resolve itself. Is there a term for that? |
The type is resolved - it's generic, since |
@weswigham Well, shouldn't it be safe to assume that in my example the type of |
I think this is essentially the same as #29225.
type Example<T extends string> = T extends string ? "yes" : "no"; This example is "stuck" until you actually instantiate it with a particular The result in your case is that you get a "stuck" type that cannot be simplified, and therefore the compiler can't determine that it actually has the key you're expecting (because the conditional type that contains the The reason things are this way is because of the following example: type Example2<T extends {x: any}> = T extends {x: string} ? "yes" : "no" The problem here is that if I think it may be possible to lift this design limitation, but only in some cases (where the constraint-bound can be fully simplified with no "stuck" mapped or conditional types, where no " |
@Nathan-Fenner I appreciate the reference and explanation. I'd love to see some of the more straightforward constraints handled more thoroughly, but I understand why the design limitation is there. I mean, I'd really love to see that. I have been working on an api that depends on being able to conditionally map against |
TypeScript Version: 3.3.0-dev.201xxxxx (tested with
typescript@next
-v: 3.3.0-dev.20190112)Search Terms: keyof this, mapped this type, filter this properties, filter this property keys
Code
Expected behavior:
The type of
pickNumericProps(this)
should be{ a: number, c: 11 }
.Actual behavior:
The type of
pickNumericProps(this)
is unresolved (? not sure how to describe it).Playground Link: Playground link
Related Issues:
Couldn't find any
The text was updated successfully, but these errors were encountered: