Skip to content

Commit 155ee4b

Browse files
committed
Better error message
1 parent 2913cb0 commit 155ee4b

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4698,7 +4698,7 @@ namespace ts {
46984698
for (let prop of getPropertiesOfObjectType(source)) {
46994699
if (!isKnownProperty(target, prop.name)) {
47004700
if (reportErrors) {
4701-
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target));
4701+
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
47024702
}
47034703
return true;
47044704
}

src/compiler/diagnosticInformationMap.generated.ts

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ namespace ts {
254254
Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." },
255255
Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." },
256256
Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." },
257+
Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: DiagnosticCategory.Error, key: "Object literal may only specify known properties and '{0}' does not exist in type '{1}'." },
257258
No_best_common_type_exists_among_return_expressions: { code: 2354, category: DiagnosticCategory.Error, key: "No best common type exists among return expressions." },
258259
A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." },
259260
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." },

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,10 @@
10051005
"category": "Error",
10061006
"code": 2352
10071007
},
1008+
"Object literal may only specify known properties and '{0}' does not exist in type '{1}'.": {
1009+
"category": "Error",
1010+
"code": 2353
1011+
},
10081012
"No best common type exists among return expressions.": {
10091013
"category": "Error",
10101014
"code": 2354

0 commit comments

Comments
 (0)