Add testcase when error is reported about unused react

This commit is contained in:
Sheetal Nandi
2016-10-18 12:24:41 -07:00
parent ff17eeda8f
commit 17cf4357ad
7 changed files with 198 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
tests/cases/compiler/foo.tsx(2,8): error TS6133: 'React' is declared but never used.
==== tests/cases/compiler/foo.tsx (1 errors) ====
import React = require("react");
~~~~~
!!! error TS6133: 'React' is declared but never used.
export const FooComponent = <div></div>
==== tests/cases/compiler/node_modules/@types/react/index.d.ts (0 errors) ====
export = React;
export as namespace React;
declare namespace React {
function createClass<P, S>(spec);
}
declare global {
namespace JSX {
}
}

View File

@@ -0,0 +1,27 @@
//// [tests/cases/compiler/unusedImports13.ts] ////
//// [foo.tsx]
import React = require("react");
export const FooComponent = <div></div>
//// [index.d.ts]
export = React;
export as namespace React;
declare namespace React {
function createClass<P, S>(spec);
}
declare global {
namespace JSX {
}
}
//// [foo.jsx]
"use strict";
var React = require("react");
exports.FooComponent = <div></div>;

View File

@@ -0,0 +1,27 @@
//// [tests/cases/compiler/unusedImports14.ts] ////
//// [foo.tsx]
import React = require("react");
export const FooComponent = <div></div>
//// [index.d.ts]
export = React;
export as namespace React;
declare namespace React {
function createClass<P, S>(spec);
}
declare global {
namespace JSX {
}
}
//// [foo.js]
"use strict";
var React = require("react");
exports.FooComponent = React.createElement("div", null);

View File

@@ -0,0 +1,36 @@
=== tests/cases/compiler/foo.tsx ===
import React = require("react");
>React : Symbol(React, Decl(foo.tsx, 0, 0))
export const FooComponent = <div></div>
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12))
>div : Symbol(unknown)
>div : Symbol(unknown)
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
export = React;
>React : Symbol(React, Decl(index.d.ts, 1, 26))
export as namespace React;
>React : Symbol(React, Decl(index.d.ts, 0, 15))
declare namespace React {
>React : Symbol(React, Decl(index.d.ts, 1, 26))
function createClass<P, S>(spec);
>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25))
>P : Symbol(P, Decl(index.d.ts, 4, 25))
>S : Symbol(S, Decl(index.d.ts, 4, 27))
>spec : Symbol(spec, Decl(index.d.ts, 4, 31))
}
declare global {
>global : Symbol(global, Decl(index.d.ts, 5, 1))
namespace JSX {
>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16))
}
}

View File

@@ -0,0 +1,37 @@
=== tests/cases/compiler/foo.tsx ===
import React = require("react");
>React : typeof React
export const FooComponent = <div></div>
>FooComponent : any
><div></div> : any
>div : any
>div : any
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
export = React;
>React : typeof React
export as namespace React;
>React : typeof React
declare namespace React {
>React : typeof React
function createClass<P, S>(spec);
>createClass : <P, S>(spec: any) => any
>P : P
>S : S
>spec : any
}
declare global {
>global : any
namespace JSX {
>JSX : any
}
}

View File

@@ -0,0 +1,23 @@
//@noUnusedLocals:true
//@noUnusedParameters:true
//@module: commonjs
//@jsx: preserve
// @filename: foo.tsx
import React = require("react");
export const FooComponent = <div></div>
// @filename: node_modules/@types/react/index.d.ts
export = React;
export as namespace React;
declare namespace React {
function createClass<P, S>(spec);
}
declare global {
namespace JSX {
}
}

View File

@@ -0,0 +1,23 @@
//@noUnusedLocals:true
//@noUnusedParameters:true
//@module: commonjs
//@jsx: react
// @filename: foo.tsx
import React = require("react");
export const FooComponent = <div></div>
// @filename: node_modules/@types/react/index.d.ts
export = React;
export as namespace React;
declare namespace React {
function createClass<P, S>(spec);
}
declare global {
namespace JSX {
}
}