You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classMap<T>{set(prop: membersofT,value: any): Map<T>;}
// or with "Value of string literal type as property names" (#6080)
class Map<T>{set<UextendsmembersofT>(prop: U,value: T[U]): Map<T>;}
// Although this might need to have the output of membersof T to be extensible!
DanielRosenwasser
changed the title
Suggestion: interface members as string literal types
Suggestion: type property names as string literal types
Jun 7, 2016
This should be addressed by keyof operator introduced in #11929
mhegazy
added
Fixed
A PR has been merged for this issue
and removed
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
labels
Nov 2, 2016
Consider this interface:
With an operator such as
membersof
we can have this type:Some caveats:
membersof
.The type should turn into:
'foo' | string
. Although I'm not so sure about this.4.
new
and function signature: I think these can be ignored safely:There are many use cases. immutable js is the best one:
Accompanied by #6080 we can have type safety too:
Map would look like this:
This is easier to implementation than #1295.
The text was updated successfully, but these errors were encountered: