Skip to content

Commit 58e2189

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests and update baselines
1 parent 012f459 commit 58e2189

11 files changed

+208
-112
lines changed

src/compiler/scanner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="core.ts"/>
1+
/// <reference path="core.ts"/>
22
/// <reference path="diagnosticInformationMap.generated.ts"/>
33

44
namespace ts {

tests/baselines/reference/checkJsxChildrenProperty2.errors.txt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@ tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: 10; b: "hi
22
Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
33
Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
44
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(23,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
5+
tests/cases/conformance/jsx/file.tsx(25,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
6+
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'.
67
Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'.
78
Types of property 'children' are incompatible.
89
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
910
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
1011
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
11-
tests/cases/conformance/jsx/file.tsx(29,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
12+
tests/cases/conformance/jsx/file.tsx(37,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1213
Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'Prop'.
1314
Types of property 'children' are incompatible.
1415
Type '(Element | 1000000)[]' is not assignable to type 'string | Element'.
1516
Type '(Element | 1000000)[]' is not assignable to type 'Element'.
1617
Property 'type' is missing in type '(Element | 1000000)[]'.
17-
tests/cases/conformance/jsx/file.tsx(35,11): error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
18+
tests/cases/conformance/jsx/file.tsx(43,11): error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1819
Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
1920
Types of property 'children' are incompatible.
2021
Type '(string | Element)[]' is not assignable to type 'string | Element'.
2122
Type '(string | Element)[]' is not assignable to type 'Element'.
2223
Property 'type' is missing in type '(string | Element)[]'.
23-
tests/cases/conformance/jsx/file.tsx(41,11): error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
24+
tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
2425
Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'Prop'.
2526
Types of property 'children' are incompatible.
2627
Type 'Element[]' is not assignable to type 'string | Element'.
2728
Type 'Element[]' is not assignable to type 'Element'.
2829
Property 'type' is missing in type 'Element[]'.
2930

3031

31-
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
32+
==== tests/cases/conformance/jsx/file.tsx (7 errors) ====
3233
import React = require('react');
3334

3435
interface Prop {
@@ -48,13 +49,23 @@ tests/cases/conformance/jsx/file.tsx(41,11): error TS2322: Type '{ a: 10; b: "hi
4849
!!! error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
4950
!!! error TS2322: Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
5051

51-
let k1 =
52+
let k0 =
5253
<Comp a={10} b="hi" children="Random" >
5354
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5455
!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
5556
hi hi hi!
5657
</Comp>;
5758

59+
let o = {
60+
children:"Random"
61+
}
62+
let k1 =
63+
<Comp a={10} b="hi" {...o} >
64+
~~~~~~~~~~~~~~~~~~~~
65+
!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
66+
hi hi hi!
67+
</Comp>;
68+
5869
// Error: incorrect type
5970
let k2 =
6071
<Comp a={10} b="hi">

tests/baselines/reference/checkJsxChildrenProperty2.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ function Comp(p: Prop) {
1414
// Error: missing children
1515
let k = <Comp a={10} b="hi" />;
1616

17-
let k1 =
17+
let k0 =
1818
<Comp a={10} b="hi" children="Random" >
1919
hi hi hi!
2020
</Comp>;
2121

22+
let o = {
23+
children:"Random"
24+
}
25+
let k1 =
26+
<Comp a={10} b="hi" {...o} >
27+
hi hi hi!
28+
</Comp>;
29+
2230
// Error: incorrect type
2331
let k2 =
2432
<Comp a={10} b="hi">
@@ -53,7 +61,13 @@ function Comp(p) {
5361
}
5462
// Error: missing children
5563
var k = <Comp a={10} b="hi"/>;
56-
var k1 = <Comp a={10} b="hi" children="Random">
64+
var k0 = <Comp a={10} b="hi" children="Random">
65+
hi hi hi!
66+
</Comp>;
67+
var o = {
68+
children: "Random"
69+
};
70+
var k1 = <Comp a={10} b="hi" {...o}>
5771
hi hi hi!
5872
</Comp>;
5973
// Error: incorrect type

tests/baselines/reference/tsxStatelessFunctionComponentOverload1.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React = require('react')
33

44
declare function OneThing(k: {yxx: string}): JSX.Element;
5+
declare function OneThing(k: {yxx1: string, children: string}): JSX.Element;
56
declare function OneThing(l: {yy: number, yy1: string}): JSX.Element;
67
declare function OneThing(l: {yy: number, yy1: string, yy2: boolean}): JSX.Element;
78
declare function OneThing(l1: {data: string, "data-prop": boolean}): JSX.Element;
@@ -11,6 +12,8 @@ const c1 = <OneThing yxx='ok' />
1112
const c2 = <OneThing yy={100} yy1="hello"/>
1213
const c3 = <OneThing yxx="hello" ignore-prop />
1314
const c4 = <OneThing data="hello" data-prop />
15+
const c5 = <OneThing yxx1='ok'>Hello</OneThing>
16+
1417

1518
declare function TestingOneThing({y1: string}): JSX.Element;
1619
declare function TestingOneThing(j: {"extra-data": string, yy?: string}): JSX.Element;
@@ -48,6 +51,7 @@ define(["require", "exports", "react"], function (require, exports, React) {
4851
var c2 = <OneThing yy={100} yy1="hello"/>;
4952
var c3 = <OneThing yxx="hello" ignore-prop/>;
5053
var c4 = <OneThing data="hello" data-prop/>;
54+
var c5 = <OneThing yxx1='ok'>Hello</OneThing>;
5155
// OK
5256
var d1 = <TestingOneThing y1 extra-data/>;
5357
var d2 = <TestingOneThing extra-data="hello"/>;

0 commit comments

Comments
 (0)