Skip to content

Commit e8741d8

Browse files
author
Kanchalai Tanglertsampan
committed
Update tests anad baselines
1 parent f9dbfd4 commit e8741d8

21 files changed

+120
-86
lines changed

tests/baselines/reference/checkJsxChildrenProperty2.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ 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 TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
5-
tests/cases/conformance/jsx/file.tsx(25,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
65
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'.
76
Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'.
87
Types of property 'children' are incompatible.
@@ -29,7 +28,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi
2928
Property 'type' is missing in type 'Element[]'.
3029

3130

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

3534
interface Prop {
@@ -61,8 +60,6 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi
6160
}
6261
let k1 =
6362
<Comp a={10} b="hi" {...o} >
64-
~~~~~~~~~~~~~~~~~~~~
65-
!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
6663
hi hi hi!
6764
</Comp>;
6865

tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,24): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
2-
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
2+
Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'.
3+
Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'.
4+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,64): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
35
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,24): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
46
Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
5-
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,24): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
6-
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
7+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,43): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
78
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,24): error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
89
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
9-
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,25): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
10-
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
11-
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,25): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
12-
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
10+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,65): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
11+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
1312

1413

15-
==== tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx (6 errors) ====
14+
==== tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx (7 errors) ====
1615
import React = require('react')
1716

1817
export interface ClickableProps {
@@ -42,29 +41,29 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,25): err
4241
const b0 = <MainButton {...{onClick: (k) => {console.log(k)}}} extra />; // k has type "left" | "right"
4342
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4443
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
45-
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
44+
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'.
45+
!!! error TS2322: Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'.
46+
~~~~~
47+
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
4648
const b2 = <MainButton onClick={(k)=>{console.log(k)}} extra />; // k has type "left" | "right"
4749
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4850
!!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
4951
!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
5052
const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "contact"
51-
~~~~~~~~~~~~~~~~~~~~~~~~
52-
!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
53-
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
53+
~~~~~
54+
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
5455
const b4 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact"
5556
~~~~~~~~~~~~~~~~~
5657
!!! error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
5758
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
5859

5960
export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
6061
const c1 = <NoOverload {...{onClick: (k) => {console.log(k)}}} extra />; // k has type any
61-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62-
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
63-
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
62+
~~~~~
63+
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
6464

6565
export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined }
6666
const d1 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" | "contact"
67-
~~~~~~~~~~~~~~~~~~~~~~~~
68-
!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
69-
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
67+
~~~~~
68+
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
7069

tests/baselines/reference/tsxAttributeResolution3.errors.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '{ y: number; }'
66
tests/cases/conformance/jsx/file.tsx(31,8): error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'Attribs1'.
77
Types of property 'x' are incompatible.
88
Type 'number' is not assignable to type 'string'.
9-
tests/cases/conformance/jsx/file.tsx(35,8): error TS2322: Type '{ x: string; y: number; extra: number; }' is not assignable to type 'Attribs1'.
10-
Property 'extra' does not exist on type 'Attribs1'.
119

1210

13-
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
11+
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
1412
declare module JSX {
1513
interface Element { }
1614
interface IntrinsicElements {
@@ -54,12 +52,9 @@ tests/cases/conformance/jsx/file.tsx(35,8): error TS2322: Type '{ x: string; y:
5452
!!! error TS2322: Types of property 'x' are incompatible.
5553
!!! error TS2322: Type 'number' is not assignable to type 'string'.
5654

57-
// Error
55+
// Ok
5856
var obj6 = { x: 'ok', y: 32, extra: 100 };
5957
<test1 {...obj6} />
60-
~~~~~~~~~
61-
!!! error TS2322: Type '{ x: string; y: number; extra: number; }' is not assignable to type 'Attribs1'.
62-
!!! error TS2322: Property 'extra' does not exist on type 'Attribs1'.
6358

6459
// OK (spread override)
6560
var obj7 = { x: 'foo' };

tests/baselines/reference/tsxAttributeResolution3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var obj4 = { x: 32, y: 32 };
3131
var obj5 = { x: 32, y: 32 };
3232
<test1 x="ok" {...obj5} />
3333

34-
// Error
34+
// Ok
3535
var obj6 = { x: 'ok', y: 32, extra: 100 };
3636
<test1 {...obj6} />
3737

@@ -56,7 +56,7 @@ var obj4 = { x: 32, y: 32 };
5656
// Error
5757
var obj5 = { x: 32, y: 32 };
5858
<test1 x="ok" {...obj5}/>;
59-
// Error
59+
// Ok
6060
var obj6 = { x: 'ok', y: 32, extra: 100 };
6161
<test1 {...obj6}/>;
6262
// OK (spread override)

tests/baselines/reference/tsxSpreadAttributesResolution12.errors.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ tests/cases/conformance/jsx/file.tsx(28,25): error TS2322: Type '{ y: true; x: 3
66
Type '{ y: true; x: 3; overwrite: "hi"; }' is not assignable to type 'Prop'.
77
Types of property 'x' are incompatible.
88
Type '3' is not assignable to type '2'.
9+
tests/cases/conformance/jsx/file.tsx(30,25): error TS2322: Type '{ y: true; x: 2; overwrite: "hi"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<OverWriteAttr> & Prop & { children?: ReactNode; }'.
10+
Type '{ y: true; x: 2; overwrite: "hi"; }' is not assignable to type 'Prop'.
11+
Types of property 'y' are incompatible.
12+
Type 'true' is not assignable to type 'false'.
913

1014

11-
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
15+
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
1216
import React = require('react');
1317

1418
const obj = {};
@@ -48,4 +52,11 @@ tests/cases/conformance/jsx/file.tsx(28,25): error TS2322: Type '{ y: true; x: 3
4852
!!! error TS2322: Types of property 'x' are incompatible.
4953
!!! error TS2322: Type '3' is not assignable to type '2'.
5054
let x2 = <OverWriteAttr {...anyobj} x={3} />
55+
let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
56+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57+
!!! error TS2322: Type '{ y: true; x: 2; overwrite: "hi"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<OverWriteAttr> & Prop & { children?: ReactNode; }'.
58+
!!! error TS2322: Type '{ y: true; x: 2; overwrite: "hi"; }' is not assignable to type 'Prop'.
59+
!!! error TS2322: Types of property 'y' are incompatible.
60+
!!! error TS2322: Type 'true' is not assignable to type 'false'.
61+
5162

tests/baselines/reference/tsxSpreadAttributesResolution12.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ let anyobj: any;
2828
let x = <OverWriteAttr {...obj} y overwrite="hi" {...obj1} />
2929
let x1 = <OverWriteAttr overwrite="hi" {...obj1} x={3} {...{y: true}} />
3030
let x2 = <OverWriteAttr {...anyobj} x={3} />
31+
let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
32+
3133

3234

3335
//// [file.jsx]
@@ -67,3 +69,4 @@ var anyobj;
6769
var x = <OverWriteAttr {...obj} y overwrite="hi" {...obj1}/>;
6870
var x1 = <OverWriteAttr overwrite="hi" {...obj1} x={3} {...{ y: true }}/>;
6971
var x2 = <OverWriteAttr {...anyobj} x={3}/>;
72+
var x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{ y: true }}/>;

tests/baselines/reference/tsxSpreadAttributesResolution2.errors.txt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ tests/cases/conformance/jsx/file.tsx(19,19): error TS2322: Type '{ x: true; y: t
88
Type '{ x: true; y: true; }' is not assignable to type 'PoisonedProp'.
99
Types of property 'x' are incompatible.
1010
Type 'true' is not assignable to type 'string'.
11+
tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '{ x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
12+
Type '{ x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
13+
Types of property 'x' are incompatible.
14+
Type 'number' is not assignable to type 'string'.
15+
tests/cases/conformance/jsx/file.tsx(21,20): error TS2322: Type '{ X: "hi"; x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
16+
Type '{ X: "hi"; x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
17+
Types of property 'x' are incompatible.
18+
Type 'number' is not assignable to type 'string'.
19+
tests/cases/conformance/jsx/file.tsx(21,40): error TS2339: Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
1120

1221

13-
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
22+
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
1423
import React = require('react');
1524

1625
interface PoisonedProp {
@@ -42,4 +51,18 @@ tests/cases/conformance/jsx/file.tsx(19,19): error TS2322: Type '{ x: true; y: t
4251
!!! error TS2322: Type '{ x: true; y: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
4352
!!! error TS2322: Type '{ x: true; y: true; }' is not assignable to type 'PoisonedProp'.
4453
!!! error TS2322: Types of property 'x' are incompatible.
45-
!!! error TS2322: Type 'true' is not assignable to type 'string'.
54+
!!! error TS2322: Type 'true' is not assignable to type 'string'.
55+
let w = <Poisoned {...{x: 5, y: "2"}}/>;
56+
~~~~~~~~~~~~~~~~~~~
57+
!!! error TS2322: Type '{ x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
58+
!!! error TS2322: Type '{ x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
59+
!!! error TS2322: Types of property 'x' are incompatible.
60+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
61+
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
62+
~~~~~~~~~~~~~~~~~~~~~~~~~~
63+
!!! error TS2322: Type '{ X: "hi"; x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
64+
!!! error TS2322: Type '{ X: "hi"; x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
65+
!!! error TS2322: Types of property 'x' are incompatible.
66+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
67+
~~~~~~
68+
!!! error TS2339: Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.

tests/baselines/reference/tsxSpreadAttributesResolution2.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const obj = {};
1717
// Error
1818
let p = <Poisoned {...obj} />;
1919
let y = <Poisoned />;
20-
let z = <Poisoned x y/>;
20+
let z = <Poisoned x y/>;
21+
let w = <Poisoned {...{x: 5, y: "2"}}/>;
22+
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
2123

2224
//// [file.jsx]
2325
"use strict";
@@ -48,3 +50,5 @@ var obj = {};
4850
var p = <Poisoned {...obj}/>;
4951
var y = <Poisoned />;
5052
var z = <Poisoned x y/>;
53+
var w = <Poisoned {...{ x: 5, y: "2" }}/>;
54+
var w1 = <Poisoned {...{ x: 5, y: "2" }} X="hi"/>;

tests/baselines/reference/tsxSpreadAttributesResolution5.errors.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '{ x: string; y:
22
Type '{ x: string; y: number; }' is not assignable to type 'PoisonedProp'.
33
Types of property 'y' are incompatible.
44
Type 'number' is not assignable to type '2'.
5-
tests/cases/conformance/jsx/file.tsx(33,20): error TS2322: Type '{ prop1: boolean; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<EmptyProp> & { children?: ReactNode; }'.
6-
Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<EmptyProp> & { children?: ReactNode; }'.
75

86

9-
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
7+
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
108
import React = require('react');
119

1210
interface PoisonedProp {
@@ -43,8 +41,5 @@ tests/cases/conformance/jsx/file.tsx(33,20): error TS2322: Type '{ prop1: boolea
4341
let o = {
4442
prop1: false
4543
}
46-
// Error
47-
let e = <EmptyProp {...o} />;
48-
~~~~~~
49-
!!! error TS2322: Type '{ prop1: boolean; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<EmptyProp> & { children?: ReactNode; }'.
50-
!!! error TS2322: Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<EmptyProp> & { children?: ReactNode; }'.
44+
// Ok
45+
let e = <EmptyProp {...o} />;

tests/baselines/reference/tsxSpreadAttributesResolution5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class EmptyProp extends React.Component<{}, {}> {
3030
let o = {
3131
prop1: false
3232
}
33-
// Error
33+
// Ok
3434
let e = <EmptyProp {...o} />;
3535

3636
//// [file.jsx]
@@ -76,5 +76,5 @@ var EmptyProp = (function (_super) {
7676
var o = {
7777
prop1: false
7878
};
79-
// Error
79+
// Ok
8080
var e = <EmptyProp {...o}/>;

0 commit comments

Comments
 (0)