mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Update tests
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
// @module: commonjs
|
||||
// @target: es6
|
||||
// @noImplicitAny: false
|
||||
|
||||
declare function getSpecifier(): string;
|
||||
declare var whatToLoad: boolean;
|
||||
import(getSpecifier());
|
||||
var p1 = import(getSpecifier());
|
||||
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
|
||||
p1.then(zero => {
|
||||
return zero.foo(); // ok, zero is any
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
// @module: commonjs
|
||||
// @target: es6
|
||||
// @noImplicitAny: false
|
||||
|
||||
declare function getSpecifier(): string;
|
||||
declare var whatToLoad: boolean;
|
||||
|
||||
var a = ["./0"];
|
||||
import(...["PathModule"]);
|
||||
|
||||
var p1 = import(...a);
|
||||
const p2 = import();
|
||||
const p3 = import(,);
|
||||
const p4 = import("pathToModule", "secondModule");
|
||||
@@ -0,0 +1,17 @@
|
||||
// @module: umd
|
||||
// @target: esnext
|
||||
// @filename: 0.ts
|
||||
export class B {
|
||||
print() { return "I am B"}
|
||||
}
|
||||
|
||||
// @filename: 2.ts
|
||||
// We use Promise<any> for now as there is no way to specify shape of module object
|
||||
function foo(x: Promise<any>) {
|
||||
x.then(value => {
|
||||
let b = new value.B();
|
||||
b.print();
|
||||
})
|
||||
}
|
||||
|
||||
foo(import("./0"));
|
||||
@@ -0,0 +1,14 @@
|
||||
// @module: umd
|
||||
// @target: esnext
|
||||
// @filename: 0.ts
|
||||
export class B {
|
||||
print() { return "I am B"}
|
||||
}
|
||||
|
||||
// @filename: 2.ts
|
||||
async function foo() {
|
||||
class C extends (await import("./0")).B {}
|
||||
var c = new C();
|
||||
c.print();
|
||||
}
|
||||
foo();
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: umd
|
||||
// @target: esnext
|
||||
// @filename: 0.ts
|
||||
export class B {
|
||||
print() { return "I am B"}
|
||||
}
|
||||
|
||||
export function foo() { return "foo" }
|
||||
|
||||
// @filename: 1.ts
|
||||
export function backup() { return "backup"; }
|
||||
|
||||
// @filename: 2.ts
|
||||
declare var console: any;
|
||||
class C {
|
||||
private myModule = import("./0");
|
||||
method() {
|
||||
this.myModule.then(Zero => {
|
||||
console.log(Zero.foo());
|
||||
}, async err => {
|
||||
console.log(err);
|
||||
let one = await import("./1");
|
||||
console.log(one.backup());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: commonjs
|
||||
// @target: es6
|
||||
// @noImplicitAny: false
|
||||
|
||||
declare function getSpecifier(): string;
|
||||
declare var whatToLoad: boolean;
|
||||
declare const directory: string;
|
||||
declare const moduleFile: number;
|
||||
|
||||
import(`${directory}\${moduleFile}`);
|
||||
import(getSpecifier());
|
||||
var p1 = import(getSpecifier());
|
||||
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
|
||||
p1.then(zero => {
|
||||
return zero.foo(); // ok, zero is any
|
||||
});
|
||||
|
||||
let j: string;
|
||||
var p3 = import(j=getSpecifier());
|
||||
|
||||
function * loadModule(directories: string[]) {
|
||||
for (const directory of directories) {
|
||||
const path = `${directory}\moduleFile`;
|
||||
import(yield path);
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,14 @@
|
||||
|
||||
declare function getSpecifier(): boolean;
|
||||
declare var whatToLoad: boolean;
|
||||
|
||||
// Error specifier is not assignable to string
|
||||
import(getSpecifier());
|
||||
var p1 = import(getSpecifier());
|
||||
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
|
||||
p1.then(zero => {
|
||||
return zero.foo(); // ok, zero is any
|
||||
});
|
||||
});
|
||||
|
||||
var p3 = import(["path1", "path2"]);
|
||||
var p4 = import(()=>"PathToModule");
|
||||
Reference in New Issue
Block a user