-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use generic defaults for "empty" constructors of Array, Map, Set #29786
Comments
This is working as intended. JS always returns the RHS, which you can observe by making The real problem is that interface MapConstructor {
- new(): Map<any, any>;
- new<K, V>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
+ new<K = any, V = any>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
// ...
} |
It's worth noting that array literals are special-cased to work according to my expectations in the OP. |
It’s not possible to make this work without breaking other things, primarily preventing people from writing |
TypeScript Version: 3.4.0-dev.20190202
Search Terms:
Code
Expected behavior: Infer
foo
to beMap<object, string>
Actual behavior: Infers
foo
to beMap<any, any>
Playground Link: Click here
Related Issues: Maybe #7782
The text was updated successfully, but these errors were encountered: