added object name to TS2571, 2531, 2532 and 2533

This commit is contained in:
Alexis Cheron
2022-07-05 19:48:31 +04:00
parent 3dbe62e3f0
commit f7d0f12e0a
2 changed files with 16 additions and 9 deletions
+12 -5
View File
@@ -28910,10 +28910,13 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
}
function reportObjectPossiblyNullOrUndefinedError(node: Node, facts: TypeFacts) {
const source = getSourceFileOfNode(node);
const text = getSourceTextOfNodeFromSourceFile(source, node);
error(node, facts & TypeFacts.IsUndefined ? facts & TypeFacts.IsNull ?
Diagnostics.Object_is_possibly_null_or_undefined :
Diagnostics.Object_is_possibly_undefined :
Diagnostics.Object_is_possibly_null
Diagnostics._0_is_possibly_null_or_undefined :
Diagnostics._0_is_possibly_undefined :
Diagnostics._0_is_possibly_null,
text
);
}
@@ -28931,7 +28934,9 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
reportError: (node: Node, facts: TypeFacts) => void
): Type {
if (strictNullChecks && type.flags & TypeFlags.Unknown) {
error(node, Diagnostics.Object_is_of_type_unknown);
const source = getSourceFileOfNode(node);
const text = getSourceTextOfNodeFromSourceFile(source, node);
error(node, Diagnostics._0_is_of_type_unknown, text);
return errorType;
}
const facts = getTypeFacts(type);
@@ -28948,9 +28953,11 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
}
function checkNonNullNonVoidType(type: Type, node: Node): Type {
const source = getSourceFileOfNode(node);
const text = getSourceTextOfNodeFromSourceFile(source, node);
const nonNullType = checkNonNullType(type, node);
if (nonNullType.flags & TypeFlags.Void) {
error(node, Diagnostics.Object_is_possibly_undefined);
error(node, Diagnostics._0_is_possibly_undefined, text);
}
return nonNullType;
}
+4 -4
View File
@@ -2416,15 +2416,15 @@
"category": "Error",
"code": 2530
},
"Object is possibly 'null'.": {
"'{0}' is possibly 'null'.": {
"category": "Error",
"code": 2531
},
"Object is possibly 'undefined'.": {
"'{0}' is possibly 'undefined'.": {
"category": "Error",
"code": 2532
},
"Object is possibly 'null' or 'undefined'.": {
"'{0}' is possibly 'null' or 'undefined'.": {
"category": "Error",
"code": 2533
},
@@ -2561,7 +2561,7 @@
"category": "Error",
"code": 2570
},
"Object is of type 'unknown'.": {
"'{0}' is of type 'unknown'.": {
"category": "Error",
"code": 2571
},