fix(54694): Class incorrectly implements interface generated with template string literal mapped type (#54715)

This commit is contained in:
Oleksandr T
2023-07-20 13:51:32 -07:00
committed by GitHub
parent 5128e06a9d
commit 2136bef652
5 changed files with 67 additions and 23 deletions
+2 -20
View File
@@ -335,6 +335,7 @@ import {
getParseTreeNode,
getPropertyAssignmentAliasLikeExpression,
getPropertyNameForPropertyNameNode,
getPropertyNameFromType,
getResolutionDiagnostic,
getResolutionModeOverrideForClause,
getResolvedExternalModuleName,
@@ -729,6 +730,7 @@ import {
isTypeQueryNode,
isTypeReferenceNode,
isTypeReferenceType,
isTypeUsableAsPropertyName,
isUMDExportSymbol,
isValidBigIntString,
isValidESSymbolDeclaration,
@@ -12286,13 +12288,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return type as InterfaceTypeWithDeclaredMembers;
}
/**
* Indicates whether a type can be used as a property name.
*/
function isTypeUsableAsPropertyName(type: Type): type is StringLiteralType | NumberLiteralType | UniqueESSymbolType {
return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique);
}
/**
* Indicates whether a declaration name is definitely late-bindable.
* A declaration name is only late-bindable if:
@@ -12338,19 +12333,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return isDynamicName(node) && !isLateBindableName(node);
}
/**
* Gets the symbolic name for a member from its type.
*/
function getPropertyNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String {
if (type.flags & TypeFlags.UniqueESSymbol) {
return (type as UniqueESSymbolType).escapedName;
}
if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
return escapeLeadingUnderscores("" + (type as StringLiteralType | NumberLiteralType).value);
}
return Debug.fail();
}
/**
* Adds a declaration to a late-bound dynamic member. This performs the same function for
* late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound
+25
View File
@@ -416,6 +416,7 @@ import {
noop,
normalizePath,
NoSubstitutionTemplateLiteral,
NumberLiteralType,
NumericLiteral,
ObjectFlags,
ObjectFlagsType,
@@ -494,6 +495,7 @@ import {
stringContains,
StringLiteral,
StringLiteralLike,
StringLiteralType,
stringToToken,
SuperCall,
SuperExpression,
@@ -544,6 +546,7 @@ import {
TypeReferenceNode,
unescapeLeadingUnderscores,
UnionOrIntersectionTypeNode,
UniqueESSymbolType,
UserPreferences,
ValidImportTypeNode,
VariableDeclaration,
@@ -10313,3 +10316,25 @@ export function getTextOfJsxNamespacedName(node: JsxNamespacedName) {
export function intrinsicTagNameToString(node: Identifier | JsxNamespacedName) {
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
}
/**
* Indicates whether a type can be used as a property name.
* @internal
*/
export function isTypeUsableAsPropertyName(type: Type): type is StringLiteralType | NumberLiteralType | UniqueESSymbolType {
return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique);
}
/**
* Gets the symbolic name for a member from its type.
* @internal
*/
export function getPropertyNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String {
if (type.flags & TypeFlags.UniqueESSymbol) {
return (type as UniqueESSymbolType).escapedName;
}
if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
return escapeLeadingUnderscores("" + (type as StringLiteralType | NumberLiteralType).value);
}
return Debug.fail();
}