mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(54694): Class incorrectly implements interface generated with template string literal mapped type (#54715)
This commit is contained in:
+2
-20
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user