-
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
Cannot access properties of type parameter constrainted by 'any' #7700
Comments
The problems seems to be when Simpler repro: function f<T extends any>(x: T) {
// Error "Property 'children does' not exist on type 'T'"
console.log(x.children);
// Error: x has no call signatures
x();
// But the compiler says that these are okay?
new x();
x[100];
x["hello"];
} |
I'm going to say this is a bug, but @RyanCavanaugh and others can weigh in. |
It's behaving according to spec. We should probably just change that language to say "is any or a type parameter constrained to |
The fix is up at #8770 |
I have a problem where if I use a generic function which extends from another generic type, the function parameter's type doesn't seem to be respected.
TypeScript Version:
1.8.9 (current stable)
Code
Expected behavior:
I expect the "displayTree1" function to compile fine, T extends Tree so it can be assumed to have a 'children' property.
Actual behavior:
Compile time error: Property 'children does' not exist on type 'T'.
The text was updated successfully, but these errors were encountered: