mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 07:45:18 -06:00
Test for asyncIterator existance before defining
This commit is contained in:
parent
c224a824f3
commit
394862e829
@ -18,13 +18,17 @@ namespace ts {
|
||||
throw new Error(`Module '${id}' could not be found.`);
|
||||
}
|
||||
|
||||
// Define a custom "Symbol" constructor to attach missing built-in symbols without
|
||||
// modifying the global "Symbol" constructor
|
||||
// tslint:disable-next-line:variable-name
|
||||
const FakeSymbol: SymbolConstructor = ((description?: string) => Symbol(description)) as any;
|
||||
(<any>FakeSymbol).prototype = Symbol.prototype;
|
||||
for (const key of Object.getOwnPropertyNames(Symbol)) {
|
||||
Object.defineProperty(FakeSymbol, key, Object.getOwnPropertyDescriptor(Symbol, key)!);
|
||||
}
|
||||
(<any>FakeSymbol).asyncIterator = (<any>FakeSymbol).asyncIterator || Symbol.for("Symbol.asyncIterator");
|
||||
|
||||
// Add "asyncIterator" if missing
|
||||
if (!hasProperty(FakeSymbol, "asyncIterator")) Object.defineProperty(FakeSymbol, "asyncIterator", { value: Symbol.for("Symbol.asyncIterator"), configurable: true });
|
||||
|
||||
function evaluate(result: compiler.CompilationResult) {
|
||||
const output = result.getOutput(sourceFile, "js")!;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user