mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-21 13:14:43 -06:00
Merge pull request #16120 from Microsoft/fix15857
Add wrapper to emit statics/decorators inside es5 class
This commit is contained in:
commit
2fa59d5bc5
@ -752,6 +752,14 @@ namespace ts {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual offset into an array for a relative offset. Negative offsets indicate a
|
||||
* position offset from the end of the array.
|
||||
*/
|
||||
function toOffset(array: any[], offset: number) {
|
||||
return offset < 0 ? array.length + offset : offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a range of value to an array, returning the array.
|
||||
*
|
||||
@ -759,11 +767,19 @@ namespace ts {
|
||||
* is created if `value` was appended.
|
||||
* @param from The values to append to the array. If `from` is `undefined`, nothing is
|
||||
* appended. If an element of `from` is `undefined`, that element is not appended.
|
||||
* @param start The offset in `from` at which to start copying values.
|
||||
* @param end The offset in `from` at which to stop copying values (non-inclusive).
|
||||
*/
|
||||
export function addRange<T>(to: T[] | undefined, from: T[] | undefined): T[] | undefined {
|
||||
export function addRange<T>(to: T[] | undefined, from: T[] | undefined, start?: number, end?: number): T[] | undefined {
|
||||
if (from === undefined) return to;
|
||||
for (const v of from) {
|
||||
to = append(to, v);
|
||||
if (to === undefined) return from.slice(start, end);
|
||||
start = start === undefined ? 0 : toOffset(from, start);
|
||||
end = end === undefined ? from.length : toOffset(from, end);
|
||||
for (let i = start; i < end && i < from.length; i++) {
|
||||
const v = from[i];
|
||||
if (v !== undefined) {
|
||||
to.push(from[i]);
|
||||
}
|
||||
}
|
||||
return to;
|
||||
}
|
||||
@ -788,28 +804,38 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at a specific offset in an array if non-empty, `undefined` otherwise.
|
||||
* A negative offset indicates the element should be retrieved from the end of the array.
|
||||
*/
|
||||
export function elementAt<T>(array: T[] | undefined, offset: number): T | undefined {
|
||||
if (array) {
|
||||
offset = toOffset(array, offset);
|
||||
if (offset < array.length) {
|
||||
return array[offset];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function firstOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length > 0
|
||||
? array[0]
|
||||
: undefined;
|
||||
export function firstOrUndefined<T>(array: T[]): T | undefined {
|
||||
return elementAt(array, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length > 0
|
||||
? array[array.length - 1]
|
||||
: undefined;
|
||||
export function lastOrUndefined<T>(array: T[]): T | undefined {
|
||||
return elementAt(array, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the only element of an array if it contains only one element, `undefined` otherwise.
|
||||
*/
|
||||
export function singleOrUndefined<T>(array: T[]): T {
|
||||
export function singleOrUndefined<T>(array: T[]): T | undefined {
|
||||
return array && array.length === 1
|
||||
? array[0]
|
||||
: undefined;
|
||||
@ -1137,6 +1163,15 @@ namespace ts {
|
||||
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
||||
}
|
||||
|
||||
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined {
|
||||
return value !== undefined && test(value) ? value : undefined;
|
||||
}
|
||||
|
||||
export function cast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut {
|
||||
if (value !== undefined && test(value)) return value;
|
||||
Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`);
|
||||
}
|
||||
|
||||
/** Does nothing. */
|
||||
export function noop(): void {}
|
||||
|
||||
@ -2222,8 +2257,11 @@ namespace ts {
|
||||
this.declarations = undefined;
|
||||
}
|
||||
|
||||
function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) {
|
||||
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
|
||||
this.flags = flags;
|
||||
if (Debug.isDebugging) {
|
||||
this.checker = checker;
|
||||
}
|
||||
}
|
||||
|
||||
function Signature() {
|
||||
@ -2260,24 +2298,42 @@ namespace ts {
|
||||
|
||||
export namespace Debug {
|
||||
export let currentAssertionLevel = AssertionLevel.None;
|
||||
export let isDebugging = false;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
return currentAssertionLevel >= level;
|
||||
}
|
||||
|
||||
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
|
||||
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string, stackCrawlMark?: Function): void {
|
||||
if (!expression) {
|
||||
let verboseDebugString = "";
|
||||
if (verboseDebugInfo) {
|
||||
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
|
||||
message += "\r\nVerbose Debug Information: " + verboseDebugInfo();
|
||||
}
|
||||
debugger;
|
||||
throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString);
|
||||
fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
|
||||
}
|
||||
}
|
||||
|
||||
export function fail(message?: string): void {
|
||||
Debug.assert(/*expression*/ false, message);
|
||||
export function fail(message?: string, stackCrawlMark?: Function): void {
|
||||
debugger;
|
||||
const e = new Error(message ? `Debug Failure. ` : "Debug Failure.");
|
||||
if ((<any>Error).captureStackTrace) {
|
||||
(<any>Error).captureStackTrace(e, stackCrawlMark || fail);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
export function getFunctionName(func: Function) {
|
||||
if (typeof func !== "function") {
|
||||
return "";
|
||||
}
|
||||
else if (func.hasOwnProperty("name")) {
|
||||
return (<any>func).name;
|
||||
}
|
||||
else {
|
||||
const text = Function.prototype.toString.call(func);
|
||||
const match = /^function\s+([\w\$]+)\s*\(/.exec(text);
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2443,4 +2499,4 @@ namespace ts {
|
||||
export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) {
|
||||
return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2134,6 +2134,24 @@ namespace ts {
|
||||
|
||||
// Compound nodes
|
||||
|
||||
export function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
|
||||
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) {
|
||||
return createCall(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ param ? [param] : [],
|
||||
/*type*/ undefined,
|
||||
createBlock(statements, /*multiLine*/ true)
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
/*argumentsArray*/ paramValue ? [paramValue] : []
|
||||
);
|
||||
}
|
||||
|
||||
export function createComma(left: Expression, right: Expression) {
|
||||
return <Expression>createBinary(left, SyntaxKind.CommaToken, right);
|
||||
}
|
||||
@ -3216,6 +3234,26 @@ namespace ts {
|
||||
return isBlock(node) ? node : setTextRange(createBlock([setTextRange(createReturn(node), node)], multiLine), node);
|
||||
}
|
||||
|
||||
export function convertFunctionDeclarationToExpression(node: FunctionDeclaration) {
|
||||
Debug.assert(!!node.body);
|
||||
const updated = createFunctionExpression(
|
||||
node.modifiers,
|
||||
node.asteriskToken,
|
||||
node.name,
|
||||
node.typeParameters,
|
||||
node.parameters,
|
||||
node.type,
|
||||
node.body
|
||||
);
|
||||
setOriginalNode(updated, node);
|
||||
setTextRange(updated, node);
|
||||
if (node.startsOnNewLine) {
|
||||
updated.startsOnNewLine = true;
|
||||
}
|
||||
aggregateTransformFlags(updated);
|
||||
return updated;
|
||||
}
|
||||
|
||||
function isUseStrictPrologue(node: ExpressionStatement): boolean {
|
||||
return (node.expression as StringLiteral).text === "use strict";
|
||||
}
|
||||
@ -3614,7 +3652,7 @@ namespace ts {
|
||||
if (kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction) {
|
||||
const mutableCall = getMutableClone(emittedExpression);
|
||||
mutableCall.expression = setTextRange(createParen(callee), callee);
|
||||
return recreatePartiallyEmittedExpressions(expression, mutableCall);
|
||||
return recreateOuterExpressions(expression, mutableCall, OuterExpressionKinds.PartiallyEmittedExpressions);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3656,22 +3694,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a series of not-emitted expressions with a new inner expression.
|
||||
*
|
||||
* @param originalOuterExpression The original outer expression.
|
||||
* @param newInnerExpression The new inner expression.
|
||||
*/
|
||||
function recreatePartiallyEmittedExpressions(originalOuterExpression: Expression, newInnerExpression: Expression) {
|
||||
if (isPartiallyEmittedExpression(originalOuterExpression)) {
|
||||
const clone = getMutableClone(originalOuterExpression);
|
||||
clone.expression = recreatePartiallyEmittedExpressions(clone.expression, newInnerExpression);
|
||||
return clone;
|
||||
}
|
||||
|
||||
return newInnerExpression;
|
||||
}
|
||||
|
||||
function getLeftmostExpression(node: Expression): Expression {
|
||||
while (true) {
|
||||
switch (node.kind) {
|
||||
@ -3718,6 +3740,22 @@ namespace ts {
|
||||
All = Parentheses | Assertions | PartiallyEmittedExpressions
|
||||
}
|
||||
|
||||
export type OuterExpression = ParenthesizedExpression | TypeAssertion | AsExpression | NonNullExpression | PartiallyEmittedExpression;
|
||||
|
||||
export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All): node is OuterExpression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return (kinds & OuterExpressionKinds.Parentheses) !== 0;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return (kinds & OuterExpressionKinds.Assertions) !== 0;
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
return (kinds & OuterExpressionKinds.PartiallyEmittedExpressions) !== 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression;
|
||||
export function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node;
|
||||
export function skipOuterExpressions(node: Node, kinds = OuterExpressionKinds.All) {
|
||||
@ -3754,8 +3792,8 @@ namespace ts {
|
||||
export function skipAssertions(node: Expression): Expression;
|
||||
export function skipAssertions(node: Node): Node;
|
||||
export function skipAssertions(node: Node): Node {
|
||||
while (isAssertionExpression(node)) {
|
||||
node = (<AssertionExpression>node).expression;
|
||||
while (isAssertionExpression(node) || node.kind === SyntaxKind.NonNullExpression) {
|
||||
node = (<AssertionExpression | NonNullExpression>node).expression;
|
||||
}
|
||||
|
||||
return node;
|
||||
@ -3771,6 +3809,26 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function updateOuterExpression(outerExpression: OuterExpression, expression: Expression) {
|
||||
switch (outerExpression.kind) {
|
||||
case SyntaxKind.ParenthesizedExpression: return updateParen(outerExpression, expression);
|
||||
case SyntaxKind.TypeAssertionExpression: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
|
||||
case SyntaxKind.AsExpression: return updateAsExpression(outerExpression, expression, outerExpression.type);
|
||||
case SyntaxKind.NonNullExpression: return updateNonNullExpression(outerExpression, expression);
|
||||
case SyntaxKind.PartiallyEmittedExpression: return updatePartiallyEmittedExpression(outerExpression, expression);
|
||||
}
|
||||
}
|
||||
|
||||
export function recreateOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds = OuterExpressionKinds.All): Expression {
|
||||
if (outerExpression && isOuterExpression(outerExpression, kinds)) {
|
||||
return updateOuterExpression(
|
||||
outerExpression,
|
||||
recreateOuterExpressions(outerExpression.expression, innerExpression)
|
||||
);
|
||||
}
|
||||
return innerExpression;
|
||||
}
|
||||
|
||||
export function startOnNewLine<T extends Node>(node: T): T {
|
||||
node.startsOnNewLine = true;
|
||||
return node;
|
||||
|
||||
@ -41,6 +41,7 @@ namespace ts {
|
||||
realpath?(path: string): string;
|
||||
/*@internal*/ getEnvironmentVariable(name: string): string;
|
||||
/*@internal*/ tryEnableSourceMapsForHost?(): void;
|
||||
/*@internal*/ debugMode?: boolean;
|
||||
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
||||
clearTimeout?(timeoutId: any): void;
|
||||
}
|
||||
@ -428,6 +429,7 @@ namespace ts {
|
||||
realpath(path: string): string {
|
||||
return _fs.realpathSync(path);
|
||||
},
|
||||
debugMode: some(<string[]>process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)),
|
||||
tryEnableSourceMapsForHost() {
|
||||
try {
|
||||
require("source-map-support").install();
|
||||
@ -517,4 +519,7 @@ namespace ts {
|
||||
? AssertionLevel.Normal
|
||||
: AssertionLevel.None;
|
||||
}
|
||||
if (sys && sys.debugMode) {
|
||||
Debug.isDebugging = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,11 +339,64 @@ namespace ts {
|
||||
&& !(<ReturnStatement>node).expression;
|
||||
}
|
||||
|
||||
function isClassLikeVariableStatement(node: Node) {
|
||||
if (!isVariableStatement(node)) return false;
|
||||
const variable = singleOrUndefined((<VariableStatement>node).declarationList.declarations);
|
||||
return variable
|
||||
&& variable.initializer
|
||||
&& isIdentifier(variable.name)
|
||||
&& (isClassLike(variable.initializer)
|
||||
|| (isAssignmentExpression(variable.initializer)
|
||||
&& isIdentifier(variable.initializer.left)
|
||||
&& isClassLike(variable.initializer.right)));
|
||||
}
|
||||
|
||||
function isTypeScriptClassWrapper(node: Node) {
|
||||
const call = tryCast(node, isCallExpression);
|
||||
if (!call || isParseTreeNode(call) ||
|
||||
some(call.typeArguments) ||
|
||||
some(call.arguments)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const func = tryCast(skipOuterExpressions(call.expression), isFunctionExpression);
|
||||
if (!func || isParseTreeNode(func) ||
|
||||
some(func.typeParameters) ||
|
||||
some(func.parameters) ||
|
||||
func.type ||
|
||||
!func.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const statements = func.body.statements;
|
||||
if (statements.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const firstStatement = statements[0];
|
||||
if (isParseTreeNode(firstStatement) ||
|
||||
!isClassLike(firstStatement) &&
|
||||
!isClassLikeVariableStatement(firstStatement)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lastStatement = elementAt(statements, -1);
|
||||
const returnStatement = tryCast(isVariableStatement(lastStatement) ? elementAt(statements, -2) : lastStatement, isReturnStatement);
|
||||
if (!returnStatement ||
|
||||
!returnStatement.expression ||
|
||||
!isIdentifier(skipOuterExpressions(returnStatement.expression))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function shouldVisitNode(node: Node): boolean {
|
||||
return (node.transformFlags & TransformFlags.ContainsES2015) !== 0
|
||||
|| convertedLoopState !== undefined
|
||||
|| (hierarchyFacts & HierarchyFacts.ConstructorWithCapturedSuper && isStatement(node))
|
||||
|| (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node));
|
||||
|| (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node))
|
||||
|| isTypeScriptClassWrapper(node);
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
@ -3251,6 +3304,10 @@ namespace ts {
|
||||
* @param node a CallExpression.
|
||||
*/
|
||||
function visitCallExpression(node: CallExpression) {
|
||||
if (isTypeScriptClassWrapper(node)) {
|
||||
return visitTypeScriptClassWrapper(node);
|
||||
}
|
||||
|
||||
if (node.transformFlags & TransformFlags.ES2015) {
|
||||
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true);
|
||||
}
|
||||
@ -3262,6 +3319,163 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function visitTypeScriptClassWrapper(node: CallExpression) {
|
||||
// This is a call to a class wrapper function (an IIFE) created by the 'ts' transformer.
|
||||
// The wrapper has a form similar to:
|
||||
//
|
||||
// (function() {
|
||||
// class C { // 1
|
||||
// }
|
||||
// C.x = 1; // 2
|
||||
// return C;
|
||||
// }())
|
||||
//
|
||||
// When we transform the class, we end up with something like this:
|
||||
//
|
||||
// (function () {
|
||||
// var C = (function () { // 3
|
||||
// function C() {
|
||||
// }
|
||||
// return C; // 4
|
||||
// }());
|
||||
// C.x = 1;
|
||||
// return C;
|
||||
// }())
|
||||
//
|
||||
// We want to simplify the two nested IIFEs to end up with something like this:
|
||||
//
|
||||
// (function () {
|
||||
// function C() {
|
||||
// }
|
||||
// C.x = 1;
|
||||
// return C;
|
||||
// }())
|
||||
|
||||
// We skip any outer expressions in a number of places to get to the innermost
|
||||
// expression, but we will restore them later to preserve comments and source maps.
|
||||
const body = cast(skipOuterExpressions(node.expression), isFunctionExpression).body;
|
||||
|
||||
// The class statements are the statements generated by visiting the first statement of the
|
||||
// body (1), while all other statements are added to remainingStatements (2)
|
||||
const classStatements = visitNodes(body.statements, visitor, isStatement, 0, 1);
|
||||
const remainingStatements = visitNodes(body.statements, visitor, isStatement, 1, body.statements.length - 1);
|
||||
const varStatement = cast(firstOrUndefined(classStatements), isVariableStatement);
|
||||
|
||||
// We know there is only one variable declaration here as we verified this in an
|
||||
// earlier call to isTypeScriptClassWrapper
|
||||
const variable = varStatement.declarationList.declarations[0];
|
||||
const initializer = skipOuterExpressions(variable.initializer);
|
||||
|
||||
// Under certain conditions, the 'ts' transformer may introduce a class alias, which
|
||||
// we see as an assignment, for example:
|
||||
//
|
||||
// (function () {
|
||||
// var C = C_1 = (function () {
|
||||
// function C() {
|
||||
// }
|
||||
// C.x = function () { return C_1; }
|
||||
// return C;
|
||||
// }());
|
||||
// C = C_1 = __decorate([dec], C);
|
||||
// return C;
|
||||
// var C_1;
|
||||
// }())
|
||||
//
|
||||
const aliasAssignment = tryCast(initializer, isAssignmentExpression);
|
||||
|
||||
// The underlying call (3) is another IIFE that may contain a '_super' argument.
|
||||
const call = cast(aliasAssignment ? skipOuterExpressions(aliasAssignment.right) : initializer, isCallExpression);
|
||||
const func = cast(skipOuterExpressions(call.expression), isFunctionExpression);
|
||||
|
||||
const funcStatements = func.body.statements;
|
||||
let classBodyStart = 0;
|
||||
let classBodyEnd = -1;
|
||||
|
||||
const statements: Statement[] = [];
|
||||
if (aliasAssignment) {
|
||||
// If we have a class alias assignment, we need to move it to the down-level constructor
|
||||
// function we generated for the class.
|
||||
const extendsCall = tryCast(funcStatements[classBodyStart], isExpressionStatement);
|
||||
if (extendsCall) {
|
||||
statements.push(extendsCall);
|
||||
classBodyStart++;
|
||||
}
|
||||
|
||||
// We reuse the comment and source-map positions from the original variable statement
|
||||
// and class alias, while converting the function declaration for the class constructor
|
||||
// into an expression.
|
||||
statements.push(
|
||||
updateVariableStatement(
|
||||
varStatement,
|
||||
/*modifiers*/ undefined,
|
||||
updateVariableDeclarationList(varStatement.declarationList, [
|
||||
updateVariableDeclaration(variable,
|
||||
variable.name,
|
||||
/*type*/ undefined,
|
||||
updateBinary(aliasAssignment,
|
||||
aliasAssignment.left,
|
||||
convertFunctionDeclarationToExpression(
|
||||
cast(funcStatements[classBodyStart], isFunctionDeclaration)
|
||||
)
|
||||
)
|
||||
)
|
||||
])
|
||||
)
|
||||
);
|
||||
classBodyStart++;
|
||||
}
|
||||
|
||||
// Find the trailing 'return' statement (4)
|
||||
while (!isReturnStatement(elementAt(funcStatements, classBodyEnd))) {
|
||||
classBodyEnd--;
|
||||
}
|
||||
|
||||
// When we extract the statements of the inner IIFE, we exclude the 'return' statement (4)
|
||||
// as we already have one that has been introduced by the 'ts' transformer.
|
||||
addRange(statements, funcStatements, classBodyStart, classBodyEnd);
|
||||
|
||||
if (classBodyEnd < -1) {
|
||||
// If there were any hoisted declarations following the return statement, we should
|
||||
// append them.
|
||||
addRange(statements, funcStatements, classBodyEnd + 1);
|
||||
}
|
||||
|
||||
// Add the remaining statements of the outer wrapper.
|
||||
addRange(statements, remainingStatements);
|
||||
|
||||
// The 'es2015' class transform may add an end-of-declaration marker. If so we will add it
|
||||
// after the remaining statements from the 'ts' transformer.
|
||||
addRange(statements, classStatements, /*start*/ 1);
|
||||
|
||||
// Recreate any outer parentheses or partially-emitted expressions to preserve source map
|
||||
// and comment locations.
|
||||
return recreateOuterExpressions(node.expression,
|
||||
recreateOuterExpressions(variable.initializer,
|
||||
recreateOuterExpressions(aliasAssignment && aliasAssignment.right,
|
||||
updateCall(call,
|
||||
recreateOuterExpressions(call.expression,
|
||||
updateFunctionExpression(
|
||||
func,
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
func.parameters,
|
||||
/*type*/ undefined,
|
||||
updateBlock(
|
||||
func.body,
|
||||
statements
|
||||
)
|
||||
)
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
call.arguments
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function visitImmediateSuperCallInBody(node: CallExpression) {
|
||||
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
|
||||
}
|
||||
@ -3806,9 +4020,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
if (isClassElement(currentNode) && currentNode.parent === declaration) {
|
||||
// we are in the class body, but we treat static fields as outside of the class body
|
||||
return currentNode.kind !== SyntaxKind.PropertyDeclaration
|
||||
|| (getModifierFlags(currentNode) & ModifierFlags.Static) === 0;
|
||||
return true;
|
||||
}
|
||||
currentNode = currentNode.parent;
|
||||
}
|
||||
|
||||
@ -18,6 +18,23 @@ namespace ts {
|
||||
NonQualifiedEnumMembers = 1 << 3
|
||||
}
|
||||
|
||||
const enum ClassFacts {
|
||||
None = 0,
|
||||
HasStaticInitializedProperties = 1 << 0,
|
||||
HasConstructorDecorators = 1 << 1,
|
||||
HasMemberDecorators = 1 << 2,
|
||||
IsExportOfNamespace = 1 << 3,
|
||||
IsNamedExternalExport = 1 << 4,
|
||||
IsDefaultExternalExport = 1 << 5,
|
||||
HasExtendsClause = 1 << 6,
|
||||
UseImmediatelyInvokedFunctionExpression = 1 << 7,
|
||||
|
||||
HasAnyDecorators = HasConstructorDecorators | HasMemberDecorators,
|
||||
NeedsName = HasStaticInitializedProperties | HasMemberDecorators,
|
||||
MayNeedImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties,
|
||||
IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport,
|
||||
}
|
||||
|
||||
export function transformTypeScript(context: TransformationContext) {
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
@ -505,6 +522,19 @@ namespace ts {
|
||||
return parameter.decorators !== undefined && parameter.decorators.length > 0;
|
||||
}
|
||||
|
||||
function getClassFacts(node: ClassDeclaration, staticProperties: PropertyDeclaration[]) {
|
||||
let facts = ClassFacts.None;
|
||||
if (some(staticProperties)) facts |= ClassFacts.HasStaticInitializedProperties;
|
||||
if (getClassExtendsHeritageClauseElement(node)) facts |= ClassFacts.HasExtendsClause;
|
||||
if (shouldEmitDecorateCallForClass(node)) facts |= ClassFacts.HasConstructorDecorators;
|
||||
if (childIsDecorated(node)) facts |= ClassFacts.HasMemberDecorators;
|
||||
if (isExportOfNamespace(node)) facts |= ClassFacts.IsExportOfNamespace;
|
||||
else if (isDefaultExternalModuleExport(node)) facts |= ClassFacts.IsDefaultExternalExport;
|
||||
else if (isNamedExternalModuleExport(node)) facts |= ClassFacts.IsNamedExternalExport;
|
||||
if (languageVersion <= ScriptTarget.ES5 && (facts & ClassFacts.MayNeedImmediatelyInvokedFunctionExpression)) facts |= ClassFacts.UseImmediatelyInvokedFunctionExpression;
|
||||
return facts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a class declaration with TypeScript syntax into compatible ES6.
|
||||
*
|
||||
@ -518,32 +548,26 @@ namespace ts {
|
||||
*/
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
|
||||
const hasExtendsClause = getClassExtendsHeritageClauseElement(node) !== undefined;
|
||||
const isDecoratedClass = shouldEmitDecorateCallForClass(node);
|
||||
const facts = getClassFacts(node, staticProperties);
|
||||
|
||||
// emit name if
|
||||
// - node has a name
|
||||
// - node has static initializers
|
||||
// - node has a member that is decorated
|
||||
//
|
||||
let name = node.name;
|
||||
if (!name && (staticProperties.length > 0 || childIsDecorated(node))) {
|
||||
name = getGeneratedNameForNode(node);
|
||||
if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) {
|
||||
context.startLexicalEnvironment();
|
||||
}
|
||||
|
||||
const classStatement = isDecoratedClass
|
||||
? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause)
|
||||
: createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0);
|
||||
const name = node.name || (facts & ClassFacts.NeedsName ? getGeneratedNameForNode(node) : undefined);
|
||||
const classStatement = facts & ClassFacts.HasConstructorDecorators
|
||||
? createClassDeclarationHeadWithDecorators(node, name, facts)
|
||||
: createClassDeclarationHeadWithoutDecorators(node, name, facts);
|
||||
|
||||
const statements: Statement[] = [classStatement];
|
||||
let statements: Statement[] = [classStatement];
|
||||
|
||||
// Emit static property assignment. Because classDeclaration is lexically evaluated,
|
||||
// it is safe to emit static property assignment after classDeclaration
|
||||
// From ES6 specification:
|
||||
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
||||
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
||||
if (staticProperties.length) {
|
||||
addInitializedPropertyStatements(statements, staticProperties, getLocalName(node));
|
||||
if (facts & ClassFacts.HasStaticInitializedProperties) {
|
||||
addInitializedPropertyStatements(statements, staticProperties, facts & ClassFacts.UseImmediatelyInvokedFunctionExpression ? getInternalName(node) : getLocalName(node));
|
||||
}
|
||||
|
||||
// Write any decorators of the node.
|
||||
@ -551,17 +575,63 @@ namespace ts {
|
||||
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
|
||||
addConstructorDecorationStatement(statements, node);
|
||||
|
||||
if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) {
|
||||
// When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
|
||||
// 'es2015' transformer can properly nest static initializers and decorators. The result
|
||||
// looks something like:
|
||||
//
|
||||
// var C = function () {
|
||||
// class C {
|
||||
// }
|
||||
// C.static_prop = 1;
|
||||
// return C;
|
||||
// }();
|
||||
//
|
||||
const closingBraceLocation = createTokenRange(skipTrivia(currentSourceFile.text, node.members.end), SyntaxKind.CloseBraceToken);
|
||||
const localName = getInternalName(node);
|
||||
|
||||
// The following partially-emitted expression exists purely to align our sourcemap
|
||||
// emit with the original emitter.
|
||||
const outer = createPartiallyEmittedExpression(localName);
|
||||
outer.end = closingBraceLocation.end;
|
||||
setEmitFlags(outer, EmitFlags.NoComments);
|
||||
|
||||
const statement = createReturn(outer);
|
||||
statement.pos = closingBraceLocation.pos;
|
||||
setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps);
|
||||
statements.push(statement);
|
||||
|
||||
addRange(statements, context.endLexicalEnvironment());
|
||||
|
||||
const varStatement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false),
|
||||
/*type*/ undefined,
|
||||
createImmediatelyInvokedFunctionExpression(statements)
|
||||
)
|
||||
])
|
||||
);
|
||||
|
||||
setOriginalNode(varStatement, node);
|
||||
setCommentRange(varStatement, node);
|
||||
setSourceMapRange(varStatement, moveRangePastDecorators(node));
|
||||
startOnNewLine(varStatement);
|
||||
statements = [varStatement];
|
||||
}
|
||||
|
||||
// If the class is exported as part of a TypeScript namespace, emit the namespace export.
|
||||
// Otherwise, if the class was exported at the top level and was decorated, emit an export
|
||||
// declaration or export default for the class.
|
||||
if (isNamespaceExport(node)) {
|
||||
if (facts & ClassFacts.IsExportOfNamespace) {
|
||||
addExportMemberAssignment(statements, node);
|
||||
}
|
||||
else if (isDecoratedClass) {
|
||||
if (isDefaultExternalModuleExport(node)) {
|
||||
else if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression || facts & ClassFacts.HasConstructorDecorators) {
|
||||
if (facts & ClassFacts.IsDefaultExternalExport) {
|
||||
statements.push(createExportDefault(getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)));
|
||||
}
|
||||
else if (isNamedExternalModuleExport(node)) {
|
||||
else if (facts & ClassFacts.IsNamedExternalExport) {
|
||||
statements.push(createExternalModuleExport(getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)));
|
||||
}
|
||||
}
|
||||
@ -580,26 +650,31 @@ namespace ts {
|
||||
*
|
||||
* @param node A ClassDeclaration node.
|
||||
* @param name The name of the class.
|
||||
* @param hasExtendsClause A value indicating whether the class has an extends clause.
|
||||
* @param hasStaticProperties A value indicating whether the class has static properties.
|
||||
* @param facts Precomputed facts about the class.
|
||||
*/
|
||||
function createClassDeclarationHeadWithoutDecorators(node: ClassDeclaration, name: Identifier, hasExtendsClause: boolean, hasStaticProperties: boolean) {
|
||||
function createClassDeclarationHeadWithoutDecorators(node: ClassDeclaration, name: Identifier, facts: ClassFacts) {
|
||||
// ${modifiers} class ${name} ${heritageClauses} {
|
||||
// ${members}
|
||||
// }
|
||||
|
||||
// we do not emit modifiers on the declaration if we are emitting an IIFE
|
||||
const modifiers = !(facts & ClassFacts.UseImmediatelyInvokedFunctionExpression)
|
||||
? visitNodes(node.modifiers, modifierVisitor, isModifier)
|
||||
: undefined;
|
||||
|
||||
const classDeclaration = createClassDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, modifierVisitor, isModifier),
|
||||
modifiers,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.heritageClauses, visitor, isHeritageClause),
|
||||
transformClassMembers(node, hasExtendsClause)
|
||||
transformClassMembers(node, (facts & ClassFacts.HasExtendsClause) !== 0)
|
||||
);
|
||||
|
||||
// To better align with the old emitter, we should not emit a trailing source map
|
||||
// entry if the class has static properties.
|
||||
let emitFlags = getEmitFlags(node);
|
||||
if (hasStaticProperties) {
|
||||
if (facts & ClassFacts.HasStaticInitializedProperties) {
|
||||
emitFlags |= EmitFlags.NoTrailingSourceMap;
|
||||
}
|
||||
|
||||
@ -612,13 +687,8 @@ namespace ts {
|
||||
/**
|
||||
* Transforms a decorated class declaration and appends the resulting statements. If
|
||||
* the class requires an alias to avoid issues with double-binding, the alias is returned.
|
||||
*
|
||||
* @param statements A statement list to which to add the declaration.
|
||||
* @param node A ClassDeclaration node.
|
||||
* @param name The name of the class.
|
||||
* @param hasExtendsClause A value indicating whether the class has an extends clause.
|
||||
*/
|
||||
function createClassDeclarationHeadWithDecorators(node: ClassDeclaration, name: Identifier, hasExtendsClause: boolean) {
|
||||
function createClassDeclarationHeadWithDecorators(node: ClassDeclaration, name: Identifier, facts: ClassFacts) {
|
||||
// When we emit an ES6 class that has a class decorator, we must tailor the
|
||||
// emit to certain specific cases.
|
||||
//
|
||||
@ -713,7 +783,7 @@ namespace ts {
|
||||
// ${members}
|
||||
// }
|
||||
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
|
||||
const members = transformClassMembers(node, hasExtendsClause);
|
||||
const members = transformClassMembers(node, (facts & ClassFacts.HasExtendsClause) !== 0);
|
||||
const classExpression = createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
|
||||
setOriginalNode(classExpression, node);
|
||||
setTextRange(classExpression, location);
|
||||
@ -2163,7 +2233,7 @@ namespace ts {
|
||||
/*type*/ undefined,
|
||||
visitFunctionBody(node.body, visitor, context) || createBlock([])
|
||||
);
|
||||
if (isNamespaceExport(node)) {
|
||||
if (isExportOfNamespace(node)) {
|
||||
const statements: Statement[] = [updated];
|
||||
addExportMemberAssignment(statements, node);
|
||||
return statements;
|
||||
@ -2256,7 +2326,7 @@ namespace ts {
|
||||
* - The node is exported from a TypeScript namespace.
|
||||
*/
|
||||
function visitVariableStatement(node: VariableStatement): Statement {
|
||||
if (isNamespaceExport(node)) {
|
||||
if (isExportOfNamespace(node)) {
|
||||
const variables = getInitializedVariables(node.declarationList);
|
||||
if (variables.length === 0) {
|
||||
// elide statement if there are no initialized variables.
|
||||
@ -2560,7 +2630,7 @@ namespace ts {
|
||||
* or `exports.x`).
|
||||
*/
|
||||
function hasNamespaceQualifiedExportName(node: Node) {
|
||||
return isNamespaceExport(node)
|
||||
return isExportOfNamespace(node)
|
||||
|| (isExternalModuleExport(node)
|
||||
&& moduleKind !== ModuleKind.ES2015
|
||||
&& moduleKind !== ModuleKind.System);
|
||||
@ -3002,7 +3072,7 @@ namespace ts {
|
||||
const moduleReference = createExpressionFromEntityName(<EntityName>node.moduleReference);
|
||||
setEmitFlags(moduleReference, EmitFlags.NoComments | EmitFlags.NoNestedComments);
|
||||
|
||||
if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) {
|
||||
if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
|
||||
// export var ${name} = ${moduleReference};
|
||||
// var ${name} = ${moduleReference};
|
||||
return setOriginalNode(
|
||||
@ -3043,7 +3113,7 @@ namespace ts {
|
||||
*
|
||||
* @param node The node to test.
|
||||
*/
|
||||
function isNamespaceExport(node: Node) {
|
||||
function isExportOfNamespace(node: Node) {
|
||||
return currentNamespace !== undefined && hasModifier(node, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
|
||||
@ -3087,6 +3087,7 @@ namespace ts {
|
||||
export interface Type {
|
||||
flags: TypeFlags; // Flags
|
||||
/* @internal */ id: number; // Unique ID
|
||||
/* @internal */ checker: TypeChecker;
|
||||
symbol?: Symbol; // Symbol associated with type (if any)
|
||||
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
||||
aliasSymbol?: Symbol; // Alias associated with type
|
||||
@ -3996,34 +3997,34 @@ namespace ts {
|
||||
}
|
||||
|
||||
export const enum EmitFlags {
|
||||
SingleLine = 1 << 0, // The contents of this node should be emitted on a single line.
|
||||
AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node.
|
||||
NoSubstitution = 1 << 2, // Disables further substitution of an expression.
|
||||
CapturesThis = 1 << 3, // The function captures a lexical `this`
|
||||
NoLeadingSourceMap = 1 << 4, // Do not emit a leading source map location for this node.
|
||||
NoTrailingSourceMap = 1 << 5, // Do not emit a trailing source map location for this node.
|
||||
SingleLine = 1 << 0, // The contents of this node should be emitted on a single line.
|
||||
AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node.
|
||||
NoSubstitution = 1 << 2, // Disables further substitution of an expression.
|
||||
CapturesThis = 1 << 3, // The function captures a lexical `this`
|
||||
NoLeadingSourceMap = 1 << 4, // Do not emit a leading source map location for this node.
|
||||
NoTrailingSourceMap = 1 << 5, // Do not emit a trailing source map location for this node.
|
||||
NoSourceMap = NoLeadingSourceMap | NoTrailingSourceMap, // Do not emit a source map location for this node.
|
||||
NoNestedSourceMaps = 1 << 6, // Do not emit source map locations for children of this node.
|
||||
NoTokenLeadingSourceMaps = 1 << 7, // Do not emit leading source map location for token nodes.
|
||||
NoTokenTrailingSourceMaps = 1 << 8, // Do not emit trailing source map location for token nodes.
|
||||
NoNestedSourceMaps = 1 << 6, // Do not emit source map locations for children of this node.
|
||||
NoTokenLeadingSourceMaps = 1 << 7, // Do not emit leading source map location for token nodes.
|
||||
NoTokenTrailingSourceMaps = 1 << 8, // Do not emit trailing source map location for token nodes.
|
||||
NoTokenSourceMaps = NoTokenLeadingSourceMaps | NoTokenTrailingSourceMaps, // Do not emit source map locations for tokens of this node.
|
||||
NoLeadingComments = 1 << 9, // Do not emit leading comments for this node.
|
||||
NoTrailingComments = 1 << 10, // Do not emit trailing comments for this node.
|
||||
NoLeadingComments = 1 << 9, // Do not emit leading comments for this node.
|
||||
NoTrailingComments = 1 << 10, // Do not emit trailing comments for this node.
|
||||
NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node.
|
||||
NoNestedComments = 1 << 11,
|
||||
HelperName = 1 << 12,
|
||||
ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
||||
InternalName = 1 << 15, // The name is internal to an ES5 class body function.
|
||||
Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
NoIndentation = 1 << 17, // Do not indent the node.
|
||||
ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
||||
InternalName = 1 << 15, // The name is internal to an ES5 class body function.
|
||||
Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
NoIndentation = 1 << 17, // Do not indent the node.
|
||||
AsyncFunctionBody = 1 << 18,
|
||||
ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit.
|
||||
CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
||||
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
||||
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||
NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions.
|
||||
ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit.
|
||||
CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
||||
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
||||
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||
NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions.
|
||||
}
|
||||
|
||||
export interface EmitHelper {
|
||||
|
||||
@ -2935,6 +2935,14 @@ namespace ts {
|
||||
return node.modifierFlagsCache & ~ModifierFlags.HasComputedFlags;
|
||||
}
|
||||
|
||||
const flags = getModifierFlagsNoCache(node);
|
||||
node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
|
||||
let flags = ModifierFlags.None;
|
||||
if (node.modifiers) {
|
||||
for (const modifier of node.modifiers) {
|
||||
@ -2946,7 +2954,6 @@ namespace ts {
|
||||
flags |= ModifierFlags.Export;
|
||||
}
|
||||
|
||||
node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -3235,27 +3242,76 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
const syntaxKindCache: string[] = [];
|
||||
|
||||
export function formatSyntaxKind(kind: SyntaxKind): string {
|
||||
const syntaxKindEnum = (<any>ts).SyntaxKind;
|
||||
if (syntaxKindEnum) {
|
||||
const cached = syntaxKindCache[kind];
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
for (const name in syntaxKindEnum) {
|
||||
if (syntaxKindEnum[name] === kind) {
|
||||
const result = `${kind} (${name})`;
|
||||
syntaxKindCache[kind] = result;
|
||||
return result;
|
||||
/**
|
||||
* Formats an enum value as a string for debugging and debug assertions.
|
||||
*/
|
||||
function formatEnum(value = 0, enumObject: any, isFlags?: boolean) {
|
||||
const members = getEnumMembers(enumObject);
|
||||
if (value === 0) {
|
||||
return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
|
||||
}
|
||||
if (isFlags) {
|
||||
let result = "";
|
||||
let remainingFlags = value;
|
||||
for (let i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
|
||||
const [enumValue, enumName] = members[i];
|
||||
if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
|
||||
remainingFlags &= ~enumValue;
|
||||
result = `${enumName}${result ? ", " : ""}${result}`;
|
||||
}
|
||||
}
|
||||
if (remainingFlags === 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return kind.toString();
|
||||
for (const [enumValue, enumName] of members) {
|
||||
if (enumValue === value) {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
function getEnumMembers(enumObject: any) {
|
||||
const result: [number, string][] = [];
|
||||
for (const name in enumObject) {
|
||||
const value = enumObject[name];
|
||||
if (typeof value === "number") {
|
||||
result.push([value, name]);
|
||||
}
|
||||
}
|
||||
|
||||
return stableSort(result, (x, y) => compareValues(x[0], y[0]));
|
||||
}
|
||||
|
||||
export function formatSyntaxKind(kind: SyntaxKind): string {
|
||||
return formatEnum(kind, (<any>ts).SyntaxKind, /*isFlags*/ false);
|
||||
}
|
||||
|
||||
export function formatModifierFlags(flags: ModifierFlags): string {
|
||||
return formatEnum(flags, (<any>ts).ModifierFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatTransformFlags(flags: TransformFlags): string {
|
||||
return formatEnum(flags, (<any>ts).TransformFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatEmitFlags(flags: EmitFlags): string {
|
||||
return formatEnum(flags, (<any>ts).EmitFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatSymbolFlags(flags: SymbolFlags): string {
|
||||
return formatEnum(flags, (<any>ts).SymbolFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatTypeFlags(flags: TypeFlags): string {
|
||||
return formatEnum(flags, (<any>ts).TypeFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function formatObjectFlags(flags: ObjectFlags): string {
|
||||
return formatEnum(flags, (<any>ts).ObjectFlags, /*isFlags*/ true);
|
||||
}
|
||||
|
||||
export function getRangePos(range: TextRange | undefined) {
|
||||
|
||||
@ -1517,57 +1517,80 @@ namespace ts {
|
||||
}
|
||||
|
||||
export namespace Debug {
|
||||
if (isDebugging) {
|
||||
// Add additional properties in debug mode to assist with debugging.
|
||||
Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, {
|
||||
"__debugFlags": { get(this: Symbol) { return formatSymbolFlags(this.flags); } }
|
||||
});
|
||||
|
||||
Object.defineProperties(objectAllocator.getTypeConstructor().prototype, {
|
||||
"__debugFlags": { get(this: Type) { return formatTypeFlags(this.flags); } },
|
||||
"__debugObjectFlags": { get(this: Type) { return this.flags & TypeFlags.Object ? formatObjectFlags((<ObjectType>this).objectFlags) : ""; } },
|
||||
"__debugTypeToString": { value(this: Type) { return this.checker.typeToString(this); } },
|
||||
});
|
||||
|
||||
for (const ctor of [objectAllocator.getNodeConstructor(), objectAllocator.getIdentifierConstructor(), objectAllocator.getTokenConstructor(), objectAllocator.getSourceFileConstructor()]) {
|
||||
if (!ctor.prototype.hasOwnProperty("__debugKind")) {
|
||||
Object.defineProperties(ctor.prototype, {
|
||||
"__debugKind": { get(this: Node) { return formatSyntaxKind(this.kind); } },
|
||||
"__debugModifierFlags": { get(this: Node) { return formatModifierFlags(getModifierFlagsNoCache(this)); } },
|
||||
"__debugTransformFlags": { get(this: Node) { return formatTransformFlags(this.transformFlags); } },
|
||||
"__debugEmitFlags": { get(this: Node) { return formatEmitFlags(getEmitFlags(this)); } },
|
||||
"__debugGetText": { value(this: Node, includeTrivia?: boolean) {
|
||||
if (nodeIsSynthesized(this)) return "";
|
||||
const parseNode = getParseTreeNode(this);
|
||||
const sourceFile = parseNode && getSourceFileOfNode(parseNode);
|
||||
return sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
|
||||
} }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`)
|
||||
? (node: Node, message?: string): void => fail(
|
||||
`${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`,
|
||||
failBadSyntaxKind)
|
||||
: noop;
|
||||
|
||||
export const assertEachNode = shouldAssert(AssertionLevel.Normal)
|
||||
? (nodes: Node[], test: (node: Node) => boolean, message?: string) => assert(
|
||||
test === undefined || every(nodes, test),
|
||||
message || "Unexpected node.",
|
||||
() => `Node array did not pass test '${getFunctionName(test)}'.`)
|
||||
? (nodes: Node[], test: (node: Node) => boolean, message?: string): void => assert(
|
||||
test === undefined || every(nodes, test),
|
||||
message || "Unexpected node.",
|
||||
() => `Node array did not pass test '${getFunctionName(test)}'.`,
|
||||
assertEachNode)
|
||||
: noop;
|
||||
|
||||
export const assertNode = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, test: (node: Node) => boolean, message?: string) => assert(
|
||||
test === undefined || test(node),
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`)
|
||||
? (node: Node, test: (node: Node) => boolean, message?: string): void => assert(
|
||||
test === undefined || test(node),
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`,
|
||||
assertNode)
|
||||
: noop;
|
||||
|
||||
export const assertOptionalNode = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, test: (node: Node) => boolean, message?: string) => assert(
|
||||
test === undefined || node === undefined || test(node),
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`)
|
||||
? (node: Node, test: (node: Node) => boolean, message?: string): void => assert(
|
||||
test === undefined || node === undefined || test(node),
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`,
|
||||
assertOptionalNode)
|
||||
: noop;
|
||||
|
||||
export const assertOptionalToken = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, kind: SyntaxKind, message?: string) => assert(
|
||||
kind === undefined || node === undefined || node.kind === kind,
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} was not a '${formatSyntaxKind(kind)}' token.`)
|
||||
? (node: Node, kind: SyntaxKind, message?: string): void => assert(
|
||||
kind === undefined || node === undefined || node.kind === kind,
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} was not a '${formatSyntaxKind(kind)}' token.`,
|
||||
assertOptionalToken)
|
||||
: noop;
|
||||
|
||||
export const assertMissingNode = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, message?: string) => assert(
|
||||
node === undefined,
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} was unexpected'.`)
|
||||
? (node: Node, message?: string): void => assert(
|
||||
node === undefined,
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} was unexpected'.`,
|
||||
assertMissingNode)
|
||||
: noop;
|
||||
|
||||
function getFunctionName(func: Function) {
|
||||
if (typeof func !== "function") {
|
||||
return "";
|
||||
}
|
||||
else if (func.hasOwnProperty("name")) {
|
||||
return (<any>func).name;
|
||||
}
|
||||
else {
|
||||
const text = Function.prototype.toString.call(func);
|
||||
const match = /^function\s+([\w\$]+)\s*\(/.exec(text);
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,9 +28,9 @@ var Point = (function () {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
}());
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
(function (Point) {
|
||||
Point.Origin = ""; //expected duplicate identifier error
|
||||
})(Point || (Point = {}));
|
||||
@ -41,9 +41,9 @@ var A;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
}());
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
A.Point = Point;
|
||||
(function (Point) {
|
||||
Point.Origin = ""; //expected duplicate identifier error
|
||||
|
||||
@ -28,9 +28,9 @@ var Point = (function () {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
}());
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
(function (Point) {
|
||||
var Origin = ""; // not an error, since not exported
|
||||
})(Point || (Point = {}));
|
||||
@ -41,9 +41,9 @@ var A;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
}());
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
A.Point = Point;
|
||||
(function (Point) {
|
||||
var Origin = ""; // not an error since not exported
|
||||
|
||||
@ -7,6 +7,6 @@ class AtomicNumbers {
|
||||
var AtomicNumbers = (function () {
|
||||
function AtomicNumbers() {
|
||||
}
|
||||
AtomicNumbers.H = 1;
|
||||
return AtomicNumbers;
|
||||
}());
|
||||
AtomicNumbers.H = 1;
|
||||
|
||||
@ -39,9 +39,9 @@ define(["require", "exports"], function (require, exports) {
|
||||
function C1() {
|
||||
this.m1 = 42;
|
||||
}
|
||||
C1.s1 = true;
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
var E1;
|
||||
(function (E1) {
|
||||
|
||||
@ -42,9 +42,9 @@ var Point = (function () {
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt(this.x * this.x + this.y * this.y);
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
}());
|
||||
Point.origin = new Point(0, 0);
|
||||
var Point3D = (function (_super) {
|
||||
__extends(Point3D, _super);
|
||||
function Point3D(x, y, z, m) {
|
||||
|
||||
@ -27,9 +27,9 @@ var C;
|
||||
var Name = (function () {
|
||||
function Name(parameters) {
|
||||
}
|
||||
Name.funcData = A.AA.func();
|
||||
Name.someConst = A.AA.foo;
|
||||
return Name;
|
||||
}());
|
||||
Name.funcData = A.AA.func();
|
||||
Name.someConst = A.AA.foo;
|
||||
C.Name = Name;
|
||||
})(C || (C = {}));
|
||||
|
||||
@ -177,9 +177,9 @@ function foo10() {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.a = x;
|
||||
return A;
|
||||
}());
|
||||
A.a = x;
|
||||
var x;
|
||||
}
|
||||
function foo11() {
|
||||
|
||||
@ -5,6 +5,6 @@ class foo { constructor() { static f = 3; } }
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
foo.f = 3;
|
||||
return foo;
|
||||
}());
|
||||
foo.f = 3;
|
||||
|
||||
@ -62,9 +62,9 @@ function f(b) {
|
||||
Foo.prototype.m = function () {
|
||||
new Foo();
|
||||
};
|
||||
Foo.y = new Foo();
|
||||
return Foo;
|
||||
}());
|
||||
Foo_1.y = new Foo_1();
|
||||
new Foo_1();
|
||||
}
|
||||
var _a;
|
||||
|
||||
@ -12,10 +12,10 @@ var v = ;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.p = 1;
|
||||
C = __decorate([
|
||||
decorate
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C.p = 1;
|
||||
C = __decorate([
|
||||
decorate
|
||||
], C);
|
||||
;
|
||||
|
||||
@ -27,9 +27,9 @@ var CCC = (function () {
|
||||
this.y = aaa;
|
||||
this.y = ''; // was: error, cannot assign string to number
|
||||
}
|
||||
CCC.staticY = aaa; // This shouldnt be error
|
||||
return CCC;
|
||||
}());
|
||||
CCC.staticY = aaa; // This shouldnt be error
|
||||
// above is equivalent to this:
|
||||
var aaaa = 1;
|
||||
var CCCC = (function () {
|
||||
|
||||
@ -40,12 +40,12 @@ var Test = (function () {
|
||||
console.log(field); // Using field here shouldnt be error
|
||||
};
|
||||
}
|
||||
Test.staticMessageHandler = function () {
|
||||
var field = Test.field;
|
||||
console.log(field); // Using field here shouldnt be error
|
||||
};
|
||||
return Test;
|
||||
}());
|
||||
Test.staticMessageHandler = function () {
|
||||
var field = Test.field;
|
||||
console.log(field); // Using field here shouldnt be error
|
||||
};
|
||||
var field1;
|
||||
var Test1 = (function () {
|
||||
function Test1(field1) {
|
||||
@ -56,8 +56,8 @@ var Test1 = (function () {
|
||||
// it would resolve to private field1 and thats not what user intended here.
|
||||
};
|
||||
}
|
||||
Test1.staticMessageHandler = function () {
|
||||
console.log(field1); // This shouldnt be error as its a static property
|
||||
};
|
||||
return Test1;
|
||||
}());
|
||||
Test1.staticMessageHandler = function () {
|
||||
console.log(field1); // This shouldnt be error as its a static property
|
||||
};
|
||||
|
||||
@ -32,9 +32,9 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.c = function () { return ''; };
|
||||
C.f = function () { return ''; };
|
||||
C.g = function () { return ''; };
|
||||
return C;
|
||||
}());
|
||||
C.g = function () { return ''; };
|
||||
var c = new C();
|
||||
var r1 = c.x;
|
||||
var r2 = c.a;
|
||||
|
||||
@ -47,9 +47,9 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.c = function () { return ''; };
|
||||
C.f = function () { return ''; };
|
||||
C.g = function () { return ''; };
|
||||
return C;
|
||||
}());
|
||||
C.g = function () { return ''; };
|
||||
var D = (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
|
||||
@ -30,9 +30,9 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.c = function () { return ''; };
|
||||
C.f = function () { return ''; };
|
||||
C.g = function () { return ''; };
|
||||
return C;
|
||||
}());
|
||||
C.g = function () { return ''; };
|
||||
// all of these are valid
|
||||
var c = new C();
|
||||
var r1 = c.x;
|
||||
|
||||
@ -16,10 +16,10 @@ module Clod {
|
||||
var Clod = (function () {
|
||||
function Clod() {
|
||||
}
|
||||
Clod.x = 10;
|
||||
Clod.y = 10;
|
||||
return Clod;
|
||||
}());
|
||||
Clod.x = 10;
|
||||
Clod.y = 10;
|
||||
(function (Clod) {
|
||||
var p = Clod.x;
|
||||
var q = x;
|
||||
|
||||
@ -29,19 +29,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var Remote = (function () {
|
||||
function Remote() {
|
||||
}
|
||||
Remote = __decorate([
|
||||
decorator("hello")
|
||||
], Remote);
|
||||
return Remote;
|
||||
}());
|
||||
Remote = __decorate([
|
||||
decorator("hello")
|
||||
], Remote);
|
||||
/**
|
||||
* Floating Comment
|
||||
*/
|
||||
var AnotherRomote = (function () {
|
||||
function AnotherRomote() {
|
||||
}
|
||||
AnotherRomote = __decorate([
|
||||
decorator("hi")
|
||||
], AnotherRomote);
|
||||
return AnotherRomote;
|
||||
}());
|
||||
AnotherRomote = __decorate([
|
||||
decorator("hi")
|
||||
], AnotherRomote);
|
||||
|
||||
@ -23,13 +23,13 @@ class test {
|
||||
var test = (function () {
|
||||
function test() {
|
||||
}
|
||||
/**
|
||||
* p1 comment appears in output
|
||||
*/
|
||||
test.p1 = "";
|
||||
/**
|
||||
* p3 comment appears in output
|
||||
*/
|
||||
test.p3 = "";
|
||||
return test;
|
||||
}());
|
||||
/**
|
||||
* p1 comment appears in output
|
||||
*/
|
||||
test.p1 = "";
|
||||
/**
|
||||
* p3 comment appears in output
|
||||
*/
|
||||
test.p3 = "";
|
||||
|
||||
@ -20,9 +20,9 @@ var C1 = (function () {
|
||||
function C1() {
|
||||
this.m1 = 42;
|
||||
}
|
||||
C1.s1 = true;
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
//// [foo_1.js]
|
||||
"use strict";
|
||||
|
||||
@ -38,9 +38,9 @@ var C1 = (function () {
|
||||
function C1() {
|
||||
this.m1 = 42;
|
||||
}
|
||||
C1.s1 = true;
|
||||
return C1;
|
||||
}());
|
||||
C1.s1 = true;
|
||||
exports.C1 = C1;
|
||||
var E1;
|
||||
(function (E1) {
|
||||
|
||||
@ -26,6 +26,6 @@ var C = (function () {
|
||||
this[s + n] = 2;
|
||||
this["hello bye"] = 0;
|
||||
}
|
||||
C["hello " + a + " bye"] = 0;
|
||||
return C;
|
||||
}());
|
||||
C["hello " + a + " bye"] = 0;
|
||||
|
||||
@ -22,8 +22,8 @@ var CtorDtor = (function () {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
CtorDtor
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
CtorDtor
|
||||
], C);
|
||||
|
||||
@ -39,10 +39,10 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C.x = 1;
|
||||
C.y = 1;
|
||||
return C;
|
||||
}());
|
||||
C.x = 1;
|
||||
C.y = 1;
|
||||
|
||||
|
||||
//// [declFilePrivateStatic.d.ts]
|
||||
|
||||
@ -24,8 +24,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.m = function () { };
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
|
||||
@ -29,12 +29,12 @@ var A = (function () {
|
||||
}
|
||||
A.prototype.m = function () {
|
||||
};
|
||||
__decorate([
|
||||
(function (x, p) {
|
||||
var a = 3;
|
||||
func(a);
|
||||
return x;
|
||||
})
|
||||
], A.prototype, "m", null);
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
(function (x, p) {
|
||||
var a = 3;
|
||||
func(a);
|
||||
return x;
|
||||
})
|
||||
], A.prototype, "m", null);
|
||||
|
||||
@ -46,8 +46,8 @@ var Wat = (function () {
|
||||
Wat.whatever = function () {
|
||||
// ...
|
||||
};
|
||||
__decorate([
|
||||
filter(function () { return a_1.test == 'abc'; })
|
||||
], Wat, "whatever", null);
|
||||
return Wat;
|
||||
}());
|
||||
__decorate([
|
||||
filter(function () { return a_1.test == 'abc'; })
|
||||
], Wat, "whatever", null);
|
||||
|
||||
@ -46,15 +46,15 @@ var MyComponent = (function () {
|
||||
}
|
||||
MyComponent.prototype.method = function (x) {
|
||||
};
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MyComponent.prototype, "method", null);
|
||||
MyComponent = __decorate([
|
||||
decorator,
|
||||
__metadata("design:paramtypes", [service_1.default])
|
||||
], MyComponent);
|
||||
return MyComponent;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MyComponent.prototype, "method", null);
|
||||
MyComponent = __decorate([
|
||||
decorator,
|
||||
__metadata("design:paramtypes", [service_1.default])
|
||||
], MyComponent);
|
||||
|
||||
@ -19,11 +19,11 @@ var MyClass = (function () {
|
||||
}
|
||||
MyClass.prototype.doSomething = function () {
|
||||
};
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MyClass.prototype, "doSomething", null);
|
||||
return MyClass;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MyClass.prototype, "doSomething", null);
|
||||
|
||||
@ -31,10 +31,10 @@ var B = (function () {
|
||||
function B() {
|
||||
this.x = new A();
|
||||
}
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Object)
|
||||
], B.prototype, "x", void 0);
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", Object)
|
||||
], B.prototype, "x", void 0);
|
||||
exports.B = B;
|
||||
|
||||
@ -100,16 +100,16 @@ var ClassA = (function () {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
annotation1(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [aux1_1.SomeClass1]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ClassA.prototype, "foo", null);
|
||||
ClassA = __decorate([
|
||||
annotation(),
|
||||
__metadata("design:paramtypes", [aux_1.SomeClass])
|
||||
], ClassA);
|
||||
return ClassA;
|
||||
}());
|
||||
__decorate([
|
||||
annotation1(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [aux1_1.SomeClass1]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ClassA.prototype, "foo", null);
|
||||
ClassA = __decorate([
|
||||
annotation(),
|
||||
__metadata("design:paramtypes", [aux_1.SomeClass])
|
||||
], ClassA);
|
||||
exports.ClassA = ClassA;
|
||||
|
||||
@ -31,10 +31,10 @@ var B = (function () {
|
||||
function B() {
|
||||
this.x = new A();
|
||||
}
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", A)
|
||||
], B.prototype, "x", void 0);
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata("design:type", A)
|
||||
], B.prototype, "x", void 0);
|
||||
exports.B = B;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db.db])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,11 +46,11 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [typeof (_a = (typeof db_1.default !== "undefined" && db_1.default).db) === "function" && _a || Object])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
var _a;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [typeof (_a = (typeof db_1.default !== "undefined" && db_1.default).db) === "function" && _a || Object])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
var _a;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [db_1.default])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -46,10 +46,10 @@ var MyClass = (function () {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [database.db])
|
||||
], MyClass);
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass = __decorate([
|
||||
someDecorator,
|
||||
__metadata("design:paramtypes", [database.db])
|
||||
], MyClass);
|
||||
exports.MyClass = MyClass;
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
|
||||
@ -17,9 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
exports.C = C;
|
||||
|
||||
@ -16,8 +16,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
dec()
|
||||
], C);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -20,8 +20,8 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", null);
|
||||
|
||||
@ -48,11 +48,11 @@ var A = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec1
|
||||
], A.prototype, "x", null);
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], A.prototype, "x", null);
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
@ -62,11 +62,11 @@ var B = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec2
|
||||
], B.prototype, "x", null);
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
dec2
|
||||
], B.prototype, "x", null);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
@ -76,11 +76,11 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec1
|
||||
], C.prototype, "x", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], C.prototype, "x", null);
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
@ -90,11 +90,11 @@ var D = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec2
|
||||
], D.prototype, "x", null);
|
||||
return D;
|
||||
}());
|
||||
__decorate([
|
||||
dec2
|
||||
], D.prototype, "x", null);
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
@ -104,11 +104,11 @@ var E = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec1
|
||||
], E.prototype, "x", null);
|
||||
return E;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], E.prototype, "x", null);
|
||||
var F = (function () {
|
||||
function F() {
|
||||
}
|
||||
@ -118,8 +118,8 @@ var F = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec1
|
||||
], F.prototype, "x", null);
|
||||
return F;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], F.prototype, "x", null);
|
||||
|
||||
@ -48,13 +48,13 @@ var A = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], A.prototype, "x", null);
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], A.prototype, "x", null);
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
@ -64,13 +64,13 @@ var B = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B.prototype, "x", null);
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B.prototype, "x", null);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
@ -80,13 +80,13 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], C.prototype, "x", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], C.prototype, "x", null);
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
@ -96,13 +96,13 @@ var D = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], D.prototype, "x", null);
|
||||
return D;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], D.prototype, "x", null);
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
@ -111,13 +111,13 @@ var E = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], E.prototype, "x", null);
|
||||
return E;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], E.prototype, "x", null);
|
||||
var F = (function () {
|
||||
function F() {
|
||||
}
|
||||
@ -126,10 +126,10 @@ var F = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], F.prototype, "x", null);
|
||||
return F;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], F.prototype, "x", null);
|
||||
|
||||
@ -53,9 +53,9 @@ var C = (function (_super) {
|
||||
function C(prop) {
|
||||
return _super.call(this) || this;
|
||||
}
|
||||
C = __decorate([
|
||||
__param(0, _0_ts_2.foo)
|
||||
], C);
|
||||
return C;
|
||||
}(_0_ts_1.base));
|
||||
C = __decorate([
|
||||
__param(0, _0_ts_2.foo)
|
||||
], C);
|
||||
exports.C = C;
|
||||
|
||||
@ -56,9 +56,9 @@ var C = (function (_super) {
|
||||
function C(prop) {
|
||||
return _super.call(this) || this;
|
||||
}
|
||||
C = __decorate([
|
||||
__param(0, _0_2.foo)
|
||||
], C);
|
||||
return C;
|
||||
}(_0_1.base));
|
||||
C = __decorate([
|
||||
__param(0, _0_2.foo)
|
||||
], C);
|
||||
exports.C = C;
|
||||
|
||||
@ -37,27 +37,27 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A = __decorate([
|
||||
dec
|
||||
], A);
|
||||
return A;
|
||||
}());
|
||||
A = __decorate([
|
||||
dec
|
||||
], A);
|
||||
var B = (function () {
|
||||
function B(x) {
|
||||
}
|
||||
B = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B);
|
||||
return B;
|
||||
}());
|
||||
B = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B);
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
}(A));
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
|
||||
@ -18,8 +18,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
var C = (function () {
|
||||
function C(p) {
|
||||
}
|
||||
C = __decorate([
|
||||
__param(0, dec)
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
__param(0, dec)
|
||||
], C);
|
||||
|
||||
@ -18,8 +18,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
var C = (function () {
|
||||
function C(public, p) {
|
||||
}
|
||||
C = __decorate([
|
||||
__param(1, dec)
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
C = __decorate([
|
||||
__param(1, dec)
|
||||
], C);
|
||||
|
||||
@ -16,8 +16,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -16,8 +16,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -22,9 +22,9 @@ var M;
|
||||
}
|
||||
C.prototype.decorator = function (target, key) { };
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
this.decorator
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
this.decorator
|
||||
], C.prototype, "method", null);
|
||||
})(M || (M = {}));
|
||||
|
||||
@ -40,9 +40,9 @@ var M;
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
_super.decorator
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}(S));
|
||||
__decorate([
|
||||
_super.decorator
|
||||
], C.prototype, "method", null);
|
||||
})(M || (M = {}));
|
||||
|
||||
@ -16,8 +16,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -16,8 +16,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -16,8 +16,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -18,8 +18,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -19,8 +19,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function (p) { };
|
||||
__decorate([
|
||||
__param(0, dec)
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
__param(0, dec)
|
||||
], C.prototype, "method", null);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec()
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec()
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop", void 0);
|
||||
|
||||
@ -29,8 +29,8 @@ var A = (function () {
|
||||
A.prototype.__foo = function (bar) {
|
||||
// do something with bar
|
||||
};
|
||||
__decorate([
|
||||
dec()
|
||||
], A.prototype, "__foo");
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
dec()
|
||||
], A.prototype, "__foo");
|
||||
|
||||
@ -83,6 +83,6 @@ var Derived = (function (_super) {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Derived.a = _this = _super.call(this) || this;
|
||||
return Derived;
|
||||
}(Base));
|
||||
Derived.a = _this = _super.call(this) || this;
|
||||
|
||||
@ -24,15 +24,15 @@ var A = (function () {
|
||||
function A(hi) {
|
||||
}
|
||||
A.prototype.method = function (there) { };
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], A.prototype, "method", null);
|
||||
A = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], A);
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], A.prototype, "method", null);
|
||||
A = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], A);
|
||||
|
||||
@ -40,18 +40,18 @@ var A = (function () {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], A.prototype, "method", null);
|
||||
A = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], A);
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], A.prototype, "method", null);
|
||||
A = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], A);
|
||||
var B = (function () {
|
||||
function B() {
|
||||
var args = [];
|
||||
@ -65,15 +65,15 @@ var B = (function () {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], B.prototype, "method", null);
|
||||
B = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B);
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
MyMethodDecorator,
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], B.prototype, "method", null);
|
||||
B = __decorate([
|
||||
MyClassDecorator,
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B);
|
||||
|
||||
@ -124,10 +124,10 @@ var NoBase = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
//super call in static class member initializer with no base type
|
||||
NoBase.k = _this = _super.call(this) || this;
|
||||
return NoBase;
|
||||
}());
|
||||
//super call in static class member initializer with no base type
|
||||
NoBase.k = _this = _super.call(this) || this;
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
|
||||
@ -180,10 +180,10 @@ var SomeBase = (function () {
|
||||
SomeBase.prototype.publicFunc = function () { };
|
||||
SomeBase.privateStaticFunc = function () { };
|
||||
SomeBase.publicStaticFunc = function () { };
|
||||
SomeBase.privateStaticMember = 0;
|
||||
SomeBase.publicStaticMember = 0;
|
||||
return SomeBase;
|
||||
}());
|
||||
SomeBase.privateStaticMember = 0;
|
||||
SomeBase.publicStaticMember = 0;
|
||||
//super.publicInstanceMemberNotFunction in constructor of derived class
|
||||
//super.publicInstanceMemberNotFunction in instance member function of derived class
|
||||
//super.publicInstanceMemberNotFunction in instance member accessor(get and set) of derived class
|
||||
|
||||
@ -19,9 +19,9 @@ exports.__esModule = true;
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.CONSTANT = "Foo";
|
||||
return Foo;
|
||||
}());
|
||||
Foo.CONSTANT = "Foo";
|
||||
exports.Foo = Foo;
|
||||
function assert(value) {
|
||||
if (!value)
|
||||
|
||||
@ -119,9 +119,9 @@ var Foo = (function (_super) {
|
||||
}
|
||||
Foo.prototype.bar = function () { return 0; };
|
||||
Foo.prototype.boo = function (x) { return x; };
|
||||
Foo.statVal = 0;
|
||||
return Foo;
|
||||
}(Bar));
|
||||
Foo.statVal = 0;
|
||||
var f = new Foo();
|
||||
//class GetSetMonster {
|
||||
// // attack(target) {
|
||||
|
||||
@ -288,9 +288,9 @@ var Statics = (function () {
|
||||
Statics.baz = function () {
|
||||
return "";
|
||||
};
|
||||
Statics.foo = 1;
|
||||
return Statics;
|
||||
}());
|
||||
Statics.foo = 1;
|
||||
var stat = new Statics();
|
||||
var ImplementsInterface = (function () {
|
||||
function ImplementsInterface() {
|
||||
|
||||
@ -31,22 +31,22 @@ var C = (function () {
|
||||
this.p = 1;
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
C.s = 0;
|
||||
return C;
|
||||
}());
|
||||
export { C };
|
||||
C.s = 0;
|
||||
export { C as C2 };
|
||||
var D = (function () {
|
||||
function D() {
|
||||
this.p = 1;
|
||||
}
|
||||
D.prototype.method = function () { };
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}());
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
export { D };
|
||||
export { D as D2 };
|
||||
var E = (function () {
|
||||
|
||||
@ -15,17 +15,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var C = C_1 = (function () {
|
||||
function C() {
|
||||
var C = (function () {
|
||||
var C = C_1 = function C() {
|
||||
this.p = 1;
|
||||
}
|
||||
};
|
||||
C.x = function () { return C_1.y; };
|
||||
C.prototype.method = function () { };
|
||||
C.y = 1;
|
||||
C = C_1 = __decorate([
|
||||
foo
|
||||
], C);
|
||||
return C;
|
||||
var C_1;
|
||||
}());
|
||||
C.y = 1;
|
||||
C = C_1 = __decorate([
|
||||
foo
|
||||
], C);
|
||||
export default C;
|
||||
var C_1;
|
||||
|
||||
@ -12,7 +12,7 @@ var C = (function () {
|
||||
this.p = 1;
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
C.s = 0;
|
||||
return C;
|
||||
}());
|
||||
export default C;
|
||||
C.s = 0;
|
||||
|
||||
@ -19,10 +19,10 @@ var D = (function () {
|
||||
this.p = 1;
|
||||
}
|
||||
D.prototype.method = function () { };
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}());
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
export default D;
|
||||
|
||||
@ -30,9 +30,9 @@ var C = (function (_super) {
|
||||
_this.known = 1;
|
||||
return _this;
|
||||
}
|
||||
C.sknown = 2;
|
||||
return C;
|
||||
}(Base));
|
||||
C.sknown = 2;
|
||||
var c = new C();
|
||||
c.known.length; // error, 'known' has no 'length' property
|
||||
C.sknown.length; // error, 'sknown' has no 'length' property
|
||||
|
||||
@ -25,7 +25,7 @@ var Test = (function () {
|
||||
var a = b; // Block-scoped variable 'b' used before its declaration
|
||||
var b = 3;
|
||||
};
|
||||
Test._B = Test._A; // undefined, no error/warning
|
||||
Test._A = 3;
|
||||
return Test;
|
||||
}());
|
||||
Test._B = Test._A; // undefined, no error/warning
|
||||
Test._A = 3;
|
||||
|
||||
@ -616,219 +616,219 @@ var x48 = (function () {
|
||||
var x49 = (function () {
|
||||
function x49() {
|
||||
}
|
||||
x49.member = function () { return [d1, d2]; };
|
||||
return x49;
|
||||
}());
|
||||
x49.member = function () { return [d1, d2]; };
|
||||
var x50 = (function () {
|
||||
function x50() {
|
||||
}
|
||||
x50.member = function () { return [d1, d2]; };
|
||||
return x50;
|
||||
}());
|
||||
x50.member = function () { return [d1, d2]; };
|
||||
var x51 = (function () {
|
||||
function x51() {
|
||||
}
|
||||
x51.member = function named() { return [d1, d2]; };
|
||||
return x51;
|
||||
}());
|
||||
x51.member = function named() { return [d1, d2]; };
|
||||
var x52 = (function () {
|
||||
function x52() {
|
||||
}
|
||||
x52.member = function () { return [d1, d2]; };
|
||||
return x52;
|
||||
}());
|
||||
x52.member = function () { return [d1, d2]; };
|
||||
var x53 = (function () {
|
||||
function x53() {
|
||||
}
|
||||
x53.member = function () { return [d1, d2]; };
|
||||
return x53;
|
||||
}());
|
||||
x53.member = function () { return [d1, d2]; };
|
||||
var x54 = (function () {
|
||||
function x54() {
|
||||
}
|
||||
x54.member = function named() { return [d1, d2]; };
|
||||
return x54;
|
||||
}());
|
||||
x54.member = function named() { return [d1, d2]; };
|
||||
var x55 = (function () {
|
||||
function x55() {
|
||||
}
|
||||
x55.member = [d1, d2];
|
||||
return x55;
|
||||
}());
|
||||
x55.member = [d1, d2];
|
||||
var x56 = (function () {
|
||||
function x56() {
|
||||
}
|
||||
x56.member = [d1, d2];
|
||||
return x56;
|
||||
}());
|
||||
x56.member = [d1, d2];
|
||||
var x57 = (function () {
|
||||
function x57() {
|
||||
}
|
||||
x57.member = [d1, d2];
|
||||
return x57;
|
||||
}());
|
||||
x57.member = [d1, d2];
|
||||
var x58 = (function () {
|
||||
function x58() {
|
||||
}
|
||||
x58.member = { n: [d1, d2] };
|
||||
return x58;
|
||||
}());
|
||||
x58.member = { n: [d1, d2] };
|
||||
var x59 = (function () {
|
||||
function x59() {
|
||||
}
|
||||
x59.member = function (n) { var n; return null; };
|
||||
return x59;
|
||||
}());
|
||||
x59.member = function (n) { var n; return null; };
|
||||
var x60 = (function () {
|
||||
function x60() {
|
||||
}
|
||||
x60.member = { func: function (n) { return [d1, d2]; } };
|
||||
return x60;
|
||||
}());
|
||||
x60.member = { func: function (n) { return [d1, d2]; } };
|
||||
var x61 = (function () {
|
||||
function x61() {
|
||||
}
|
||||
x61.member = function () { return [d1, d2]; };
|
||||
return x61;
|
||||
}());
|
||||
x61.member = function () { return [d1, d2]; };
|
||||
var x62 = (function () {
|
||||
function x62() {
|
||||
}
|
||||
x62.member = function () { return [d1, d2]; };
|
||||
return x62;
|
||||
}());
|
||||
x62.member = function () { return [d1, d2]; };
|
||||
var x63 = (function () {
|
||||
function x63() {
|
||||
}
|
||||
x63.member = function named() { return [d1, d2]; };
|
||||
return x63;
|
||||
}());
|
||||
x63.member = function named() { return [d1, d2]; };
|
||||
var x64 = (function () {
|
||||
function x64() {
|
||||
}
|
||||
x64.member = function () { return [d1, d2]; };
|
||||
return x64;
|
||||
}());
|
||||
x64.member = function () { return [d1, d2]; };
|
||||
var x65 = (function () {
|
||||
function x65() {
|
||||
}
|
||||
x65.member = function () { return [d1, d2]; };
|
||||
return x65;
|
||||
}());
|
||||
x65.member = function () { return [d1, d2]; };
|
||||
var x66 = (function () {
|
||||
function x66() {
|
||||
}
|
||||
x66.member = function named() { return [d1, d2]; };
|
||||
return x66;
|
||||
}());
|
||||
x66.member = function named() { return [d1, d2]; };
|
||||
var x67 = (function () {
|
||||
function x67() {
|
||||
}
|
||||
x67.member = [d1, d2];
|
||||
return x67;
|
||||
}());
|
||||
x67.member = [d1, d2];
|
||||
var x68 = (function () {
|
||||
function x68() {
|
||||
}
|
||||
x68.member = [d1, d2];
|
||||
return x68;
|
||||
}());
|
||||
x68.member = [d1, d2];
|
||||
var x69 = (function () {
|
||||
function x69() {
|
||||
}
|
||||
x69.member = [d1, d2];
|
||||
return x69;
|
||||
}());
|
||||
x69.member = [d1, d2];
|
||||
var x70 = (function () {
|
||||
function x70() {
|
||||
}
|
||||
x70.member = { n: [d1, d2] };
|
||||
return x70;
|
||||
}());
|
||||
x70.member = { n: [d1, d2] };
|
||||
var x71 = (function () {
|
||||
function x71() {
|
||||
}
|
||||
x71.member = function (n) { var n; return null; };
|
||||
return x71;
|
||||
}());
|
||||
x71.member = function (n) { var n; return null; };
|
||||
var x72 = (function () {
|
||||
function x72() {
|
||||
}
|
||||
x72.member = { func: function (n) { return [d1, d2]; } };
|
||||
return x72;
|
||||
}());
|
||||
x72.member = { func: function (n) { return [d1, d2]; } };
|
||||
var x73 = (function () {
|
||||
function x73() {
|
||||
}
|
||||
x73.member = function () { return [d1, d2]; };
|
||||
return x73;
|
||||
}());
|
||||
x73.member = function () { return [d1, d2]; };
|
||||
var x74 = (function () {
|
||||
function x74() {
|
||||
}
|
||||
x74.member = function () { return [d1, d2]; };
|
||||
return x74;
|
||||
}());
|
||||
x74.member = function () { return [d1, d2]; };
|
||||
var x75 = (function () {
|
||||
function x75() {
|
||||
}
|
||||
x75.member = function named() { return [d1, d2]; };
|
||||
return x75;
|
||||
}());
|
||||
x75.member = function named() { return [d1, d2]; };
|
||||
var x76 = (function () {
|
||||
function x76() {
|
||||
}
|
||||
x76.member = function () { return [d1, d2]; };
|
||||
return x76;
|
||||
}());
|
||||
x76.member = function () { return [d1, d2]; };
|
||||
var x77 = (function () {
|
||||
function x77() {
|
||||
}
|
||||
x77.member = function () { return [d1, d2]; };
|
||||
return x77;
|
||||
}());
|
||||
x77.member = function () { return [d1, d2]; };
|
||||
var x78 = (function () {
|
||||
function x78() {
|
||||
}
|
||||
x78.member = function named() { return [d1, d2]; };
|
||||
return x78;
|
||||
}());
|
||||
x78.member = function named() { return [d1, d2]; };
|
||||
var x79 = (function () {
|
||||
function x79() {
|
||||
}
|
||||
x79.member = [d1, d2];
|
||||
return x79;
|
||||
}());
|
||||
x79.member = [d1, d2];
|
||||
var x80 = (function () {
|
||||
function x80() {
|
||||
}
|
||||
x80.member = [d1, d2];
|
||||
return x80;
|
||||
}());
|
||||
x80.member = [d1, d2];
|
||||
var x81 = (function () {
|
||||
function x81() {
|
||||
}
|
||||
x81.member = [d1, d2];
|
||||
return x81;
|
||||
}());
|
||||
x81.member = [d1, d2];
|
||||
var x82 = (function () {
|
||||
function x82() {
|
||||
}
|
||||
x82.member = { n: [d1, d2] };
|
||||
return x82;
|
||||
}());
|
||||
x82.member = { n: [d1, d2] };
|
||||
var x83 = (function () {
|
||||
function x83() {
|
||||
}
|
||||
x83.member = function (n) { var n; return null; };
|
||||
return x83;
|
||||
}());
|
||||
x83.member = function (n) { var n; return null; };
|
||||
var x84 = (function () {
|
||||
function x84() {
|
||||
}
|
||||
x84.member = { func: function (n) { return [d1, d2]; } };
|
||||
return x84;
|
||||
}());
|
||||
x84.member = { func: function (n) { return [d1, d2]; } };
|
||||
var x85 = (function () {
|
||||
function x85(parm) {
|
||||
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
|
||||
|
||||
@ -25,9 +25,9 @@ var Foo = (function () {
|
||||
Foo.f = function (xs) {
|
||||
return xs.reverse();
|
||||
};
|
||||
Foo.a = function (n) { };
|
||||
Foo.c = [];
|
||||
Foo.d = false || (function (x) { return x || undefined; })(null);
|
||||
Foo.e = function (x) { return null; };
|
||||
return Foo;
|
||||
}());
|
||||
Foo.a = function (n) { };
|
||||
Foo.c = [];
|
||||
Foo.d = false || (function (x) { return x || undefined; })(null);
|
||||
Foo.e = function (x) { return null; };
|
||||
|
||||
@ -65,9 +65,9 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C.barBack = "";
|
||||
return C;
|
||||
}());
|
||||
C.barBack = "";
|
||||
var c = new C();
|
||||
var foo = c.Foo;
|
||||
c.Foo = "foov";
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user