From d290cf7633d2d05300ff7332decff7de095b4eab Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 17 Apr 2017 13:11:16 -0700 Subject: [PATCH] Update error message to use variable name for "children" --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../reference/checkJsxChildrenProperty2.errors.txt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c5b531337c9..95b3de8df40 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13322,7 +13322,7 @@ namespace ts { const jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); if (jsxChildrenPropertyName) { if (attributesTable.has(jsxChildrenPropertyName)) { - error(attributes, Diagnostics.props_children_are_specified_twice_The_attribute_named_children_will_be_overwritten); + error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); } // 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 diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 72554a9f0ba..b7f30e2b209 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2099,7 +2099,7 @@ "category": "Error", "code": 2707 }, - "props.children are specified twice. The attribute named 'children' will be overwritten.": { + "'{0}' are specified twice. The attribute named '{0}' will be overwritten.": { "category": "Error", "code": 2708 }, diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt index ecde87c6fbf..d288d92e93b 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'. Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'. Property 'children' is missing in type '{ a: 10; b: "hi"; }'. -tests/cases/conformance/jsx/file.tsx(17,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten. -tests/cases/conformance/jsx/file.tsx(25,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten. +tests/cases/conformance/jsx/file.tsx(17,11): error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten. +tests/cases/conformance/jsx/file.tsx(25,11): error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten. 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'. Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'. 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 let k0 = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten. +!!! error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten. hi hi hi! ; @@ -62,7 +62,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi let k1 = ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten. +!!! error TS2708: 'children' are specified twice. The attribute named 'children' will be overwritten. hi hi hi! ;