mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Cleanup emit helper checks
This commit is contained in:
@@ -21059,7 +21059,7 @@ namespace ts {
|
||||
function checkExternalEmitHelpers(location: Node, helpers: ExternalEmitHelpers) {
|
||||
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
|
||||
const sourceFile = getSourceFileOfNode(location);
|
||||
if (isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
if (!isDeclarationFile(sourceFile) && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
const helpersModule = resolveHelpersModule(sourceFile, location);
|
||||
if (helpersModule !== unknownSymbol) {
|
||||
const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
||||
@@ -21089,10 +21089,12 @@ namespace ts {
|
||||
case ExternalEmitHelpers.Awaiter: return "__awaiter";
|
||||
case ExternalEmitHelpers.Generator: return "__generator";
|
||||
case ExternalEmitHelpers.Values: return "__values";
|
||||
case ExternalEmitHelpers.Step: return "__step";
|
||||
case ExternalEmitHelpers.Close: return "__close";
|
||||
case ExternalEmitHelpers.Read: return "__read";
|
||||
case ExternalEmitHelpers.Spread: return "__spread";
|
||||
case ExternalEmitHelpers.AsyncGenerator: return "__asyncGenerator";
|
||||
case ExternalEmitHelpers.AsyncDelegator: return "__asyncDelegator";
|
||||
case ExternalEmitHelpers.AsyncValues: return "__asyncValues";
|
||||
default: Debug.fail("Unrecognized helper.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -858,7 +858,8 @@ namespace ts {
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { c = void 0, f(v), next(); }
|
||||
};`
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) {
|
||||
@@ -878,28 +879,6 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
const asyncValues: EmitHelper = {
|
||||
name: "typescript:asyncValues",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||
var m = o[Symbol.asyncIterator];
|
||||
if (m) return m.call(o);
|
||||
return typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
|
||||
context.requestEmitHelper(asyncValues);
|
||||
return createCall(
|
||||
getHelperName("__asyncValues"),
|
||||
/*typeArguments*/ undefined,
|
||||
[expression],
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
const asyncDelegator: EmitHelper = {
|
||||
name: "typescript:asyncDelegator",
|
||||
scoped: false,
|
||||
@@ -921,4 +900,25 @@ namespace ts {
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
const asyncValues: EmitHelper = {
|
||||
name: "typescript:asyncValues",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||
var m = o[Symbol.asyncIterator];
|
||||
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
|
||||
context.requestEmitHelper(asyncValues);
|
||||
return createCall(
|
||||
getHelperName("__asyncValues"),
|
||||
/*typeArguments*/ undefined,
|
||||
[expression],
|
||||
location
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3744,20 +3744,17 @@ namespace ts {
|
||||
Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation)
|
||||
Generator = 1 << 7, // __generator (used by ES2015 generator transformation)
|
||||
Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations)
|
||||
Step = 1 << 9, // __step (used by ES2015 for..of transformation)
|
||||
Close = 1 << 10, // __close (used by ES2015 for..of transformation)
|
||||
Read = 1 << 11, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Spread = 1 << 12, // __spread (used by ES2015 array spread and argument list spread transformations)
|
||||
AsyncGenerator = 1 << 13, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
AsyncStep = 1 << 15, // __asyncStep (used by ES2017 for..await..of transformation)
|
||||
AsyncDelegator = 1 << 16, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Spread = 1 << 10, // __spread (used by ES2015 array spread and argument list spread transformations)
|
||||
AsyncGenerator = 1 << 11, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncDelegator = 1 << 12, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 13, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
|
||||
// Helpers included by ES2015 for..of
|
||||
ForOfIncludes = Values | Step | Close,
|
||||
ForOfIncludes = Values,
|
||||
|
||||
// Helpers included by ES2017 for..await..of
|
||||
ForAwaitOfIncludes = AsyncValues | AsyncStep | Close,
|
||||
ForAwaitOfIncludes = AsyncValues,
|
||||
|
||||
// Helpers included by ES2015 spread
|
||||
SpreadIncludes = Read | Spread,
|
||||
|
||||
Reference in New Issue
Block a user