Skip to content

Commit

Permalink
Small error message change
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jan 4, 2019
1 parent 74e9f9f commit 5dc1782
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11373,7 +11373,7 @@ namespace ts {
result = true;
error(
containingElement.openingElement.tagName,
Diagnostics.Target_JSX_element_expects_0_prop_of_type_1_but_multiple_children_were_provided,
Diagnostics.Target_JSX_element_expects_a_0_prop_of_type_1_but_multiple_children_were_provided,
childPropName ? unescapeLeadingUnderscores(childPropName) : "children",
typeToString(childrenTargetType)
);
Expand All @@ -11397,7 +11397,7 @@ namespace ts {
result = true;
error(
containingElement.openingElement.tagName,
Diagnostics.Target_JSX_element_expects_0_prop_of_type_1_but_only_a_single_child_was_provided,
Diagnostics.Target_JSX_element_expects_a_0_prop_of_type_1_but_only_a_single_child_was_provided,
childPropName ? unescapeLeadingUnderscores(childPropName) : "children",
typeToString(childrenTargetType)
);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2541,11 +2541,11 @@
"category": "Error",
"code": 2744
},
"Target JSX element expects {0} prop of type {1}, but only a single child was provided.": {
"Target JSX element expects a '{0}' prop of type '{1}', but only a single child was provided.": {
"category": "Error",
"code": 2745
},
"Target JSX element expects {0} prop of type {1}, but multiple children were provided.": {
"Target JSX element expects a '{0}' prop of type '{1}', but multiple children were provided.": {
"category": "Error",
"code": 2746
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: Target JSX element expects children prop of type Element, but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: Target JSX element expects a 'children' prop of type 'Element', but multiple children were provided.


==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
Expand Down Expand Up @@ -45,4 +45,4 @@ tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: Target JSX element ex
// Error
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
~~~~~~~~~~~~~~~
!!! error TS2746: Target JSX element expects children prop of type Element, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type 'Element', but multiple children were provided.
16 changes: 8 additions & 8 deletions tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/jsx/file.tsx(14,10): error TS2741: Property 'children' is missing in type '{ a: number; b: string; }' but required in type 'Prop'.
tests/cases/conformance/jsx/file.tsx(17,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
tests/cases/conformance/jsx/file.tsx(31,6): error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(37,6): error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(43,6): error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(49,6): error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(31,6): error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(37,6): error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(43,6): error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
tests/cases/conformance/jsx/file.tsx(49,6): error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.


==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
Expand Down Expand Up @@ -44,31 +44,31 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2746: Target JSX element exp
let k2 =
<Comp a={10} b="hi">
~~~~
!!! error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
<div> My Div </div>
{(name: string) => <div> My name {name} </div>}
</Comp>;

let k3 =
<Comp a={10} b="hi">
~~~~
!!! error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
<div> My Div </div>
{1000000}
</Comp>;

let k4 =
<Comp a={10} b="hi" >
~~~~
!!! error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
<div> My Div </div>
hi hi hi!
</Comp>;

let k5 =
<Comp a={10} b="hi" >
~~~~
!!! error TS2746: Target JSX element expects children prop of type string | Element, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type 'string | Element', but multiple children were provided.
<div> My Div </div>
<div> My Div </div>
</Comp>;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests/cases/compiler/index.tsx(14,9): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/index.tsx(18,15): error TS2322: Type 'string' is not assignable to type '(x: number) => string'.
tests/cases/compiler/index.tsx(23,10): error TS2746: Target JSX element expects children prop of type (x: number) => string, but multiple children were provided.
tests/cases/compiler/index.tsx(37,10): error TS2745: Target JSX element expects children prop of type ((x: number) => string)[], but only a single child was provided.
tests/cases/compiler/index.tsx(42,10): error TS2745: Target JSX element expects children prop of type ((x: number) => string)[], but only a single child was provided.
tests/cases/compiler/index.tsx(23,10): error TS2746: Target JSX element expects a 'children' prop of type '(x: number) => string', but multiple children were provided.
tests/cases/compiler/index.tsx(37,10): error TS2745: Target JSX element expects a 'children' prop of type '((x: number) => string)[]', but only a single child was provided.
tests/cases/compiler/index.tsx(42,10): error TS2745: Target JSX element expects a 'children' prop of type '((x: number) => string)[]', but only a single child was provided.
tests/cases/compiler/index.tsx(48,9): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/index.tsx(49,9): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/index.tsx(63,3): error TS2322: Type '(x: number) => number' is not assignable to type 'Cb | Cb[]'.
Expand Down Expand Up @@ -46,7 +46,7 @@ tests/cases/compiler/index.tsx(74,9): error TS2322: Type 'number' is not assigna
// Blah components don't accept multiple children.
var a = <Blah>
~~~~
!!! error TS2746: Target JSX element expects children prop of type (x: number) => string, but multiple children were provided.
!!! error TS2746: Target JSX element expects a 'children' prop of type '(x: number) => string', but multiple children were provided.
{x => "" + x}
{x => "" + x}
</Blah>
Expand All @@ -62,14 +62,14 @@ tests/cases/compiler/index.tsx(74,9): error TS2322: Type 'number' is not assigna
// Incompatible child.
var a = <Blah2>
~~~~~
!!! error TS2745: Target JSX element expects children prop of type ((x: number) => string)[], but only a single child was provided.
!!! error TS2745: Target JSX element expects a 'children' prop of type '((x: number) => string)[]', but only a single child was provided.
{x => x}
</Blah2>

// Blah2 components don't accept text as child elements
var a = <Blah2>
~~~~~
!!! error TS2745: Target JSX element expects children prop of type ((x: number) => string)[], but only a single child was provided.
!!! error TS2745: Target JSX element expects a 'children' prop of type '((x: number) => string)[]', but only a single child was provided.
Hello unexpected text!
</Blah2>

Expand Down

0 comments on commit 5dc1782

Please sign in to comment.