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
TypeScript Version: 2.2.2
Also present in the current nightly build 2.3.0-dev.20170423.
Code
interfaceProperties{property1: string;__property2: string;}// As expected, I can make an object satisfying this interfaceconstok: Properties={property1: "",__property2: ""}// As expected, "__property2" is indeed a key of the typetypeKeys=keyofProperties;constk: Keys="__property2";// ok// Unexpected: it cannot be accessed in the type mapping.// Error: "Property '__property2' does not exist on type 'Properties'."typeProperty2Type=Properties["__property2"];// This results in unexpected behavior with Partial and other things that rely on mapped types.constpartial: Partial<Properties>={property1: "",__property2: ""// Error: Object literal may only specify known properties}
Expected behavior:
Regarding Mapped Type semantics, properties prefixed with two underscores behave the same as those without.
Actual behavior:
Properties prefixed with two underscores seem to be present in keyof T, but their corresponding entry is not present in the type mapping T[Key].
Alternatively...
Alternatively, if there's some limitation about double-underscore-prefixed member names I'm not aware of, it would seem acceptable to document that mapped types do not map over properties prefixed with two underscores __, and to have keyof T be consistent with that by not including such properties.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.2.2
Also present in the current nightly build 2.3.0-dev.20170423.
Code
Expected behavior:
Regarding Mapped Type semantics, properties prefixed with two underscores behave the same as those without.
Actual behavior:
Properties prefixed with two underscores seem to be present in
keyof T
, but their corresponding entry is not present in the type mappingT[Key]
.Alternatively...
Alternatively, if there's some limitation about double-underscore-prefixed member names I'm not aware of, it would seem acceptable to document that mapped types do not map over properties prefixed with two underscores
__
, and to havekeyof T
be consistent with that by not including such properties.The text was updated successfully, but these errors were encountered: