Added test for noCustomAsyncPromise switch

This commit is contained in:
Ron Buckton
2016-02-08 17:59:54 -08:00
parent 6e30675822
commit b0e37ab036
3 changed files with 47 additions and 0 deletions
@@ -0,0 +1,16 @@
tests/cases/conformance/async/es6/noCustomAsyncReturnType_es6.ts(3,5): error TS2529: Duplicate identifier 'Promise'. Compiler reserves name 'Promise' in top level scope of a module containing async functions.
tests/cases/conformance/async/es6/noCustomAsyncReturnType_es6.ts(5,28): error TS1064: The return type of an async function or method must be the global Promise<T> type.
==== tests/cases/conformance/async/es6/noCustomAsyncReturnType_es6.ts (2 errors) ====
interface Promise<T> extends PromiseLike<T> {}
var Promise: PromiseConstructorLike;
~~~~~~~
!!! error TS2529: Duplicate identifier 'Promise'. Compiler reserves name 'Promise' in top level scope of a module containing async functions.
export async function f(): Promise<void> {
~~~~~~~~~~~~~
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type.
}
@@ -0,0 +1,23 @@
//// [noCustomAsyncReturnType_es6.ts]
interface Promise<T> extends PromiseLike<T> {}
var Promise: PromiseConstructorLike;
export async function f(): Promise<void> {
}
//// [noCustomAsyncReturnType_es6.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
var Promise;
export function f() {
return __awaiter(this, void 0, void 0, function* () {
});
}
@@ -0,0 +1,8 @@
// @target: ES6
// @noCustomAsyncPromise: true
interface Promise<T> extends PromiseLike<T> {}
var Promise: PromiseConstructorLike;
export async function f(): Promise<void> {
}