mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added test for noCustomAsyncPromise switch
This commit is contained in:
@@ -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> {
|
||||
}
|
||||
Reference in New Issue
Block a user