mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'transforms' into transforms-visitPerf
This commit is contained in:
+47
-12
@@ -1638,7 +1638,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkStrictModeNumericLiteral(node: LiteralExpression) {
|
||||
function checkStrictModeNumericLiteral(node: NumericLiteral) {
|
||||
if (inStrictMode && node.isOctalLiteral) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
|
||||
}
|
||||
@@ -1786,7 +1786,7 @@ namespace ts {
|
||||
case SyntaxKind.DeleteExpression:
|
||||
return checkStrictModeDeleteExpression(<DeleteExpression>node);
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return checkStrictModeNumericLiteral(<LiteralExpression>node);
|
||||
return checkStrictModeNumericLiteral(<NumericLiteral>node);
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return checkStrictModePostfixUnaryExpression(<PostfixUnaryExpression>node);
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
@@ -2568,6 +2568,7 @@ namespace ts {
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const body = node.body;
|
||||
const typeParameters = node.typeParameters;
|
||||
const asteriskToken = node.asteriskToken;
|
||||
|
||||
// A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded,
|
||||
// generic, or has a decorator.
|
||||
@@ -2578,6 +2579,11 @@ namespace ts {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// Currently, we only support generators that were originally async function bodies.
|
||||
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
return transformFlags & ~TransformFlags.MethodOrAccessorExcludes;
|
||||
}
|
||||
@@ -2625,7 +2631,7 @@ namespace ts {
|
||||
transformFlags = TransformFlags.AssertTypeScript;
|
||||
}
|
||||
else {
|
||||
transformFlags = subtreeFlags;
|
||||
transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion;
|
||||
|
||||
// If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Export) {
|
||||
@@ -2637,12 +2643,21 @@ namespace ts {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// If a FunctionDeclaration has an asterisk token, is exported, or its
|
||||
// subtree has marked the container as needing to capture the lexical `this`,
|
||||
// then this node is ES6 syntax.
|
||||
if (asteriskToken || (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask)) {
|
||||
// If a FunctionDeclaration's subtree has marked the container as needing to capture the
|
||||
// lexical this, or the function contains parameters with initializers, then this node is
|
||||
// ES6 syntax.
|
||||
if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
}
|
||||
|
||||
// If a FunctionDeclaration is generator function and is the body of a
|
||||
// transformed async function, then this node can be transformed to a
|
||||
// down-level generator.
|
||||
// Currently we do not support transforming any other generator fucntions
|
||||
// down level.
|
||||
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2659,12 +2674,22 @@ namespace ts {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// If a FunctionExpression contains an asterisk token, or its subtree has marked the container
|
||||
// as needing to capture the lexical this, then this node is ES6 syntax.
|
||||
if (asteriskToken || (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask)) {
|
||||
// If a FunctionExpression's subtree has marked the container as needing to capture the
|
||||
// lexical this, or the function contains parameters with initializers, then this node is
|
||||
// ES6 syntax.
|
||||
if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
}
|
||||
|
||||
// If a FunctionExpression is generator function and is the body of a
|
||||
// transformed async function, then this node can be transformed to a
|
||||
// down-level generator.
|
||||
// Currently we do not support transforming any other generator fucntions
|
||||
// down level.
|
||||
if (asteriskToken && node.emitFlags & NodeEmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
return transformFlags & ~TransformFlags.FunctionExcludes;
|
||||
}
|
||||
@@ -2794,7 +2819,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function computeVariableDeclarationList(node: VariableDeclarationList, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
let transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion;
|
||||
|
||||
if (subtreeFlags & TransformFlags.ContainsBindingPattern) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
@@ -2859,11 +2884,15 @@ namespace ts {
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.YieldExpression:
|
||||
// These nodes are ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
break;
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
// This node is ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsYield;
|
||||
break;
|
||||
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
@@ -2985,6 +3014,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.BreakStatement:
|
||||
transformFlags |= TransformFlags.ContainsHoistedDeclarationOrCompletion;
|
||||
break;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
|
||||
+29
-20
@@ -149,6 +149,7 @@ namespace ts {
|
||||
let getGlobalESSymbolConstructorSymbol: () => Symbol;
|
||||
|
||||
let getGlobalPromiseConstructorSymbol: () => Symbol;
|
||||
let tryGetGlobalPromiseConstructorSymbol: () => Symbol;
|
||||
|
||||
let globalObjectType: ObjectType;
|
||||
let globalFunctionType: ObjectType;
|
||||
@@ -8337,10 +8338,13 @@ namespace ts {
|
||||
// can explicitly bound arguments objects
|
||||
if (symbol === argumentsSymbol) {
|
||||
const container = getContainingFunction(node);
|
||||
if (container.kind === SyntaxKind.ArrowFunction) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (container.kind === SyntaxKind.ArrowFunction) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
|
||||
}
|
||||
else if (hasModifier(container, ModifierFlags.Async)) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.flags & NodeFlags.AwaitContext) {
|
||||
@@ -12991,7 +12995,7 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
function checkNumericLiteral(node: LiteralExpression): Type {
|
||||
function checkNumericLiteral(node: NumericLiteral): Type {
|
||||
// Grammar checking
|
||||
checkGrammarNumericLiteral(node);
|
||||
return numberType;
|
||||
@@ -13011,7 +13015,7 @@ namespace ts {
|
||||
case SyntaxKind.FalseKeyword:
|
||||
return booleanType;
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return checkNumericLiteral(<LiteralExpression>node);
|
||||
return checkNumericLiteral(<NumericLiteral>node);
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return checkTemplateExpression(<TemplateExpression>node);
|
||||
case SyntaxKind.StringLiteral:
|
||||
@@ -14194,7 +14198,7 @@ namespace ts {
|
||||
* @param returnType The return type of a FunctionLikeDeclaration
|
||||
* @param location The node on which to report the error.
|
||||
*/
|
||||
function checkCorrectPromiseType(returnType: Type, location: Node) {
|
||||
function checkCorrectPromiseType(returnType: Type, location: Node, diagnostic: DiagnosticMessage, typeName?: string) {
|
||||
if (returnType === unknownType) {
|
||||
// The return type already had some other error, so we ignore and return
|
||||
// the unknown type.
|
||||
@@ -14213,7 +14217,7 @@ namespace ts {
|
||||
|
||||
// The promise type was not a valid type reference to the global promise type, so we
|
||||
// report an error and return the unknown type.
|
||||
error(location, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
||||
error(location, diagnostic, typeName);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -14233,7 +14237,7 @@ namespace ts {
|
||||
function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
const returnType = getTypeFromTypeNode(node.type);
|
||||
return checkCorrectPromiseType(returnType, node.type);
|
||||
return checkCorrectPromiseType(returnType, node.type, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
||||
}
|
||||
|
||||
const globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType();
|
||||
@@ -14279,11 +14283,11 @@ namespace ts {
|
||||
|
||||
const promiseConstructor = getNodeLinks(node.type).resolvedSymbol;
|
||||
if (!promiseConstructor || !symbolIsValue(promiseConstructor)) {
|
||||
// try to fall back to global promise type.
|
||||
const typeName = promiseConstructor
|
||||
? symbolToString(promiseConstructor)
|
||||
: typeToString(promiseType);
|
||||
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName);
|
||||
return unknownType;
|
||||
return checkCorrectPromiseType(promiseType, node.type, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName);
|
||||
}
|
||||
|
||||
// If the Promise constructor, resolved locally, is an alias symbol we should mark it as referenced.
|
||||
@@ -14291,7 +14295,7 @@ namespace ts {
|
||||
|
||||
// Validate the promise constructor type.
|
||||
const promiseConstructorType = getTypeOfSymbol(promiseConstructor);
|
||||
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) {
|
||||
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -16272,7 +16276,7 @@ namespace ts {
|
||||
}
|
||||
return undefined;
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return +(<LiteralExpression>e).text;
|
||||
return +(<NumericLiteral>e).text;
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return evalConstant((<ParenthesizedExpression>e).expression);
|
||||
case SyntaxKind.Identifier:
|
||||
@@ -17491,7 +17495,7 @@ namespace ts {
|
||||
if (objectType === unknownType) return undefined;
|
||||
const apparentType = getApparentType(objectType);
|
||||
if (apparentType === unknownType) return undefined;
|
||||
return getPropertyOfType(apparentType, (<LiteralExpression>node).text);
|
||||
return getPropertyOfType(apparentType, (<NumericLiteral>node).text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -17976,6 +17980,11 @@ namespace ts {
|
||||
function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind {
|
||||
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
|
||||
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
|
||||
const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol();
|
||||
if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
|
||||
return TypeReferenceSerializationKind.Promise;
|
||||
}
|
||||
|
||||
const constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined;
|
||||
if (constructorType && isConstructorType(constructorType)) {
|
||||
return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
|
||||
@@ -17994,8 +18003,8 @@ namespace ts {
|
||||
else if (type.flags & TypeFlags.Any) {
|
||||
return TypeReferenceSerializationKind.ObjectType;
|
||||
}
|
||||
else if (isTypeOfKind(type, TypeFlags.Void)) {
|
||||
return TypeReferenceSerializationKind.VoidType;
|
||||
else if (isTypeOfKind(type, TypeFlags.Void | TypeFlags.Nullable | TypeFlags.Never)) {
|
||||
return TypeReferenceSerializationKind.VoidNullableOrNeverType;
|
||||
}
|
||||
else if (isTypeOfKind(type, TypeFlags.Boolean)) {
|
||||
return TypeReferenceSerializationKind.BooleanType;
|
||||
@@ -18293,6 +18302,7 @@ namespace ts {
|
||||
getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1));
|
||||
getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType);
|
||||
getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise"));
|
||||
tryGetGlobalPromiseConstructorSymbol = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Value, /*diagnostic*/ undefined) && getGlobalPromiseConstructorSymbol());
|
||||
getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike"));
|
||||
getGlobalThenableType = memoize(createThenableType);
|
||||
|
||||
@@ -18348,6 +18358,9 @@ namespace ts {
|
||||
}
|
||||
if (requestedExternalEmitHelpers & NodeFlags.HasAsyncFunctions) {
|
||||
verifyHelperSymbol(exports, "__awaiter", SymbolFlags.Value);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
verifyHelperSymbol(exports, "__generator", SymbolFlags.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18654,10 +18667,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkGrammarAsyncModifier(node: Node, asyncModifier: Node): boolean {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
return grammarErrorOnNode(asyncModifier, Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_2015_or_higher);
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -18967,7 +18976,7 @@ namespace ts {
|
||||
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
|
||||
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
|
||||
if (name.kind === SyntaxKind.NumericLiteral) {
|
||||
checkGrammarNumericLiteral(<LiteralExpression>name);
|
||||
checkGrammarNumericLiteral(<NumericLiteral>name);
|
||||
}
|
||||
currentKind = Property;
|
||||
}
|
||||
@@ -19489,7 +19498,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarNumericLiteral(node: LiteralExpression): boolean {
|
||||
function checkGrammarNumericLiteral(node: NumericLiteral): boolean {
|
||||
// Grammar checking
|
||||
if (node.isOctalLiteral && languageVersion >= ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
|
||||
|
||||
+15
-12
@@ -426,13 +426,14 @@ namespace ts {
|
||||
return ~low;
|
||||
}
|
||||
|
||||
export function reduceLeft<T, U>(array: T[], f: (memo: U, value: T, i: number) => U, initial: U): U;
|
||||
export function reduceLeft<T, U>(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U;
|
||||
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T): T;
|
||||
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T): T {
|
||||
if (array) {
|
||||
const count = array.length;
|
||||
if (count > 0) {
|
||||
let pos = 0;
|
||||
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T {
|
||||
if (array && array.length > 0) {
|
||||
const size = array.length;
|
||||
if (size > 0) {
|
||||
let pos = start === undefined || start < 0 ? 0 : start;
|
||||
const end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
|
||||
let result: T;
|
||||
if (arguments.length <= 2) {
|
||||
result = array[pos];
|
||||
@@ -441,7 +442,7 @@ namespace ts {
|
||||
else {
|
||||
result = initial;
|
||||
}
|
||||
while (pos < count) {
|
||||
while (pos <= end) {
|
||||
result = f(result, array[pos], pos);
|
||||
pos++;
|
||||
}
|
||||
@@ -451,12 +452,14 @@ namespace ts {
|
||||
return initial;
|
||||
}
|
||||
|
||||
export function reduceRight<T, U>(array: T[], f: (memo: U, value: T, i: number) => U, initial: U): U;
|
||||
export function reduceRight<T, U>(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U;
|
||||
export function reduceRight<T>(array: T[], f: (memo: T, value: T, i: number) => T): T;
|
||||
export function reduceRight<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T): T {
|
||||
export function reduceRight<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T {
|
||||
if (array) {
|
||||
let pos = array.length - 1;
|
||||
if (pos >= 0) {
|
||||
const size = array.length;
|
||||
if (size > 0) {
|
||||
let pos = start === undefined || start > size - 1 ? size - 1 : start;
|
||||
const end = count === undefined || pos - count < 0 ? 0 : pos - count;
|
||||
let result: T;
|
||||
if (arguments.length <= 2) {
|
||||
result = array[pos];
|
||||
@@ -465,7 +468,7 @@ namespace ts {
|
||||
else {
|
||||
result = initial;
|
||||
}
|
||||
while (pos >= 0) {
|
||||
while (pos >= end) {
|
||||
result = f(result, array[pos], pos);
|
||||
pos--;
|
||||
}
|
||||
|
||||
@@ -827,10 +827,6 @@
|
||||
"category": "Error",
|
||||
"code": 1308
|
||||
},
|
||||
"Async functions are only available when targeting ECMAScript 2015 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1311
|
||||
},
|
||||
"'=' can only be used in an object literal property inside a destructuring assignment.": {
|
||||
"category": "Error",
|
||||
"code": 1312
|
||||
@@ -1703,7 +1699,7 @@
|
||||
"category": "Error",
|
||||
"code": 2521
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": {
|
||||
"The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.": {
|
||||
"category": "Error",
|
||||
"code": 2522
|
||||
},
|
||||
|
||||
+64
-6
@@ -71,6 +71,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};`;
|
||||
|
||||
const generatorHelper = `
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (sent[0] === 1) throw sent[1]; return sent[1]; }, trys: [], stack: [] }, sent, f;
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (1) {
|
||||
if (_.done) switch (op[0]) {
|
||||
case 0: return { value: void 0, done: true };
|
||||
case 1: case 6: throw op[1];
|
||||
case 2: return { value: op[1], done: true };
|
||||
}
|
||||
try {
|
||||
switch (f = 1, op[0]) {
|
||||
case 0: case 1: sent = op; break;
|
||||
case 4: return _.label++, { value: op[1], done: false };
|
||||
case 7: op = _.stack.pop(), _.trys.pop(); continue;
|
||||
default:
|
||||
var r = _.trys.length > 0 && _.trys[_.trys.length - 1];
|
||||
if (!r && (op[0] === 6 || op[0] === 2)) { _.done = 1; continue; }
|
||||
if (op[0] === 3 && (!r || (op[1] > r[0] && op[1] < r[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < r[1]) { _.label = r[1], sent = op; break; }
|
||||
if (r && _.label < r[2]) { _.label = r[2], _.stack.push(op); break; }
|
||||
if (r[2]) { _.stack.pop(); }
|
||||
_.trys.pop();
|
||||
continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
}
|
||||
catch (e) { op = [6, e]; }
|
||||
finally { f = 0, sent = void 0; }
|
||||
}
|
||||
}
|
||||
return {
|
||||
next: function (v) { return step([0, v]); },
|
||||
"throw": function (v) { return step([1, v]); },
|
||||
"return": function (v) { return step([2, v]); }
|
||||
};
|
||||
};`;
|
||||
|
||||
// emit output for the __export helper function
|
||||
const exportStarHelper = `
|
||||
function __export(m) {
|
||||
@@ -685,6 +724,8 @@ const _super = (function (geti, seti) {
|
||||
switch (kind) {
|
||||
// Literals
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return emitNumericLiteral(<NumericLiteral>node);
|
||||
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
@@ -773,6 +814,13 @@ const _super = (function (geti, seti) {
|
||||
//
|
||||
|
||||
// SyntaxKind.NumericLiteral
|
||||
function emitNumericLiteral(node: NumericLiteral) {
|
||||
emitLiteral(node);
|
||||
if (node.trailingComment) {
|
||||
write(` /*${node.trailingComment}*/`);
|
||||
}
|
||||
}
|
||||
|
||||
// SyntaxKind.StringLiteral
|
||||
// SyntaxKind.RegularExpressionLiteral
|
||||
// SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
@@ -1563,15 +1611,21 @@ const _super = (function (geti, seti) {
|
||||
increaseIndent();
|
||||
}
|
||||
|
||||
const savedTempFlags = tempFlags;
|
||||
tempFlags = 0;
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
if (node.emitFlags & NodeEmitFlags.ReuseTempVariableScope) {
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
}
|
||||
else {
|
||||
const savedTempFlags = tempFlags;
|
||||
tempFlags = 0;
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
tempFlags = savedTempFlags;
|
||||
}
|
||||
|
||||
if (indentedFlag) {
|
||||
decreaseIndent();
|
||||
}
|
||||
|
||||
tempFlags = savedTempFlags;
|
||||
}
|
||||
else {
|
||||
emitSignatureHead(node);
|
||||
@@ -2157,6 +2211,10 @@ const _super = (function (geti, seti) {
|
||||
|
||||
if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) {
|
||||
writeLines(awaiterHelper);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
writeLines(generatorHelper);
|
||||
}
|
||||
|
||||
awaiterEmitted = true;
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
+187
-29
@@ -104,7 +104,7 @@ namespace ts {
|
||||
|
||||
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: string, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: number, location?: TextRange): LiteralExpression;
|
||||
export function createLiteral(value: number, location?: TextRange): NumericLiteral;
|
||||
export function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression;
|
||||
export function createLiteral(value: string | number | boolean | StringLiteral | Identifier, location?: TextRange): PrimaryExpression {
|
||||
if (typeof value === "number") {
|
||||
@@ -141,7 +141,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTempVariable(recordTempVariable: (node: Identifier) => void, location?: TextRange): Identifier {
|
||||
export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier {
|
||||
const name = <Identifier>createNode(SyntaxKind.Identifier, location);
|
||||
name.text = "";
|
||||
name.originalKeywordKind = SyntaxKind.Unknown;
|
||||
@@ -430,8 +430,9 @@ namespace ts {
|
||||
const node = <ArrayLiteralExpression>createNode(SyntaxKind.ArrayLiteralExpression, location);
|
||||
node.elements = parenthesizeListElements(createNodeArray(elements));
|
||||
if (multiLine) {
|
||||
node.multiLine = multiLine;
|
||||
node.multiLine = true;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -446,7 +447,7 @@ namespace ts {
|
||||
const node = <ObjectLiteralExpression>createNode(SyntaxKind.ObjectLiteralExpression, location);
|
||||
node.properties = createNodeArray(properties);
|
||||
if (multiLine) {
|
||||
node.multiLine = multiLine;
|
||||
node.multiLine = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -996,6 +997,22 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTryCatchFinally(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange) {
|
||||
const node = <TryStatement>createNode(SyntaxKind.TryStatement, location);
|
||||
node.tryBlock = tryBlock;
|
||||
node.catchClause = catchClause;
|
||||
node.finallyBlock = finallyBlock;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTryCatch(tryBlock: Block, catchClause: CatchClause, location?: TextRange) {
|
||||
return createTryCatchFinally(tryBlock, catchClause, /*finallyBlock*/ undefined, location);
|
||||
}
|
||||
|
||||
export function createTryFinally(tryBlock: Block, finallyBlock: Block, location?: TextRange) {
|
||||
return createTryCatchFinally(tryBlock, /*catchClause*/ undefined, finallyBlock, location);
|
||||
}
|
||||
|
||||
export function updateReturn(node: ReturnStatement, expression: Expression) {
|
||||
if (node.expression !== expression) {
|
||||
return updateNode(createReturn(expression, /*location*/ node), node);
|
||||
@@ -1391,13 +1408,13 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, setNodeEmitFlags: (node: Node, flags: NodeEmitFlags) => void, location?: TextRange): MemberExpression {
|
||||
export function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression {
|
||||
if (isComputedPropertyName(memberName)) {
|
||||
return createElementAccess(target, memberName.expression, location);
|
||||
}
|
||||
else {
|
||||
const expression = isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location);
|
||||
setNodeEmitFlags(expression, expression.emitFlags ? NodeEmitFlags.NoNestedSourceMaps | expression.emitFlags : NodeEmitFlags.NoNestedSourceMaps);
|
||||
expression.emitFlags |= NodeEmitFlags.NoNestedSourceMaps;
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
@@ -1564,6 +1581,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) {
|
||||
const generatorFunc = createFunctionExpression(
|
||||
createNode(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
/*type*/ undefined,
|
||||
body
|
||||
);
|
||||
|
||||
// Mark this node as originally an async function
|
||||
generatorFunc.emitFlags |= NodeEmitFlags.AsyncFunctionBody;
|
||||
|
||||
return createCall(
|
||||
createHelperName(externalHelpersModuleName, "__awaiter"),
|
||||
/*typeArguments*/ undefined,
|
||||
@@ -1571,14 +1600,7 @@ namespace ts {
|
||||
createThis(),
|
||||
hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(),
|
||||
promiseConstructor ? createExpressionFromEntityName(promiseConstructor) : createVoidZero(),
|
||||
createFunctionExpression(
|
||||
createNode(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
/*type*/ undefined,
|
||||
body
|
||||
)
|
||||
generatorFunc
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1776,19 +1798,29 @@ namespace ts {
|
||||
thisArg: Expression;
|
||||
}
|
||||
|
||||
function shouldBeCapturedInTempVariable(node: Expression): boolean {
|
||||
switch (skipParentheses(node).kind) {
|
||||
function shouldBeCapturedInTempVariable(node: Expression, cacheIdentifiers: boolean): boolean {
|
||||
const target = skipParentheses(node);
|
||||
switch (target.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return cacheIdentifiers;
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return false;
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
const elements = (<ArrayLiteralExpression>target).elements;
|
||||
if (elements.length === 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return (<ObjectLiteralExpression>target).properties.length > 0;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget): CallBinding {
|
||||
export function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding {
|
||||
const callee = skipOuterExpressions(expression, OuterExpressionKinds.All);
|
||||
let thisArg: Expression;
|
||||
let target: LeftHandSideExpression;
|
||||
@@ -1803,7 +1835,7 @@ namespace ts {
|
||||
else {
|
||||
switch (callee.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression: {
|
||||
if (shouldBeCapturedInTempVariable((<PropertyAccessExpression>callee).expression)) {
|
||||
if (shouldBeCapturedInTempVariable((<PropertyAccessExpression>callee).expression, cacheIdentifiers)) {
|
||||
// for `a.b()` target is `(_a = a).b` and thisArg is `_a`
|
||||
thisArg = createTempVariable(recordTempVariable);
|
||||
target = createPropertyAccess(
|
||||
@@ -1824,7 +1856,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
case SyntaxKind.ElementAccessExpression: {
|
||||
if (shouldBeCapturedInTempVariable((<ElementAccessExpression>callee).expression)) {
|
||||
if (shouldBeCapturedInTempVariable((<ElementAccessExpression>callee).expression, cacheIdentifiers)) {
|
||||
// for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a`
|
||||
thisArg = createTempVariable(recordTempVariable);
|
||||
target = createElementAccess(
|
||||
@@ -1884,6 +1916,124 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function createExpressionForObjectLiteralElement(node: ObjectLiteralExpression, property: ObjectLiteralElement, receiver: Expression): Expression {
|
||||
switch (property.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return createExpressionForAccessorDeclaration(node.properties, <AccessorDeclaration>property, receiver, node.multiLine);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return createExpressionForPropertyAssignment(<PropertyAssignment>property, receiver);
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return createExpressionForShorthandPropertyAssignment(<ShorthandPropertyAssignment>property, receiver);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return createExpressionForMethodDeclaration(<MethodDeclaration>property, receiver);
|
||||
}
|
||||
}
|
||||
|
||||
function createExpressionForAccessorDeclaration(properties: NodeArray<Declaration>, property: AccessorDeclaration, receiver: Expression, multiLine: boolean) {
|
||||
const { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(properties, property);
|
||||
if (property === firstAccessor) {
|
||||
const properties: ObjectLiteralElement[] = [];
|
||||
if (getAccessor) {
|
||||
const getterFunction = createFunctionExpression(
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
getAccessor.parameters,
|
||||
/*type*/ undefined,
|
||||
getAccessor.body,
|
||||
/*location*/ getAccessor
|
||||
);
|
||||
setOriginalNode(getterFunction, getAccessor);
|
||||
const getter = createPropertyAssignment("get", getterFunction);
|
||||
properties.push(getter);
|
||||
}
|
||||
|
||||
if (setAccessor) {
|
||||
const setterFunction = createFunctionExpression(
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
setAccessor.parameters,
|
||||
/*type*/ undefined,
|
||||
setAccessor.body,
|
||||
/*location*/ setAccessor
|
||||
);
|
||||
setOriginalNode(setterFunction, setAccessor);
|
||||
const setter = createPropertyAssignment("set", setterFunction);
|
||||
properties.push(setter);
|
||||
}
|
||||
|
||||
properties.push(createPropertyAssignment("enumerable", createLiteral(true)));
|
||||
properties.push(createPropertyAssignment("configurable", createLiteral(true)));
|
||||
|
||||
const expression = createCall(
|
||||
createPropertyAccess(createIdentifier("Object"), "defineProperty"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
receiver,
|
||||
createExpressionForPropertyName(property.name),
|
||||
createObjectLiteral(properties, /*location*/ undefined, multiLine)
|
||||
],
|
||||
/*location*/ firstAccessor
|
||||
);
|
||||
|
||||
return aggregateTransformFlags(expression);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createExpressionForPropertyAssignment(property: PropertyAssignment, receiver: Expression) {
|
||||
return aggregateTransformFlags(
|
||||
setOriginalNode(
|
||||
createAssignment(
|
||||
createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name),
|
||||
property.initializer,
|
||||
/*location*/ property
|
||||
),
|
||||
/*original*/ property
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function createExpressionForShorthandPropertyAssignment(property: ShorthandPropertyAssignment, receiver: Expression) {
|
||||
return aggregateTransformFlags(
|
||||
setOriginalNode(
|
||||
createAssignment(
|
||||
createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name),
|
||||
getSynthesizedClone(property.name),
|
||||
/*location*/ property
|
||||
),
|
||||
/*original*/ property
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function createExpressionForMethodDeclaration(method: MethodDeclaration, receiver: Expression) {
|
||||
return aggregateTransformFlags(
|
||||
setOriginalNode(
|
||||
createAssignment(
|
||||
createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name),
|
||||
setOriginalNode(
|
||||
createFunctionExpression(
|
||||
method.asteriskToken,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
method.parameters,
|
||||
/*type*/ undefined,
|
||||
method.body,
|
||||
/*location*/ method
|
||||
),
|
||||
/*original*/ method
|
||||
),
|
||||
/*location*/ method
|
||||
),
|
||||
/*original*/ method
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
||||
function isUseStrictPrologue(node: ExpressionStatement): boolean {
|
||||
@@ -1899,28 +2049,36 @@ namespace ts {
|
||||
* @param target: result statements array
|
||||
* @param source: origin statements array
|
||||
* @param ensureUseStrict: boolean determining whether the function need to add prologue-directives
|
||||
* @param visitor: Optional callback used to visit any custom prologue directives.
|
||||
*/
|
||||
export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean): number {
|
||||
export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult<Node>): number {
|
||||
Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array");
|
||||
let foundUseStrict = false;
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
if (isPrologueDirective(source[i])) {
|
||||
if (isUseStrictPrologue(source[i] as ExpressionStatement)) {
|
||||
let statementOffset = 0;
|
||||
const numStatements = source.length;
|
||||
while (statementOffset < numStatements) {
|
||||
const statement = source[statementOffset];
|
||||
if (isPrologueDirective(statement)) {
|
||||
if (isUseStrictPrologue(statement as ExpressionStatement)) {
|
||||
foundUseStrict = true;
|
||||
}
|
||||
|
||||
target.push(source[i]);
|
||||
target.push(statement);
|
||||
}
|
||||
else {
|
||||
if (ensureUseStrict && !foundUseStrict) {
|
||||
target.push(startOnNewLine(createStatement(createLiteral("use strict"))));
|
||||
foundUseStrict = true;
|
||||
}
|
||||
if (statement.emitFlags & NodeEmitFlags.CustomPrologue) {
|
||||
target.push(visitor ? visitNode(statement, visitor, isStatement) : statement);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
statementOffset++;
|
||||
}
|
||||
|
||||
return source.length;
|
||||
return statementOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <reference path="transformers/jsx.ts" />
|
||||
/// <reference path="transformers/es7.ts" />
|
||||
/// <reference path="transformers/es6.ts" />
|
||||
/// <reference path="transformers/generators.ts" />
|
||||
/// <reference path="transformers/module/module.ts" />
|
||||
/// <reference path="transformers/module/system.ts" />
|
||||
/// <reference path="transformers/module/es6.ts" />
|
||||
@@ -179,6 +180,7 @@ namespace ts {
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
transformers.push(transformES6);
|
||||
transformers.push(transformGenerators);
|
||||
}
|
||||
|
||||
return transformers;
|
||||
|
||||
@@ -376,6 +376,9 @@ namespace ts {
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return visitTemplateExpression(<TemplateExpression>node);
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
return visitYieldExpression(<YieldExpression>node);
|
||||
|
||||
case SyntaxKind.SuperKeyword:
|
||||
return visitSuperKeyword(<PrimaryExpression>node);
|
||||
|
||||
@@ -927,21 +930,27 @@ namespace ts {
|
||||
// of an initializer, we must emit that expression to preserve side effects.
|
||||
if (name.elements.length > 0) {
|
||||
statements.push(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(
|
||||
flattenParameterDestructuring(context, parameter, temp, visitor)
|
||||
)
|
||||
setNodeEmitFlags(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(
|
||||
flattenParameterDestructuring(context, parameter, temp, visitor)
|
||||
)
|
||||
),
|
||||
NodeEmitFlags.CustomPrologue
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (initializer) {
|
||||
statements.push(
|
||||
createStatement(
|
||||
createAssignment(
|
||||
temp,
|
||||
visitNode(initializer, visitor, isExpression)
|
||||
)
|
||||
setNodeEmitFlags(
|
||||
createStatement(
|
||||
createAssignment(
|
||||
temp,
|
||||
visitNode(initializer, visitor, isExpression)
|
||||
)
|
||||
),
|
||||
NodeEmitFlags.CustomPrologue
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -978,7 +987,7 @@ namespace ts {
|
||||
/*location*/ parameter
|
||||
);
|
||||
statement.startsOnNewLine = true;
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoTrailingSourceMap);
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoTrailingSourceMap | NodeEmitFlags.CustomPrologue);
|
||||
statements.push(statement);
|
||||
}
|
||||
|
||||
@@ -1020,16 +1029,19 @@ namespace ts {
|
||||
|
||||
// var param = [];
|
||||
statements.push(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
declarationName,
|
||||
/*type*/ undefined,
|
||||
createArrayLiteral([])
|
||||
)
|
||||
]),
|
||||
/*location*/ parameter
|
||||
setNodeEmitFlags(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
declarationName,
|
||||
/*type*/ undefined,
|
||||
createArrayLiteral([])
|
||||
)
|
||||
]),
|
||||
/*location*/ parameter
|
||||
),
|
||||
NodeEmitFlags.CustomPrologue
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1062,7 +1074,7 @@ namespace ts {
|
||||
])
|
||||
);
|
||||
|
||||
setNodeEmitFlags(forStatement, NodeEmitFlags.SourceMapAdjustRestParameterLoop);
|
||||
setNodeEmitFlags(forStatement, NodeEmitFlags.SourceMapAdjustRestParameterLoop | NodeEmitFlags.CustomPrologue);
|
||||
startOnNewLine(forStatement);
|
||||
statements.push(forStatement);
|
||||
}
|
||||
@@ -1087,7 +1099,7 @@ namespace ts {
|
||||
])
|
||||
);
|
||||
|
||||
setNodeEmitFlags(captureThisStatement, NodeEmitFlags.NoComments);
|
||||
setNodeEmitFlags(captureThisStatement, NodeEmitFlags.NoComments | NodeEmitFlags.CustomPrologue);
|
||||
setSourceMapRange(captureThisStatement, node);
|
||||
statements.push(captureThisStatement);
|
||||
}
|
||||
@@ -1159,7 +1171,6 @@ namespace ts {
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
visitNode(member.name, visitor, isPropertyName),
|
||||
setNodeEmitFlags,
|
||||
/*location*/ member.name
|
||||
),
|
||||
func
|
||||
@@ -1345,7 +1356,7 @@ namespace ts {
|
||||
if (isBlock(body)) {
|
||||
// ensureUseStrict is false because no new prologue-directive should be added.
|
||||
// addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array
|
||||
statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false);
|
||||
statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor);
|
||||
}
|
||||
|
||||
addCaptureThisForNodeIfNeeded(statements, node);
|
||||
@@ -1859,22 +1870,24 @@ namespace ts {
|
||||
*
|
||||
* @param node An ObjectLiteralExpression node.
|
||||
*/
|
||||
function visitObjectLiteralExpression(node: ObjectLiteralExpression): LeftHandSideExpression {
|
||||
function visitObjectLiteralExpression(node: ObjectLiteralExpression): Expression {
|
||||
// We are here because a ComputedPropertyName was used somewhere in the expression.
|
||||
const properties = node.properties;
|
||||
const numProperties = properties.length;
|
||||
|
||||
// Find the first computed property.
|
||||
// Everything until that point can be emitted as part of the initial object literal.
|
||||
let numInitialNonComputedProperties = numProperties;
|
||||
for (let i = 0, n = properties.length; i < n; i++) {
|
||||
if (properties[i].name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
numInitialNonComputedProperties = i;
|
||||
let numInitialProperties = numProperties;
|
||||
for (let i = 0; i < numProperties; i++) {
|
||||
const property = properties[i];
|
||||
if (property.transformFlags & TransformFlags.ContainsYield
|
||||
|| property.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
numInitialProperties = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(numInitialNonComputedProperties !== numProperties);
|
||||
Debug.assert(numInitialProperties !== numProperties);
|
||||
|
||||
// For computed properties, we need to create a unique handle to the object
|
||||
// literal so we can modify it without risking internal assignments tainting the object.
|
||||
@@ -1887,7 +1900,7 @@ namespace ts {
|
||||
temp,
|
||||
setNodeEmitFlags(
|
||||
createObjectLiteral(
|
||||
visitNodes(properties, visitor, isObjectLiteralElement, 0, numInitialNonComputedProperties),
|
||||
visitNodes(properties, visitor, isObjectLiteralElement, 0, numInitialProperties),
|
||||
/*location*/ undefined,
|
||||
node.multiLine
|
||||
),
|
||||
@@ -1897,12 +1910,12 @@ namespace ts {
|
||||
node.multiLine
|
||||
);
|
||||
|
||||
addObjectLiteralMembers(expressions, node, temp, numInitialNonComputedProperties);
|
||||
addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
|
||||
|
||||
// We need to clone the temporary identifier so that we can write it on a
|
||||
// new line
|
||||
addNode(expressions, getMutableClone(temp), node.multiLine);
|
||||
return createParen(inlineExpressions(expressions));
|
||||
return inlineExpressions(expressions);
|
||||
}
|
||||
|
||||
function shouldConvertIterationStatementBody(node: IterationStatement): boolean {
|
||||
@@ -2290,10 +2303,10 @@ namespace ts {
|
||||
* @param numInitialNonComputedProperties The number of initial properties without
|
||||
* computed property names.
|
||||
*/
|
||||
function addObjectLiteralMembers(expressions: Expression[], node: ObjectLiteralExpression, receiver: Identifier, numInitialNonComputedProperties: number) {
|
||||
function addObjectLiteralMembers(expressions: Expression[], node: ObjectLiteralExpression, receiver: Identifier, start: number) {
|
||||
const properties = node.properties;
|
||||
const numProperties = properties.length;
|
||||
for (let i = numInitialNonComputedProperties; i < numProperties; i++) {
|
||||
for (let i = start; i < numProperties; i++) {
|
||||
const property = properties[i];
|
||||
switch (property.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
@@ -2335,8 +2348,7 @@ namespace ts {
|
||||
return createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
visitNode(property.name, visitor, isPropertyName),
|
||||
setNodeEmitFlags
|
||||
visitNode(property.name, visitor, isPropertyName)
|
||||
),
|
||||
visitNode(property.initializer, visitor, isExpression),
|
||||
/*location*/ property
|
||||
@@ -2354,8 +2366,7 @@ namespace ts {
|
||||
return createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
visitNode(property.name, visitor, isPropertyName),
|
||||
setNodeEmitFlags
|
||||
visitNode(property.name, visitor, isPropertyName)
|
||||
),
|
||||
getSynthesizedClone(property.name),
|
||||
/*location*/ property
|
||||
@@ -2373,8 +2384,7 @@ namespace ts {
|
||||
return createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
visitNode(method.name, visitor, isPropertyName),
|
||||
setNodeEmitFlags
|
||||
visitNode(method.name, visitor, isPropertyName)
|
||||
),
|
||||
transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined),
|
||||
/*location*/ method
|
||||
@@ -2414,6 +2424,16 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a YieldExpression node.
|
||||
*
|
||||
* @param node A YieldExpression node.
|
||||
*/
|
||||
function visitYieldExpression(node: YieldExpression): Expression {
|
||||
// `yield` expressions are transformed using the generators transformer.
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an ArrayLiteralExpression that contains a spread element.
|
||||
*
|
||||
@@ -2982,4 +3002,4 @@ namespace ts {
|
||||
return isIdentifier(expression) && expression === parameter.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -84,7 +84,7 @@ namespace ts {
|
||||
startLexicalEnvironment();
|
||||
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor);
|
||||
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
|
||||
addRange(statements, endLexicalEnvironment());
|
||||
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false);
|
||||
@@ -203,7 +203,7 @@ namespace ts {
|
||||
startLexicalEnvironment();
|
||||
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor);
|
||||
|
||||
// Visit each statement of the module body.
|
||||
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace ts {
|
||||
startLexicalEnvironment();
|
||||
|
||||
// Add any prologue directives.
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict);
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement);
|
||||
|
||||
// var __moduleName = context_1 && context_1.id;
|
||||
addNode(statements,
|
||||
|
||||
@@ -425,7 +425,7 @@ namespace ts {
|
||||
&& (isExternalModule(node) || compilerOptions.isolatedModules)) {
|
||||
startLexicalEnvironment();
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements);
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor);
|
||||
const externalHelpersModuleName = createUniqueName(externalHelpersModuleNameText);
|
||||
const externalHelpersModuleImport = createImportDeclaration(
|
||||
createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)),
|
||||
@@ -938,7 +938,7 @@ namespace ts {
|
||||
if (ctor.body) {
|
||||
const statements = ctor.body.statements;
|
||||
// add prologue directives to the list (if any)
|
||||
const index = addPrologueDirectives(result, statements);
|
||||
const index = addPrologueDirectives(result, statements, /*ensureUseStrict*/ false, visitor);
|
||||
if (index === statements.length) {
|
||||
// list contains nothing but prologue directives (or empty) - exit
|
||||
return index;
|
||||
@@ -1089,7 +1089,7 @@ namespace ts {
|
||||
function transformInitializedProperty(node: ClassExpression | ClassDeclaration, property: PropertyDeclaration, receiver: LeftHandSideExpression) {
|
||||
const propertyName = visitPropertyNameOfClassElement(property);
|
||||
const initializer = visitNode(property.initializer, visitor, isExpression);
|
||||
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, setNodeEmitFlags, /*location*/ propertyName);
|
||||
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
|
||||
|
||||
return createAssignment(memberAccess, initializer);
|
||||
}
|
||||
@@ -1776,7 +1776,7 @@ namespace ts {
|
||||
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
||||
return serializeEntityNameAsExpression(node.typeName, /*useFallback*/ false);
|
||||
|
||||
case TypeReferenceSerializationKind.VoidType:
|
||||
case TypeReferenceSerializationKind.VoidNullableOrNeverType:
|
||||
return createVoidZero();
|
||||
|
||||
case TypeReferenceSerializationKind.BooleanType:
|
||||
@@ -1799,6 +1799,9 @@ namespace ts {
|
||||
case TypeReferenceSerializationKind.TypeWithCallSignature:
|
||||
return createIdentifier("Function");
|
||||
|
||||
case TypeReferenceSerializationKind.Promise:
|
||||
return createIdentifier("Promise");
|
||||
|
||||
case TypeReferenceSerializationKind.ObjectType:
|
||||
default:
|
||||
return createIdentifier("Object");
|
||||
@@ -2186,11 +2189,13 @@ namespace ts {
|
||||
return transformFunctionBodyWorker(node.body);
|
||||
}
|
||||
|
||||
function transformFunctionBodyWorker(body: Block) {
|
||||
function transformFunctionBodyWorker(body: Block, start = 0) {
|
||||
const savedCurrentScope = currentScope;
|
||||
currentScope = body;
|
||||
startLexicalEnvironment();
|
||||
const visited = visitEachChild(body, visitor, context);
|
||||
|
||||
const statements = visitNodes(body.statements, visitor, isStatement, start);
|
||||
const visited = updateBlock(body, statements);
|
||||
const declarations = endLexicalEnvironment();
|
||||
currentScope = savedCurrentScope;
|
||||
return mergeFunctionBodyLexicalEnvironment(visited, declarations);
|
||||
@@ -2224,8 +2229,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getPromiseConstructor(type: TypeNode) {
|
||||
const typeName = getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody {
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getEntityNameFromTypeNode(node.type) : undefined;
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(node.type) : undefined;
|
||||
const isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
|
||||
@@ -2238,14 +2256,14 @@ namespace ts {
|
||||
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
|
||||
const statementOffset = addPrologueDirectives(statements, (<Block>node.body).statements, /*ensureUseStrict*/ false, visitor);
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(<Block>node.body)
|
||||
transformFunctionBodyWorker(<Block>node.body, statementOffset)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/module/system.ts",
|
||||
|
||||
+38
-22
@@ -359,6 +359,8 @@ namespace ts {
|
||||
// Markers
|
||||
FirstAssignment = EqualsToken,
|
||||
LastAssignment = CaretEqualsToken,
|
||||
FirstCompoundAssignment = PlusEqualsToken,
|
||||
LastCompoundAssignment = CaretEqualsToken,
|
||||
FirstReservedWord = BreakKeyword,
|
||||
LastReservedWord = WithKeyword,
|
||||
FirstKeyword = BreakKeyword,
|
||||
@@ -975,13 +977,18 @@ namespace ts {
|
||||
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
||||
// or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
|
||||
// For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
|
||||
// @kind(SyntaxKind.NumericLiteral)
|
||||
// @kind(SyntaxKind.RegularExpressionLiteral)
|
||||
// @kind(SyntaxKind.NoSubstitutionTemplateLiteral)
|
||||
export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression {
|
||||
_literalExpressionBrand: any;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.NumericLiteral)
|
||||
export interface NumericLiteral extends LiteralExpression {
|
||||
_numericLiteralBrand: any;
|
||||
trailingComment?: string;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.TemplateHead)
|
||||
// @kind(SyntaxKind.TemplateMiddle)
|
||||
// @kind(SyntaxKind.TemplateTail)
|
||||
@@ -2058,12 +2065,13 @@ namespace ts {
|
||||
// function that can be reached at runtime (e.g. a `class`
|
||||
// declaration or a `var` declaration for the static side
|
||||
// of a type, such as the global `Promise` type in lib.d.ts).
|
||||
VoidType, // The TypeReferenceNode resolves to a Void-like type.
|
||||
VoidNullableOrNeverType, // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type.
|
||||
NumberLikeType, // The TypeReferenceNode resolves to a Number-like type.
|
||||
StringLikeType, // The TypeReferenceNode resolves to a String-like type.
|
||||
BooleanType, // The TypeReferenceNode resolves to a Boolean-like type.
|
||||
ArrayLikeType, // The TypeReferenceNode resolves to an Array-like type.
|
||||
ESSymbolType, // The TypeReferenceNode resolves to the ESSymbol type.
|
||||
Promise, // The TypeReferenceNode resolved to the global Promise constructor symbol.
|
||||
TypeWithCallSignature, // The TypeReferenceNode resolves to a Function type or a type
|
||||
// with call signatures.
|
||||
ObjectType, // The TypeReferenceNode resolves to any other type.
|
||||
@@ -3022,20 +3030,24 @@ namespace ts {
|
||||
ES6 = 1 << 6,
|
||||
ContainsES6 = 1 << 7,
|
||||
DestructuringAssignment = 1 << 8,
|
||||
Generator = 1 << 9,
|
||||
ContainsGenerator = 1 << 10,
|
||||
|
||||
// Markers
|
||||
// - Flags used to indicate that a subtree contains a specific transformation.
|
||||
ContainsDecorators = 1 << 9,
|
||||
ContainsPropertyInitializer = 1 << 10,
|
||||
ContainsLexicalThis = 1 << 11,
|
||||
ContainsCapturedLexicalThis = 1 << 12,
|
||||
ContainsLexicalThisInComputedPropertyName = 1 << 13,
|
||||
ContainsDefaultValueAssignments = 1 << 14,
|
||||
ContainsParameterPropertyAssignments = 1 << 15,
|
||||
ContainsSpreadElementExpression = 1 << 16,
|
||||
ContainsComputedPropertyName = 1 << 17,
|
||||
ContainsBlockScopedBinding = 1 << 18,
|
||||
ContainsBindingPattern = 1 << 19,
|
||||
ContainsDecorators = 1 << 11,
|
||||
ContainsPropertyInitializer = 1 << 12,
|
||||
ContainsLexicalThis = 1 << 13,
|
||||
ContainsCapturedLexicalThis = 1 << 14,
|
||||
ContainsLexicalThisInComputedPropertyName = 1 << 15,
|
||||
ContainsDefaultValueAssignments = 1 << 16,
|
||||
ContainsParameterPropertyAssignments = 1 << 17,
|
||||
ContainsSpreadElementExpression = 1 << 18,
|
||||
ContainsComputedPropertyName = 1 << 19,
|
||||
ContainsBlockScopedBinding = 1 << 20,
|
||||
ContainsBindingPattern = 1 << 21,
|
||||
ContainsYield = 1 << 22,
|
||||
ContainsHoistedDeclarationOrCompletion = 1 << 23,
|
||||
|
||||
HasComputedFlags = 1 << 29, // Transform flags have been computed.
|
||||
|
||||
@@ -3045,17 +3057,18 @@ namespace ts {
|
||||
AssertJsx = Jsx | ContainsJsx,
|
||||
AssertES7 = ES7 | ContainsES7,
|
||||
AssertES6 = ES6 | ContainsES6,
|
||||
AssertGenerator = Generator | ContainsGenerator,
|
||||
|
||||
// Scope Exclusions
|
||||
// - Bitmasks that exclude flags from propagating out of a specific context
|
||||
// into the subtree flags of their container.
|
||||
NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | HasComputedFlags,
|
||||
ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding,
|
||||
FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding,
|
||||
ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
MethodOrAccessorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | Generator | HasComputedFlags,
|
||||
ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
MethodOrAccessorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
ClassExcludes = NodeExcludes | ContainsDecorators | ContainsPropertyInitializer | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsComputedPropertyName | ContainsParameterPropertyAssignments | ContainsLexicalThisInComputedPropertyName,
|
||||
ModuleExcludes = NodeExcludes | ContainsDecorators | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding,
|
||||
ModuleExcludes = NodeExcludes | ContainsDecorators | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion,
|
||||
TypeExcludes = ~ContainsTypeScript,
|
||||
ObjectLiteralExcludes = NodeExcludes | ContainsDecorators | ContainsComputedPropertyName | ContainsLexicalThisInComputedPropertyName,
|
||||
ArrayLiteralOrCallOrNewExcludes = NodeExcludes | ContainsSpreadElementExpression,
|
||||
@@ -3093,14 +3106,17 @@ namespace ts {
|
||||
ExportName = 1 << 17, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
LocalName = 1 << 18, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
||||
Indented = 1 << 19, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
NoIndentation = 1 << 20, // Do not indent the node.
|
||||
NoIndentation = 1 << 20, // Do not indent the node.
|
||||
AsyncFunctionBody = 1 << 21,
|
||||
ReuseTempVariableScope = 1 << 22, // Reuse the existing temp variable scope during emit.
|
||||
CustomPrologue = 1 << 23, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
||||
|
||||
// SourceMap Specialization.
|
||||
// TODO(rbuckton): These should be removed once source maps are aligned with the old
|
||||
// emitter and new baselines are taken. This exists solely to
|
||||
// align with the old emitter.
|
||||
SourceMapEmitOpenBraceAsToken = 1 << 21, // Emits the open brace of a block function body as a source mapped token.
|
||||
SourceMapAdjustRestParameterLoop = 1 << 22, // Emits adjusted source map positions for a ForStatement generated when transforming a rest parameter for ES5/3.
|
||||
SourceMapEmitOpenBraceAsToken = 1 << 24, // Emits the open brace of a block function body as a source mapped token.
|
||||
SourceMapAdjustRestParameterLoop = 1 << 25, // Emits adjusted source map positions for a ForStatement generated when transforming a rest parameter for ES5/3.
|
||||
}
|
||||
|
||||
/** Additional context provided to `visitEachChild` */
|
||||
|
||||
@@ -3038,6 +3038,12 @@ namespace ts {
|
||||
return ModifierFlags.None;
|
||||
}
|
||||
|
||||
export function isLogicalOperator(token: SyntaxKind): boolean {
|
||||
return token === SyntaxKind.BarBarToken
|
||||
|| token === SyntaxKind.AmpersandAmpersandToken
|
||||
|| token === SyntaxKind.ExclamationToken;
|
||||
}
|
||||
|
||||
export function isAssignmentOperator(token: SyntaxKind): boolean {
|
||||
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
@@ -1197,8 +1197,9 @@ namespace ts {
|
||||
/**
|
||||
* Aggregates the TransformFlags for a Node and its subtree.
|
||||
*/
|
||||
export function aggregateTransformFlags(node: Node): void {
|
||||
export function aggregateTransformFlags<T extends Node>(node: T): T {
|
||||
aggregateTransformFlagsForNode(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"../compiler/transformers/jsx.ts",
|
||||
"../compiler/transformers/es7.ts",
|
||||
"../compiler/transformers/es6.ts",
|
||||
"../compiler/transformers/generators.ts",
|
||||
"../compiler/transformers/destructuring.ts",
|
||||
"../compiler/transformers/module/module.ts",
|
||||
"../compiler/transformers/module/system.ts",
|
||||
|
||||
Reference in New Issue
Block a user