Skip to content

Commit d290cf7

Browse files
author
Kanchalai Tanglertsampan
committed
Update error message to use variable name for "children"
1 parent 7829cba commit d290cf7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13322,7 +13322,7 @@ namespace ts {
1332213322
const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
1332313323
if (jsxChildrenPropertyName) {
1332413324
if (attributesTable.has(jsxChildrenPropertyName)) {
13325-
error(attributes, Diagnostics.props_children_are_specified_twice_The_attribute_named_children_will_be_overwritten);
13325+
error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName);
1332613326
}
1332713327

1332813328
// If there are children in the body of JSX element, create dummy attribute "children" with anyType so that it will pass the attribute checking process

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@
20992099
"category": "Error",
21002100
"code": 2707
21012101
},
2102-
"props.children are specified twice. The attribute named 'children' will be overwritten.": {
2102+
"'{0}' are specified twice. The attribute named '{0}' will be overwritten.": {
21032103
"category": "Error",
21042104
"code": 2708
21052105
},

tests/baselines/reference/checkJsxChildrenProperty2.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'.
22
Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
33
Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
4-
tests/cases/conformance/jsx/file.tsx(17,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
5-
tests/cases/conformance/jsx/file.tsx(25,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
4+
tests/cases/conformance/jsx/file.tsx(17,11): error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten.
5+
tests/cases/conformance/jsx/file.tsx(25,11): error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten.
66
tests/cases/conformance/jsx/file.tsx(31,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
77
Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'.
88
Types of property 'children' are incompatible.
@@ -52,7 +52,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi
5252
let k0 =
5353
<Comp a={10} b="hi" children="Random" >
5454
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55-
!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
55+
!!! error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten.
5656
hi hi hi!
5757
</Comp>;
5858

@@ -62,7 +62,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi
6262
let k1 =
6363
<Comp a={10} b="hi" {...o} >
6464
~~~~~~~~~~~~~~~~~~~~
65-
!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
65+
!!! error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten.
6666
hi hi hi!
6767
</Comp>;
6868

0 commit comments

Comments
 (0)