Skip to content

Commit fc6eee1

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests and baselines
1 parent 096c15b commit fc6eee1

11 files changed

+253
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [file.tsx]
2+
3+
import React = require('react');
4+
5+
const Foo = (props: any) => null;
6+
7+
function Greet(x: {name?: string}) {
8+
return null;
9+
}
10+
11+
const foo = <Foo />;
12+
const G = <Greet />;
13+
14+
//// [file.jsx]
15+
define(["require", "exports", "react"], function (require, exports, React) {
16+
"use strict";
17+
exports.__esModule = true;
18+
var Foo = function (props) { return null; };
19+
function Greet(x) {
20+
return null;
21+
}
22+
var foo = <Foo />;
23+
var G = <Greet />;
24+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
3+
import React = require('react');
4+
>React : Symbol(React, Decl(file.tsx, 0, 0))
5+
6+
const Foo = (props: any) => null;
7+
>Foo : Symbol(Foo, Decl(file.tsx, 3, 5))
8+
>props : Symbol(props, Decl(file.tsx, 3, 13))
9+
10+
function Greet(x: {name?: string}) {
11+
>Greet : Symbol(Greet, Decl(file.tsx, 3, 33))
12+
>x : Symbol(x, Decl(file.tsx, 5, 15))
13+
>name : Symbol(name, Decl(file.tsx, 5, 19))
14+
15+
return null;
16+
}
17+
18+
const foo = <Foo />;
19+
>foo : Symbol(foo, Decl(file.tsx, 9, 5))
20+
>Foo : Symbol(Foo, Decl(file.tsx, 3, 5))
21+
22+
const G = <Greet />;
23+
>G : Symbol(G, Decl(file.tsx, 10, 5))
24+
>Greet : Symbol(Greet, Decl(file.tsx, 3, 33))
25+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
3+
import React = require('react');
4+
>React : typeof React
5+
6+
const Foo = (props: any) => null;
7+
>Foo : (props: any) => any
8+
>(props: any) => null : (props: any) => any
9+
>props : any
10+
>null : null
11+
12+
function Greet(x: {name?: string}) {
13+
>Greet : (x: { name?: string; }) => any
14+
>x : { name?: string; }
15+
>name : string
16+
17+
return null;
18+
>null : null
19+
}
20+
21+
const foo = <Foo />;
22+
>foo : JSX.Element
23+
><Foo /> : JSX.Element
24+
>Foo : (props: any) => any
25+
26+
const G = <Greet />;
27+
>G : JSX.Element
28+
><Greet /> : JSX.Element
29+
>Greet : (x: { name?: string; }) => any
30+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [file.tsx]
2+
3+
import React = require('react');
4+
5+
const Foo = (props: any) => null;
6+
7+
function Greet(x: {name?: string}) {
8+
return null;
9+
}
10+
11+
const foo = <Foo />;
12+
const G = <Greet />;
13+
14+
//// [file.jsx]
15+
define(["require", "exports", "react"], function (require, exports, React) {
16+
"use strict";
17+
exports.__esModule = true;
18+
var Foo = function (props) { return null; };
19+
function Greet(x) {
20+
return null;
21+
}
22+
var foo = <Foo />;
23+
var G = <Greet />;
24+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
3+
import React = require('react');
4+
>React : Symbol(React, Decl(file.tsx, 0, 0))
5+
6+
const Foo = (props: any) => null;
7+
>Foo : Symbol(Foo, Decl(file.tsx, 3, 5))
8+
>props : Symbol(props, Decl(file.tsx, 3, 13))
9+
10+
function Greet(x: {name?: string}) {
11+
>Greet : Symbol(Greet, Decl(file.tsx, 3, 33))
12+
>x : Symbol(x, Decl(file.tsx, 5, 15))
13+
>name : Symbol(name, Decl(file.tsx, 5, 19))
14+
15+
return null;
16+
}
17+
18+
const foo = <Foo />;
19+
>foo : Symbol(foo, Decl(file.tsx, 9, 5))
20+
>Foo : Symbol(Foo, Decl(file.tsx, 3, 5))
21+
22+
const G = <Greet />;
23+
>G : Symbol(G, Decl(file.tsx, 10, 5))
24+
>Greet : Symbol(Greet, Decl(file.tsx, 3, 33))
25+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
3+
import React = require('react');
4+
>React : typeof React
5+
6+
const Foo = (props: any) => null;
7+
>Foo : (props: any) => null
8+
>(props: any) => null : (props: any) => null
9+
>props : any
10+
>null : null
11+
12+
function Greet(x: {name?: string}) {
13+
>Greet : (x: { name?: string | undefined; }) => null
14+
>x : { name?: string | undefined; }
15+
>name : string | undefined
16+
17+
return null;
18+
>null : null
19+
}
20+
21+
const foo = <Foo />;
22+
>foo : JSX.Element
23+
><Foo /> : JSX.Element
24+
>Foo : (props: any) => null
25+
26+
const G = <Greet />;
27+
>G : JSX.Element
28+
><Greet /> : JSX.Element
29+
>Greet : (x: { name?: string | undefined; }) => null
30+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/conformance/jsx/file.tsx(10,13): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements.
2+
tests/cases/conformance/jsx/file.tsx(11,11): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements.
3+
4+
5+
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
6+
7+
import React = require('react');
8+
9+
const Foo = (props: any) => undefined;
10+
function Greet(x: {name?: string}) {
11+
return undefined;
12+
}
13+
14+
// Error
15+
const foo = <Foo />;
16+
~~~~~~~
17+
!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements.
18+
const G = <Greet />;
19+
~~~~~~~~~
20+
!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [file.tsx]
2+
3+
import React = require('react');
4+
5+
const Foo = (props: any) => undefined;
6+
function Greet(x: {name?: string}) {
7+
return undefined;
8+
}
9+
10+
// Error
11+
const foo = <Foo />;
12+
const G = <Greet />;
13+
14+
//// [file.jsx]
15+
define(["require", "exports", "react"], function (require, exports, React) {
16+
"use strict";
17+
exports.__esModule = true;
18+
var Foo = function (props) { return undefined; };
19+
function Greet(x) {
20+
return undefined;
21+
}
22+
// Error
23+
var foo = <Foo />;
24+
var G = <Greet />;
25+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @filename: file.tsx
2+
// @jsx: preserve
3+
// @module: amd
4+
// @noLib: true
5+
// @libFiles: react.d.ts,lib.d.ts
6+
7+
import React = require('react');
8+
9+
const Foo = (props: any) => null;
10+
11+
function Greet(x: {name?: string}) {
12+
return null;
13+
}
14+
15+
const foo = <Foo />;
16+
const G = <Greet />;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @filename: file.tsx
2+
// @jsx: preserve
3+
// @module: amd
4+
// @noLib: true
5+
// @strictNullChecks: true
6+
// @libFiles: react.d.ts,lib.d.ts
7+
8+
import React = require('react');
9+
10+
const Foo = (props: any) => null;
11+
12+
function Greet(x: {name?: string}) {
13+
return null;
14+
}
15+
16+
const foo = <Foo />;
17+
const G = <Greet />;

0 commit comments

Comments
 (0)