Skip to content

Commit 23e9e0b

Browse files
committed
Adding testcases for reactnamespace
1 parent 96a7b7b commit 23e9e0b

10 files changed

Lines changed: 246 additions & 2 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [tests/cases/compiler/unusedImports15.ts] ////
2+
3+
//// [foo.tsx]
4+
5+
import Element = require("react");
6+
7+
export const FooComponent = <div></div>
8+
9+
//// [index.d.ts]
10+
export = React;
11+
export as namespace React;
12+
13+
declare namespace React {
14+
function createClass<P, S>(spec);
15+
}
16+
declare global {
17+
namespace JSX {
18+
}
19+
}
20+
21+
22+
23+
24+
//// [foo.jsx]
25+
"use strict";
26+
var Element = require("react");
27+
exports.FooComponent = <div></div>;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/foo.tsx ===
2+
3+
import Element = require("react");
4+
>Element : Symbol(Element, Decl(foo.tsx, 0, 0))
5+
6+
export const FooComponent = <div></div>
7+
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12))
8+
>div : Symbol(unknown)
9+
>div : Symbol(unknown)
10+
11+
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
12+
export = React;
13+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
14+
15+
export as namespace React;
16+
>React : Symbol(React, Decl(index.d.ts, 0, 15))
17+
18+
declare namespace React {
19+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
20+
21+
function createClass<P, S>(spec);
22+
>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25))
23+
>P : Symbol(P, Decl(index.d.ts, 4, 25))
24+
>S : Symbol(S, Decl(index.d.ts, 4, 27))
25+
>spec : Symbol(spec, Decl(index.d.ts, 4, 31))
26+
}
27+
declare global {
28+
>global : Symbol(global, Decl(index.d.ts, 5, 1))
29+
30+
namespace JSX {
31+
>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16))
32+
}
33+
}
34+
35+
36+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== tests/cases/compiler/foo.tsx ===
2+
3+
import Element = require("react");
4+
>Element : typeof Element
5+
6+
export const FooComponent = <div></div>
7+
>FooComponent : any
8+
><div></div> : any
9+
>div : any
10+
>div : any
11+
12+
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
13+
export = React;
14+
>React : typeof React
15+
16+
export as namespace React;
17+
>React : typeof React
18+
19+
declare namespace React {
20+
>React : typeof React
21+
22+
function createClass<P, S>(spec);
23+
>createClass : <P, S>(spec: any) => any
24+
>P : P
25+
>S : S
26+
>spec : any
27+
}
28+
declare global {
29+
>global : any
30+
31+
namespace JSX {
32+
>JSX : any
33+
}
34+
}
35+
36+
37+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [tests/cases/compiler/unusedImports16.ts] ////
2+
3+
//// [foo.tsx]
4+
5+
import Element = require("react");
6+
7+
export const FooComponent = <div></div>
8+
9+
//// [index.d.ts]
10+
export = React;
11+
export as namespace React;
12+
13+
declare namespace React {
14+
function createClass<P, S>(spec);
15+
}
16+
declare global {
17+
namespace JSX {
18+
}
19+
}
20+
21+
22+
23+
24+
//// [foo.js]
25+
"use strict";
26+
var Element = require("react");
27+
exports.FooComponent = Element.createElement("div", null);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/foo.tsx ===
2+
3+
import Element = require("react");
4+
>Element : Symbol(Element, Decl(foo.tsx, 0, 0))
5+
6+
export const FooComponent = <div></div>
7+
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12))
8+
>div : Symbol(unknown)
9+
>div : Symbol(unknown)
10+
11+
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
12+
export = React;
13+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
14+
15+
export as namespace React;
16+
>React : Symbol(React, Decl(index.d.ts, 0, 15))
17+
18+
declare namespace React {
19+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
20+
21+
function createClass<P, S>(spec);
22+
>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25))
23+
>P : Symbol(P, Decl(index.d.ts, 4, 25))
24+
>S : Symbol(S, Decl(index.d.ts, 4, 27))
25+
>spec : Symbol(spec, Decl(index.d.ts, 4, 31))
26+
}
27+
declare global {
28+
>global : Symbol(global, Decl(index.d.ts, 5, 1))
29+
30+
namespace JSX {
31+
>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16))
32+
}
33+
}
34+
35+
36+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== tests/cases/compiler/foo.tsx ===
2+
3+
import Element = require("react");
4+
>Element : typeof Element
5+
6+
export const FooComponent = <div></div>
7+
>FooComponent : any
8+
><div></div> : any
9+
>div : any
10+
>div : any
11+
12+
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
13+
export = React;
14+
>React : typeof React
15+
16+
export as namespace React;
17+
>React : typeof React
18+
19+
declare namespace React {
20+
>React : typeof React
21+
22+
function createClass<P, S>(spec);
23+
>createClass : <P, S>(spec: any) => any
24+
>P : P
25+
>S : S
26+
>spec : any
27+
}
28+
declare global {
29+
>global : any
30+
31+
namespace JSX {
32+
>JSX : any
33+
}
34+
}
35+
36+
37+

tests/cases/compiler/unusedImports13.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@noUnusedLocals:true
2-
//@noUnusedParameters:true
32
//@module: commonjs
43
//@jsx: preserve
54

tests/cases/compiler/unusedImports14.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@noUnusedLocals:true
2-
//@noUnusedParameters:true
32
//@module: commonjs
43
//@jsx: react
54

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@noUnusedLocals:true
2+
//@module: commonjs
3+
//@reactNamespace: Element
4+
//@jsx: preserve
5+
6+
// @filename: foo.tsx
7+
import Element = require("react");
8+
9+
export const FooComponent = <div></div>
10+
11+
// @filename: node_modules/@types/react/index.d.ts
12+
export = React;
13+
export as namespace React;
14+
15+
declare namespace React {
16+
function createClass<P, S>(spec);
17+
}
18+
declare global {
19+
namespace JSX {
20+
}
21+
}
22+
23+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@noUnusedLocals:true
2+
//@module: commonjs
3+
//@reactNamespace: Element
4+
//@jsx: react
5+
6+
// @filename: foo.tsx
7+
import Element = require("react");
8+
9+
export const FooComponent = <div></div>
10+
11+
// @filename: node_modules/@types/react/index.d.ts
12+
export = React;
13+
export as namespace React;
14+
15+
declare namespace React {
16+
function createClass<P, S>(spec);
17+
}
18+
declare global {
19+
namespace JSX {
20+
}
21+
}
22+
23+

0 commit comments

Comments
 (0)