Skip to content
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

WeakMap keys require no primitive type constraint #2057

Closed
srenault opened this issue Feb 17, 2015 · 3 comments
Closed

WeakMap keys require no primitive type constraint #2057

srenault opened this issue Feb 17, 2015 · 3 comments
Labels
Bug A bug in TypeScript By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Revisit An issue worth coming back to

Comments

@srenault
Copy link

The type checker shouldn't accept this:

var map = new WeakMap();
map.set('foo', 'bar');

A key must be of type "Object".

@danquirk danquirk added the Bug A bug in TypeScript label Feb 17, 2015
@danquirk
Copy link
Member

The construct signature for WeakMap at the moment is:

new <K, V>(): WeakMap<K, V>;

which is why this is allowed. We don't currently have a way to specify that K must be an object type but not a primitive, but such a feature has been suggested in #1809.

@danquirk danquirk changed the title WeekMap WeakMap Feb 17, 2015
@danquirk danquirk changed the title WeakMap WeakMap keys require no primitive type constraint Feb 17, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Mar 11, 2015

We currently do not have a way to type that. if and when #1809 is available, we should revisit this bug.

@mhegazy mhegazy closed this as completed Mar 11, 2015
@mhegazy mhegazy added By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Revisit An issue worth coming back to labels Mar 11, 2015
@cpcallen
Copy link

Looks like #1809 is available. Should this be revisited? (Or if done in the mean time, have the Revisit tag removed?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Revisit An issue worth coming back to
Projects
None yet
Development

No branches or pull requests

4 participants