mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
change error message for assigning from object
This commit is contained in:
@@ -19,7 +19,7 @@ namespace ts {
|
||||
|
||||
export function getSymbolId(symbol: Symbol): number {
|
||||
if (!symbol.id) {
|
||||
symbol.id = nextSymbolId;
|
||||
symbol.id = nextSymbolId;
|
||||
nextSymbolId++;
|
||||
}
|
||||
|
||||
@@ -6365,7 +6365,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) {
|
||||
const sourceType = typeToString(source);
|
||||
const sourceType = typeToString(source);
|
||||
const targetType = typeToString(target);
|
||||
|
||||
if ((globalStringType === source && stringType === target) ||
|
||||
@@ -6501,6 +6501,8 @@ namespace ts {
|
||||
if (reportErrors) {
|
||||
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) {
|
||||
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
||||
} else if (source.symbol && source.flags & TypeFlags.ObjectType && globalObjectType === source) {
|
||||
reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
||||
}
|
||||
reportRelationError(headMessage, source, target);
|
||||
}
|
||||
|
||||
@@ -1959,6 +1959,10 @@
|
||||
"category": "Error",
|
||||
"code": 2695
|
||||
},
|
||||
"The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?": {
|
||||
"category": "Error",
|
||||
"code": 2696
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Reference in New Issue
Block a user