mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Separate error messages for 'null', 'undefined', or both.
This commit is contained in:
@@ -9554,8 +9554,14 @@ namespace ts {
|
||||
|
||||
function checkNonNullExpression(node: Expression | QualifiedName) {
|
||||
const type = checkExpression(node);
|
||||
if (strictNullChecks && getNullableKind(type)) {
|
||||
error(node, Diagnostics.Object_is_possibly_null_or_undefined);
|
||||
if (strictNullChecks) {
|
||||
const kind = getNullableKind(type);
|
||||
if (kind) {
|
||||
error(node, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ?
|
||||
Diagnostics.Object_is_possibly_null_or_undefined :
|
||||
Diagnostics.Object_is_possibly_undefined :
|
||||
Diagnostics.Object_is_possibly_null);
|
||||
}
|
||||
return getNonNullableType(type);
|
||||
}
|
||||
return type;
|
||||
|
||||
@@ -1727,10 +1727,18 @@
|
||||
"category": "Error",
|
||||
"code": 2530
|
||||
},
|
||||
"Object is possibly 'null' or 'undefined'.": {
|
||||
"Object is possibly 'null'.": {
|
||||
"category": "Error",
|
||||
"code": 2531
|
||||
},
|
||||
"Object is possibly 'undefined'.": {
|
||||
"category": "Error",
|
||||
"code": 2532
|
||||
},
|
||||
"Object is possibly 'null' or 'undefined'.": {
|
||||
"category": "Error",
|
||||
"code": 2533
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
|
||||
Reference in New Issue
Block a user