Skip to content

Commit 8cb515a

Browse files
committed
Add members for numeric and symbol named properties in mapped types
1 parent 6c60f7e commit 8cb515a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/compiler/checker.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6035,7 +6035,7 @@ namespace ts {
60356035
(<TypeOperatorNode>constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) {
60366036
// We have a { [P in keyof T]: X }
60376037
for (const prop of getPropertiesOfType(modifiersType)) {
6038-
addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include), undefined, prop);
6038+
addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include), /*_index*/ undefined, prop);
60396039
}
60406040
if (modifiersType.flags & TypeFlags.Any || getIndexInfoOfType(modifiersType, IndexKind.String)) {
60416041
addMemberForKeyType(stringType);
@@ -6062,7 +6062,7 @@ namespace ts {
60626062
const propType = instantiateType(templateType, templateMapper);
60636063
// If the current iteration type constituent is a string literal type, create a property.
60646064
// Otherwise, for type string create a string index signature.
6065-
if (t.flags & TypeFlags.StringLiteral) {
6065+
if (t.flags & TypeFlags.StringOrNumberLiteralOrUnique) {
60666066
const propName = getLateBoundNameFromType(t as LiteralType);
60676067
const modifiersProp = getPropertyOfType(modifiersType, propName);
60686068
const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional ||
@@ -6511,7 +6511,7 @@ namespace ts {
65116511
let declarations: Declaration[];
65126512
let commonType: Type;
65136513
let nameType: Type;
6514-
let propTypes: Type[] = [];
6514+
const propTypes: Type[] = [];
65156515
let first = true;
65166516
for (const prop of props) {
65176517
declarations = addRange(declarations, prop.declarations);
@@ -8146,7 +8146,7 @@ namespace ts {
81468146
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? keyofConstraintType :
81478147
keyofStringsOnly ? getLiteralTypeFromPropertyNames(type, TypeFlags.StringLiteral) :
81488148
getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, TypeFlags.StringLiteral | TypeFlags.UniqueESSymbol)]) :
8149-
getLiteralTypeFromPropertyNames(type, TypeFlags.StringLiteral | TypeFlags.NumberLiteral | TypeFlags.UniqueESSymbol);
8149+
getLiteralTypeFromPropertyNames(type, TypeFlags.StringOrNumberLiteralOrUnique);
81508150
}
81518151

81528152
function getExtractStringType(type: Type) {

0 commit comments

Comments
 (0)