mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Add tests
This commit is contained in:
parent
cc1947b94f
commit
1e433bfb4f
20
tests/baselines/reference/reactNamespaceImportPresevation.js
Normal file
20
tests/baselines/reference/reactNamespaceImportPresevation.js
Normal file
@ -0,0 +1,20 @@
|
||||
//// [tests/cases/compiler/reactNamespaceImportPresevation.tsx] ////
|
||||
|
||||
//// [modules.d.ts]
|
||||
|
||||
declare module "my-React-Lib" {
|
||||
var a: any;
|
||||
export = a;
|
||||
}
|
||||
|
||||
//// [test.tsx]
|
||||
import * as myReactLib from "my-React-Lib"; // should not be elided
|
||||
declare var foo: any;
|
||||
|
||||
<foo data/>;
|
||||
|
||||
|
||||
//// [test.jsx]
|
||||
"use strict";
|
||||
var myReactLib = require("my-React-Lib"); // should not be elided
|
||||
<foo data/>;
|
||||
@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/modules.d.ts ===
|
||||
|
||||
declare module "my-React-Lib" {
|
||||
var a: any;
|
||||
>a : Symbol(a, Decl(modules.d.ts, 2, 7))
|
||||
|
||||
export = a;
|
||||
>a : Symbol(a, Decl(modules.d.ts, 2, 7))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import * as myReactLib from "my-React-Lib"; // should not be elided
|
||||
>myReactLib : Symbol(myReactLib, Decl(test.tsx, 0, 6))
|
||||
|
||||
declare var foo: any;
|
||||
>foo : Symbol(foo, Decl(test.tsx, 1, 11))
|
||||
|
||||
<foo data/>;
|
||||
>data : Symbol(unknown)
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/modules.d.ts ===
|
||||
|
||||
declare module "my-React-Lib" {
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
export = a;
|
||||
>a : any
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
import * as myReactLib from "my-React-Lib"; // should not be elided
|
||||
>myReactLib : any
|
||||
|
||||
declare var foo: any;
|
||||
>foo : any
|
||||
|
||||
<foo data/>;
|
||||
><foo data/> : any
|
||||
>foo : any
|
||||
>data : any
|
||||
|
||||
20
tests/baselines/reference/reactNamespaceJSXEmit.js
Normal file
20
tests/baselines/reference/reactNamespaceJSXEmit.js
Normal file
@ -0,0 +1,20 @@
|
||||
//// [reactNamespaceJSXEmit.tsx]
|
||||
|
||||
declare var myReactLib: any;
|
||||
declare var foo: any;
|
||||
declare var Bar: any;
|
||||
declare var x: any;
|
||||
|
||||
<foo data/>;
|
||||
<Bar x={x} />;
|
||||
<x-component />;
|
||||
<Bar {...x} />;
|
||||
<Bar { ...x } y={2} />;
|
||||
|
||||
|
||||
//// [reactNamespaceJSXEmit.js]
|
||||
myReactLib.createElement("foo", {data: true});
|
||||
myReactLib.createElement(Bar, {x: x});
|
||||
myReactLib.createElement("x-component", null);
|
||||
myReactLib.createElement(Bar, myReactLib.__spread({}, x));
|
||||
myReactLib.createElement(Bar, myReactLib.__spread({}, x, {y: 2}));
|
||||
32
tests/baselines/reference/reactNamespaceJSXEmit.symbols
Normal file
32
tests/baselines/reference/reactNamespaceJSXEmit.symbols
Normal file
@ -0,0 +1,32 @@
|
||||
=== tests/cases/compiler/reactNamespaceJSXEmit.tsx ===
|
||||
|
||||
declare var myReactLib: any;
|
||||
>myReactLib : Symbol(myReactLib, Decl(reactNamespaceJSXEmit.tsx, 1, 11))
|
||||
|
||||
declare var foo: any;
|
||||
>foo : Symbol(foo, Decl(reactNamespaceJSXEmit.tsx, 2, 11))
|
||||
|
||||
declare var Bar: any;
|
||||
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
|
||||
|
||||
declare var x: any;
|
||||
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
|
||||
|
||||
<foo data/>;
|
||||
>data : Symbol(unknown)
|
||||
|
||||
<Bar x={x} />;
|
||||
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
|
||||
>x : Symbol(unknown)
|
||||
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
|
||||
|
||||
<x-component />;
|
||||
<Bar {...x} />;
|
||||
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
|
||||
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
|
||||
|
||||
<Bar { ...x } y={2} />;
|
||||
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
|
||||
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
|
||||
>y : Symbol(unknown)
|
||||
|
||||
41
tests/baselines/reference/reactNamespaceJSXEmit.types
Normal file
41
tests/baselines/reference/reactNamespaceJSXEmit.types
Normal file
@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/reactNamespaceJSXEmit.tsx ===
|
||||
|
||||
declare var myReactLib: any;
|
||||
>myReactLib : any
|
||||
|
||||
declare var foo: any;
|
||||
>foo : any
|
||||
|
||||
declare var Bar: any;
|
||||
>Bar : any
|
||||
|
||||
declare var x: any;
|
||||
>x : any
|
||||
|
||||
<foo data/>;
|
||||
><foo data/> : any
|
||||
>foo : any
|
||||
>data : any
|
||||
|
||||
<Bar x={x} />;
|
||||
><Bar x={x} /> : any
|
||||
>Bar : any
|
||||
>x : any
|
||||
>x : any
|
||||
|
||||
<x-component />;
|
||||
><x-component /> : any
|
||||
>x-component : any
|
||||
|
||||
<Bar {...x} />;
|
||||
><Bar {...x} /> : any
|
||||
>Bar : any
|
||||
>x : any
|
||||
|
||||
<Bar { ...x } y={2} />;
|
||||
><Bar { ...x } y={2} /> : any
|
||||
>Bar : any
|
||||
>x : any
|
||||
>y : any
|
||||
>2 : number
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/reactNamespaceMissingDeclaration.tsx(3,2): error TS2304: Cannot find name 'myReactLib'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/reactNamespaceMissingDeclaration.tsx (1 errors) ====
|
||||
|
||||
// Error myReactLib not declared
|
||||
<foo data/>
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'myReactLib'.
|
||||
@ -0,0 +1,8 @@
|
||||
//// [reactNamespaceMissingDeclaration.tsx]
|
||||
|
||||
// Error myReactLib not declared
|
||||
<foo data/>
|
||||
|
||||
//// [reactNamespaceMissingDeclaration.js]
|
||||
// Error myReactLib not declared
|
||||
myReactLib.createElement("foo", {data: true});
|
||||
15
tests/cases/compiler/reactNamespaceImportPresevation.tsx
Normal file
15
tests/cases/compiler/reactNamespaceImportPresevation.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
//@jsx: preserve
|
||||
//@module: commonjs
|
||||
//@reactNamespace: myReactLib
|
||||
|
||||
//@filename: modules.d.ts
|
||||
declare module "my-React-Lib" {
|
||||
var a: any;
|
||||
export = a;
|
||||
}
|
||||
|
||||
//@filename: test.tsx
|
||||
import * as myReactLib from "my-React-Lib"; // should not be elided
|
||||
declare var foo: any;
|
||||
|
||||
<foo data/>;
|
||||
13
tests/cases/compiler/reactNamespaceJSXEmit.tsx
Normal file
13
tests/cases/compiler/reactNamespaceJSXEmit.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
//@jsx: react
|
||||
//@reactNamespace: myReactLib
|
||||
|
||||
declare var myReactLib: any;
|
||||
declare var foo: any;
|
||||
declare var Bar: any;
|
||||
declare var x: any;
|
||||
|
||||
<foo data/>;
|
||||
<Bar x={x} />;
|
||||
<x-component />;
|
||||
<Bar {...x} />;
|
||||
<Bar { ...x } y={2} />;
|
||||
@ -0,0 +1,5 @@
|
||||
//@jsx: react
|
||||
//@reactNamespace: myReactLib
|
||||
|
||||
// Error myReactLib not declared
|
||||
<foo data/>
|
||||
Loading…
x
Reference in New Issue
Block a user