mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
fix(41227): change message about incorrect property access with possible replacement with static access (#41275)
This commit is contained in:
@@ -13910,7 +13910,8 @@ namespace ts {
|
||||
}
|
||||
else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
|
||||
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
|
||||
error(accessExpression, Diagnostics.Property_0_is_a_static_member_of_type_1, propName as string, typeToString(objectType));
|
||||
const typeName = typeToString(objectType);
|
||||
error(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName as string, typeName, typeName + "[" + getTextOfNode(accessExpression.argumentExpression) + "]");
|
||||
}
|
||||
else if (getIndexTypeOfType(objectType, IndexKind.Number)) {
|
||||
error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
|
||||
@@ -26038,7 +26039,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (typeHasStaticProperty(propNode.escapedText, containingType)) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_is_a_static_member_of_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
const propName = declarationNameToString(propNode);
|
||||
const typeName = typeToString(containingType);
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "." + propName);
|
||||
}
|
||||
else {
|
||||
const promisedType = getPromisedTypeOfPromise(containingType);
|
||||
|
||||
@@ -2293,7 +2293,7 @@
|
||||
"category": "Error",
|
||||
"code": 2575
|
||||
},
|
||||
"Property '{0}' is a static member of type '{1}'.": {
|
||||
"Property '{0}' does not exist on type '{1}'. Did you mean to access the static member '{2}' instead?": {
|
||||
"category": "Error",
|
||||
"code": 2576
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user