diff --git a/.travis.yml b/.travis.yml index 7231d89d354..33e44a349aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ branches: - release-2.3 install: - - npm uninstall typescript - - npm uninstall tslint + - npm uninstall typescript --no-save + - npm uninstall tslint --no-save - npm install cache: diff --git a/jenkins.sh b/jenkins.sh index 377a44b7bf7..b716f5bbeb2 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -2,12 +2,12 @@ # Set up NVM export NVM_DIR="/home/dotnet-bot/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" nvm install $1 -npm uninstall typescript -npm uninstall tslint +npm uninstall typescript --no-save +npm uninstall tslint --no-save npm install npm update npm test diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac0ae1a1cd5..c3a0d617f0a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1101,13 +1101,13 @@ namespace ts { if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestionForNonexistentSymbol(originalLocation, name, meaning); if (suggestion) { - suggestionCount++; error(errorLocation, suggestedNameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), suggestion); } } if (!suggestion) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } + suggestionCount++; } } return undefined; @@ -4123,7 +4123,7 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); + const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); if (declaration.dotDotDotToken) { // Rest element has an array type with the same element type as the parent type type = createArrayType(elementType); @@ -10894,12 +10894,12 @@ namespace ts { function getTypeOfDestructuredArrayElement(type: Type, index: number) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || + checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type: Type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node: BinaryExpression): Type { @@ -12873,7 +12873,7 @@ namespace ts { const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); + || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); } return undefined; } @@ -13111,7 +13111,7 @@ namespace ts { } const arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node: BindingElement | Expression): boolean { @@ -13140,7 +13140,7 @@ namespace ts { // if there is no index type / iterated type. const restArrayType = checkExpression((e).expression, checkMode); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); + getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); if (restElementType) { elementTypes.push(restElementType); } @@ -16993,7 +16993,7 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; const elements = node.elements; for (let i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); @@ -20137,12 +20137,12 @@ namespace ts { return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean): Type { + function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterables: boolean): Type { if (isTypeAny(inputType)) { return inputType; } - return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, /*checkAssignability*/ true) || anyType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterables, /*checkAssignability*/ true) || anyType; } /** @@ -20150,16 +20150,16 @@ namespace ts { * we want to get the iterated type of an iterable for ES2015 or later, or the iterated type * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ - function getIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean, checkAssignability: boolean): Type { + function getIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterables: boolean, checkAssignability: boolean): Type { const uplevelIteration = languageVersion >= ScriptTarget.ES2015; const downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. - if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + if (uplevelIteration || downlevelIteration || allowAsyncIterables) { // We only report errors for an invalid iterable type in ES2015 or higher. - const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); if (iteratedType || uplevelIteration) { return iteratedType; } @@ -20273,79 +20273,75 @@ namespace ts { * For a **for-await-of** statement or a `yield*` in an async generator we will look for * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, isAsyncIterable: boolean, allowNonAsyncIterables: boolean, checkAssignability: boolean): Type | undefined { + function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: boolean): Type | undefined { if (isTypeAny(type)) { return undefined; } - const typeAsIterable = type; - if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { - return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; - } + return mapType(type, getIteratedType); - if (isAsyncIterable) { - // As an optimization, if the type is an instantiation of the global `AsyncIterable` - // or the global `AsyncIterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { - return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0]; + function getIteratedType(type: Type) { + const typeAsIterable = type; + if (allowAsyncIterables) { + if (typeAsIterable.iteratedTypeOfAsyncIterable) { + return typeAsIterable.iteratedTypeOfAsyncIterable; + } + + // As an optimization, if the type is an instantiation of the global `AsyncIterable` + // or the global `AsyncIterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0]; + } } - } - if (!isAsyncIterable || allowNonAsyncIterables) { - // As an optimization, if the type is an instantiation of the global `Iterable` or - // `IterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { - return isAsyncIterable - ? typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0] - : typeAsIterable.iteratedTypeOfIterable = (type).typeArguments[0]; + if (allowSyncIterables) { + if (typeAsIterable.iteratedTypeOfIterable) { + return typeAsIterable.iteratedTypeOfIterable; + } + + // As an optimization, if the type is an instantiation of the global `Iterable` or + // `IterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfIterable = (type).typeArguments[0]; + } } - } - let iteratorMethodSignatures: Signature[]; - let isNonAsyncIterable = false; - if (isAsyncIterable) { - const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("asyncIterator")); - if (isTypeAny(iteratorMethod)) { + const asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("asyncIterator")); + const methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator"))); + if (isTypeAny(methodType)) { return undefined; } - iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); - } - if (!isAsyncIterable || (allowNonAsyncIterables && !some(iteratorMethodSignatures))) { - const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorMethod)) { + const signatures = methodType && getSignaturesOfType(methodType, SignatureKind.Call); + if (!some(signatures)) { + if (errorNode) { + error(errorNode, + allowAsyncIterables + ? Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + // only report on the first error + errorNode = undefined; + } return undefined; } - iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); - isNonAsyncIterable = true; - } - if (some(iteratorMethodSignatures)) { - const iteratorMethodReturnType = getUnionType(map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - const iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); + const returnType = getUnionType(map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + const iteratedType = getIteratedTypeOfIterator(returnType, errorNode, /*isAsyncIterator*/ !!asyncMethodType); if (checkAssignability && errorNode && iteratedType) { // If `checkAssignability` was specified, we were called from // `checkIteratedTypeOrElementType`. As such, we need to validate that // the type passed in is actually an Iterable. - checkTypeAssignableTo(type, isNonAsyncIterable - ? createIterableType(iteratedType) - : createAsyncIterableType(iteratedType), errorNode); + checkTypeAssignableTo(type, asyncMethodType + ? createAsyncIterableType(iteratedType) + : createIterableType(iteratedType), errorNode); } - return isAsyncIterable + + return asyncMethodType ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType : typeAsIterable.iteratedTypeOfIterable = iteratedType; } - - if (errorNode) { - error(errorNode, - isAsyncIterable - ? Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator - : Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - - return undefined; } /** @@ -20445,7 +20441,7 @@ namespace ts { return undefined; } - return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, isAsyncGenerator, /*allowNonAsyncIterables*/ false, /*checkAssignability*/ false) + return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, /*allowAsyncIterables*/ isAsyncGenerator, /*allowSyncIterables*/ !isAsyncGenerator, /*checkAssignability*/ false) || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); } @@ -21092,10 +21088,6 @@ namespace ts { } } - function isAccessor(kind: SyntaxKind): boolean { - return kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor; - } - function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { @@ -22655,7 +22647,7 @@ namespace ts { Debug.assert(expr.parent.kind === SyntaxKind.ArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; const typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, indexOf((expr.parent).elements, expr), elementType || unknownType); } @@ -24565,7 +24557,7 @@ namespace ts { function checkGrammarStatementInAmbientContext(node: Node): boolean { if (isInAmbientContext(node)) { // An accessors is already reported about the ambient context - if (isAccessor(node.parent.kind)) { + if (isAccessor(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = true; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 91355d94e72..5aeb6a20827 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -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(to: T[] | undefined, from: T[] | undefined): T[] | undefined { + export function addRange(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(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(array: T[]): T { - return array && array.length > 0 - ? array[0] - : undefined; + export function firstOrUndefined(array: T[]): T | undefined { + return elementAt(array, 0); } /** * Returns the last element of an array if non-empty, `undefined` otherwise. */ - export function lastOrUndefined(array: T[]): T { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + export function lastOrUndefined(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(array: T[]): T { + export function singleOrUndefined(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(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined { + return value !== undefined && test(value) ? value : undefined; + } + + export function cast(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 {} @@ -2224,8 +2259,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() { @@ -2262,24 +2300,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 ((Error).captureStackTrace) { + (Error).captureStackTrace(e, stackCrawlMark || fail); + } + throw e; + } + + export function getFunctionName(func: Function) { + if (typeof func !== "function") { + return ""; + } + else if (func.hasOwnProperty("name")) { + return (func).name; + } + else { + const text = Function.prototype.toString.call(func); + const match = /^function\s+([\w\$]+)\s*\(/.exec(text); + return match ? match[1] : ""; + } } } @@ -2445,4 +2501,4 @@ namespace ts { export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } -} +} \ No newline at end of file diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 2fc17974ceb..30ce1baca43 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -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 createBinary(left, SyntaxKind.CommaToken, right); } @@ -3208,6 +3226,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"; } @@ -3606,7 +3644,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 { @@ -3648,22 +3686,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) { @@ -3710,6 +3732,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) { @@ -3746,13 +3784,33 @@ namespace ts { export function skipAssertions(node: Expression): Expression; export function skipAssertions(node: Node): Node; export function skipAssertions(node: Node): Node { - while (isAssertionExpression(node)) { - node = (node).expression; + while (isAssertionExpression(node) || node.kind === SyntaxKind.NonNullExpression) { + node = (node).expression; } 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(node: T): T { node.startsOnNewLine = true; return node; @@ -3890,7 +3948,7 @@ namespace ts { return bindingElement.right; } - if (isSpreadExpression(bindingElement)) { + if (isSpreadElement(bindingElement)) { // Recovery consistent with existing emit. return getInitializerOfBindingOrAssignmentElement(bindingElement.expression); } @@ -3958,7 +4016,7 @@ namespace ts { return getTargetOfBindingOrAssignmentElement(bindingElement.left); } - if (isSpreadExpression(bindingElement)) { + if (isSpreadElement(bindingElement)) { // `a` in `[...a] = ...` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c710c612dbe..257bce5c082 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6355,6 +6355,12 @@ namespace ts { comment.parent = parent; } + if (isInJavaScriptFile(parent)) { + if (!sourceFile.jsDocDiagnostics) { + sourceFile.jsDocDiagnostics = []; + } + sourceFile.jsDocDiagnostics.push(...parseDiagnostics); + } currentToken = saveToken; parseDiagnostics.length = saveParseDiagnosticsLength; parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -6543,7 +6549,7 @@ namespace ts { case "arg": case "argument": case "param": - tag = parseParamTag(atToken, tagName); + tag = parseParameterOrPropertyTag(atToken, tagName, /*shouldParseParamTag*/ true); break; case "return": case "returns": @@ -6688,11 +6694,12 @@ namespace ts { return { name, isBracketed }; } - function parseParamTag(atToken: AtToken, tagName: Identifier) { + function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, shouldParseParamTag: boolean): JSDocPropertyTag | JSDocParameterTag { let typeExpression = tryParseTypeExpression(); skipWhitespace(); const { name, isBracketed } = parseBracketNameInPropertyAndParamTag(); + skipWhitespace(); if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected); @@ -6711,13 +6718,15 @@ namespace ts { typeExpression = tryParseTypeExpression(); } - const result = createNode(SyntaxKind.JSDocParameterTag, atToken.pos); + const result = shouldParseParamTag ? + createNode(SyntaxKind.JSDocParameterTag, atToken.pos) : + createNode(SyntaxKind.JSDocPropertyTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; - result.parameterName = postName || preName; + result.name = postName || preName; result.isBracketed = isBracketed; return finishNode(result); } @@ -6746,26 +6755,6 @@ namespace ts { return finishNode(result); } - function parsePropertyTag(atToken: AtToken, tagName: Identifier): JSDocPropertyTag { - const typeExpression = tryParseTypeExpression(); - skipWhitespace(); - const { name, isBracketed } = parseBracketNameInPropertyAndParamTag(); - skipWhitespace(); - - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, Diagnostics.Identifier_expected); - return undefined; - } - - const result = createNode(SyntaxKind.JSDocPropertyTag, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.name = name; - result.typeExpression = typeExpression; - result.isBracketed = isBracketed; - return finishNode(result); - } - function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag { const typeExpression = tryParseTypeExpression(); @@ -6902,7 +6891,7 @@ namespace ts { return true; case "prop": case "property": - const propertyTag = parsePropertyTag(atToken, tagName); + const propertyTag = parseParameterOrPropertyTag(atToken, tagName, /*shouldParseParamTag*/ false) as JSDocPropertyTag; if (propertyTag) { if (!parentTag.jsDocPropertyTags) { parentTag.jsDocPropertyTags = >[]; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4db6f50552c..b44c4b0c801 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1022,6 +1022,9 @@ namespace ts { if (isSourceFileJavaScript(sourceFile)) { if (!sourceFile.additionalSyntacticDiagnostics) { sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + if (isCheckJsEnabledForFile(sourceFile, options)) { + sourceFile.additionalSyntacticDiagnostics = concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.jsDocDiagnostics); + } } return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 7074abd3436..1abebe937e6 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -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(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; + } } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 63c10145165..a0656476421 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -339,11 +339,64 @@ namespace ts { && !(node).expression; } + function isClassLikeVariableStatement(node: Node) { + if (!isVariableStatement(node)) return false; + const variable = singleOrUndefined((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 { @@ -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); } @@ -3396,7 +3610,7 @@ namespace ts { else { if (segments.length === 1) { const firstElement = elements[0]; - return needsUniqueCopy && isSpreadExpression(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression + return needsUniqueCopy && isSpreadElement(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression ? createArraySlice(segments[0]) : segments[0]; } @@ -3407,7 +3621,7 @@ namespace ts { } function partitionSpread(node: Expression) { - return isSpreadExpression(node) + return isSpreadElement(node) ? visitSpanOfSpreads : visitSpanOfNonSpreads; } @@ -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; } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 3355ad35633..e6351c0965e 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1502,7 +1502,7 @@ namespace ts { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { return hasExportedReferenceInDestructuringTarget(node.left); } - else if (isSpreadExpression(node)) { + else if (isSpreadElement(node)) { return hasExportedReferenceInDestructuringTarget(node.expression); } else if (isObjectLiteralExpression(node)) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d02aaecf333..bcfa5985b57 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -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 { 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(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); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7a0754f2b1f..adb9b6e7dcb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2145,6 +2145,10 @@ namespace ts { parent: JSDoc; kind: SyntaxKind.JSDocPropertyTag; name: Identifier; + /** the parameter name, if provided *before* the type (TypeScript-style) */ + preParameterName?: Identifier; + /** the parameter name, if provided *after* the type (JSDoc-standard) */ + postParameterName?: Identifier; typeExpression: JSDocTypeExpression; isBracketed: boolean; } @@ -2163,7 +2167,7 @@ namespace ts { /** the parameter name, if provided *after* the type (JSDoc-standard) */ postParameterName?: Identifier; /** the parameter name, regardless of the location it was provided */ - parameterName: Identifier; + name: Identifier; isBracketed: boolean; } @@ -2312,16 +2316,19 @@ namespace ts { /* @internal */ identifierCount: number; /* @internal */ symbolCount: number; - // File level diagnostics reported by the parser (includes diagnostics about /// references + // File-level diagnostics reported by the parser (includes diagnostics about /// references // as well as code diagnostics). /* @internal */ parseDiagnostics: Diagnostic[]; - // Stores additional file level diagnostics reported by the program - /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; - - // File level diagnostics reported by the binder. + // File-level diagnostics reported by the binder. /* @internal */ bindDiagnostics: Diagnostic[]; + // File-level JSDoc diagnostics reported by the JSDoc parser + /* @internal */ jsDocDiagnostics?: Diagnostic[]; + + // Stores additional file-level diagnostics reported by the program + /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; + // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. /* @internal */ lineMap: number[]; @@ -3088,6 +3095,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 @@ -4001,34 +4009,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 { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7571bbf3c21..6f6404f0688 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -254,10 +254,6 @@ namespace ts { return !nodeIsMissing(node); } - export function isToken(n: Node): boolean { - return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; - } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -284,22 +280,6 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } - export function isJSDocNode(node: Node) { - return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; - } - - export function isJSDoc(node: Node): node is JSDoc { - return node.kind === SyntaxKind.JSDocComment; - } - - export function isJSDocTypedefTag(node: Node): node is JSDocTypedefTag { - return node.kind === SyntaxKind.JSDocTypedefTag; - } - - export function isJSDocTag(node: Node) { - return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; - } - export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); @@ -751,10 +731,6 @@ namespace ts { return false; } - export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { - return node.kind === SyntaxKind.PrefixUnaryExpression; - } - // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. export function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T { @@ -862,49 +838,6 @@ namespace ts { return false; } - export function isAccessor(node: Node): node is AccessorDeclaration { - return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); - } - - export function isClassLike(node: Node): node is ClassLikeDeclaration { - return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); - } - - export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { - return node && isFunctionLikeKind(node.kind); - } - - export function isFunctionLikeKind(kind: SyntaxKind): boolean { - switch (kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return true; - } - - return false; - } - - export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode { - switch (node.kind) { - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return true; - } - - return false; - } - export function introducesArgumentsExoticObject(node: Node) { switch (node.kind) { case SyntaxKind.MethodDeclaration: @@ -919,21 +852,6 @@ namespace ts { return false; } - export function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement { - switch (node.kind) { - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return true; - case SyntaxKind.LabeledStatement: - return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); - } - - return false; - } - export function unwrapInnermostStatementOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) { while (true) { if (beforeUnwrapLabelCallback) { @@ -1161,24 +1079,6 @@ namespace ts { return undefined; } - export function isCallLikeExpression(node: Node): node is CallLikeExpression { - switch (node.kind) { - case SyntaxKind.JsxOpeningElement: - case SyntaxKind.JsxSelfClosingElement: - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.Decorator: - return true; - default: - return false; - } - } - - export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression { - return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression; - } - export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; @@ -1646,7 +1546,7 @@ namespace ts { } else if (param.name.kind === SyntaxKind.Identifier) { const name = (param.name as Identifier).text; - return filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && tag.parameterName.text === name); + return filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && tag.name.text === name); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -1657,7 +1557,7 @@ namespace ts { /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ export function getParameterFromJSDoc(node: JSDocParameterTag): ParameterDeclaration | undefined { - const name = node.parameterName.text; + const name = node.name.text; const grandParent = node.parent!.parent!; Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment); if (!isFunctionLike(grandParent)) { @@ -2023,10 +1923,6 @@ namespace ts { return false; } - export function isNumericLiteral(node: Node): node is NumericLiteral { - return node.kind === SyntaxKind.NumericLiteral; - } - export function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { const kind = node.kind; return kind === SyntaxKind.StringLiteral @@ -2093,24 +1989,6 @@ namespace ts { return node.text === "push" || node.text === "unshift"; } - export function isModifierKind(token: SyntaxKind): boolean { - switch (token) { - case SyntaxKind.AbstractKeyword: - case SyntaxKind.AsyncKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.DefaultKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.ReadonlyKeyword: - case SyntaxKind.StaticKeyword: - return true; - } - return false; - } - export function isParameterDeclaration(node: VariableLikeDeclaration) { const root = getRootDeclaration(node); return root.kind === SyntaxKind.Parameter; @@ -3000,6 +2878,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) { @@ -3011,7 +2897,6 @@ namespace ts { flags |= ModifierFlags.Export; } - node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags; return flags; } @@ -3300,27 +3185,76 @@ namespace ts { return false; } - const syntaxKindCache: string[] = []; - - export function formatSyntaxKind(kind: SyntaxKind): string { - const syntaxKindEnum = (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, (ts).SyntaxKind, /*isFlags*/ false); + } + + export function formatModifierFlags(flags: ModifierFlags): string { + return formatEnum(flags, (ts).ModifierFlags, /*isFlags*/ true); + } + + export function formatTransformFlags(flags: TransformFlags): string { + return formatEnum(flags, (ts).TransformFlags, /*isFlags*/ true); + } + + export function formatEmitFlags(flags: EmitFlags): string { + return formatEnum(flags, (ts).EmitFlags, /*isFlags*/ true); + } + + export function formatSymbolFlags(flags: SymbolFlags): string { + return formatEnum(flags, (ts).SymbolFlags, /*isFlags*/ true); + } + + export function formatTypeFlags(flags: TypeFlags): string { + return formatEnum(flags, (ts).TypeFlags, /*isFlags*/ true); + } + + export function formatObjectFlags(flags: ObjectFlags): string { + return formatEnum(flags, (ts).ObjectFlags, /*isFlags*/ true); } export function getRangePos(range: TextRange | undefined) { @@ -3506,710 +3440,6 @@ namespace ts { return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; } - // Node tests - // - // All node tests in the following list should *not* reference parent pointers so that - // they may be used with transformations. - - // Node Arrays - - export function isNodeArray(array: T[]): array is NodeArray { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - - // Literals - - export function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression { - return node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isLiteralKind(kind: SyntaxKind): boolean { - return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken; - } - - export function isTextualLiteralKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isLiteralExpression(node: Node): node is LiteralExpression { - return isLiteralKind(node.kind); - } - - // Pseudo-literals - - export function isTemplateLiteralKind(kind: SyntaxKind): boolean { - return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; - } - - export function isTemplateHead(node: Node): node is TemplateHead { - return node.kind === SyntaxKind.TemplateHead; - } - - export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail { - const kind = node.kind; - return kind === SyntaxKind.TemplateMiddle - || kind === SyntaxKind.TemplateTail; - } - - // Identifiers - - export function isIdentifier(node: Node): node is Identifier { - return node.kind === SyntaxKind.Identifier; - } - - export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier { - // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. - return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; - } - - // Keywords - - export function isModifier(node: Node): node is Modifier { - return isModifierKind(node.kind); - } - - // Names - - export function isQualifiedName(node: Node): node is QualifiedName { - return node.kind === SyntaxKind.QualifiedName; - } - - export function isComputedPropertyName(node: Node): node is ComputedPropertyName { - return node.kind === SyntaxKind.ComputedPropertyName; - } - - export function isEntityName(node: Node): node is EntityName { - const kind = node.kind; - return kind === SyntaxKind.QualifiedName - || kind === SyntaxKind.Identifier; - } - - export function isPropertyName(node: Node): node is PropertyName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.NumericLiteral - || kind === SyntaxKind.ComputedPropertyName; - } - - export function isModuleName(node: Node): node is ModuleName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.StringLiteral; - } - - export function isBindingName(node: Node): node is BindingName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.ObjectBindingPattern - || kind === SyntaxKind.ArrayBindingPattern; - } - - // Signature elements - - export function isTypeParameter(node: Node): node is TypeParameterDeclaration { - return node.kind === SyntaxKind.TypeParameter; - } - - export function isParameter(node: Node): node is ParameterDeclaration { - return node.kind === SyntaxKind.Parameter; - } - - export function isDecorator(node: Node): node is Decorator { - return node.kind === SyntaxKind.Decorator; - } - - // Type members - - export function isMethodDeclaration(node: Node): node is MethodDeclaration { - return node.kind === SyntaxKind.MethodDeclaration; - } - - export function isClassElement(node: Node): node is ClassElement { - const kind = node.kind; - return kind === SyntaxKind.Constructor - || kind === SyntaxKind.PropertyDeclaration - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.IndexSignature - || kind === SyntaxKind.SemicolonClassElement - || kind === SyntaxKind.MissingDeclaration; - } - - export function isTypeElement(node: Node): node is TypeElement { - const kind = node.kind; - return kind === SyntaxKind.ConstructSignature - || kind === SyntaxKind.CallSignature - || kind === SyntaxKind.PropertySignature - || kind === SyntaxKind.MethodSignature - || kind === SyntaxKind.IndexSignature - || kind === SyntaxKind.MissingDeclaration; - } - - export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike { - const kind = node.kind; - return kind === SyntaxKind.PropertyAssignment - || kind === SyntaxKind.ShorthandPropertyAssignment - || kind === SyntaxKind.SpreadAssignment - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.MissingDeclaration; - } - - // Type - - function isTypeNodeKind(kind: SyntaxKind) { - return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) - || kind === SyntaxKind.AnyKeyword - || kind === SyntaxKind.NumberKeyword - || kind === SyntaxKind.ObjectKeyword - || kind === SyntaxKind.BooleanKeyword - || kind === SyntaxKind.StringKeyword - || kind === SyntaxKind.SymbolKeyword - || kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.VoidKeyword - || kind === SyntaxKind.UndefinedKeyword - || kind === SyntaxKind.NullKeyword - || kind === SyntaxKind.NeverKeyword - || kind === SyntaxKind.ExpressionWithTypeArguments; - } - - /** - * Node test that determines whether a node is a valid type node. - * This differs from the `isPartOfTypeNode` function which determines whether a node is *part* - * of a TypeNode. - */ - export function isTypeNode(node: Node): node is TypeNode { - return isTypeNodeKind(node.kind); - } - - // Binding patterns - - export function isArrayBindingPattern(node: Node): node is ArrayBindingPattern { - return node.kind === SyntaxKind.ArrayBindingPattern; - } - - export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern { - return node.kind === SyntaxKind.ObjectBindingPattern; - } - - export function isBindingPattern(node: Node): node is BindingPattern { - if (node) { - const kind = node.kind; - return kind === SyntaxKind.ArrayBindingPattern - || kind === SyntaxKind.ObjectBindingPattern; - } - - return false; - } - - export function isAssignmentPattern(node: Node): node is AssignmentPattern { - const kind = node.kind; - return kind === SyntaxKind.ArrayLiteralExpression - || kind === SyntaxKind.ObjectLiteralExpression; - } - - export function isBindingElement(node: Node): node is BindingElement { - return node.kind === SyntaxKind.BindingElement; - } - - export function isArrayBindingElement(node: Node): node is ArrayBindingElement { - const kind = node.kind; - return kind === SyntaxKind.BindingElement - || kind === SyntaxKind.OmittedExpression; - } - - - /** - * Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration - */ - export function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement { - switch (bindingElement.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.BindingElement: - return true; - } - - return false; - } - - /** - * Determines whether a node is a BindingOrAssignmentPattern - */ - export function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern { - return isObjectBindingOrAssignmentPattern(node) - || isArrayBindingOrAssignmentPattern(node); - } - - /** - * Determines whether a node is an ObjectBindingOrAssignmentPattern - */ - export function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern { - switch (node.kind) { - case SyntaxKind.ObjectBindingPattern: - case SyntaxKind.ObjectLiteralExpression: - return true; - } - - return false; - } - - /** - * Determines whether a node is an ArrayBindingOrAssignmentPattern - */ - export function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern { - switch (node.kind) { - case SyntaxKind.ArrayBindingPattern: - case SyntaxKind.ArrayLiteralExpression: - return true; - } - - return false; - } - - // Expression - - export function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression { - return node.kind === SyntaxKind.ArrayLiteralExpression; - } - - export function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression { - return node.kind === SyntaxKind.ObjectLiteralExpression; - } - - export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { - return node.kind === SyntaxKind.PropertyAccessExpression; - } - - export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName { - const kind = node.kind; - return kind === SyntaxKind.PropertyAccessExpression - || kind === SyntaxKind.QualifiedName; - } - - export function isElementAccessExpression(node: Node): node is ElementAccessExpression { - return node.kind === SyntaxKind.ElementAccessExpression; - } - - export function isBinaryExpression(node: Node): node is BinaryExpression { - return node.kind === SyntaxKind.BinaryExpression; - } - - export function isConditionalExpression(node: Node): node is ConditionalExpression { - return node.kind === SyntaxKind.ConditionalExpression; - } - - export function isCallExpression(node: Node): node is CallExpression { - return node.kind === SyntaxKind.CallExpression; - } - - export function isTemplateLiteral(node: Node): node is TemplateLiteral { - const kind = node.kind; - return kind === SyntaxKind.TemplateExpression - || kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isSpreadExpression(node: Node): node is SpreadElement { - return node.kind === SyntaxKind.SpreadElement; - } - - export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments { - return node.kind === SyntaxKind.ExpressionWithTypeArguments; - } - - function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PropertyAccessExpression - || kind === SyntaxKind.ElementAccessExpression - || kind === SyntaxKind.NewExpression - || kind === SyntaxKind.CallExpression - || kind === SyntaxKind.JsxElement - || kind === SyntaxKind.JsxSelfClosingElement - || kind === SyntaxKind.TaggedTemplateExpression - || kind === SyntaxKind.ArrayLiteralExpression - || kind === SyntaxKind.ParenthesizedExpression - || kind === SyntaxKind.ObjectLiteralExpression - || kind === SyntaxKind.ClassExpression - || kind === SyntaxKind.FunctionExpression - || kind === SyntaxKind.Identifier - || kind === SyntaxKind.RegularExpressionLiteral - || kind === SyntaxKind.NumericLiteral - || kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.NoSubstitutionTemplateLiteral - || kind === SyntaxKind.TemplateExpression - || kind === SyntaxKind.FalseKeyword - || kind === SyntaxKind.NullKeyword - || kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.TrueKeyword - || kind === SyntaxKind.SuperKeyword - || kind === SyntaxKind.NonNullExpression - || kind === SyntaxKind.MetaProperty; - } - - export function skipPartiallyEmittedExpressions(node: Expression): Expression; - export function skipPartiallyEmittedExpressions(node: Node): Node; - export function skipPartiallyEmittedExpressions(node: Node) { - while (node.kind === SyntaxKind.PartiallyEmittedExpression) { - node = (node).expression; - } - - return node; - } - - export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { - return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - function isUnaryExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PrefixUnaryExpression - || kind === SyntaxKind.PostfixUnaryExpression - || kind === SyntaxKind.DeleteExpression - || kind === SyntaxKind.TypeOfExpression - || kind === SyntaxKind.VoidExpression - || kind === SyntaxKind.AwaitExpression - || kind === SyntaxKind.TypeAssertionExpression - || isLeftHandSideExpressionKind(kind); - } - - export function isUnaryExpression(node: Node): node is UnaryExpression { - return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - function isExpressionKind(kind: SyntaxKind) { - return kind === SyntaxKind.ConditionalExpression - || kind === SyntaxKind.YieldExpression - || kind === SyntaxKind.ArrowFunction - || kind === SyntaxKind.BinaryExpression - || kind === SyntaxKind.SpreadElement - || kind === SyntaxKind.AsExpression - || kind === SyntaxKind.OmittedExpression - || kind === SyntaxKind.CommaListExpression - || isUnaryExpressionKind(kind); - } - - export function isExpression(node: Node): node is Expression { - return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - export function isAssertionExpression(node: Node): node is AssertionExpression { - const kind = node.kind; - return kind === SyntaxKind.TypeAssertionExpression - || kind === SyntaxKind.AsExpression; - } - - export function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression { - return node.kind === SyntaxKind.PartiallyEmittedExpression; - } - - export function isNotEmittedStatement(node: Node): node is NotEmittedStatement { - return node.kind === SyntaxKind.NotEmittedStatement; - } - - export function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - - export function isOmittedExpression(node: Node): node is OmittedExpression { - return node.kind === SyntaxKind.OmittedExpression; - } - - // Misc - - export function isTemplateSpan(node: Node): node is TemplateSpan { - return node.kind === SyntaxKind.TemplateSpan; - } - - // Element - - export function isBlock(node: Node): node is Block { - return node.kind === SyntaxKind.Block; - } - - export function isConciseBody(node: Node): node is ConciseBody { - return isBlock(node) - || isExpression(node); - } - - export function isFunctionBody(node: Node): node is FunctionBody { - return isBlock(node); - } - - export function isForInitializer(node: Node): node is ForInitializer { - return isVariableDeclarationList(node) - || isExpression(node); - } - - export function isVariableDeclaration(node: Node): node is VariableDeclaration { - return node.kind === SyntaxKind.VariableDeclaration; - } - - export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { - return node.kind === SyntaxKind.VariableDeclarationList; - } - - export function isCaseBlock(node: Node): node is CaseBlock { - return node.kind === SyntaxKind.CaseBlock; - } - - export function isModuleBody(node: Node): node is ModuleBody { - const kind = node.kind; - return kind === SyntaxKind.ModuleBlock - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.Identifier; - } - - export function isNamespaceBody(node: Node): node is NamespaceBody { - const kind = node.kind; - return kind === SyntaxKind.ModuleBlock - || kind === SyntaxKind.ModuleDeclaration; - } - - export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.ModuleDeclaration; - } - - export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { - return node.kind === SyntaxKind.ImportEqualsDeclaration; - } - - export function isImportDeclaration(node: Node): node is ImportDeclaration { - return node.kind === SyntaxKind.ImportDeclaration; - } - - export function isImportClause(node: Node): node is ImportClause { - return node.kind === SyntaxKind.ImportClause; - } - - export function isNamedImportBindings(node: Node): node is NamedImportBindings { - const kind = node.kind; - return kind === SyntaxKind.NamedImports - || kind === SyntaxKind.NamespaceImport; - } - - export function isImportSpecifier(node: Node): node is ImportSpecifier { - return node.kind === SyntaxKind.ImportSpecifier; - } - - export function isNamedExports(node: Node): node is NamedExports { - return node.kind === SyntaxKind.NamedExports; - } - - export function isExportSpecifier(node: Node): node is ExportSpecifier { - return node.kind === SyntaxKind.ExportSpecifier; - } - - export function isExportAssignment(node: Node): node is ExportAssignment { - return node.kind === SyntaxKind.ExportAssignment; - } - - export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration { - return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration; - } - - function isDeclarationKind(kind: SyntaxKind) { - return kind === SyntaxKind.ArrowFunction - || kind === SyntaxKind.BindingElement - || kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.ClassExpression - || kind === SyntaxKind.Constructor - || kind === SyntaxKind.EnumDeclaration - || kind === SyntaxKind.EnumMember - || kind === SyntaxKind.ExportSpecifier - || kind === SyntaxKind.FunctionDeclaration - || kind === SyntaxKind.FunctionExpression - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.ImportClause - || kind === SyntaxKind.ImportEqualsDeclaration - || kind === SyntaxKind.ImportSpecifier - || kind === SyntaxKind.InterfaceDeclaration - || kind === SyntaxKind.JsxAttribute - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.MethodSignature - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.NamespaceExportDeclaration - || kind === SyntaxKind.NamespaceImport - || kind === SyntaxKind.Parameter - || kind === SyntaxKind.PropertyAssignment - || kind === SyntaxKind.PropertyDeclaration - || kind === SyntaxKind.PropertySignature - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.ShorthandPropertyAssignment - || kind === SyntaxKind.TypeAliasDeclaration - || kind === SyntaxKind.TypeParameter - || kind === SyntaxKind.VariableDeclaration - || kind === SyntaxKind.JSDocTypedefTag; - } - - function isDeclarationStatementKind(kind: SyntaxKind) { - return kind === SyntaxKind.FunctionDeclaration - || kind === SyntaxKind.MissingDeclaration - || kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.InterfaceDeclaration - || kind === SyntaxKind.TypeAliasDeclaration - || kind === SyntaxKind.EnumDeclaration - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.ImportDeclaration - || kind === SyntaxKind.ImportEqualsDeclaration - || kind === SyntaxKind.ExportDeclaration - || kind === SyntaxKind.ExportAssignment - || kind === SyntaxKind.NamespaceExportDeclaration; - } - - function isStatementKindButNotDeclarationKind(kind: SyntaxKind) { - return kind === SyntaxKind.BreakStatement - || kind === SyntaxKind.ContinueStatement - || kind === SyntaxKind.DebuggerStatement - || kind === SyntaxKind.DoStatement - || kind === SyntaxKind.ExpressionStatement - || kind === SyntaxKind.EmptyStatement - || kind === SyntaxKind.ForInStatement - || kind === SyntaxKind.ForOfStatement - || kind === SyntaxKind.ForStatement - || kind === SyntaxKind.IfStatement - || kind === SyntaxKind.LabeledStatement - || kind === SyntaxKind.ReturnStatement - || kind === SyntaxKind.SwitchStatement - || kind === SyntaxKind.ThrowStatement - || kind === SyntaxKind.TryStatement - || kind === SyntaxKind.VariableStatement - || kind === SyntaxKind.WhileStatement - || kind === SyntaxKind.WithStatement - || kind === SyntaxKind.NotEmittedStatement - || kind === SyntaxKind.EndOfDeclarationMarker - || kind === SyntaxKind.MergeDeclarationMarker; - } - - export function isDeclaration(node: Node): node is NamedDeclaration { - return isDeclarationKind(node.kind); - } - - export function isDeclarationStatement(node: Node): node is DeclarationStatement { - return isDeclarationStatementKind(node.kind); - } - - /** - * Determines whether the node is a statement that is not also a declaration - */ - export function isStatementButNotDeclaration(node: Node): node is Statement { - return isStatementKindButNotDeclarationKind(node.kind); - } - - export function isStatement(node: Node): node is Statement { - const kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === SyntaxKind.Block; - } - - // Module references - - export function isModuleReference(node: Node): node is ModuleReference { - const kind = node.kind; - return kind === SyntaxKind.ExternalModuleReference - || kind === SyntaxKind.QualifiedName - || kind === SyntaxKind.Identifier; - } - - // JSX - - export function isJsxOpeningElement(node: Node): node is JsxOpeningElement { - return node.kind === SyntaxKind.JsxOpeningElement; - } - - export function isJsxClosingElement(node: Node): node is JsxClosingElement { - return node.kind === SyntaxKind.JsxClosingElement; - } - - export function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression { - const kind = node.kind; - return kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.Identifier - || kind === SyntaxKind.PropertyAccessExpression; - } - - export function isJsxChild(node: Node): node is JsxChild { - const kind = node.kind; - return kind === SyntaxKind.JsxElement - || kind === SyntaxKind.JsxExpression - || kind === SyntaxKind.JsxSelfClosingElement - || kind === SyntaxKind.JsxText; - } - - export function isJsxAttributes(node: Node): node is JsxAttributes { - const kind = node.kind; - return kind === SyntaxKind.JsxAttributes; - } - - export function isJsxAttributeLike(node: Node): node is JsxAttributeLike { - const kind = node.kind; - return kind === SyntaxKind.JsxAttribute - || kind === SyntaxKind.JsxSpreadAttribute; - } - - export function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute { - return node.kind === SyntaxKind.JsxSpreadAttribute; - } - - export function isJsxAttribute(node: Node): node is JsxAttribute { - return node.kind === SyntaxKind.JsxAttribute; - } - - export function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression { - const kind = node.kind; - return kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.JsxExpression; - } - - export function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement { - const kind = node.kind; - return kind === SyntaxKind.JsxOpeningElement - || kind === SyntaxKind.JsxSelfClosingElement; - } - - // Clauses - - export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { - const kind = node.kind; - return kind === SyntaxKind.CaseClause - || kind === SyntaxKind.DefaultClause; - } - - export function isHeritageClause(node: Node): node is HeritageClause { - return node.kind === SyntaxKind.HeritageClause; - } - - export function isCatchClause(node: Node): node is CatchClause { - return node.kind === SyntaxKind.CatchClause; - } - - - // Property assignments - - export function isPropertyAssignment(node: Node): node is PropertyAssignment { - return node.kind === SyntaxKind.PropertyAssignment; - } - - export function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment { - return node.kind === SyntaxKind.ShorthandPropertyAssignment; - } - - // Enum - - export function isEnumMember(node: Node): node is EnumMember { - return node.kind === SyntaxKind.EnumMember; - } - - // Top-level nodes - export function isSourceFile(node: Node): node is SourceFile { - return node.kind === SyntaxKind.SourceFile; - } - export function isWatchSet(options: CompilerOptions) { // Firefox has Object.prototype.watch return options.watch && options.hasOwnProperty("watch"); @@ -4712,3 +3942,1334 @@ namespace ts { } } } + +// Simple node tests of the form `node.kind === SyntaxKind.Foo`. +namespace ts { + // Literals + export function isNumericLiteral(node: Node): node is NumericLiteral { + return node.kind === SyntaxKind.NumericLiteral; + } + + export function isStringLiteral(node: Node): node is StringLiteral { + return node.kind === SyntaxKind.StringLiteral; + } + + export function isJsxText(node: Node): node is JsxText { + return node.kind === SyntaxKind.JsxText; + } + + export function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral { + return node.kind === SyntaxKind.RegularExpressionLiteral; + } + + export function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression { + return node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } + + // Pseudo-literals + + export function isTemplateHead(node: Node): node is TemplateHead { + return node.kind === SyntaxKind.TemplateHead; + } + + export function isTemplateMiddle(node: Node): node is TemplateMiddle { + return node.kind === SyntaxKind.TemplateMiddle; + } + + export function isTemplateTail(node: Node): node is TemplateTail { + return node.kind === SyntaxKind.TemplateTail; + } + + export function isIdentifier(node: Node): node is Identifier { + return node.kind === SyntaxKind.Identifier; + } + + // Names + + export function isQualifiedName(node: Node): node is QualifiedName { + return node.kind === SyntaxKind.QualifiedName; + } + + export function isComputedPropertyName(node: Node): node is ComputedPropertyName { + return node.kind === SyntaxKind.ComputedPropertyName; + } + + // Signature elements + + export function isTypeParameter(node: Node): node is TypeParameterDeclaration { + return node.kind === SyntaxKind.TypeParameter; + } + + export function isParameter(node: Node): node is ParameterDeclaration { + return node.kind === SyntaxKind.Parameter; + } + + export function isDecorator(node: Node): node is Decorator { + return node.kind === SyntaxKind.Decorator; + } + + // TypeMember + + export function isPropertySignature(node: Node): node is PropertySignature { + return node.kind === SyntaxKind.PropertySignature; + } + + export function isPropertyDeclaration(node: Node): node is PropertyDeclaration { + return node.kind === SyntaxKind.PropertyDeclaration; + } + + export function isMethodSignature(node: Node): node is MethodSignature { + return node.kind === SyntaxKind.MethodSignature; + } + + export function isMethodDeclaration(node: Node): node is MethodDeclaration { + return node.kind === SyntaxKind.MethodDeclaration; + } + + export function isConstructorDeclaration(node: Node): node is ConstructorDeclaration { + return node.kind === SyntaxKind.Constructor; + } + + export function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration { + return node.kind === SyntaxKind.GetAccessor; + } + + export function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration { + return node.kind === SyntaxKind.SetAccessor; + } + + export function isCallSignatureDeclaration(node: Node): node is CallSignatureDeclaration { + return node.kind === SyntaxKind.CallSignature; + } + + export function isConstructSignatureDeclaration(node: Node): node is ConstructSignatureDeclaration { + return node.kind === SyntaxKind.ConstructSignature; + } + + export function isIndexSignatureDeclaration(node: Node): node is IndexSignatureDeclaration { + return node.kind === SyntaxKind.IndexSignature; + } + + // Type + + export function isTypePredicateNode(node: Node): node is TypePredicateNode { + return node.kind === SyntaxKind.TypePredicate; + } + + export function isTypeReferenceNode(node: Node): node is TypeReferenceNode { + return node.kind === SyntaxKind.TypeReference; + } + + export function isFunctionTypeNode(node: Node): node is FunctionTypeNode { + return node.kind === SyntaxKind.FunctionType; + } + + export function isConstructorTypeNode(node: Node): node is ConstructorTypeNode { + return node.kind === SyntaxKind.ConstructorType; + } + + export function isTypeQueryNode(node: Node): node is TypeQueryNode { + return node.kind === SyntaxKind.TypeQuery; + } + + export function isTypeLiteralNode(node: Node): node is TypeLiteralNode { + return node.kind === SyntaxKind.TypeLiteral; + } + + export function isArrayTypeNode(node: Node): node is ArrayTypeNode { + return node.kind === SyntaxKind.ArrayType; + } + + export function isTupleTypeNode(node: Node): node is TupleTypeNode { + return node.kind === SyntaxKind.TupleType; + } + + export function isUnionTypeNode(node: Node): node is UnionTypeNode { + return node.kind === SyntaxKind.UnionType; + } + + export function isIntersectionTypeNode(node: Node): node is IntersectionTypeNode { + return node.kind === SyntaxKind.IntersectionType; + } + + export function isParenthesizedTypeNode(node: Node): node is ParenthesizedTypeNode { + return node.kind === SyntaxKind.ParenthesizedType; + } + + export function isThisTypeNode(node: Node): node is ThisTypeNode { + return node.kind === SyntaxKind.ThisType; + } + + export function isTypeOperatorNode(node: Node): node is TypeOperatorNode { + return node.kind === SyntaxKind.TypeOperator; + } + + export function isIndexedAccessTypeNode(node: Node): node is IndexedAccessTypeNode { + return node.kind === SyntaxKind.IndexedAccessType; + } + + export function isMappedTypeNode(node: Node): node is MappedTypeNode { + return node.kind === SyntaxKind.MappedType; + } + + export function isLiteralTypeNode(node: Node): node is LiteralTypeNode { + return node.kind === SyntaxKind.LiteralType; + } + + // Binding patterns + + export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern { + return node.kind === SyntaxKind.ObjectBindingPattern; + } + + export function isArrayBindingPattern(node: Node): node is ArrayBindingPattern { + return node.kind === SyntaxKind.ArrayBindingPattern; + } + + export function isBindingElement(node: Node): node is BindingElement { + return node.kind === SyntaxKind.BindingElement; + } + + // Expression + + export function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression { + return node.kind === SyntaxKind.ArrayLiteralExpression; + } + + export function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression { + return node.kind === SyntaxKind.ObjectLiteralExpression; + } + + export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { + return node.kind === SyntaxKind.PropertyAccessExpression; + } + + export function isElementAccessExpression(node: Node): node is ElementAccessExpression { + return node.kind === SyntaxKind.ElementAccessExpression; + } + + export function isCallExpression(node: Node): node is CallExpression { + return node.kind === SyntaxKind.CallExpression; + } + + export function isNewExpression(node: Node): node is NewExpression { + return node.kind === SyntaxKind.NewExpression; + } + + export function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression { + return node.kind === SyntaxKind.TaggedTemplateExpression; + } + + export function isTypeAssertion(node: Node): node is TypeAssertion { + return node.kind === SyntaxKind.TypeAssertionExpression; + } + + export function isParenthesizedExpression(node: Node): node is ParenthesizedExpression { + return node.kind === SyntaxKind.ParenthesizedExpression; + } + + export function skipPartiallyEmittedExpressions(node: Expression): Expression; + export function skipPartiallyEmittedExpressions(node: Node): Node; + export function skipPartiallyEmittedExpressions(node: Node) { + while (node.kind === SyntaxKind.PartiallyEmittedExpression) { + node = (node).expression; + } + + return node; + } + + export function isFunctionExpression(node: Node): node is FunctionExpression { + return node.kind === SyntaxKind.FunctionExpression; + } + + export function isArrowFunction(node: Node): node is ArrowFunction { + return node.kind === SyntaxKind.ArrowFunction; + } + + export function isDeleteExpression(node: Node): node is DeleteExpression { + return node.kind === SyntaxKind.DeleteExpression; + } + + export function isTypeOfExpression(node: Node): node is TypeOfExpression { + return node.kind === SyntaxKind.AwaitExpression; + } + + export function isVoidExpression(node: Node): node is VoidExpression { + return node.kind === SyntaxKind.VoidExpression; + } + + export function isAwaitExpression(node: Node): node is AwaitExpression { + return node.kind === SyntaxKind.AwaitExpression; + } + + export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { + return node.kind === SyntaxKind.PrefixUnaryExpression; + } + + export function isPostfixUnaryExpression(node: Node): node is PostfixUnaryExpression { + return node.kind === SyntaxKind.PostfixUnaryExpression; + } + + export function isBinaryExpression(node: Node): node is BinaryExpression { + return node.kind === SyntaxKind.BinaryExpression; + } + + export function isConditionalExpression(node: Node): node is ConditionalExpression { + return node.kind === SyntaxKind.ConditionalExpression; + } + + export function isTemplateExpression(node: Node): node is TemplateExpression { + return node.kind === SyntaxKind.TemplateExpression; + } + + export function isYieldExpression(node: Node): node is YieldExpression { + return node.kind === SyntaxKind.YieldExpression; + } + + export function isSpreadElement(node: Node): node is SpreadElement { + return node.kind === SyntaxKind.SpreadElement; + } + + export function isClassExpression(node: Node): node is ClassExpression { + return node.kind === SyntaxKind.ClassExpression; + } + + export function isOmittedExpression(node: Node): node is OmittedExpression { + return node.kind === SyntaxKind.OmittedExpression; + } + + export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments { + return node.kind === SyntaxKind.ExpressionWithTypeArguments; + } + + export function isAsExpression(node: Node): node is AsExpression { + return node.kind === SyntaxKind.AsExpression; + } + + export function isNonNullExpression(node: Node): node is NonNullExpression { + return node.kind === SyntaxKind.NonNullExpression; + } + + export function isMetaProperty(node: Node): node is MetaProperty { + return node.kind === SyntaxKind.MetaProperty; + } + + // Misc + + export function isTemplateSpan(node: Node): node is TemplateSpan { + return node.kind === SyntaxKind.TemplateSpan; + } + + export function isSemicolonClassElement(node: Node): node is SemicolonClassElement { + return node.kind === SyntaxKind.SemicolonClassElement; + } + + // Block + + export function isBlock(node: Node): node is Block { + return node.kind === SyntaxKind.Block; + } + + export function isVariableStatement(node: Node): node is VariableStatement { + return node.kind === SyntaxKind.VariableStatement; + } + + export function isEmptyStatement(node: Node): node is EmptyStatement { + return node.kind === SyntaxKind.EmptyStatement; + } + + export function isExpressionStatement(node: Node): node is ExpressionStatement { + return node.kind === SyntaxKind.ExpressionStatement; + } + + export function isIfStatement(node: Node): node is IfStatement { + return node.kind === SyntaxKind.IfStatement; + } + + export function isDoStatement(node: Node): node is DoStatement { + return node.kind === SyntaxKind.DoStatement; + } + + export function isWhileStatement(node: Node): node is WhileStatement { + return node.kind === SyntaxKind.WhileStatement; + } + + export function isForStatement(node: Node): node is ForStatement { + return node.kind === SyntaxKind.ForStatement; + } + + export function isForInStatement(node: Node): node is ForInStatement { + return node.kind === SyntaxKind.ForInStatement; + } + + export function isForOfStatement(node: Node): node is ForOfStatement { + return node.kind === SyntaxKind.ForOfStatement; + } + + export function isContinueStatement(node: Node): node is ContinueStatement { + return node.kind === SyntaxKind.ContinueStatement; + } + + export function isBreakStatement(node: Node): node is BreakStatement { + return node.kind === SyntaxKind.BreakStatement; + } + + export function isReturnStatement(node: Node): node is ReturnStatement { + return node.kind === SyntaxKind.ReturnStatement; + } + + export function isWithStatement(node: Node): node is WithStatement { + return node.kind === SyntaxKind.WithStatement; + } + + export function isSwitchStatement(node: Node): node is SwitchStatement { + return node.kind === SyntaxKind.SwitchStatement; + } + + export function isLabeledStatement(node: Node): node is LabeledStatement { + return node.kind === SyntaxKind.LabeledStatement; + } + + export function isThrowStatement(node: Node): node is ThrowStatement { + return node.kind === SyntaxKind.ThrowStatement; + } + + export function isTryStatement(node: Node): node is TryStatement { + return node.kind === SyntaxKind.TryStatement; + } + + export function isDebuggerStatement(node: Node): node is DebuggerStatement { + return node.kind === SyntaxKind.DebuggerStatement; + } + + export function isVariableDeclaration(node: Node): node is VariableDeclaration { + return node.kind === SyntaxKind.VariableDeclaration; + } + + export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { + return node.kind === SyntaxKind.VariableDeclarationList; + } + + export function isFunctionDeclaration(node: Node): node is FunctionDeclaration { + return node.kind === SyntaxKind.FunctionDeclaration; + } + + export function isClassDeclaration(node: Node): node is ClassDeclaration { + return node.kind === SyntaxKind.ClassDeclaration; + } + + export function isInterfaceDeclaration(node: Node): node is InterfaceDeclaration { + return node.kind === SyntaxKind.InterfaceDeclaration; + } + + export function isTypeAliasDeclaration(node: Node): node is TypeAliasDeclaration { + return node.kind === SyntaxKind.TypeAliasDeclaration; + } + + export function isEnumDeclaration(node: Node): node is EnumDeclaration { + return node.kind === SyntaxKind.EnumDeclaration; + } + + export function isModuleDeclaration(node: Node): node is ModuleDeclaration { + return node.kind === SyntaxKind.ModuleDeclaration; + } + + export function isModuleBlock(node: Node): node is ModuleBlock { + return node.kind === SyntaxKind.ModuleBlock; + } + + export function isCaseBlock(node: Node): node is CaseBlock { + return node.kind === SyntaxKind.CaseBlock; + } + + export function isNamespaceExportDeclaration(node: Node): node is NamespaceExportDeclaration { + return node.kind === SyntaxKind.NamespaceExportDeclaration; + } + + export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { + return node.kind === SyntaxKind.ImportEqualsDeclaration; + } + + export function isImportDeclaration(node: Node): node is ImportDeclaration { + return node.kind === SyntaxKind.ImportDeclaration; + } + + export function isImportClause(node: Node): node is ImportClause { + return node.kind === SyntaxKind.ImportClause; + } + + export function isNamespaceImport(node: Node): node is NamespaceImport { + return node.kind === SyntaxKind.NamespaceImport; + } + + export function isNamedImports(node: Node): node is NamedImports { + return node.kind === SyntaxKind.NamedImports; + } + + export function isImportSpecifier(node: Node): node is ImportSpecifier { + return node.kind === SyntaxKind.ImportSpecifier; + } + + export function isExportAssignment(node: Node): node is ExportAssignment { + return node.kind === SyntaxKind.ExportAssignment; + } + + export function isExportDeclaration(node: Node): node is ExportDeclaration { + return node.kind === SyntaxKind.ExportDeclaration; + } + + export function isNamedExports(node: Node): node is NamedExports { + return node.kind === SyntaxKind.NamedExports; + } + + export function isExportSpecifier(node: Node): node is ExportSpecifier { + return node.kind === SyntaxKind.ExportSpecifier; + } + + export function isMissingDeclaration(node: Node): node is MissingDeclaration { + return node.kind === SyntaxKind.MissingDeclaration; + } + + // Module References + + export function isExternalModuleReference(node: Node): node is ExternalModuleReference { + return node.kind === SyntaxKind.ExternalModuleReference; + } + + // JSX + + export function isJsxElement(node: Node): node is JsxElement { + return node.kind === SyntaxKind.JsxElement; + } + + export function isJsxSelfClosingElement(node: Node): node is JsxSelfClosingElement { + return node.kind === SyntaxKind.JsxSelfClosingElement; + } + + export function isJsxOpeningElement(node: Node): node is JsxOpeningElement { + return node.kind === SyntaxKind.JsxOpeningElement; + } + + export function isJsxClosingElement(node: Node): node is JsxClosingElement { + return node.kind === SyntaxKind.JsxClosingElement; + } + + export function isJsxAttribute(node: Node): node is JsxAttribute { + return node.kind === SyntaxKind.JsxAttribute; + } + + export function isJsxAttributes(node: Node): node is JsxAttributes { + return node.kind === SyntaxKind.JsxAttributes; + } + + export function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute { + return node.kind === SyntaxKind.JsxSpreadAttribute; + } + + export function isJsxExpression(node: Node): node is JsxExpression { + return node.kind === SyntaxKind.JsxExpression; + } + + // Clauses + + export function isCaseClause(node: Node): node is CaseClause { + return node.kind === SyntaxKind.CaseClause; + } + + export function isDefaultClause(node: Node): node is DefaultClause { + return node.kind === SyntaxKind.DefaultClause; + } + + export function isHeritageClause(node: Node): node is HeritageClause { + return node.kind === SyntaxKind.HeritageClause; + } + + export function isCatchClause(node: Node): node is CatchClause { + return node.kind === SyntaxKind.CatchClause; + } + + // Property assignments + + export function isPropertyAssignment(node: Node): node is PropertyAssignment { + return node.kind === SyntaxKind.PropertyAssignment; + } + + export function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment { + return node.kind === SyntaxKind.ShorthandPropertyAssignment; + } + + export function isSpreadAssignment(node: Node): node is SpreadAssignment { + return node.kind === SyntaxKind.SpreadAssignment; + } + + // Enum + + export function isEnumMember(node: Node): node is EnumMember { + return node.kind === SyntaxKind.EnumMember; + } + + // Top-level nodes + export function isSourceFile(node: Node): node is SourceFile { + return node.kind === SyntaxKind.SourceFile; + } + + export function isBundle(node: Node): node is Bundle { + return node.kind === SyntaxKind.Bundle; + } + + // JSDoc + + export function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression { + return node.kind === SyntaxKind.JSDocTypeExpression; + } + + export function isJSDocAllType(node: JSDocAllType): node is JSDocAllType { + return node.kind === SyntaxKind.JSDocAllType; + } + + export function isJSDocUnknownType(node: Node): node is JSDocUnknownType { + return node.kind === SyntaxKind.JSDocUnknownType; + } + + export function isJSDocArrayType(node: Node): node is JSDocArrayType { + return node.kind === SyntaxKind.JSDocArrayType; + } + + export function isJSDocUnionType(node: Node): node is JSDocUnionType { + return node.kind === SyntaxKind.JSDocUnionType; + } + + export function isJSDocTupleType(node: Node): node is JSDocTupleType { + return node.kind === SyntaxKind.JSDocTupleType; + } + + export function isJSDocNullableType(node: Node): node is JSDocNullableType { + return node.kind === SyntaxKind.JSDocNullableType; + } + + export function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType { + return node.kind === SyntaxKind.JSDocNonNullableType; + } + + export function isJSDocRecordType(node: Node): node is JSDocRecordType { + return node.kind === SyntaxKind.JSDocRecordType; + } + + export function isJSDocRecordMember(node: Node): node is JSDocRecordMember { + return node.kind === SyntaxKind.JSDocRecordMember; + } + + export function isJSDocTypeReference(node: Node): node is JSDocTypeReference { + return node.kind === SyntaxKind.JSDocTypeReference; + } + + export function isJSDocOptionalType(node: Node): node is JSDocOptionalType { + return node.kind === SyntaxKind.JSDocOptionalType; + } + + export function isJSDocFunctionType(node: Node): node is JSDocFunctionType { + return node.kind === SyntaxKind.JSDocFunctionType; + } + + export function isJSDocVariadicType(node: Node): node is JSDocVariadicType { + return node.kind === SyntaxKind.JSDocVariadicType; + } + + export function isJSDocConstructorType(node: Node): node is JSDocConstructorType { + return node.kind === SyntaxKind.JSDocConstructorType; + } + + export function isJSDocThisType(node: Node): node is JSDocThisType { + return node.kind === SyntaxKind.JSDocThisType; + } + + export function isJSDoc(node: Node): node is JSDoc { + return node.kind === SyntaxKind.JSDocComment; + } + + export function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag { + return node.kind === SyntaxKind.JSDocAugmentsTag; + } + + export function isJSDocParameterTag(node: Node): node is JSDocParameterTag { + return node.kind === SyntaxKind.JSDocParameterTag; + } + + export function isJSDocReturnTag(node: Node): node is JSDocReturnTag { + return node.kind === SyntaxKind.JSDocReturnTag; + } + + export function isJSDocTypeTag(node: Node): node is JSDocTypeTag { + return node.kind === SyntaxKind.JSDocTypeTag; + } + + export function isJSDocTemplateTag(node: Node): node is JSDocTemplateTag { + return node.kind === SyntaxKind.JSDocTemplateTag; + } + + export function isJSDocTypedefTag(node: Node): node is JSDocTypedefTag { + return node.kind === SyntaxKind.JSDocTypedefTag; + } + + export function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag { + return node.kind === SyntaxKind.JSDocPropertyTag; + } + + export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral { + return node.kind === SyntaxKind.JSDocTypeLiteral; + } + + export function isJSDocLiteralType(node: Node): node is JSDocLiteralType { + return node.kind === SyntaxKind.JSDocLiteralType; + } +} + +// Node tests +// +// All node tests in the following list should *not* reference parent pointers so that +// they may be used with transformations. +namespace ts { + /** + * True if node is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + */ + export function isToken(n: Node): boolean { + return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; + } + + // Node Arrays + + /* @internal */ + export function isNodeArray(array: T[]): array is NodeArray { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + + // Literals + + /* @internal */ + export function isLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken; + } + + export function isLiteralExpression(node: Node): node is LiteralExpression { + return isLiteralKind(node.kind); + } + + // Pseudo-literals + + /* @internal */ + export function isTemplateLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; + } + + export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail { + const kind = node.kind; + return kind === SyntaxKind.TemplateMiddle + || kind === SyntaxKind.TemplateTail; + } + + // Identifiers + + /* @internal */ + export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier { + // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. + return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; + } + + // Keywords + + /* @internal */ + export function isModifierKind(token: SyntaxKind): boolean { + switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsyncKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: + case SyntaxKind.PublicKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.StaticKeyword: + return true; + } + return false; + } + + export function isModifier(node: Node): node is Modifier { + return isModifierKind(node.kind); + } + + export function isEntityName(node: Node): node is EntityName { + const kind = node.kind; + return kind === SyntaxKind.QualifiedName + || kind === SyntaxKind.Identifier; + } + + export function isPropertyName(node: Node): node is PropertyName { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.NumericLiteral + || kind === SyntaxKind.ComputedPropertyName; + } + + export function isBindingName(node: Node): node is BindingName { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.ObjectBindingPattern + || kind === SyntaxKind.ArrayBindingPattern; + } + + // Functions + + export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { + return node && isFunctionLikeKind(node.kind); + } + + /* @internal */ + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.Constructor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return true; + } + + return false; + } + + // Classes + export function isClassElement(node: Node): node is ClassElement { + const kind = node.kind; + return kind === SyntaxKind.Constructor + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.SemicolonClassElement + || kind === SyntaxKind.MissingDeclaration; + } + + export function isClassLike(node: Node): node is ClassLikeDeclaration { + return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); + } + + export function isAccessor(node: Node): node is AccessorDeclaration { + return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); + } + + // Type members + + export function isTypeElement(node: Node): node is TypeElement { + const kind = node.kind; + return kind === SyntaxKind.ConstructSignature + || kind === SyntaxKind.CallSignature + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.MissingDeclaration; + } + + export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike { + const kind = node.kind; + return kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.SpreadAssignment + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.MissingDeclaration; + } + + // Type + + function isTypeNodeKind(kind: SyntaxKind) { + return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) + || kind === SyntaxKind.AnyKeyword + || kind === SyntaxKind.NumberKeyword + || kind === SyntaxKind.ObjectKeyword + || kind === SyntaxKind.BooleanKeyword + || kind === SyntaxKind.StringKeyword + || kind === SyntaxKind.SymbolKeyword + || kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.VoidKeyword + || kind === SyntaxKind.UndefinedKeyword + || kind === SyntaxKind.NullKeyword + || kind === SyntaxKind.NeverKeyword + || kind === SyntaxKind.ExpressionWithTypeArguments; + } + + /** + * Node test that determines whether a node is a valid type node. + * This differs from the `isPartOfTypeNode` function which determines whether a node is *part* + * of a TypeNode. + */ + export function isTypeNode(node: Node): node is TypeNode { + return isTypeNodeKind(node.kind); + } + + export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode { + switch (node.kind) { + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return true; + } + + return false; + } + + // Binding patterns + + /* @internal */ + export function isBindingPattern(node: Node): node is BindingPattern { + if (node) { + const kind = node.kind; + return kind === SyntaxKind.ArrayBindingPattern + || kind === SyntaxKind.ObjectBindingPattern; + } + + return false; + } + + /* @internal */ + export function isAssignmentPattern(node: Node): node is AssignmentPattern { + const kind = node.kind; + return kind === SyntaxKind.ArrayLiteralExpression + || kind === SyntaxKind.ObjectLiteralExpression; + } + + + /* @internal */ + export function isArrayBindingElement(node: Node): node is ArrayBindingElement { + const kind = node.kind; + return kind === SyntaxKind.BindingElement + || kind === SyntaxKind.OmittedExpression; + } + + + /** + * Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration + */ + /* @internal */ + export function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement { + switch (bindingElement.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.BindingElement: + return true; + } + + return false; + } + + /** + * Determines whether a node is a BindingOrAssignmentPattern + */ + /* @internal */ + export function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern { + return isObjectBindingOrAssignmentPattern(node) + || isArrayBindingOrAssignmentPattern(node); + } + + /** + * Determines whether a node is an ObjectBindingOrAssignmentPattern + */ + /* @internal */ + export function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern { + switch (node.kind) { + case SyntaxKind.ObjectBindingPattern: + case SyntaxKind.ObjectLiteralExpression: + return true; + } + + return false; + } + + /** + * Determines whether a node is an ArrayBindingOrAssignmentPattern + */ + /* @internal */ + export function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern { + switch (node.kind) { + case SyntaxKind.ArrayBindingPattern: + case SyntaxKind.ArrayLiteralExpression: + return true; + } + + return false; + } + + // Expression + + export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName { + const kind = node.kind; + return kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.QualifiedName; + } + + export function isCallLikeExpression(node: Node): node is CallLikeExpression { + switch (node.kind) { + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.Decorator: + return true; + default: + return false; + } + } + + export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression { + return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression; + } + + export function isTemplateLiteral(node: Node): node is TemplateLiteral { + const kind = node.kind; + return kind === SyntaxKind.TemplateExpression + || kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } + + function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { + return kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.ElementAccessExpression + || kind === SyntaxKind.NewExpression + || kind === SyntaxKind.CallExpression + || kind === SyntaxKind.JsxElement + || kind === SyntaxKind.JsxSelfClosingElement + || kind === SyntaxKind.TaggedTemplateExpression + || kind === SyntaxKind.ArrayLiteralExpression + || kind === SyntaxKind.ParenthesizedExpression + || kind === SyntaxKind.ObjectLiteralExpression + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.FunctionExpression + || kind === SyntaxKind.Identifier + || kind === SyntaxKind.RegularExpressionLiteral + || kind === SyntaxKind.NumericLiteral + || kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.NoSubstitutionTemplateLiteral + || kind === SyntaxKind.TemplateExpression + || kind === SyntaxKind.FalseKeyword + || kind === SyntaxKind.NullKeyword + || kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.TrueKeyword + || kind === SyntaxKind.SuperKeyword + || kind === SyntaxKind.NonNullExpression + || kind === SyntaxKind.MetaProperty; + } + + /* @internal */ + export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { + return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isUnaryExpressionKind(kind: SyntaxKind): boolean { + return kind === SyntaxKind.PrefixUnaryExpression + || kind === SyntaxKind.PostfixUnaryExpression + || kind === SyntaxKind.DeleteExpression + || kind === SyntaxKind.TypeOfExpression + || kind === SyntaxKind.VoidExpression + || kind === SyntaxKind.AwaitExpression + || kind === SyntaxKind.TypeAssertionExpression + || isLeftHandSideExpressionKind(kind); + } + + /* @internal */ + export function isUnaryExpression(node: Node): node is UnaryExpression { + return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isExpressionKind(kind: SyntaxKind) { + return kind === SyntaxKind.ConditionalExpression + || kind === SyntaxKind.YieldExpression + || kind === SyntaxKind.ArrowFunction + || kind === SyntaxKind.BinaryExpression + || kind === SyntaxKind.SpreadElement + || kind === SyntaxKind.AsExpression + || kind === SyntaxKind.OmittedExpression + || kind === SyntaxKind.CommaListExpression + || isUnaryExpressionKind(kind); + } + + /* @internal */ + export function isExpression(node: Node): node is Expression { + return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + export function isAssertionExpression(node: Node): node is AssertionExpression { + const kind = node.kind; + return kind === SyntaxKind.TypeAssertionExpression + || kind === SyntaxKind.AsExpression; + } + + /* @internal */ + export function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression { + return node.kind === SyntaxKind.PartiallyEmittedExpression; + } + + /* @internal */ + export function isNotEmittedStatement(node: Node): node is NotEmittedStatement { + return node.kind === SyntaxKind.NotEmittedStatement; + } + + /* @internal */ + export function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + + // Statement + + export function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement { + switch (node.kind) { + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return true; + case SyntaxKind.LabeledStatement: + return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); + } + + return false; + } + + // Element + + /* @internal */ + export function isConciseBody(node: Node): node is ConciseBody { + return isBlock(node) + || isExpression(node); + } + + /* @internal */ + export function isFunctionBody(node: Node): node is FunctionBody { + return isBlock(node); + } + + /* @internal */ + export function isForInitializer(node: Node): node is ForInitializer { + return isVariableDeclarationList(node) + || isExpression(node); + } + + /* @internal */ + export function isModuleBody(node: Node): node is ModuleBody { + const kind = node.kind; + return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.Identifier; + } + + /* @internal */ + export function isNamespaceBody(node: Node): node is NamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration; + } + + /* @internal */ + export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.ModuleDeclaration; + } + + /* @internal */ + export function isNamedImportBindings(node: Node): node is NamedImportBindings { + const kind = node.kind; + return kind === SyntaxKind.NamedImports + || kind === SyntaxKind.NamespaceImport; + } + + /* @internal */ + export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration { + return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration; + } + + function isDeclarationKind(kind: SyntaxKind) { + return kind === SyntaxKind.ArrowFunction + || kind === SyntaxKind.BindingElement + || kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.EnumMember + || kind === SyntaxKind.ExportSpecifier + || kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.FunctionExpression + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.ImportClause + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ImportSpecifier + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.JsxAttribute + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration + || kind === SyntaxKind.NamespaceImport + || kind === SyntaxKind.Parameter + || kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.TypeParameter + || kind === SyntaxKind.VariableDeclaration + || kind === SyntaxKind.JSDocTypedefTag; + } + + function isDeclarationStatementKind(kind: SyntaxKind) { + return kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.MissingDeclaration + || kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.ImportDeclaration + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ExportDeclaration + || kind === SyntaxKind.ExportAssignment + || kind === SyntaxKind.NamespaceExportDeclaration; + } + + function isStatementKindButNotDeclarationKind(kind: SyntaxKind) { + return kind === SyntaxKind.BreakStatement + || kind === SyntaxKind.ContinueStatement + || kind === SyntaxKind.DebuggerStatement + || kind === SyntaxKind.DoStatement + || kind === SyntaxKind.ExpressionStatement + || kind === SyntaxKind.EmptyStatement + || kind === SyntaxKind.ForInStatement + || kind === SyntaxKind.ForOfStatement + || kind === SyntaxKind.ForStatement + || kind === SyntaxKind.IfStatement + || kind === SyntaxKind.LabeledStatement + || kind === SyntaxKind.ReturnStatement + || kind === SyntaxKind.SwitchStatement + || kind === SyntaxKind.ThrowStatement + || kind === SyntaxKind.TryStatement + || kind === SyntaxKind.VariableStatement + || kind === SyntaxKind.WhileStatement + || kind === SyntaxKind.WithStatement + || kind === SyntaxKind.NotEmittedStatement + || kind === SyntaxKind.EndOfDeclarationMarker + || kind === SyntaxKind.MergeDeclarationMarker; + } + + /* @internal */ + export function isDeclaration(node: Node): node is NamedDeclaration { + return isDeclarationKind(node.kind); + } + + /* @internal */ + export function isDeclarationStatement(node: Node): node is DeclarationStatement { + return isDeclarationStatementKind(node.kind); + } + + /** + * Determines whether the node is a statement that is not also a declaration + */ + /* @internal */ + export function isStatementButNotDeclaration(node: Node): node is Statement { + return isStatementKindButNotDeclarationKind(node.kind); + } + + /* @internal */ + export function isStatement(node: Node): node is Statement { + const kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === SyntaxKind.Block; + } + + // Module references + + /* @internal */ + export function isModuleReference(node: Node): node is ModuleReference { + const kind = node.kind; + return kind === SyntaxKind.ExternalModuleReference + || kind === SyntaxKind.QualifiedName + || kind === SyntaxKind.Identifier; + } + + // JSX + + /* @internal */ + export function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression { + const kind = node.kind; + return kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.Identifier + || kind === SyntaxKind.PropertyAccessExpression; + } + + /* @internal */ + export function isJsxChild(node: Node): node is JsxChild { + const kind = node.kind; + return kind === SyntaxKind.JsxElement + || kind === SyntaxKind.JsxExpression + || kind === SyntaxKind.JsxSelfClosingElement + || kind === SyntaxKind.JsxText; + } + + /* @internal */ + export function isJsxAttributeLike(node: Node): node is JsxAttributeLike { + const kind = node.kind; + return kind === SyntaxKind.JsxAttribute + || kind === SyntaxKind.JsxSpreadAttribute; + } + + /* @internal */ + export function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression { + const kind = node.kind; + return kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.JsxExpression; + } + + export function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement { + const kind = node.kind; + return kind === SyntaxKind.JsxOpeningElement + || kind === SyntaxKind.JsxSelfClosingElement; + } + + // Clauses + + export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { + const kind = node.kind; + return kind === SyntaxKind.CaseClause + || kind === SyntaxKind.DefaultClause; + } + + // JSDoc + + /** True if node is of some JSDoc syntax kind. */ + /* @internal */ + export function isJSDocNode(node: Node): boolean { + return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; + } + + // TODO: determine what this does before making it public. + /* @internal */ + export function isJSDocTag(node: Node): boolean { + return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; + } +} diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index fa642b7a3c4..fc3b9c784cc 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -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((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 (func).name; - } - else { - const text = Function.prototype.toString.call(func); - const match = /^function\s+([\w\$]+)\s*\(/.exec(text); - return match ? match[1] : ""; - } - } } } diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index a9af46b2780..4bdafe04ba1 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -14,7 +14,9 @@ namespace ts { describe("printFile", () => { const printsCorrectly = makePrintsCorrectly("printsFileCorrectly"); - const sourceFile = createSourceFile("source.ts", ` + // Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run. + let sourceFile: SourceFile; + before(() => sourceFile = createSourceFile("source.ts", ` interface A { // comment1 readonly prop?: T; @@ -48,8 +50,7 @@ namespace ts { // comment10 function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } - `, ScriptTarget.ES2015); - + `, ScriptTarget.ES2015)); printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile)); @@ -59,7 +60,8 @@ namespace ts { describe("printBundle", () => { const printsCorrectly = makePrintsCorrectly("printsBundleCorrectly"); - const bundle = createBundle([ + let bundle: Bundle; + before(() => bundle = createBundle([ createSourceFile("a.ts", ` /*! [a.ts] */ @@ -72,14 +74,15 @@ namespace ts { // comment1 const b = 2; `, ScriptTarget.ES2015) - ]); + ])); printsCorrectly("default", {}, printer => printer.printBundle(bundle)); printsCorrectly("removeComments", { removeComments: true }, printer => printer.printBundle(bundle)); }); describe("printNode", () => { const printsCorrectly = makePrintsCorrectly("printsNodeCorrectly"); - const sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015); + let sourceFile: SourceFile; + before(() => sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015)); // tslint:disable boolean-trivia const syntheticNode = createClassDeclaration( undefined, diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js index cb2f7c6cb77..05f14d26369 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js @@ -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 diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js index ef77d6257fb..90c7523b931 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js @@ -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 diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js index 7633955b227..d5c3b3d63f4 100644 --- a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js @@ -7,6 +7,6 @@ class AtomicNumbers { var AtomicNumbers = (function () { function AtomicNumbers() { } + AtomicNumbers.H = 1; return AtomicNumbers; }()); -AtomicNumbers.H = 1; diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json index 064a040c58f..92b9cb450e6 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 27, + "end": 28, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 27, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 22, "end": 27, @@ -44,6 +44,6 @@ }, "length": 1, "pos": 8, - "end": 27 + "end": 28 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json index 264b5850223..f398fb3af41 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 32, + "end": 33, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 32, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 27, "end": 32, @@ -44,6 +44,6 @@ }, "length": 1, "pos": 8, - "end": 32 + "end": 33 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json index 9d303955ab1..e70fc95367f 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 29, + "end": 30, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 29, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 24, "end": 29, @@ -44,6 +44,6 @@ }, "length": 1, "pos": 8, - "end": 29 + "end": 30 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json index 1b87d268b93..0dbdd83d2ba 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 29, + "end": 30, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 29, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 24, "end": 29, @@ -44,6 +44,6 @@ }, "length": 1, "pos": 8, - "end": 29 + "end": 30 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json index fe01df58851..1df54fadcd7 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json @@ -34,7 +34,7 @@ "end": 30, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 25, "end": 30, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json index f50ce732606..5347b99be7a 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json @@ -34,7 +34,7 @@ "end": 31, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 26, "end": 31, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json index 70f2641fd51..204d94779b3 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json @@ -34,7 +34,7 @@ "end": 28 } }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 15, "end": 20, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json index 4b720567cc7..7c79459768b 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json @@ -34,7 +34,7 @@ "end": 28 } }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 15, "end": 20, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json index d77e80c7512..2ff182483d9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 18, + "end": 19, "atToken": { "kind": "AtToken", "pos": 8, @@ -24,7 +24,7 @@ "end": 18, "text": "foo" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 15, "end": 18, @@ -34,6 +34,6 @@ }, "length": 1, "pos": 8, - "end": 18 + "end": 19 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json index 16968061afc..b51ab3598e6 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 29, + "end": 32, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 29, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 24, "end": 29, @@ -45,7 +45,7 @@ "1": { "kind": "JSDocParameterTag", "pos": 34, - "end": 55, + "end": 56, "atToken": { "kind": "AtToken", "pos": 34, @@ -73,7 +73,7 @@ "end": 55, "text": "name2" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 50, "end": 55, @@ -83,6 +83,6 @@ }, "length": 2, "pos": 8, - "end": 55 + "end": 56 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json index 8818c3a909e..3c20d5edcbc 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 29, + "end": 30, "atToken": { "kind": "AtToken", "pos": 8, @@ -34,7 +34,7 @@ "end": 29, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 24, "end": 29, @@ -45,7 +45,7 @@ "1": { "kind": "JSDocParameterTag", "pos": 30, - "end": 51, + "end": 52, "atToken": { "kind": "AtToken", "pos": 30, @@ -73,7 +73,7 @@ "end": 51, "text": "name2" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 46, "end": 51, @@ -83,6 +83,6 @@ }, "length": 2, "pos": 8, - "end": 51 + "end": 52 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index 7ef64f5a971..7a8f9c4bcc9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -82,12 +82,6 @@ "end": 56, "text": "property" }, - "name": { - "kind": "Identifier", - "pos": 66, - "end": 69, - "text": "age" - }, "typeExpression": { "kind": "JSDocTypeExpression", "pos": 57, @@ -97,6 +91,18 @@ "pos": 58, "end": 64 } + }, + "postParameterName": { + "kind": "Identifier", + "pos": 66, + "end": 69, + "text": "age" + }, + "name": { + "kind": "Identifier", + "pos": 66, + "end": 69, + "text": "age" } }, { @@ -114,12 +120,6 @@ "end": 83, "text": "property" }, - "name": { - "kind": "Identifier", - "pos": 93, - "end": 97, - "text": "name" - }, "typeExpression": { "kind": "JSDocTypeExpression", "pos": 84, @@ -129,6 +129,18 @@ "pos": 85, "end": 91 } + }, + "postParameterName": { + "kind": "Identifier", + "pos": 93, + "end": 97, + "text": "name" + }, + "name": { + "kind": "Identifier", + "pos": 93, + "end": 97, + "text": "name" } } ] diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js index 651ae7a6d39..40bb07fa9c3 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js @@ -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) { diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 6d91c61d59d..d784798358e 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -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) { diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js index 3eab7477c09..82d72e466e1 100644 --- a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js @@ -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 = {})); diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index 0197d919fef..619ee51ce75 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -177,9 +177,9 @@ function foo10() { var A = (function () { function A() { } + A.a = x; return A; }()); - A.a = x; var x; } function foo11() { diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js index cc2e302ffca..d50f126c54e 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js @@ -15,6 +15,19 @@ function foo(opts) { foo({x: 'abc'}); +/** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ +function foo1(opts) { + opts.anotherX; +} + +foo1({anotherX: "world"}); + /** * @typedef {object} Opts1 * @property {string} x @@ -24,10 +37,10 @@ foo({x: 'abc'}); * * @param {Opts1} opts */ -function foo1(opts) { +function foo2(opts) { opts.x; } -foo1({x: 'abc'}); +foo2({x: 'abc'}); //// [0.js] @@ -45,6 +58,17 @@ function foo(opts) { opts.x; } foo({ x: 'abc' }); +/** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ +function foo1(opts) { + opts.anotherX; +} +foo1({ anotherX: "world" }); /** * @typedef {object} Opts1 * @property {string} x @@ -54,7 +78,7 @@ foo({ x: 'abc' }); * * @param {Opts1} opts */ -function foo1(opts) { +function foo2(opts) { opts.x; } -foo1({ x: 'abc' }); +foo2({ x: 'abc' }); diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols b/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols index 844c4c045aa..e6f98a76fa3 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols @@ -23,6 +23,27 @@ foo({x: 'abc'}); >foo : Symbol(foo, Decl(0.js, 0, 0)) >x : Symbol(x, Decl(0.js, 14, 5)) +/** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ +function foo1(opts) { +>foo1 : Symbol(foo1, Decl(0.js, 14, 16)) +>opts : Symbol(opts, Decl(0.js, 23, 14)) + + opts.anotherX; +>opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) +>opts : Symbol(opts, Decl(0.js, 23, 14)) +>anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) +} + +foo1({anotherX: "world"}); +>foo1 : Symbol(foo1, Decl(0.js, 14, 16)) +>anotherX : Symbol(anotherX, Decl(0.js, 27, 6)) + /** * @typedef {object} Opts1 * @property {string} x @@ -32,16 +53,16 @@ foo({x: 'abc'}); * * @param {Opts1} opts */ -function foo1(opts) { ->foo1 : Symbol(foo1, Decl(0.js, 14, 16)) ->opts : Symbol(opts, Decl(0.js, 25, 14)) +function foo2(opts) { +>foo2 : Symbol(foo2, Decl(0.js, 27, 26)) +>opts : Symbol(opts, Decl(0.js, 38, 14)) opts.x; ->opts.x : Symbol(x, Decl(0.js, 18, 3)) ->opts : Symbol(opts, Decl(0.js, 25, 14)) ->x : Symbol(x, Decl(0.js, 18, 3)) +>opts.x : Symbol(x, Decl(0.js, 31, 3)) +>opts : Symbol(opts, Decl(0.js, 38, 14)) +>x : Symbol(x, Decl(0.js, 31, 3)) } -foo1({x: 'abc'}); ->foo1 : Symbol(foo1, Decl(0.js, 14, 16)) ->x : Symbol(x, Decl(0.js, 28, 6)) +foo2({x: 'abc'}); +>foo2 : Symbol(foo2, Decl(0.js, 27, 26)) +>x : Symbol(x, Decl(0.js, 41, 6)) diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types index cb21ea2ef06..b0847a71522 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types @@ -26,6 +26,30 @@ foo({x: 'abc'}); >x : string >'abc' : "abc" +/** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ +function foo1(opts) { +>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void +>opts : { anotherX: string; anotherY?: string; } + + opts.anotherX; +>opts.anotherX : string +>opts : { anotherX: string; anotherY?: string; } +>anotherX : string +} + +foo1({anotherX: "world"}); +>foo1({anotherX: "world"}) : void +>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void +>{anotherX: "world"} : { anotherX: string; } +>anotherX : string +>"world" : "world" + /** * @typedef {object} Opts1 * @property {string} x @@ -35,8 +59,8 @@ foo({x: 'abc'}); * * @param {Opts1} opts */ -function foo1(opts) { ->foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void +function foo2(opts) { +>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void >opts : { x: string; y?: string; z?: string; w?: string; } opts.x; @@ -44,9 +68,9 @@ function foo1(opts) { >opts : { x: string; y?: string; z?: string; w?: string; } >x : string } -foo1({x: 'abc'}); ->foo1({x: 'abc'}) : void ->foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void +foo2({x: 'abc'}); +>foo2({x: 'abc'}) : void +>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" diff --git a/tests/baselines/reference/class2.js b/tests/baselines/reference/class2.js index 91ac89da109..6ef78ed46ee 100644 --- a/tests/baselines/reference/class2.js +++ b/tests/baselines/reference/class2.js @@ -5,6 +5,6 @@ class foo { constructor() { static f = 3; } } var foo = (function () { function foo() { } + foo.f = 3; return foo; }()); -foo.f = 3; diff --git a/tests/baselines/reference/classBlockScoping.js b/tests/baselines/reference/classBlockScoping.js index 76d0dd892de..3cae2d3cb7d 100644 --- a/tests/baselines/reference/classBlockScoping.js +++ b/tests/baselines/reference/classBlockScoping.js @@ -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; diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index 9b52891b559..e051e05251b 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -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); ; diff --git a/tests/baselines/reference/classMemberInitializerScoping.js b/tests/baselines/reference/classMemberInitializerScoping.js index 52bbaee8945..8f78cfb9ac6 100644 --- a/tests/baselines/reference/classMemberInitializerScoping.js +++ b/tests/baselines/reference/classMemberInitializerScoping.js @@ -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 () { diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js index c5b661831a2..752220a4cbc 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js @@ -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 -}; diff --git a/tests/baselines/reference/classWithPrivateProperty.js b/tests/baselines/reference/classWithPrivateProperty.js index c94f1d8ed80..6e75797523f 100644 --- a/tests/baselines/reference/classWithPrivateProperty.js +++ b/tests/baselines/reference/classWithPrivateProperty.js @@ -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; diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 2b12741d38f..2bc766cd99a 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -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() { diff --git a/tests/baselines/reference/classWithPublicProperty.js b/tests/baselines/reference/classWithPublicProperty.js index 47708b7aff3..054713264bd 100644 --- a/tests/baselines/reference/classWithPublicProperty.js +++ b/tests/baselines/reference/classWithPublicProperty.js @@ -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; diff --git a/tests/baselines/reference/cloduleStaticMembers.js b/tests/baselines/reference/cloduleStaticMembers.js index b696a842f3b..d17a2b2497d 100644 --- a/tests/baselines/reference/cloduleStaticMembers.js +++ b/tests/baselines/reference/cloduleStaticMembers.js @@ -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; diff --git a/tests/baselines/reference/commentOnDecoratedClassDeclaration.js b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js index 44a7047a2ac..8e6cd7149cf 100644 --- a/tests/baselines/reference/commentOnDecoratedClassDeclaration.js +++ b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js @@ -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); diff --git a/tests/baselines/reference/commentsOnStaticMembers.js b/tests/baselines/reference/commentsOnStaticMembers.js index 94df4089880..896aced36e4 100644 --- a/tests/baselines/reference/commentsOnStaticMembers.js +++ b/tests/baselines/reference/commentsOnStaticMembers.js @@ -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 = ""; diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index cd62c1583bc..d25c1410897 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -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"; diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js index 5ac0e3fcc64..7aee50e1106 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js @@ -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) { diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.js b/tests/baselines/reference/computedPropertyNames12_ES5.js index 10427b5dc13..2aec8856286 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.js +++ b/tests/baselines/reference/computedPropertyNames12_ES5.js @@ -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; diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.js b/tests/baselines/reference/constructableDecoratorOnClass01.js index 858d67923af..a37f96b59d1 100644 --- a/tests/baselines/reference/constructableDecoratorOnClass01.js +++ b/tests/baselines/reference/constructableDecoratorOnClass01.js @@ -22,8 +22,8 @@ var CtorDtor = (function () { var C = (function () { function C() { } + C = __decorate([ + CtorDtor + ], C); return C; }()); -C = __decorate([ - CtorDtor -], C); diff --git a/tests/baselines/reference/declFilePrivateStatic.js b/tests/baselines/reference/declFilePrivateStatic.js index cb1b47735f3..409e2f21b42 100644 --- a/tests/baselines/reference/declFilePrivateStatic.js +++ b/tests/baselines/reference/declFilePrivateStatic.js @@ -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] diff --git a/tests/baselines/reference/decoratorCallGeneric.js b/tests/baselines/reference/decoratorCallGeneric.js index a1d470b7063..acc9c48297d 100644 --- a/tests/baselines/reference/decoratorCallGeneric.js +++ b/tests/baselines/reference/decoratorCallGeneric.js @@ -24,8 +24,8 @@ var C = (function () { function C() { } C.m = function () { }; + C = __decorate([ + dec + ], C); return C; }()); -C = __decorate([ - dec -], C); diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.js b/tests/baselines/reference/decoratorChecksFunctionBodies.js index 20a58980e44..562169078af 100644 --- a/tests/baselines/reference/decoratorChecksFunctionBodies.js +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.js @@ -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); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js index 08184bb7e6c..fccd0ec95d3 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -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); diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 9998ae3d08a..93453ac4cf3 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -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); diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js index 9647165b650..9e8b4d5278e 100644 --- a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js @@ -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); diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js index e7bd55ada6f..4c532327d25 100644 --- a/tests/baselines/reference/decoratorMetadataOnInferredType.js +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js index 404bc9a1d59..f85bb476721 100644 --- a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js +++ b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js index 95c19178345..6eff4fdc282 100644 --- a/tests/baselines/reference/decoratorMetadataWithConstructorType.js +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js index b0e23a78971..f59e7f9ec13 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js index f03190cff0c..b3a5cded571 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js index c1eca081527..a3c170b24e6 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index 7d78cf7adbe..d6ed8bde3ec 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js index 3f7069902ce..a1cc10b7d3d 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js index 66eb30dc710..572787b6f20 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index 1dd09c3a177..6a45f5230bd 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -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; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js index 830e6bc80ee..6efdc7f26db 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -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; diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js index 5cff4c2649c..7ea46b4698f 100644 --- a/tests/baselines/reference/decoratorOnClass1.js +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 77020e7cb77..84098a17870 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -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; diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index fd09a6d8de5..5a3601fc1f3 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js index daf19e20327..adbe30db662 100644 --- a/tests/baselines/reference/decoratorOnClass4.js +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js index 70fc5515140..6741b26373b 100644 --- a/tests/baselines/reference/decoratorOnClass5.js +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js index ae50ab75ab8..e5cd8812ea7 100644 --- a/tests/baselines/reference/decoratorOnClass8.js +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js index 27966350fae..cf989705b79 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.js +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js index 57cb3b50461..9e9455b4380 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.js +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index c02f984e70a..8a27914e0c8 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js index 0e0af58f526..85b35e95cef 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.js +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js index c7d5d109cc0..12ec7a08adc 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.js +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index 8ac40e72299..d5477deb5af 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor7.js b/tests/baselines/reference/decoratorOnClassAccessor7.js index 5ae0c29c14b..26f0ce5c215 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor7.js +++ b/tests/baselines/reference/decoratorOnClassAccessor7.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassAccessor8.js b/tests/baselines/reference/decoratorOnClassAccessor8.js index 7347e630eab..f121d148623 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor8.js +++ b/tests/baselines/reference/decoratorOnClassAccessor8.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassConstructor2.js b/tests/baselines/reference/decoratorOnClassConstructor2.js index 999ffbc5e60..2e444b62e80 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor2.js +++ b/tests/baselines/reference/decoratorOnClassConstructor2.js @@ -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; diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.js b/tests/baselines/reference/decoratorOnClassConstructor3.js index 98edaebe920..7d9573217c4 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor3.js +++ b/tests/baselines/reference/decoratorOnClassConstructor3.js @@ -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; diff --git a/tests/baselines/reference/decoratorOnClassConstructor4.js b/tests/baselines/reference/decoratorOnClassConstructor4.js index 75286943417..62fc93cbaa0 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor4.js +++ b/tests/baselines/reference/decoratorOnClassConstructor4.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js index 176e2309ae0..fe04f569e30 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js index e14f0358808..8d02bd467d6 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js index b93d7f88771..ef029b84543 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.js +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js index bfa57f0aeb7..f90251d6196 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.js +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index c703459b88d..f1589a39286 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -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 = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index c9ff30307f0..089f5961d9c 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -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 = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js index 98ad8ad43ad..5db2922ed71 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.js +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js index 4a5943681d4..30f527368f2 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js index c1ad826cab0..bf8c06d9b90 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.js +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethodOverload2.js b/tests/baselines/reference/decoratorOnClassMethodOverload2.js index db077dd7b51..eafa5da7110 100644 --- a/tests/baselines/reference/decoratorOnClassMethodOverload2.js +++ b/tests/baselines/reference/decoratorOnClassMethodOverload2.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index d5d8599d7a8..efb1e4abff2 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js index 6547e0bdb18..65a399332f1 100644 --- a/tests/baselines/reference/decoratorOnClassProperty1.js +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js index 174f26a315a..9df40eaf83a 100644 --- a/tests/baselines/reference/decoratorOnClassProperty10.js +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js index c901637402d..8b771caf8b5 100644 --- a/tests/baselines/reference/decoratorOnClassProperty11.js +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js index ceaf43caa59..3ab2b515e3c 100644 --- a/tests/baselines/reference/decoratorOnClassProperty2.js +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js index 8436be93968..9c0d3f90e42 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.js +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js index c7f5490c648..823a652af24 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.js +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -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); diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js index 828d548ff6b..134f35022e0 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.js +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -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); diff --git a/tests/baselines/reference/decoratorWithUnderscoreMethod.js b/tests/baselines/reference/decoratorWithUnderscoreMethod.js index 9ac2a88aa51..ace73ccf595 100644 --- a/tests/baselines/reference/decoratorWithUnderscoreMethod.js +++ b/tests/baselines/reference/decoratorWithUnderscoreMethod.js @@ -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"); diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index 8703215a631..3ca0d13e671 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -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; diff --git a/tests/baselines/reference/emitDecoratorMetadata_object.js b/tests/baselines/reference/emitDecoratorMetadata_object.js index a8c8c360dfc..ff4a65710a7 100644 --- a/tests/baselines/reference/emitDecoratorMetadata_object.js +++ b/tests/baselines/reference/emitDecoratorMetadata_object.js @@ -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); diff --git a/tests/baselines/reference/emitDecoratorMetadata_restArgs.js b/tests/baselines/reference/emitDecoratorMetadata_restArgs.js index 862a1baa025..3f1ffd54bce 100644 --- a/tests/baselines/reference/emitDecoratorMetadata_restArgs.js +++ b/tests/baselines/reference/emitDecoratorMetadata_restArgs.js @@ -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); diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index ebe9de27f42..db4f0ac1798 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -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() { } diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index b33755e245a..3163007e742 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -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 diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.js b/tests/baselines/reference/es3defaultAliasIsQuoted.js index ea12fc7a3d6..ccc2085f97a 100644 --- a/tests/baselines/reference/es3defaultAliasIsQuoted.js +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.js @@ -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) diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index 9d66d2d8dc8..d727ab49a34 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -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) { diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js index e86d04bccd0..216a05ac2eb 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -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() { diff --git a/tests/baselines/reference/es6modulekindWithES5Target.js b/tests/baselines/reference/es6modulekindWithES5Target.js index 8778d178786..b813bc01992 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.js +++ b/tests/baselines/reference/es6modulekindWithES5Target.js @@ -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 () { diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.js b/tests/baselines/reference/es6modulekindWithES5Target11.js index ed3d44cb538..e958b0ca1c6 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.js +++ b/tests/baselines/reference/es6modulekindWithES5Target11.js @@ -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; diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.js b/tests/baselines/reference/es6modulekindWithES5Target2.js index 8b2f6dd3c53..a67bba11e23 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.js +++ b/tests/baselines/reference/es6modulekindWithES5Target2.js @@ -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; diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.js b/tests/baselines/reference/es6modulekindWithES5Target3.js index 87dd0409097..2a9778691a6 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.js +++ b/tests/baselines/reference/es6modulekindWithES5Target3.js @@ -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; diff --git a/tests/baselines/reference/extendFromAny.js b/tests/baselines/reference/extendFromAny.js index f2a7f945cc9..33610fd8b1f 100644 --- a/tests/baselines/reference/extendFromAny.js +++ b/tests/baselines/reference/extendFromAny.js @@ -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 diff --git a/tests/baselines/reference/forAwaitForUnion.js b/tests/baselines/reference/forAwaitForUnion.js new file mode 100644 index 00000000000..e0a4b9ebf82 --- /dev/null +++ b/tests/baselines/reference/forAwaitForUnion.js @@ -0,0 +1,11 @@ +//// [forAwaitForUnion.ts] +async function f(source: Iterable | AsyncIterable) { + for await (const x of source) { + } +} + +//// [forAwaitForUnion.js] +async function f(source) { + for await (const x of source) { + } +} diff --git a/tests/baselines/reference/forAwaitForUnion.symbols b/tests/baselines/reference/forAwaitForUnion.symbols new file mode 100644 index 00000000000..8b31ea48684 --- /dev/null +++ b/tests/baselines/reference/forAwaitForUnion.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/forAwaitForUnion.ts === +async function f(source: Iterable | AsyncIterable) { +>f : Symbol(f, Decl(forAwaitForUnion.ts, 0, 0)) +>T : Symbol(T, Decl(forAwaitForUnion.ts, 0, 17)) +>source : Symbol(source, Decl(forAwaitForUnion.ts, 0, 20)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(forAwaitForUnion.ts, 0, 17)) +>AsyncIterable : Symbol(AsyncIterable, Decl(lib.esnext.asynciterable.d.ts, --, --)) +>T : Symbol(T, Decl(forAwaitForUnion.ts, 0, 17)) + + for await (const x of source) { +>x : Symbol(x, Decl(forAwaitForUnion.ts, 1, 20)) +>source : Symbol(source, Decl(forAwaitForUnion.ts, 0, 20)) + } +} diff --git a/tests/baselines/reference/forAwaitForUnion.types b/tests/baselines/reference/forAwaitForUnion.types new file mode 100644 index 00000000000..715fd120ca8 --- /dev/null +++ b/tests/baselines/reference/forAwaitForUnion.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/forAwaitForUnion.ts === +async function f(source: Iterable | AsyncIterable) { +>f : (source: Iterable | AsyncIterable) => Promise +>T : T +>source : Iterable | AsyncIterable +>Iterable : Iterable +>T : T +>AsyncIterable : AsyncIterable +>T : T + + for await (const x of source) { +>x : T +>source : Iterable | AsyncIterable + } +} diff --git a/tests/baselines/reference/forwardRefInClassProperties.js b/tests/baselines/reference/forwardRefInClassProperties.js index 1dc455729ab..424d950055d 100644 --- a/tests/baselines/reference/forwardRefInClassProperties.js +++ b/tests/baselines/reference/forwardRefInClassProperties.js @@ -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; diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 8b0889f28ae..a5d5a418327 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -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]; }; } diff --git a/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js b/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js index 053fa785ee0..2039e459572 100644 --- a/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js +++ b/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js @@ -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; }; diff --git a/tests/baselines/reference/gettersAndSetters.js b/tests/baselines/reference/gettersAndSetters.js index 265a1210b16..16d66c7dc71 100644 --- a/tests/baselines/reference/gettersAndSetters.js +++ b/tests/baselines/reference/gettersAndSetters.js @@ -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"; diff --git a/tests/baselines/reference/importHelpers.js b/tests/baselines/reference/importHelpers.js index bf66829a435..4fc7b99a813 100644 --- a/tests/baselines/reference/importHelpers.js +++ b/tests/baselines/reference/importHelpers.js @@ -56,17 +56,17 @@ var C = (function () { } C.prototype.method = function (x) { }; + tslib_1.__decorate([ + tslib_1.__param(0, dec), + tslib_1.__metadata("design:type", Function), + tslib_1.__metadata("design:paramtypes", [Number]), + tslib_1.__metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = tslib_1.__decorate([ + dec + ], C); return C; }()); -tslib_1.__decorate([ - tslib_1.__param(0, dec), - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Number]), - tslib_1.__metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = tslib_1.__decorate([ - dec -], C); //// [script.js] var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || @@ -107,14 +107,14 @@ var C = (function () { } C.prototype.method = function (x) { }; + __decorate([ + __param(0, dec), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = __decorate([ + dec + ], C); return C; }()); -__decorate([ - __param(0, dec), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Number]), - __metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = __decorate([ - dec -], C); diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 26a9cafa188..561bfebb351 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -56,17 +56,17 @@ var C = (function () { } C.prototype.method = function (x) { }; + tslib_1.__decorate([ + tslib_1.__param(0, dec), + tslib_1.__metadata("design:type", Function), + tslib_1.__metadata("design:paramtypes", [Number]), + tslib_1.__metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = tslib_1.__decorate([ + dec + ], C); return C; }()); -tslib_1.__decorate([ - tslib_1.__param(0, dec), - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Number]), - tslib_1.__metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = tslib_1.__decorate([ - dec -], C); //// [script.js] var tslib_1 = require("tslib"); var A = (function () { @@ -86,14 +86,14 @@ var C = (function () { } C.prototype.method = function (x) { }; + tslib_1.__decorate([ + tslib_1.__param(0, dec), + tslib_1.__metadata("design:type", Function), + tslib_1.__metadata("design:paramtypes", [Number]), + tslib_1.__metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = tslib_1.__decorate([ + dec + ], C); return C; }()); -tslib_1.__decorate([ - tslib_1.__param(0, dec), - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Number]), - tslib_1.__metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = tslib_1.__decorate([ - dec -], C); diff --git a/tests/baselines/reference/importHelpersNoHelpers.js b/tests/baselines/reference/importHelpersNoHelpers.js index 5b98b61da20..9e20fc13543 100644 --- a/tests/baselines/reference/importHelpersNoHelpers.js +++ b/tests/baselines/reference/importHelpersNoHelpers.js @@ -55,17 +55,17 @@ var C = (function () { } C.prototype.method = function (x) { }; + tslib_1.__decorate([ + tslib_1.__param(0, dec), + tslib_1.__metadata("design:type", Function), + tslib_1.__metadata("design:paramtypes", [Number]), + tslib_1.__metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = tslib_1.__decorate([ + dec + ], C); return C; }()); -tslib_1.__decorate([ - tslib_1.__param(0, dec), - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Number]), - tslib_1.__metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = tslib_1.__decorate([ - dec -], C); var o = { a: 1 }; var y = tslib_1.__assign({}, o); var x = tslib_1.__rest(y, []); @@ -109,14 +109,14 @@ var C = (function () { } C.prototype.method = function (x) { }; + __decorate([ + __param(0, dec), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = __decorate([ + dec + ], C); return C; }()); -__decorate([ - __param(0, dec), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Number]), - __metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = __decorate([ - dec -], C); diff --git a/tests/baselines/reference/importHelpersNoModule.js b/tests/baselines/reference/importHelpersNoModule.js index 36a326e124d..988bec04a42 100644 --- a/tests/baselines/reference/importHelpersNoModule.js +++ b/tests/baselines/reference/importHelpersNoModule.js @@ -48,17 +48,17 @@ var C = (function () { } C.prototype.method = function (x) { }; + tslib_1.__decorate([ + tslib_1.__param(0, dec), + tslib_1.__metadata("design:type", Function), + tslib_1.__metadata("design:paramtypes", [Number]), + tslib_1.__metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = tslib_1.__decorate([ + dec + ], C); return C; }()); -tslib_1.__decorate([ - tslib_1.__param(0, dec), - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Number]), - tslib_1.__metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = tslib_1.__decorate([ - dec -], C); //// [script.js] var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || @@ -99,14 +99,14 @@ var C = (function () { } C.prototype.method = function (x) { }; + __decorate([ + __param(0, dec), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", void 0) + ], C.prototype, "method", null); + C = __decorate([ + dec + ], C); return C; }()); -__decorate([ - __param(0, dec), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Number]), - __metadata("design:returntype", void 0) -], C.prototype, "method", null); -C = __decorate([ - dec -], C); diff --git a/tests/baselines/reference/importImportOnlyModule.js b/tests/baselines/reference/importImportOnlyModule.js index 0c6f0540354..fa01655c47b 100644 --- a/tests/baselines/reference/importImportOnlyModule.js +++ b/tests/baselines/reference/importImportOnlyModule.js @@ -23,9 +23,9 @@ define(["require", "exports"], function (require, exports) { function C1() { this.m1 = 42; } + C1.s1 = true; return C1; }()); - C1.s1 = true; exports.C1 = C1; }); //// [foo_1.js] diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js index 1c1f223abe8..c6a6d0c4e27 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.js +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -124,7 +124,6 @@ var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; //// [output.js] -var _this = this; var C = (function () { function C() { var _this = this; @@ -212,16 +211,16 @@ var C = (function () { this.inStaticSetter = "string"; } }; + C.prop = function () { + if (Math.random()) { + _this.inStaticPropertyDeclaration = 0; + } + else { + _this.inStaticPropertyDeclaration = "string"; + } + }; return C; }()); -C.prop = function () { - if (Math.random()) { - _this.inStaticPropertyDeclaration = 0; - } - else { - _this.inStaticPropertyDeclaration = "string"; - } -}; var c = new C(); var stringOrNumber; var stringOrNumber = c.inConstructor; diff --git a/tests/baselines/reference/instanceAndStaticDeclarations1.js b/tests/baselines/reference/instanceAndStaticDeclarations1.js index bf9b6963bb2..093e9c15cc8 100644 --- a/tests/baselines/reference/instanceAndStaticDeclarations1.js +++ b/tests/baselines/reference/instanceAndStaticDeclarations1.js @@ -25,6 +25,6 @@ var Point = (function () { return Math.sqrt(dx * dx + dy * dy); }; Point.distance = function (p1, p2) { return p1.distance(p2); }; + Point.origin = new Point(0, 0); return Point; }()); -Point.origin = new Point(0, 0); diff --git a/tests/baselines/reference/invalidNewTarget.es5.js b/tests/baselines/reference/invalidNewTarget.es5.js index 866dac270af..1c2da520fcb 100644 --- a/tests/baselines/reference/invalidNewTarget.es5.js +++ b/tests/baselines/reference/invalidNewTarget.es5.js @@ -56,9 +56,9 @@ var C = (function () { enumerable: true, configurable: true }); + C.j = function () { return _newTarget; }; return C; }()); -C.j = function () { return _newTarget; }; var O = (_a = {}, _a[_newTarget] = undefined, _a.k = function () { var _newTarget = void 0; return _newTarget; }, diff --git a/tests/baselines/reference/invalidStaticField.js b/tests/baselines/reference/invalidStaticField.js index 08a06d5ee27..dc582e830c7 100644 --- a/tests/baselines/reference/invalidStaticField.js +++ b/tests/baselines/reference/invalidStaticField.js @@ -12,6 +12,6 @@ var A = (function () { var B = (function () { function B() { } + B.NOT_NULL = new B(); return B; }()); -B.NOT_NULL = new B(); diff --git a/tests/baselines/reference/metadataOfClassFromAlias.js b/tests/baselines/reference/metadataOfClassFromAlias.js index c99f7cc2e23..75fdd90652f 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias.js +++ b/tests/baselines/reference/metadataOfClassFromAlias.js @@ -41,10 +41,10 @@ function annotation() { var ClassA = (function () { function ClassA() { } + __decorate([ + annotation(), + __metadata("design:type", Object) + ], ClassA.prototype, "array", void 0); return ClassA; }()); -__decorate([ - annotation(), - __metadata("design:type", Object) -], ClassA.prototype, "array", void 0); exports.ClassA = ClassA; diff --git a/tests/baselines/reference/metadataOfClassFromAlias2.js b/tests/baselines/reference/metadataOfClassFromAlias2.js index bcdbb34ac50..ca568028638 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias2.js +++ b/tests/baselines/reference/metadataOfClassFromAlias2.js @@ -41,10 +41,10 @@ function annotation() { var ClassA = (function () { function ClassA() { } + __decorate([ + annotation(), + __metadata("design:type", Object) + ], ClassA.prototype, "array", void 0); return ClassA; }()); -__decorate([ - annotation(), - __metadata("design:type", Object) -], ClassA.prototype, "array", void 0); exports.ClassA = ClassA; diff --git a/tests/baselines/reference/metadataOfClassFromModule.js b/tests/baselines/reference/metadataOfClassFromModule.js index 8ef120600df..ca8c56e3c5e 100644 --- a/tests/baselines/reference/metadataOfClassFromModule.js +++ b/tests/baselines/reference/metadataOfClassFromModule.js @@ -34,11 +34,11 @@ var MyModule; var Person = (function () { function Person() { } + __decorate([ + inject, + __metadata("design:type", Leg) + ], Person.prototype, "leftLeg", void 0); return Person; }()); - __decorate([ - inject, - __metadata("design:type", Leg) - ], Person.prototype, "leftLeg", void 0); MyModule.Person = Person; })(MyModule || (MyModule = {})); diff --git a/tests/baselines/reference/metadataOfEventAlias.js b/tests/baselines/reference/metadataOfEventAlias.js index b46d5cade63..cf042586242 100644 --- a/tests/baselines/reference/metadataOfEventAlias.js +++ b/tests/baselines/reference/metadataOfEventAlias.js @@ -30,10 +30,10 @@ function Input(target, key) { } var SomeClass = (function () { function SomeClass() { } + __decorate([ + Input, + __metadata("design:type", Object) + ], SomeClass.prototype, "event", void 0); return SomeClass; }()); -__decorate([ - Input, - __metadata("design:type", Object) -], SomeClass.prototype, "event", void 0); exports.SomeClass = SomeClass; diff --git a/tests/baselines/reference/metadataOfStringLiteral.js b/tests/baselines/reference/metadataOfStringLiteral.js index 676914681cb..30536270207 100644 --- a/tests/baselines/reference/metadataOfStringLiteral.js +++ b/tests/baselines/reference/metadataOfStringLiteral.js @@ -20,9 +20,9 @@ function PropDeco(target, propKey) { } var Foo = (function () { function Foo() { } + __decorate([ + PropDeco, + __metadata("design:type", String) + ], Foo.prototype, "foo"); return Foo; }()); -__decorate([ - PropDeco, - __metadata("design:type", String) -], Foo.prototype, "foo"); diff --git a/tests/baselines/reference/metadataOfUnion.js b/tests/baselines/reference/metadataOfUnion.js index 9a88481c80a..7a063b0e93c 100644 --- a/tests/baselines/reference/metadataOfUnion.js +++ b/tests/baselines/reference/metadataOfUnion.js @@ -55,20 +55,20 @@ var A = (function () { var B = (function () { function B() { } + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "x"); + __decorate([ + PropDeco, + __metadata("design:type", Boolean) + ], B.prototype, "y"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "z"); return B; }()); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "x"); -__decorate([ - PropDeco, - __metadata("design:type", Boolean) -], B.prototype, "y"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "z"); var E; (function (E) { E[E["A"] = 0] = "A"; @@ -79,21 +79,21 @@ var E; var D = (function () { function D() { } + __decorate([ + PropDeco, + __metadata("design:type", Number) + ], D.prototype, "a"); + __decorate([ + PropDeco, + __metadata("design:type", Number) + ], D.prototype, "b"); + __decorate([ + PropDeco, + __metadata("design:type", Number) + ], D.prototype, "c"); + __decorate([ + PropDeco, + __metadata("design:type", Number) + ], D.prototype, "d"); return D; }()); -__decorate([ - PropDeco, - __metadata("design:type", Number) -], D.prototype, "a"); -__decorate([ - PropDeco, - __metadata("design:type", Number) -], D.prototype, "b"); -__decorate([ - PropDeco, - __metadata("design:type", Number) -], D.prototype, "c"); -__decorate([ - PropDeco, - __metadata("design:type", Number) -], D.prototype, "d"); diff --git a/tests/baselines/reference/metadataOfUnionWithNull.js b/tests/baselines/reference/metadataOfUnionWithNull.js index 0c834be9687..e53ca85476e 100644 --- a/tests/baselines/reference/metadataOfUnionWithNull.js +++ b/tests/baselines/reference/metadataOfUnionWithNull.js @@ -61,53 +61,53 @@ var A = (function () { var B = (function () { function B() { } + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "x"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "y"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "z"); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "a"); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "b"); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "c"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "d"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "e"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "f"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "g"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "h"); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "j"); return B; }()); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "x"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "y"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "z"); -__decorate([ - PropDeco, - __metadata("design:type", void 0) -], B.prototype, "a"); -__decorate([ - PropDeco, - __metadata("design:type", void 0) -], B.prototype, "b"); -__decorate([ - PropDeco, - __metadata("design:type", void 0) -], B.prototype, "c"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "d"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "e"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "f"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "g"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "h"); -__decorate([ - PropDeco, - __metadata("design:type", Object) -], B.prototype, "j"); diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js index ee9fbf7ce44..eca16c710e3 100644 --- a/tests/baselines/reference/missingDecoratorType.js +++ b/tests/baselines/reference/missingDecoratorType.js @@ -32,8 +32,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; + __decorate([ + dec + ], C.prototype, "method", null); return C; }()); -__decorate([ - dec -], C.prototype, "method", null); diff --git a/tests/baselines/reference/newTarget.es5.js b/tests/baselines/reference/newTarget.es5.js index 2ebe4bfcadc..38718a771ad 100644 --- a/tests/baselines/reference/newTarget.es5.js +++ b/tests/baselines/reference/newTarget.es5.js @@ -50,9 +50,9 @@ var A = (function () { var a = _newTarget; var b = function () { return _newTarget; }; } + A.c = function _a() { var _newTarget = this && this instanceof _a ? this.constructor : void 0; return _newTarget; }; return A; }()); -A.c = function _a() { var _newTarget = this && this instanceof _a ? this.constructor : void 0; return _newTarget; }; var B = (function (_super) { __extends(B, _super); function B() { @@ -69,11 +69,11 @@ function f1() { var g = _newTarget; var h = function () { return _newTarget; }; } -var f2 = function _b() { - var _newTarget = this && this instanceof _b ? this.constructor : void 0; +var f2 = function _a() { + var _newTarget = this && this instanceof _a ? this.constructor : void 0; var i = _newTarget; var j = function () { return _newTarget; }; }; var O = { - k: function _c() { var _newTarget = this && this instanceof _c ? this.constructor : void 0; return _newTarget; } + k: function _b() { var _newTarget = this && this instanceof _b ? this.constructor : void 0; return _newTarget; } }; diff --git a/tests/baselines/reference/noEmitHelpers2.js b/tests/baselines/reference/noEmitHelpers2.js index 44ab7900005..027f07cc0e8 100644 --- a/tests/baselines/reference/noEmitHelpers2.js +++ b/tests/baselines/reference/noEmitHelpers2.js @@ -11,10 +11,10 @@ class A { var A = (function () { function A(a, b) { } + A = __decorate([ + decorator, + __param(1, decorator), + __metadata("design:paramtypes", [Number, String]) + ], A); return A; }()); -A = __decorate([ - decorator, - __param(1, decorator), - __metadata("design:paramtypes", [Number, String]) -], A); diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic3.js b/tests/baselines/reference/parserAccessibilityAfterStatic3.js index 38202bc5dc8..7a9ae06e439 100644 --- a/tests/baselines/reference/parserAccessibilityAfterStatic3.js +++ b/tests/baselines/reference/parserAccessibilityAfterStatic3.js @@ -9,6 +9,6 @@ static public = 1; var Outer = (function () { function Outer() { } + Outer.public = 1; return Outer; }()); -Outer.public = 1; diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js index 57d0536e975..9bb4395e556 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js @@ -41,10 +41,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; + // Static member + Point.origin = new Point(0, 0); return Point; }()); - // Static member - Point.origin = new Point(0, 0); Shapes.Point = Point; })(Shapes || (Shapes = {})); // Local variables diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js index 2bb08a14e35..0ee73b8b1e5 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js @@ -42,10 +42,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; + // Static member + Point.origin = new Point(0, 0); return Point; }()); - // Static member - Point.origin = new Point(0, 0); Shapes.Point = Point; })(Shapes || (Shapes = {})); // Local variables diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index 26cb07614a5..598b447d965 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -46,7 +46,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(199,42): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(219,33): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(231,30): error TS2304: Cannot find name 'Emitter'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(231,48): error TS2304: Cannot find name 'TokenID'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(233,52): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(233,52): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(237,36): error TS2304: Cannot find name 'TypeFlow'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(251,21): error TS2304: Cannot find name 'Symbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(268,19): error TS2304: Cannot find name 'NodeType'. @@ -85,27 +85,27 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(427,22): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(441,30): error TS2304: Cannot find name 'Emitter'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(441,48): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(445,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(446,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(446,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(449,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(451,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(451,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(453,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(454,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(454,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(457,22): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(460,22): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(463,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(465,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(465,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(467,22): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(469,50): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(472,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(472,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(474,22): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(476,50): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(479,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(479,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(481,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(483,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(483,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(485,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(487,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(487,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(489,22): error TS2304: Cannot find name 'NodeType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(491,58): error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(491,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(494,22): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(496,58): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(498,22): error TS2304: Cannot find name 'NodeType'. @@ -848,7 +848,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.recordSourceMappingStart(this); emitter.emitJavascriptList(this, null, TokenID.Semicolon, startLine, false, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. emitter.recordSourceMappingEnd(this); } @@ -1139,7 +1139,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error !!! error TS2304: Cannot find name 'NodeType'. emitter.emitJavascript(this.operand, TokenID.PlusPlus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. emitter.writeToOutput("++"); break; case NodeType.LogNot: @@ -1148,14 +1148,14 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.writeToOutput("!"); emitter.emitJavascript(this.operand, TokenID.Exclamation, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.DecPost: ~~~~~~~~ !!! error TS2304: Cannot find name 'NodeType'. emitter.emitJavascript(this.operand, TokenID.MinusMinus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. emitter.writeToOutput("--"); break; case NodeType.ObjectLit: @@ -1174,7 +1174,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.writeToOutput("~"); emitter.emitJavascript(this.operand, TokenID.Tilde, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.Neg: ~~~~~~~~ @@ -1187,7 +1187,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error } emitter.emitJavascript(this.operand, TokenID.Minus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.Pos: ~~~~~~~~ @@ -1200,7 +1200,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error } emitter.emitJavascript(this.operand, TokenID.Plus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.IncPre: ~~~~~~~~ @@ -1208,7 +1208,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.writeToOutput("++"); emitter.emitJavascript(this.operand, TokenID.PlusPlus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.DecPre: ~~~~~~~~ @@ -1216,7 +1216,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.writeToOutput("--"); emitter.emitJavascript(this.operand, TokenID.MinusMinus, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. break; case NodeType.Throw: ~~~~~~~~ @@ -1224,7 +1224,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error emitter.writeToOutput("throw "); emitter.emitJavascript(this.operand, TokenID.Tilde, false); ~~~~~~~ -!!! error TS2552: Cannot find name 'TokenID'. Did you mean 'tokenId'? +!!! error TS2304: Cannot find name 'TokenID'. emitter.writeToOutput(";"); break; case NodeType.Typeof: diff --git a/tests/baselines/reference/parserRealSource13.errors.txt b/tests/baselines/reference/parserRealSource13.errors.txt index 35bdd1cbb62..a77c5762405 100644 --- a/tests/baselines/reference/parserRealSource13.errors.txt +++ b/tests/baselines/reference/parserRealSource13.errors.txt @@ -113,7 +113,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(123,26): error tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(123,39): error TS2304: Cannot find name 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(128,33): error TS2339: Property 'getAstWalkerFactory' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(132,51): error TS2304: Cannot find name 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(135,36): error TS2552: Cannot find name 'NodeType'. Did you mean 'nodeType'? +tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(135,36): error TS2304: Cannot find name 'NodeType'. ==== tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts (116 errors) ==== @@ -483,7 +483,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(135,36): error var nodeType = ast.nodeType; var callbackString = (NodeType)._map[nodeType] + "Callback"; ~~~~~~~~ -!!! error TS2552: Cannot find name 'NodeType'. Did you mean 'nodeType'? +!!! error TS2304: Cannot find name 'NodeType'. if (callback[callbackString]) { return callback[callbackString](pre, ast); } diff --git a/tests/baselines/reference/parserRealSource7.errors.txt b/tests/baselines/reference/parserRealSource7.errors.txt index f98dd31dba9..7d9627d4823 100644 --- a/tests/baselines/reference/parserRealSource7.errors.txt +++ b/tests/baselines/reference/parserRealSource7.errors.txt @@ -11,11 +11,11 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(34,54): error TS tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(34,68): error TS2304: Cannot find name 'TypeCollectionContext'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(35,25): error TS2304: Cannot find name 'ValueLocation'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(36,30): error TS2304: Cannot find name 'TypeLink'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(41,17): error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(41,17): error TS2304: Cannot find name 'FieldSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(43,31): error TS2304: Cannot find name 'SymbolFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(43,54): error TS2304: Cannot find name 'SymbolFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(49,58): error TS2304: Cannot find name 'Type'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(50,29): error TS2552: Cannot find name 'Signature'. Did you mean 'signature'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(50,29): error TS2304: Cannot find name 'Signature'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(51,36): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(55,30): error TS2304: Cannot find name 'SignatureGroup'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(59,66): error TS2304: Cannot find name 'Type'. @@ -46,7 +46,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(154,27): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(155,26): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(155,55): error TS2304: Cannot find name 'VarFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(165,28): error TS2304: Cannot find name 'ModuleType'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(169,26): error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(169,26): error TS2304: Cannot find name 'TypeSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(186,48): error TS2304: Cannot find name 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(186,61): error TS2304: Cannot find name 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(186,75): error TS2304: Cannot find name 'TypeCollectionContext'. @@ -81,8 +81,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(212,46): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(212,64): error TS2304: Cannot find name 'DualStringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(212,88): error TS2304: Cannot find name 'StringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(212,111): error TS2304: Cannot find name 'StringHashTable'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(216,30): error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(231,72): error TS2552: Cannot find name 'NodeType'. Did you mean 'modType'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(216,30): error TS2304: Cannot find name 'TypeSymbol'. +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(231,72): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(234,27): error TS2304: Cannot find name 'TypeSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(238,80): error TS2304: Cannot find name 'StringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(239,37): error TS2304: Cannot find name 'ScopedMembers'. @@ -142,7 +142,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(349,47): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(349,65): error TS2304: Cannot find name 'DualStringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(349,89): error TS2304: Cannot find name 'StringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(349,112): error TS2304: Cannot find name 'StringHashTable'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(350,30): error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(350,30): error TS2304: Cannot find name 'TypeSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(360,37): error TS2304: Cannot find name 'SymbolFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(364,37): error TS2304: Cannot find name 'SymbolFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(368,37): error TS2304: Cannot find name 'SymbolFlags'. @@ -196,7 +196,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(476,57): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(477,29): error TS2304: Cannot find name 'ValueLocation'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(478,29): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(478,55): error TS2304: Cannot find name 'VarFlags'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(480,21): error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(480,21): error TS2304: Cannot find name 'FieldSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(482,34): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(482,60): error TS2304: Cannot find name 'VarFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(492,30): error TS2304: Cannot find name 'getTypeLink'. @@ -218,7 +218,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(507,26): error T tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(507,52): error TS2304: Cannot find name 'ASTFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(518,22): error TS2304: Cannot find name 'FieldSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(531,29): error TS2304: Cannot find name 'ValueLocation'. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(533,21): error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(533,21): error TS2304: Cannot find name 'FieldSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(535,53): error TS2304: Cannot find name 'VarFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(535,75): error TS2304: Cannot find name 'VarFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(539,38): error TS2304: Cannot find name 'SymbolFlags'. @@ -372,7 +372,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T var fieldSymbol = new FieldSymbol("prototype", ast.minChar, ~~~~~~~~~~~ -!!! error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +!!! error TS2304: Cannot find name 'FieldSymbol'. context.checker.locationInfo.unitIndex, true, field); fieldSymbol.flags |= (SymbolFlags.Property | SymbolFlags.BuiltIn); ~~~~~~~~~~~ @@ -389,7 +389,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T !!! error TS2304: Cannot find name 'Type'. var signature = new Signature(); ~~~~~~~~~ -!!! error TS2552: Cannot find name 'Signature'. Did you mean 'signature'? +!!! error TS2304: Cannot find name 'Signature'. signature.returnType = new TypeLink(); ~~~~~~~~ !!! error TS2304: Cannot find name 'TypeLink'. @@ -570,7 +570,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T typeSymbol = new TypeSymbol(importDecl.id.text, importDecl.minChar, ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? +!!! error TS2304: Cannot find name 'TypeSymbol'. context.checker.locationInfo.unitIndex, modType); typeSymbol.aliasLink = importDecl; @@ -687,7 +687,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T typeSymbol = new TypeSymbol(modName, moduleDecl.minChar, ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? +!!! error TS2304: Cannot find name 'TypeSymbol'. context.checker.locationInfo.unitIndex, modType); if (context.scopeChain.moduleDecl) { @@ -704,7 +704,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T else { if (symbol && symbol.declAST && symbol.declAST.nodeType != NodeType.ModuleDeclaration) { ~~~~~~~~ -!!! error TS2552: Cannot find name 'NodeType'. Did you mean 'modType'? +!!! error TS2304: Cannot find name 'NodeType'. context.checker.errorReporter.simpleError(moduleDecl, "Conflicting symbol name for module '" + modName + "'"); } typeSymbol = symbol; @@ -943,7 +943,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T !!! error TS2304: Cannot find name 'StringHashTable'. typeSymbol = new TypeSymbol(className, classDecl.minChar, ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeSymbol'. Did you mean 'typeSymbol'? +!!! error TS2304: Cannot find name 'TypeSymbol'. context.checker.locationInfo.unitIndex, classType); typeSymbol.declAST = classDecl; typeSymbol.instanceType = instanceType; @@ -1181,7 +1181,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T var fieldSymbol = new FieldSymbol(argDecl.id.text, argDecl.minChar, ~~~~~~~~~~~ -!!! error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +!!! error TS2304: Cannot find name 'FieldSymbol'. context.checker.locationInfo.unitIndex, !hasFlag(argDecl.varFlags, VarFlags.Readonly), ~~~~~~~ @@ -1278,7 +1278,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T var fieldSymbol = new FieldSymbol(varDecl.id.text, varDecl.minChar, ~~~~~~~~~~~ -!!! error TS2552: Cannot find name 'FieldSymbol'. Did you mean 'fieldSymbol'? +!!! error TS2304: Cannot find name 'FieldSymbol'. context.checker.locationInfo.unitIndex, (varDecl.varFlags & VarFlags.Readonly) == VarFlags.None, ~~~~~~~~ diff --git a/tests/baselines/reference/parserRealSource8.errors.txt b/tests/baselines/reference/parserRealSource8.errors.txt index a7a2b968baf..9f536cf6c7c 100644 --- a/tests/baselines/reference/parserRealSource8.errors.txt +++ b/tests/baselines/reference/parserRealSource8.errors.txt @@ -47,7 +47,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(160,52): error T tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(160,76): error TS2304: Cannot find name 'StringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(160,99): error TS2304: Cannot find name 'StringHashTable'. tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(162,28): error TS2304: Cannot find name 'Type'. -tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(163,30): error TS2552: Cannot find name 'WithSymbol'. Did you mean 'withSymbol'? +tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(163,30): error TS2304: Cannot find name 'WithSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(170,40): error TS2339: Property 'SymbolScopeBuilder' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(176,50): error TS2304: Cannot find name 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(177,25): error TS2304: Cannot find name 'FuncDecl'. @@ -397,7 +397,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(454,35): error T !!! error TS2304: Cannot find name 'Type'. var withSymbol = new WithSymbol(withStmt.minChar, context.typeFlow.checker.locationInfo.unitIndex, withType); ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'WithSymbol'. Did you mean 'withSymbol'? +!!! error TS2304: Cannot find name 'WithSymbol'. withType.members = members; withType.ambientMembers = ambientMembers; withType.symbol = withSymbol; diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index e7c83f0a058..5ec35021fef 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -18,17 +18,17 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(721,62): e tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(724,29): error TS2304: Cannot find name 'ITextWriter'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(754,53): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(764,56): error TS2503: Cannot find namespace 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(765,37): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(767,47): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,13): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,42): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(765,37): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(767,47): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,13): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,42): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(781,23): error TS2503: Cannot find namespace 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(794,49): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(795,49): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,53): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,89): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(794,49): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(795,49): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,53): error TS2304: Cannot find name 'TypeScript'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,89): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,115): error TS2503: Cannot find namespace 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,145): error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,145): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(988,43): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(999,40): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1041,43): error TS2503: Cannot find namespace 'TypeScript'. @@ -917,11 +917,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): !!! error TS2503: Cannot find namespace 'TypeScript'. var compiler = c || new TypeScript.TypeScriptCompiler(stderr); ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. compiler.parser.errorRecovery = true; compiler.settings.codeGenTarget = TypeScript.CodeGenTarget.ES5; ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. compiler.settings.controlFlow = true; compiler.settings.controlFlowUseDef = true; if (Harness.usePull) { @@ -932,9 +932,9 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): compiler.parseEmitOption(stdout); TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Synchronous; ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. compiler.addUnit(Harness.Compiler.libText, "lib.d.ts", true); return compiler; } @@ -956,10 +956,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): // requires unit to already exist in the compiler compiler.pullUpdateUnit(new TypeScript.StringSourceText(""), filename, true); ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. compiler.pullUpdateUnit(new TypeScript.StringSourceText(code), filename, true); ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. } } else { @@ -1153,13 +1153,13 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): var script = compiler.scripts.members[m]; var enclosingScopeContext = TypeScript.findEnclosingScopeAt(new TypeScript.NullLogger(), script, new TypeScript.StringSourceText(code), 0, false); ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. ~~~~~~~~~~ !!! error TS2503: Cannot find namespace 'TypeScript'. ~~~~~~~~~~ -!!! error TS2552: Cannot find name 'TypeScript'. Did you mean 'TypeScriptLS'? +!!! error TS2304: Cannot find name 'TypeScript'. var entries = new TypeScript.ScopeTraversal(compiler).getScopeEntries(enclosingScopeContext); ~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeScript'. diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 5090c33bdc8..2275a1f682e 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2376,11 +2376,11 @@ var Harness; errorHandlerStack[errorHandlerStack.length - 1](e); } }; + // The current stack of Runnable objects + Runnable.currentStack = []; + Runnable.errorHandlerStack = []; return Runnable; }()); - // The current stack of Runnable objects - Runnable.currentStack = []; - Runnable.errorHandlerStack = []; Harness.Runnable = Runnable; var TestCase = (function (_super) { __extends(TestCase, _super); diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index 9da4e922f77..da23223510c 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -160,12 +160,12 @@ var publicClassWithWithPrivatePropertyTypes = (function () { this.myPublicProperty1 = exporter.createExportedWidget3(); // Error this.myPrivateProperty1 = exporter.createExportedWidget3(); } + publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); // Error + publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); + publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error + publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); return publicClassWithWithPrivatePropertyTypes; }()); -publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); // Error -publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); -publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error -publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); exports.publicClassWithWithPrivatePropertyTypes = publicClassWithWithPrivatePropertyTypes; var privateClassWithWithPrivatePropertyTypes = (function () { function privateClassWithWithPrivatePropertyTypes() { @@ -174,12 +174,12 @@ var privateClassWithWithPrivatePropertyTypes = (function () { this.myPublicProperty1 = exporter.createExportedWidget3(); this.myPrivateProperty1 = exporter.createExportedWidget3(); } + privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); + privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); + privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); + privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); return privateClassWithWithPrivatePropertyTypes; }()); -privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); -privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); -privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); -privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); exports.publicVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); // Error var privateVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); exports.publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error @@ -189,10 +189,10 @@ var publicClassWithPrivateModulePropertyTypes = (function () { this.myPublicProperty = exporter.createExportedWidget2(); // Error this.myPublicProperty1 = exporter.createExportedWidget4(); // Error } + publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); // Error + publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error return publicClassWithPrivateModulePropertyTypes; }()); -publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); // Error -publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error exports.publicClassWithPrivateModulePropertyTypes = publicClassWithPrivateModulePropertyTypes; exports.publicVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); // Error exports.publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error @@ -201,10 +201,10 @@ var privateClassWithPrivateModulePropertyTypes = (function () { this.myPublicProperty = exporter.createExportedWidget2(); this.myPublicProperty1 = exporter.createExportedWidget4(); } + privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); + privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); return privateClassWithPrivateModulePropertyTypes; }()); -privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); -privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); var privateVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index 92a8713ef8f..aca72ba86e5 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -31,6 +31,6 @@ var Derived = (function (_super) { _this.bing = function () { return Base.foo; }; // error return _this; } + Derived.bar = Base.foo; // error return Derived; }(Base)); -Derived.bar = Base.foo; // error diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js index 6ec26abec8e..f1d17701cf8 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -14,12 +14,12 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); exports.MyClass1 = MyClass1; - var _a; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index 274520bc752..c7191f0e4c6 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); exports.MyClass1 = MyClass1; -var _a; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js index 6ec26abec8e..f1d17701cf8 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -14,12 +14,12 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); exports.MyClass1 = MyClass1; - var _a; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index 274520bc752..c7191f0e4c6 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); exports.MyClass1 = MyClass1; -var _a; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js index 6ec26abec8e..f1d17701cf8 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -14,12 +14,12 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); exports.MyClass1 = MyClass1; - var _a; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index 274520bc752..c7191f0e4c6 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); exports.MyClass1 = MyClass1; -var _a; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js index 6ec26abec8e..f1d17701cf8 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -14,12 +14,12 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); exports.MyClass1 = MyClass1; - var _a; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index 274520bc752..c7191f0e4c6 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); exports.MyClass1 = MyClass1; -var _a; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js index 6ec26abec8e..f1d17701cf8 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -14,12 +14,12 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); exports.MyClass1 = MyClass1; - var _a; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index 274520bc752..c7191f0e4c6 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + foo, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - foo, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); exports.MyClass1 = MyClass1; -var _a; diff --git a/tests/baselines/reference/propertyAccessibility2.js b/tests/baselines/reference/propertyAccessibility2.js index 3618b86fcc5..afce6c4c24a 100644 --- a/tests/baselines/reference/propertyAccessibility2.js +++ b/tests/baselines/reference/propertyAccessibility2.js @@ -9,7 +9,7 @@ var c = C.x; var C = (function () { function C() { } + C.x = 1; return C; }()); -C.x = 1; var c = C.x; diff --git a/tests/baselines/reference/quotedPropertyName2.js b/tests/baselines/reference/quotedPropertyName2.js index 550e5299702..1c4d85076ea 100644 --- a/tests/baselines/reference/quotedPropertyName2.js +++ b/tests/baselines/reference/quotedPropertyName2.js @@ -7,6 +7,6 @@ class Test1 { var Test1 = (function () { function Test1() { } + Test1["prop1"] = 0; return Test1; }()); -Test1["prop1"] = 0; diff --git a/tests/baselines/reference/reassignStaticProp.js b/tests/baselines/reference/reassignStaticProp.js index d9c37c29ad5..2bf2bafa128 100644 --- a/tests/baselines/reference/reassignStaticProp.js +++ b/tests/baselines/reference/reassignStaticProp.js @@ -15,6 +15,6 @@ class foo { var foo = (function () { function foo() { } + foo.bar = 1; return foo; }()); -foo.bar = 1; diff --git a/tests/baselines/reference/scopeCheckStaticInitializer.js b/tests/baselines/reference/scopeCheckStaticInitializer.js index 59711f07380..a9478d44800 100644 --- a/tests/baselines/reference/scopeCheckStaticInitializer.js +++ b/tests/baselines/reference/scopeCheckStaticInitializer.js @@ -20,18 +20,18 @@ var X = (function () { function X() { } X.method = function () { }; + X.illegalBeforeProperty = X.data; + X.okBeforeMethod = X.method; + X.illegal2 = After.data; + X.illegal3 = After.method; + X.data = 13; return X; }()); -X.illegalBeforeProperty = X.data; -X.okBeforeMethod = X.method; -X.illegal2 = After.data; -X.illegal3 = After.method; -X.data = 13; var After = (function () { function After() { } After.method = function () { }; ; + After.data = 12; return After; }()); -After.data = 12; diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js b/tests/baselines/reference/sourceMap-FileWithComments.js index d2287d0bea2..7fd47997c97 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js +++ b/tests/baselines/reference/sourceMap-FileWithComments.js @@ -48,10 +48,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; + // Static member + Point.origin = new Point(0, 0); return Point; }()); - // Static member - Point.origin = new Point(0, 0); Shapes.Point = Point; // Variable comment after class var a = 10; diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js.map b/tests/baselines/reference/sourceMap-FileWithComments.js.map index a85ce154f11..073fa862fc7 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js.map +++ b/tests/baselines/reference/sourceMap-FileWithComments.js.map @@ -1,2 +1,2 @@ //// [sourceMap-FileWithComments.js.map] -{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":[],"mappings":"AAKA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAET,QAAQ;IACR;QACI,cAAc;QACd,eAAmB,CAAS,EAAS,CAAS;YAA3B,MAAC,GAAD,CAAC,CAAQ;YAAS,MAAC,GAAD,CAAC,CAAQ;QAAI,CAAC;QAEnD,kBAAkB;QAClB,uBAAO,GAAP,cAAY,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAItE,YAAC;IAAD,CAAC,AATD;IAOI,gBAAgB;IACT,YAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IARvB,YAAK,QASjB,CAAA;IAED,+BAA+B;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX;IACA,CAAC;IADe,UAAG,MAClB,CAAA;IAED;;MAEE;IACF,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAED,qBAAqB;AACrB,IAAI,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":[],"mappings":"AAKA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM;IAET,QAAQ;IACR;QACI,cAAc;QACd,eAAmB,CAAS,EAAS,CAAS;YAA3B,MAAC,GAAD,CAAC,CAAQ;YAAS,MAAC,GAAD,CAAC,CAAQ;QAAI,CAAC;QAEnD,kBAAkB;QAClB,uBAAO,GAAP,cAAY,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAElE,gBAAgB;QACT,YAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,YAAC;KAAA,AATD,IASC;IATY,YAAK,QASjB,CAAA;IAED,+BAA+B;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX;IACA,CAAC;IADe,UAAG,MAClB,CAAA;IAED;;MAEE;IACF,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAED,qBAAqB;AACrB,IAAI,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt index 9e81aba718a..b53a0a4a7ce 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt @@ -264,89 +264,90 @@ sourceFile:sourceMap-FileWithComments.ts 28>Emitted(12, 102) Source(15, 74) + SourceIndex(0) 29>Emitted(12, 103) Source(15, 75) + SourceIndex(0) --- +>>> // Static member +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^-> +1 > + > + > +2 > // Static member +1 >Emitted(13, 9) Source(17, 9) + SourceIndex(0) +2 >Emitted(13, 25) Source(17, 25) + SourceIndex(0) +--- +>>> Point.origin = new Point(0, 0); +1->^^^^^^^^ +2 > ^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^ +7 > ^ +8 > ^^ +9 > ^ +10> ^ +11> ^ +1-> + > static +2 > origin +3 > = +4 > new +5 > Point +6 > ( +7 > 0 +8 > , +9 > 0 +10> ) +11> ; +1->Emitted(14, 9) Source(18, 16) + SourceIndex(0) +2 >Emitted(14, 21) Source(18, 22) + SourceIndex(0) +3 >Emitted(14, 24) Source(18, 25) + SourceIndex(0) +4 >Emitted(14, 28) Source(18, 29) + SourceIndex(0) +5 >Emitted(14, 33) Source(18, 34) + SourceIndex(0) +6 >Emitted(14, 34) Source(18, 35) + SourceIndex(0) +7 >Emitted(14, 35) Source(18, 36) + SourceIndex(0) +8 >Emitted(14, 37) Source(18, 38) + SourceIndex(0) +9 >Emitted(14, 38) Source(18, 39) + SourceIndex(0) +10>Emitted(14, 39) Source(18, 40) + SourceIndex(0) +11>Emitted(14, 40) Source(18, 41) + SourceIndex(0) +--- >>> return Point; 1 >^^^^^^^^ 2 > ^^^^^^^^^^^^ 1 > - > - > // Static member - > static origin = new Point(0, 0); > 2 > } -1 >Emitted(13, 9) Source(19, 5) + SourceIndex(0) -2 >Emitted(13, 21) Source(19, 6) + SourceIndex(0) +1 >Emitted(15, 9) Source(19, 5) + SourceIndex(0) +2 >Emitted(15, 21) Source(19, 6) + SourceIndex(0) --- >>> }()); -1 >^^^^ -2 > ^ -3 > -4 > ^^^^^^^^^^^^^^^^-> +1 >^^^^^ +2 > +3 > ^^^^ +4 > ^^^^^^^^^^^^^^^^^-> 1 > -2 > } -3 > -1 >Emitted(14, 5) Source(19, 5) + SourceIndex(0) -2 >Emitted(14, 6) Source(19, 6) + SourceIndex(0) -3 >Emitted(14, 6) Source(10, 5) + SourceIndex(0) ---- ->>> // Static member -1->^^^^ -2 > ^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^-> -1->export class Point implements IPoint { - > // Constructor - > constructor(public x: number, public y: number) { } - > - > // Instance member - > getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } - > - > -2 > // Static member -1->Emitted(15, 5) Source(17, 9) + SourceIndex(0) -2 >Emitted(15, 21) Source(17, 25) + SourceIndex(0) ---- ->>> Point.origin = new Point(0, 0); -1->^^^^ -2 > ^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^ -7 > ^ -8 > ^^ -9 > ^ -10> ^ -11> ^ -1-> - > static -2 > origin -3 > = -4 > new -5 > Point -6 > ( -7 > 0 -8 > , -9 > 0 -10> ) -11> ; -1->Emitted(16, 5) Source(18, 16) + SourceIndex(0) -2 >Emitted(16, 17) Source(18, 22) + SourceIndex(0) -3 >Emitted(16, 20) Source(18, 25) + SourceIndex(0) -4 >Emitted(16, 24) Source(18, 29) + SourceIndex(0) -5 >Emitted(16, 29) Source(18, 34) + SourceIndex(0) -6 >Emitted(16, 30) Source(18, 35) + SourceIndex(0) -7 >Emitted(16, 31) Source(18, 36) + SourceIndex(0) -8 >Emitted(16, 33) Source(18, 38) + SourceIndex(0) -9 >Emitted(16, 34) Source(18, 39) + SourceIndex(0) -10>Emitted(16, 35) Source(18, 40) + SourceIndex(0) -11>Emitted(16, 36) Source(18, 41) + SourceIndex(0) +2 > +3 > export class Point implements IPoint { + > // Constructor + > constructor(public x: number, public y: number) { } + > + > // Instance member + > getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } + > + > // Static member + > static origin = new Point(0, 0); + > } +1 >Emitted(16, 6) Source(19, 6) + SourceIndex(0) +2 >Emitted(16, 6) Source(10, 5) + SourceIndex(0) +3 >Emitted(16, 10) Source(19, 6) + SourceIndex(0) --- >>> Shapes.Point = Point; -1 >^^^^ +1->^^^^ 2 > ^^^^^^^^^^^^ 3 > ^^^^^^^^ 4 > ^ 5 > ^^^^^^^^^^^-> -1 > +1-> 2 > Point 3 > implements IPoint { > // Constructor @@ -359,7 +360,7 @@ sourceFile:sourceMap-FileWithComments.ts > static origin = new Point(0, 0); > } 4 > -1 >Emitted(17, 5) Source(10, 18) + SourceIndex(0) +1->Emitted(17, 5) Source(10, 18) + SourceIndex(0) 2 >Emitted(17, 17) Source(10, 23) + SourceIndex(0) 3 >Emitted(17, 25) Source(19, 6) + SourceIndex(0) 4 >Emitted(17, 26) Source(19, 6) + SourceIndex(0) diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js b/tests/baselines/reference/sourceMapValidationDecorators.js index 63cdb25900c..c3bb5cd7225 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js +++ b/tests/baselines/reference/sourceMapValidationDecorators.js @@ -88,37 +88,37 @@ var Greeter = (function () { enumerable: true, configurable: true }); + Greeter.x1 = 10; + __decorate([ + PropertyDecorator1, + PropertyDecorator2(40) + ], Greeter.prototype, "greet", null); + __decorate([ + PropertyDecorator1, + PropertyDecorator2(50) + ], Greeter.prototype, "x", void 0); + __decorate([ + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(70)) + ], Greeter.prototype, "fn", null); + __decorate([ + PropertyDecorator1, + PropertyDecorator2(80), + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(90)) + ], Greeter.prototype, "greetings", null); + __decorate([ + PropertyDecorator1, + PropertyDecorator2(60) + ], Greeter, "x1", void 0); + Greeter = __decorate([ + ClassDecorator1, + ClassDecorator2(10), + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(20)), + __param(1, ParameterDecorator1), + __param(1, ParameterDecorator2(30)) + ], Greeter); return Greeter; }()); -Greeter.x1 = 10; -__decorate([ - PropertyDecorator1, - PropertyDecorator2(40) -], Greeter.prototype, "greet", null); -__decorate([ - PropertyDecorator1, - PropertyDecorator2(50) -], Greeter.prototype, "x", void 0); -__decorate([ - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(70)) -], Greeter.prototype, "fn", null); -__decorate([ - PropertyDecorator1, - PropertyDecorator2(80), - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(90)) -], Greeter.prototype, "greetings", null); -__decorate([ - PropertyDecorator1, - PropertyDecorator2(60) -], Greeter, "x1", void 0); -Greeter = __decorate([ - ClassDecorator1, - ClassDecorator2(10), - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(20)), - __param(1, ParameterDecorator1), - __param(1, ParameterDecorator2(30)) -], Greeter); //# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index ac635a518f1..c5666dc3147 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":[],"mappings":";;;;;;;;;AASA,IAAM,OAAO;IACT,iBAGS,QAAgB;QAIvB,WAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,0BAAc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAQL,cAAC;AAAD,CAAC,AA5CD,IA4CC;AArBkB,UAAE,GAAW,EAAE,CAAC;AAV/B;IAFC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;oCAGtB;AAID;IAFC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;kCACL;AAMlB;IACG,WAAA,mBAAmB,CAAA;IACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;iCAGzB;AAID;IAFC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;IAMpB,WAAA,mBAAmB,CAAA;IACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;wCAJzB;AAbD;IAFC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;yBACQ;AAvB7B,OAAO;IAFZ,eAAe;IACf,eAAe,CAAC,EAAE,CAAC;IAGb,WAAA,mBAAmB,CAAA;IACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;IAGvB,WAAA,mBAAmB,CAAA;IACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;GAPxB,OAAO,CA4CZ"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":[],"mappings":";;;;;;;;;AASA;IACI,iBAGS,QAAgB;QAIvB,WAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,0BAAc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAbc,UAAE,GAAW,EAAE,CAAC;IAV/B;QAFC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;wCAGtB;IAID;QAFC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;sCACL;IAMlB;QACG,WAAA,mBAAmB,CAAA;QACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;qCAGzB;IAID;QAFC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;QAMpB,WAAA,mBAAmB,CAAA;QACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;4CAJzB;IAbD;QAFC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;6BACQ;IAvB7B,OAAO;QAFZ,eAAe;QACf,eAAe,CAAC,EAAE,CAAC;QAGb,WAAA,mBAAmB,CAAA;QACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;QAGvB,WAAA,mBAAmB,CAAA;QACnB,WAAA,mBAAmB,CAAC,EAAE,CAAC,CAAA;OAPxB,OAAO,CA4CZ;IAAD,cAAC;CAAA,AA5CD,IA4CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index d581fdef886..2cec971546b 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -19,9 +19,7 @@ sourceFile:sourceMapValidationDecorators.ts >>>}; >>>var Greeter = (function () { 1 > -2 >^^^^ -3 > ^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >declare function ClassDecorator1(target: Function): void; >declare function ClassDecorator2(x: number): (target: Function) => void; >declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; @@ -32,17 +30,13 @@ sourceFile:sourceMapValidationDecorators.ts >@ClassDecorator1 >@ClassDecorator2(10) > -2 >class -3 > Greeter 1 >Emitted(10, 1) Source(10, 1) + SourceIndex(0) -2 >Emitted(10, 5) Source(10, 7) + SourceIndex(0) -3 >Emitted(10, 12) Source(10, 14) + SourceIndex(0) --- >>> function Greeter(greeting) { 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^ -1-> { +1->class Greeter { > 2 > constructor( > @ParameterDecorator1 @@ -362,36 +356,495 @@ sourceFile:sourceMapValidationDecorators.ts >>> configurable: true >>> }); 1->^^^^^^^ -2 > ^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^-> 1-> 1->Emitted(33, 8) Source(46, 6) + SourceIndex(0) --- +>>> Greeter.x1 = 10; +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +1-> +2 > x1 +3 > : number = +4 > 10 +5 > ; +1->Emitted(34, 5) Source(33, 20) + SourceIndex(0) +2 >Emitted(34, 15) Source(33, 22) + SourceIndex(0) +3 >Emitted(34, 18) Source(33, 33) + SourceIndex(0) +4 >Emitted(34, 20) Source(33, 35) + SourceIndex(0) +5 >Emitted(34, 21) Source(33, 36) + SourceIndex(0) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(35, 5) Source(23, 5) + SourceIndex(0) +--- +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> +1-> +2 > PropertyDecorator1 +1->Emitted(36, 9) Source(21, 6) + SourceIndex(0) +2 >Emitted(36, 27) Source(21, 24) + SourceIndex(0) +--- +>>> PropertyDecorator2(40) +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^-> +1-> + > @ +2 > PropertyDecorator2 +3 > ( +4 > 40 +5 > ) +1->Emitted(37, 9) Source(22, 6) + SourceIndex(0) +2 >Emitted(37, 27) Source(22, 24) + SourceIndex(0) +3 >Emitted(37, 28) Source(22, 25) + SourceIndex(0) +4 >Emitted(37, 30) Source(22, 27) + SourceIndex(0) +5 >Emitted(37, 31) Source(22, 28) + SourceIndex(0) +--- +>>> ], Greeter.prototype, "greet", null); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > greet() { + > return "

" + this.greeting + "

"; + > } +1->Emitted(38, 41) Source(25, 6) + SourceIndex(0) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > +1 >Emitted(39, 5) Source(29, 5) + SourceIndex(0) +--- +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> +1-> +2 > PropertyDecorator1 +1->Emitted(40, 9) Source(27, 6) + SourceIndex(0) +2 >Emitted(40, 27) Source(27, 24) + SourceIndex(0) +--- +>>> PropertyDecorator2(50) +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^-> +1-> + > @ +2 > PropertyDecorator2 +3 > ( +4 > 50 +5 > ) +1->Emitted(41, 9) Source(28, 6) + SourceIndex(0) +2 >Emitted(41, 27) Source(28, 24) + SourceIndex(0) +3 >Emitted(41, 28) Source(28, 25) + SourceIndex(0) +4 >Emitted(41, 30) Source(28, 27) + SourceIndex(0) +5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) +--- +>>> ], Greeter.prototype, "x", void 0); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > private x: string; +1->Emitted(42, 39) Source(29, 23) + SourceIndex(0) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > +1 >Emitted(43, 5) Source(35, 5) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^-> +1->private fn( + > @ +2 > +3 > ParameterDecorator1 +4 > +1->Emitted(44, 9) Source(36, 8) + SourceIndex(0) +2 >Emitted(44, 20) Source(36, 8) + SourceIndex(0) +3 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) +4 >Emitted(44, 40) Source(36, 27) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator2(70)) +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ +1-> + > @ +2 > +3 > ParameterDecorator2 +4 > ( +5 > 70 +6 > ) +7 > +1->Emitted(45, 9) Source(37, 8) + SourceIndex(0) +2 >Emitted(45, 20) Source(37, 8) + SourceIndex(0) +3 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) +4 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) +5 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) +6 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) +7 >Emitted(45, 44) Source(37, 31) + SourceIndex(0) +--- +>>> ], Greeter.prototype, "fn", null); +1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > x: number) { + > return this.greeting; + > } +1 >Emitted(46, 38) Source(40, 6) + SourceIndex(0) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > +1 >Emitted(47, 5) Source(44, 5) + SourceIndex(0) +--- +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1-> +2 > PropertyDecorator1 +1->Emitted(48, 9) Source(42, 6) + SourceIndex(0) +2 >Emitted(48, 27) Source(42, 24) + SourceIndex(0) +--- +>>> PropertyDecorator2(80), +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^-> +1-> + > @ +2 > PropertyDecorator2 +3 > ( +4 > 80 +5 > ) +1->Emitted(49, 9) Source(43, 6) + SourceIndex(0) +2 >Emitted(49, 27) Source(43, 24) + SourceIndex(0) +3 >Emitted(49, 28) Source(43, 25) + SourceIndex(0) +4 >Emitted(49, 30) Source(43, 27) + SourceIndex(0) +5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^-> +1-> + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ +2 > +3 > ParameterDecorator1 +4 > +1->Emitted(50, 9) Source(49, 8) + SourceIndex(0) +2 >Emitted(50, 20) Source(49, 8) + SourceIndex(0) +3 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) +4 >Emitted(50, 40) Source(49, 27) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator2(90)) +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ +8 > ^^^-> +1-> + > @ +2 > +3 > ParameterDecorator2 +4 > ( +5 > 90 +6 > ) +7 > +1->Emitted(51, 9) Source(50, 8) + SourceIndex(0) +2 >Emitted(51, 20) Source(50, 8) + SourceIndex(0) +3 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) +4 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) +5 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) +6 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) +7 >Emitted(51, 44) Source(50, 31) + SourceIndex(0) +--- +>>> ], Greeter.prototype, "greetings", null); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(52, 45) Source(46, 6) + SourceIndex(0) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(53, 5) Source(33, 5) + SourceIndex(0) +--- +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> +1-> +2 > PropertyDecorator1 +1->Emitted(54, 9) Source(31, 6) + SourceIndex(0) +2 >Emitted(54, 27) Source(31, 24) + SourceIndex(0) +--- +>>> PropertyDecorator2(60) +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^-> +1-> + > @ +2 > PropertyDecorator2 +3 > ( +4 > 60 +5 > ) +1->Emitted(55, 9) Source(32, 6) + SourceIndex(0) +2 >Emitted(55, 27) Source(32, 24) + SourceIndex(0) +3 >Emitted(55, 28) Source(32, 25) + SourceIndex(0) +4 >Emitted(55, 30) Source(32, 27) + SourceIndex(0) +5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) +--- +>>> ], Greeter, "x1", void 0); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > private static x1: number = 10; +1->Emitted(56, 30) Source(33, 36) + SourceIndex(0) +--- +>>> Greeter = __decorate([ +1 >^^^^ +2 > ^^^^^^^ +3 > ^^^^^^^^^^^^^^-> +1 > +2 > Greeter +1 >Emitted(57, 5) Source(10, 7) + SourceIndex(0) +2 >Emitted(57, 12) Source(10, 14) + SourceIndex(0) +--- +>>> ClassDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1-> +2 > ClassDecorator1 +1->Emitted(58, 9) Source(8, 2) + SourceIndex(0) +2 >Emitted(58, 24) Source(8, 17) + SourceIndex(0) +--- +>>> ClassDecorator2(10), +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^-> +1-> + >@ +2 > ClassDecorator2 +3 > ( +4 > 10 +5 > ) +1->Emitted(59, 9) Source(9, 2) + SourceIndex(0) +2 >Emitted(59, 24) Source(9, 17) + SourceIndex(0) +3 >Emitted(59, 25) Source(9, 18) + SourceIndex(0) +4 >Emitted(59, 27) Source(9, 20) + SourceIndex(0) +5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^^-> +1-> + >class Greeter { + > constructor( + > @ +2 > +3 > ParameterDecorator1 +4 > +1->Emitted(60, 9) Source(12, 8) + SourceIndex(0) +2 >Emitted(60, 20) Source(12, 8) + SourceIndex(0) +3 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) +4 >Emitted(60, 40) Source(12, 27) + SourceIndex(0) +--- +>>> __param(0, ParameterDecorator2(20)), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ +1-> + > @ +2 > +3 > ParameterDecorator2 +4 > ( +5 > 20 +6 > ) +7 > +1->Emitted(61, 9) Source(13, 8) + SourceIndex(0) +2 >Emitted(61, 20) Source(13, 8) + SourceIndex(0) +3 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) +4 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) +5 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) +6 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) +7 >Emitted(61, 44) Source(13, 31) + SourceIndex(0) +--- +>>> __param(1, ParameterDecorator1), +1 >^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^-> +1 > + > public greeting: string, + > + > @ +2 > +3 > ParameterDecorator1 +4 > +1 >Emitted(62, 9) Source(16, 8) + SourceIndex(0) +2 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) +3 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) +4 >Emitted(62, 40) Source(16, 27) + SourceIndex(0) +--- +>>> __param(1, ParameterDecorator2(30)) +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ +1-> + > @ +2 > +3 > ParameterDecorator2 +4 > ( +5 > 30 +6 > ) +7 > +1->Emitted(63, 9) Source(17, 8) + SourceIndex(0) +2 >Emitted(63, 20) Source(17, 8) + SourceIndex(0) +3 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) +4 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) +5 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) +6 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) +7 >Emitted(63, 44) Source(17, 31) + SourceIndex(0) +--- +>>> ], Greeter); +1 >^^^^^^^ +2 > ^^^^^^^ +3 > ^ +4 > ^^^^^-> +1 > +2 > Greeter +3 > { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + > } +1 >Emitted(64, 8) Source(10, 7) + SourceIndex(0) +2 >Emitted(64, 15) Source(10, 14) + SourceIndex(0) +3 >Emitted(64, 16) Source(54, 2) + SourceIndex(0) +--- >>> return Greeter; 1->^^^^ 2 > ^^^^^^^^^^^^^^ -1-> - > - > set greetings( - > @ParameterDecorator1 - > @ParameterDecorator2(90) - > greetings: string) { - > this.greeting = greetings; - > } - > +1-> 2 > } -1->Emitted(34, 5) Source(54, 1) + SourceIndex(0) -2 >Emitted(34, 19) Source(54, 2) + SourceIndex(0) +1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) +2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) --- >>>}()); +1 >^ +2 > +3 > ^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class Greeter { +2 > +3 > class Greeter { > constructor( > @ParameterDecorator1 > @ParameterDecorator2(20) @@ -436,478 +889,8 @@ sourceFile:sourceMapValidationDecorators.ts > this.greeting = greetings; > } > } -1 >Emitted(35, 1) Source(54, 1) + SourceIndex(0) -2 >Emitted(35, 2) Source(54, 2) + SourceIndex(0) -3 >Emitted(35, 2) Source(10, 1) + SourceIndex(0) -4 >Emitted(35, 6) Source(54, 2) + SourceIndex(0) ---- ->>>Greeter.x1 = 10; -1-> -2 >^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -1-> -2 >x1 -3 > : number = -4 > 10 -5 > ; -1->Emitted(36, 1) Source(33, 20) + SourceIndex(0) -2 >Emitted(36, 11) Source(33, 22) + SourceIndex(0) -3 >Emitted(36, 14) Source(33, 33) + SourceIndex(0) -4 >Emitted(36, 16) Source(33, 35) + SourceIndex(0) -5 >Emitted(36, 17) Source(33, 36) + SourceIndex(0) ---- ->>>__decorate([ -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(37, 1) Source(23, 5) + SourceIndex(0) ---- ->>> PropertyDecorator1, -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> -1-> -2 > PropertyDecorator1 -1->Emitted(38, 5) Source(21, 6) + SourceIndex(0) -2 >Emitted(38, 23) Source(21, 24) + SourceIndex(0) ---- ->>> PropertyDecorator2(40) -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> -1-> - > @ -2 > PropertyDecorator2 -3 > ( -4 > 40 -5 > ) -1->Emitted(39, 5) Source(22, 6) + SourceIndex(0) -2 >Emitted(39, 23) Source(22, 24) + SourceIndex(0) -3 >Emitted(39, 24) Source(22, 25) + SourceIndex(0) -4 >Emitted(39, 26) Source(22, 27) + SourceIndex(0) -5 >Emitted(39, 27) Source(22, 28) + SourceIndex(0) ---- ->>>], Greeter.prototype, "greet", null); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> - > greet() { - > return "

" + this.greeting + "

"; - > } -1->Emitted(40, 37) Source(25, 6) + SourceIndex(0) ---- ->>>__decorate([ -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > -1 >Emitted(41, 1) Source(29, 5) + SourceIndex(0) ---- ->>> PropertyDecorator1, -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> -1-> -2 > PropertyDecorator1 -1->Emitted(42, 5) Source(27, 6) + SourceIndex(0) -2 >Emitted(42, 23) Source(27, 24) + SourceIndex(0) ---- ->>> PropertyDecorator2(50) -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^-> -1-> - > @ -2 > PropertyDecorator2 -3 > ( -4 > 50 -5 > ) -1->Emitted(43, 5) Source(28, 6) + SourceIndex(0) -2 >Emitted(43, 23) Source(28, 24) + SourceIndex(0) -3 >Emitted(43, 24) Source(28, 25) + SourceIndex(0) -4 >Emitted(43, 26) Source(28, 27) + SourceIndex(0) -5 >Emitted(43, 27) Source(28, 28) + SourceIndex(0) ---- ->>>], Greeter.prototype, "x", void 0); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> - > private x: string; -1->Emitted(44, 35) Source(29, 23) + SourceIndex(0) ---- ->>>__decorate([ -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > - > @PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - > - > -1 >Emitted(45, 1) Source(35, 5) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator1), -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1->private fn( - > @ -2 > -3 > ParameterDecorator1 -4 > -1->Emitted(46, 5) Source(36, 8) + SourceIndex(0) -2 >Emitted(46, 16) Source(36, 8) + SourceIndex(0) -3 >Emitted(46, 35) Source(36, 27) + SourceIndex(0) -4 >Emitted(46, 36) Source(36, 27) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator2(70)) -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -1-> - > @ -2 > -3 > ParameterDecorator2 -4 > ( -5 > 70 -6 > ) -7 > -1->Emitted(47, 5) Source(37, 8) + SourceIndex(0) -2 >Emitted(47, 16) Source(37, 8) + SourceIndex(0) -3 >Emitted(47, 35) Source(37, 27) + SourceIndex(0) -4 >Emitted(47, 36) Source(37, 28) + SourceIndex(0) -5 >Emitted(47, 38) Source(37, 30) + SourceIndex(0) -6 >Emitted(47, 39) Source(37, 31) + SourceIndex(0) -7 >Emitted(47, 40) Source(37, 31) + SourceIndex(0) ---- ->>>], Greeter.prototype, "fn", null); -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > - > x: number) { - > return this.greeting; - > } -1 >Emitted(48, 34) Source(40, 6) + SourceIndex(0) ---- ->>>__decorate([ -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > -1 >Emitted(49, 1) Source(44, 5) + SourceIndex(0) ---- ->>> PropertyDecorator1, -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> -1-> -2 > PropertyDecorator1 -1->Emitted(50, 5) Source(42, 6) + SourceIndex(0) -2 >Emitted(50, 23) Source(42, 24) + SourceIndex(0) ---- ->>> PropertyDecorator2(80), -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^-> -1-> - > @ -2 > PropertyDecorator2 -3 > ( -4 > 80 -5 > ) -1->Emitted(51, 5) Source(43, 6) + SourceIndex(0) -2 >Emitted(51, 23) Source(43, 24) + SourceIndex(0) -3 >Emitted(51, 24) Source(43, 25) + SourceIndex(0) -4 >Emitted(51, 26) Source(43, 27) + SourceIndex(0) -5 >Emitted(51, 27) Source(43, 28) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator1), -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1-> - > get greetings() { - > return this.greeting; - > } - > - > set greetings( - > @ -2 > -3 > ParameterDecorator1 -4 > -1->Emitted(52, 5) Source(49, 8) + SourceIndex(0) -2 >Emitted(52, 16) Source(49, 8) + SourceIndex(0) -3 >Emitted(52, 35) Source(49, 27) + SourceIndex(0) -4 >Emitted(52, 36) Source(49, 27) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator2(90)) -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -8 > ^^^-> -1-> - > @ -2 > -3 > ParameterDecorator2 -4 > ( -5 > 90 -6 > ) -7 > -1->Emitted(53, 5) Source(50, 8) + SourceIndex(0) -2 >Emitted(53, 16) Source(50, 8) + SourceIndex(0) -3 >Emitted(53, 35) Source(50, 27) + SourceIndex(0) -4 >Emitted(53, 36) Source(50, 28) + SourceIndex(0) -5 >Emitted(53, 38) Source(50, 30) + SourceIndex(0) -6 >Emitted(53, 39) Source(50, 31) + SourceIndex(0) -7 >Emitted(53, 40) Source(50, 31) + SourceIndex(0) ---- ->>>], Greeter.prototype, "greetings", null); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> -1->Emitted(54, 41) Source(46, 6) + SourceIndex(0) ---- ->>>__decorate([ -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -1 >Emitted(55, 1) Source(33, 5) + SourceIndex(0) ---- ->>> PropertyDecorator1, -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> -1-> -2 > PropertyDecorator1 -1->Emitted(56, 5) Source(31, 6) + SourceIndex(0) -2 >Emitted(56, 23) Source(31, 24) + SourceIndex(0) ---- ->>> PropertyDecorator2(60) -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^-> -1-> - > @ -2 > PropertyDecorator2 -3 > ( -4 > 60 -5 > ) -1->Emitted(57, 5) Source(32, 6) + SourceIndex(0) -2 >Emitted(57, 23) Source(32, 24) + SourceIndex(0) -3 >Emitted(57, 24) Source(32, 25) + SourceIndex(0) -4 >Emitted(57, 26) Source(32, 27) + SourceIndex(0) -5 >Emitted(57, 27) Source(32, 28) + SourceIndex(0) ---- ->>>], Greeter, "x1", void 0); -1->^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> - > private static x1: number = 10; -1->Emitted(58, 26) Source(33, 36) + SourceIndex(0) ---- ->>>Greeter = __decorate([ -1 > -2 >^^^^^^^ -3 > ^^^^^^^^^^^^^^-> -1 > -2 >Greeter -1 >Emitted(59, 1) Source(10, 7) + SourceIndex(0) -2 >Emitted(59, 8) Source(10, 14) + SourceIndex(0) ---- ->>> ClassDecorator1, -1->^^^^ -2 > ^^^^^^^^^^^^^^^ -3 > ^^^^^^-> -1-> -2 > ClassDecorator1 -1->Emitted(60, 5) Source(8, 2) + SourceIndex(0) -2 >Emitted(60, 20) Source(8, 17) + SourceIndex(0) ---- ->>> ClassDecorator2(10), -1->^^^^ -2 > ^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^-> -1-> - >@ -2 > ClassDecorator2 -3 > ( -4 > 10 -5 > ) -1->Emitted(61, 5) Source(9, 2) + SourceIndex(0) -2 >Emitted(61, 20) Source(9, 17) + SourceIndex(0) -3 >Emitted(61, 21) Source(9, 18) + SourceIndex(0) -4 >Emitted(61, 23) Source(9, 20) + SourceIndex(0) -5 >Emitted(61, 24) Source(9, 21) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator1), -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^-> -1-> - >class Greeter { - > constructor( - > @ -2 > -3 > ParameterDecorator1 -4 > -1->Emitted(62, 5) Source(12, 8) + SourceIndex(0) -2 >Emitted(62, 16) Source(12, 8) + SourceIndex(0) -3 >Emitted(62, 35) Source(12, 27) + SourceIndex(0) -4 >Emitted(62, 36) Source(12, 27) + SourceIndex(0) ---- ->>> __param(0, ParameterDecorator2(20)), -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -1-> - > @ -2 > -3 > ParameterDecorator2 -4 > ( -5 > 20 -6 > ) -7 > -1->Emitted(63, 5) Source(13, 8) + SourceIndex(0) -2 >Emitted(63, 16) Source(13, 8) + SourceIndex(0) -3 >Emitted(63, 35) Source(13, 27) + SourceIndex(0) -4 >Emitted(63, 36) Source(13, 28) + SourceIndex(0) -5 >Emitted(63, 38) Source(13, 30) + SourceIndex(0) -6 >Emitted(63, 39) Source(13, 31) + SourceIndex(0) -7 >Emitted(63, 40) Source(13, 31) + SourceIndex(0) ---- ->>> __param(1, ParameterDecorator1), -1 >^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1 > - > public greeting: string, - > - > @ -2 > -3 > ParameterDecorator1 -4 > -1 >Emitted(64, 5) Source(16, 8) + SourceIndex(0) -2 >Emitted(64, 16) Source(16, 8) + SourceIndex(0) -3 >Emitted(64, 35) Source(16, 27) + SourceIndex(0) -4 >Emitted(64, 36) Source(16, 27) + SourceIndex(0) ---- ->>> __param(1, ParameterDecorator2(30)) -1->^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -1-> - > @ -2 > -3 > ParameterDecorator2 -4 > ( -5 > 30 -6 > ) -7 > -1->Emitted(65, 5) Source(17, 8) + SourceIndex(0) -2 >Emitted(65, 16) Source(17, 8) + SourceIndex(0) -3 >Emitted(65, 35) Source(17, 27) + SourceIndex(0) -4 >Emitted(65, 36) Source(17, 28) + SourceIndex(0) -5 >Emitted(65, 38) Source(17, 30) + SourceIndex(0) -6 >Emitted(65, 39) Source(17, 31) + SourceIndex(0) -7 >Emitted(65, 40) Source(17, 31) + SourceIndex(0) ---- ->>>], Greeter); -1 >^^^ -2 > ^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 > Greeter -3 > { - > constructor( - > @ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string, - > - > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[]) { - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { - > return "

" + this.greeting + "

"; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > private x: string; - > - > @PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - > - > private fn( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { - > return this.greeting; - > } - > - > set greetings( - > @ParameterDecorator1 - > @ParameterDecorator2(90) - > greetings: string) { - > this.greeting = greetings; - > } - > } -1 >Emitted(66, 4) Source(10, 7) + SourceIndex(0) -2 >Emitted(66, 11) Source(10, 14) + SourceIndex(0) -3 >Emitted(66, 12) Source(54, 2) + SourceIndex(0) +1 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) +2 >Emitted(66, 2) Source(10, 1) + SourceIndex(0) +3 >Emitted(66, 6) Source(54, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.js b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.js index a641ecd6f03..62a23d538c4 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.js +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.js @@ -148,9 +148,9 @@ function outer(x) { var Inner = (function () { function Inner() { } + Inner.y = x; return Inner; }()); - Inner.y = x; return Inner; } var y = outer(5).y; diff --git a/tests/baselines/reference/staticClassProps.js b/tests/baselines/reference/staticClassProps.js index 48798bd4def..31aa67c56df 100644 --- a/tests/baselines/reference/staticClassProps.js +++ b/tests/baselines/reference/staticClassProps.js @@ -14,6 +14,6 @@ var C = (function () { } C.prototype.foo = function () { }; + C.z = 1; return C; }()); -C.z = 1; diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index 41f2da7f4af..684594ffd5c 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -33,6 +33,6 @@ var P = (function (_super) { function P() { return _super !== null && _super.apply(this, arguments) || this; } + P.SomeNumber = P.GetNumber(); return P; }(SomeBase)); -P.SomeNumber = P.GetNumber(); diff --git a/tests/baselines/reference/staticMemberInitialization.js b/tests/baselines/reference/staticMemberInitialization.js index 13a5c8c25c6..c21c29ed4f8 100644 --- a/tests/baselines/reference/staticMemberInitialization.js +++ b/tests/baselines/reference/staticMemberInitialization.js @@ -10,8 +10,8 @@ var r = C.x; var C = (function () { function C() { } + C.x = 1; return C; }()); -C.x = 1; var c = new C(); var r = C.x; diff --git a/tests/baselines/reference/staticMemberWithStringAndNumberNames.js b/tests/baselines/reference/staticMemberWithStringAndNumberNames.js index 9d8846ba963..2fdd64ea04b 100644 --- a/tests/baselines/reference/staticMemberWithStringAndNumberNames.js +++ b/tests/baselines/reference/staticMemberWithStringAndNumberNames.js @@ -19,10 +19,10 @@ var C = (function () { this.x2 = C['0']; this.x3 = C[0]; } + C["foo"] = 0; + C[0] = 1; + C.s = C['foo']; + C.s2 = C['0']; + C.s3 = C[0]; return C; }()); -C["foo"] = 0; -C[0] = 1; -C.s = C['foo']; -C.s2 = C['0']; -C.s3 = C[0]; diff --git a/tests/baselines/reference/staticModifierAlreadySeen.js b/tests/baselines/reference/staticModifierAlreadySeen.js index c37d4c0807a..76f8b050d6f 100644 --- a/tests/baselines/reference/staticModifierAlreadySeen.js +++ b/tests/baselines/reference/staticModifierAlreadySeen.js @@ -9,6 +9,6 @@ var C = (function () { function C() { } C.bar = function () { }; + C.foo = 1; return C; }()); -C.foo = 1; diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index 5c22232534f..dc308a4769e 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -59,9 +59,9 @@ var B = (function (_super) { _this = _super.call(this) || this; return _this; } + B.s = 9; return B; }(A)); -B.s = 9; var C = (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/statics.js b/tests/baselines/reference/statics.js index d52a28208e6..3776c09c8ce 100644 --- a/tests/baselines/reference/statics.js +++ b/tests/baselines/reference/statics.js @@ -45,11 +45,11 @@ var M; C.f = function (n) { return "wow: " + (n + C.y + C.pub + C.priv); }; + C.priv = 2; + C.pub = 3; + C.y = C.priv; return C; }()); - C.priv = 2; - C.pub = 3; - C.y = C.priv; M.C = C; var c = C.y; function f() { diff --git a/tests/baselines/reference/staticsInConstructorBodies.js b/tests/baselines/reference/staticsInConstructorBodies.js index edd49456ef7..9bc3ed29325 100644 --- a/tests/baselines/reference/staticsInConstructorBodies.js +++ b/tests/baselines/reference/staticsInConstructorBodies.js @@ -11,6 +11,6 @@ var C = (function () { function C() { } C.m1 = function () { }; // ERROR + C.p1 = 0; // ERROR return C; }()); -C.p1 = 0; // ERROR diff --git a/tests/baselines/reference/staticsNotInScopeInClodule.js b/tests/baselines/reference/staticsNotInScopeInClodule.js index ccaace996cd..c43e22fce4c 100644 --- a/tests/baselines/reference/staticsNotInScopeInClodule.js +++ b/tests/baselines/reference/staticsNotInScopeInClodule.js @@ -11,9 +11,9 @@ module Clod { var Clod = (function () { function Clod() { } + Clod.x = 10; return Clod; }()); -Clod.x = 10; (function (Clod) { var p = x; // x isn't in scope here })(Clod || (Clod = {})); diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 65426391967..eb2286556ac 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -114,9 +114,9 @@ var Bs = (function (_super) { "use strict"; // No error return _super.call(this) || this; } + Bs.s = 9; return Bs; }(A)); -Bs.s = 9; var Cs = (function (_super) { __extends(Cs, _super); function Cs() { @@ -124,9 +124,9 @@ var Cs = (function (_super) { "use strict"; return _this; } + Cs.s = 9; return Cs; }(A)); -Cs.s = 9; var Ds = (function (_super) { __extends(Ds, _super); function Ds() { @@ -136,6 +136,6 @@ var Ds = (function (_super) { "use strict"; return _this; } + Ds.s = 9; return Ds; }(A)); -Ds.s = 9; diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index 468e2155e48..aac00259613 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -29,9 +29,9 @@ var MyBase = (function () { this.S2 = "test"; this.f = function () { return 5; }; } + MyBase.S1 = 5; return MyBase; }()); -MyBase.S1 = 5; var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index 51e8f61ab28..9fa848dbf6a 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -64,6 +64,6 @@ var Q = (function (_super) { _super.x.call(this); // error _super.y.call(this); }; + Q.yy = _super.; // error for static initializer accessing super return Q; }(P)); -Q.yy = _super.; // error for static initializer accessing super diff --git a/tests/baselines/reference/syntaxErrors.errors.txt b/tests/baselines/reference/syntaxErrors.errors.txt new file mode 100644 index 00000000000..8e3005891a5 --- /dev/null +++ b/tests/baselines/reference/syntaxErrors.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/jsdoc/foo.js(2,15): error TS1005: '}' expected. +tests/cases/conformance/jsdoc/foo.js(3,19): error TS1005: '}' expected. +tests/cases/conformance/jsdoc/foo.js(4,18): error TS1003: Identifier expected. +tests/cases/conformance/jsdoc/foo.js(4,19): error TS1005: '}' expected. + + +==== tests/cases/conformance/jsdoc/foo.js (4 errors) ==== + /** + * @param {(x)=>void} x + ~~ +!!! error TS1005: '}' expected. + * @param {typeof String} y + ~~~~~~ +!!! error TS1005: '}' expected. + * @param {string & number} z + +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '}' expected. + **/ + function foo(x, y, z) { } + +==== tests/cases/conformance/jsdoc/skipped.js (0 errors) ==== + // @ts-nocheck + /** + * @param {(x)=>void} x + * @param {typeof String} y + * @param {string & number} z + **/ + function bar(x, y, z) { } + \ No newline at end of file diff --git a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js index 03b86b1d225..88a4f5c6e5c 100644 --- a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js +++ b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js @@ -9,14 +9,13 @@ class Vector { } //// [thisInArrowFunctionInStaticInitializer1.js] -var _this = this; function log(a) { } var Vector = (function () { function Vector() { } + Vector.foo = function () { + // 'this' should not be available in a static initializer. + log(_this); + }; return Vector; }()); -Vector.foo = function () { - // 'this' should not be available in a static initializer. - log(_this); -}; diff --git a/tests/baselines/reference/thisInConstructorParameter2.js b/tests/baselines/reference/thisInConstructorParameter2.js index ba2917c5a4e..7260ecafcb9 100644 --- a/tests/baselines/reference/thisInConstructorParameter2.js +++ b/tests/baselines/reference/thisInConstructorParameter2.js @@ -25,6 +25,6 @@ var P = (function () { if (zz === void 0) { zz = this; } zz.y; }; + P.y = this; return P; }()); -P.y = this; diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 25350fb78cf..24b25d46a34 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -63,9 +63,9 @@ var __extends = (this && this.__extends) || (function () { var ErrClass1 = (function () { function ErrClass1() { } + ErrClass1.t = this; // Error return ErrClass1; }()); -ErrClass1.t = this; // Error var BaseErrClass = (function () { function BaseErrClass(t) { } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 070d5597fcc..845183d8df5 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -64,9 +64,9 @@ var __extends = (this && this.__extends) || (function () { var ErrClass1 = (function () { function ErrClass1() { } + ErrClass1.t = this; // Error return ErrClass1; }()); -ErrClass1.t = this; // Error var BaseErrClass = (function () { function BaseErrClass(t) { } diff --git a/tests/baselines/reference/thisInOuterClassBody.js b/tests/baselines/reference/thisInOuterClassBody.js index 40b0e2b78ae..40e4a2e2485 100644 --- a/tests/baselines/reference/thisInOuterClassBody.js +++ b/tests/baselines/reference/thisInOuterClassBody.js @@ -36,6 +36,6 @@ var Foo = (function () { var a = this.y; var b = this.x; }; + Foo.y = this; return Foo; }()); -Foo.y = this; diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.js b/tests/baselines/reference/thisInPropertyBoundDeclarations.js index f5967fbb5b2..0b378cec51a 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.js +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.js @@ -74,13 +74,13 @@ var Bug = (function () { Bug.prototype.foo = function (name) { this.name = name; }; + Bug.func = [ + function (that, name) { + that.foo(name); + } + ]; return Bug; }()); -Bug.func = [ - function (that, name) { - that.foo(name); - } -]; // Valid use of this in a property bound decl var A = (function () { function A() { diff --git a/tests/baselines/reference/thisInStaticMethod1.js b/tests/baselines/reference/thisInStaticMethod1.js index 1e39ded3b61..a42415c0b62 100644 --- a/tests/baselines/reference/thisInStaticMethod1.js +++ b/tests/baselines/reference/thisInStaticMethod1.js @@ -14,7 +14,7 @@ var foo = (function () { foo.bar = function () { return this.x; }; + foo.x = 3; return foo; }()); -foo.x = 3; var x = foo.bar(); diff --git a/tests/baselines/reference/thisTypeErrors.js b/tests/baselines/reference/thisTypeErrors.js index 5811ec6b709..f246b80f4f4 100644 --- a/tests/baselines/reference/thisTypeErrors.js +++ b/tests/baselines/reference/thisTypeErrors.js @@ -75,9 +75,9 @@ var C2 = (function () { C2.foo = function (x) { return undefined; }; + C2.y = undefined; return C2; }()); -C2.y = undefined; var N1; (function (N1) { N1.y = this; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js index cd4ce3c862e..9bdbfba8396 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -14,11 +14,11 @@ var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + fooexport, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); -MyClass1 = __decorate([ - fooexport, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) -], MyClass1); -var _a; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js index 9e3d59ce27c..e79eeceae50 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js @@ -10,7 +10,7 @@ System.register(["angular2/core"], function (exports_1, context_1) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __moduleName = context_1 && context_1.id; - var ng, MyClass1, _a; + var ng, MyClass1; return { setters: [ function (ng_1) { @@ -22,12 +22,13 @@ System.register(["angular2/core"], function (exports_1, context_1) { function MyClass1(_elementRef) { this._elementRef = _elementRef; } + MyClass1 = __decorate([ + fooexport, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); return MyClass1; + var _a; }()); - MyClass1 = __decorate([ - fooexport, - __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) - ], MyClass1); } }; }); diff --git a/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js index 0b3bbaa8d73..236f91f9594 100644 --- a/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js +++ b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js @@ -9,12 +9,12 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } + MyClass = __decorate([ + someDecorator, + __metadata("design:paramtypes", [typeof (_a = typeof db_1.db !== "undefined" && db_1.db) === "function" && _a || Object]) + ], MyClass); return MyClass; + var _a; }()); -MyClass = __decorate([ - someDecorator, - __metadata("design:paramtypes", [typeof (_a = typeof db_1.db !== "undefined" && db_1.db) === "function" && _a || Object]) -], MyClass); exports.MyClass = MyClass; -var _a; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/tsxDefaultImports.js b/tests/baselines/reference/tsxDefaultImports.js index a6c1a4217a3..c3a287c478d 100644 --- a/tests/baselines/reference/tsxDefaultImports.js +++ b/tests/baselines/reference/tsxDefaultImports.js @@ -23,9 +23,9 @@ var SomeEnum; var SomeClass = (function () { function SomeClass() { } + SomeClass.E = SomeEnum; return SomeClass; }()); -SomeClass.E = SomeEnum; exports["default"] = SomeClass; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/typeOfPrototype.js b/tests/baselines/reference/typeOfPrototype.js index a0f076113e0..3e8b3186936 100644 --- a/tests/baselines/reference/typeOfPrototype.js +++ b/tests/baselines/reference/typeOfPrototype.js @@ -11,7 +11,7 @@ var Foo = (function () { function Foo() { this.bar = 3; } + Foo.bar = ''; return Foo; }()); -Foo.bar = ''; Foo.prototype.bar = undefined; // Should be OK diff --git a/tests/baselines/reference/typeOfThisInStaticMembers2.js b/tests/baselines/reference/typeOfThisInStaticMembers2.js index 886ea04e23d..b01770446be 100644 --- a/tests/baselines/reference/typeOfThisInStaticMembers2.js +++ b/tests/baselines/reference/typeOfThisInStaticMembers2.js @@ -11,12 +11,12 @@ class C2 { var C = (function () { function C() { } + C.foo = this; // error return C; }()); -C.foo = this; // error var C2 = (function () { function C2() { } + C2.foo = this; // error return C2; }()); -C2.foo = this; // error diff --git a/tests/baselines/reference/typeQueryOnClass.js b/tests/baselines/reference/typeQueryOnClass.js index 80623af5be8..85dff0de831 100644 --- a/tests/baselines/reference/typeQueryOnClass.js +++ b/tests/baselines/reference/typeQueryOnClass.js @@ -99,10 +99,10 @@ var C = (function () { enumerable: true, configurable: true }); + C.sa = 1; + C.sb = function () { return 1; }; return C; }()); -C.sa = 1; -C.sb = function () { return 1; }; var c; // BUG 820454 var r1; diff --git a/tests/baselines/reference/typeofUsedBeforeBlockScoped.js b/tests/baselines/reference/typeofUsedBeforeBlockScoped.js index eebf4beae67..cc9003dd4f6 100644 --- a/tests/baselines/reference/typeofUsedBeforeBlockScoped.js +++ b/tests/baselines/reference/typeofUsedBeforeBlockScoped.js @@ -12,8 +12,8 @@ let o = { n: 12 }; var C = (function () { function C() { } + C.s = 2; return C; }()); -C.s = 2; var o2; var o = { n: 12 }; diff --git a/tests/baselines/reference/unqualifiedCallToClassStatic1.js b/tests/baselines/reference/unqualifiedCallToClassStatic1.js index 906e9d3795f..6c78a737fe8 100644 --- a/tests/baselines/reference/unqualifiedCallToClassStatic1.js +++ b/tests/baselines/reference/unqualifiedCallToClassStatic1.js @@ -10,9 +10,9 @@ class Vector { var Vector = (function () { function Vector() { } + Vector.foo = function () { + // 'foo' cannot be called in an unqualified manner. + foo(); + }; return Vector; }()); -Vector.foo = function () { - // 'foo' cannot be called in an unqualified manner. - foo(); -}; diff --git a/tests/baselines/reference/witness.js b/tests/baselines/reference/witness.js index 9f92c90ffa4..ebd1669d177 100644 --- a/tests/baselines/reference/witness.js +++ b/tests/baselines/reference/witness.js @@ -258,9 +258,9 @@ var c2inst; var C3 = (function () { function C3() { } + C3.q = C3.q; return C3; }()); -C3.q = C3.q; var qq = C3.q; var qq; // Parentheses - tested a bunch above diff --git a/tests/cases/compiler/forAwaitForUnion.ts b/tests/cases/compiler/forAwaitForUnion.ts new file mode 100644 index 00000000000..65e08ab77a9 --- /dev/null +++ b/tests/cases/compiler/forAwaitForUnion.ts @@ -0,0 +1,6 @@ +// @target: esnext +// @lib: esnext +async function f(source: Iterable | AsyncIterable) { + for await (const x of source) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts b/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts index fa885b9f316..89f609be202 100644 --- a/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts +++ b/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts @@ -18,6 +18,19 @@ function foo(opts) { foo({x: 'abc'}); +/** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ +function foo1(opts) { + opts.anotherX; +} + +foo1({anotherX: "world"}); + /** * @typedef {object} Opts1 * @property {string} x @@ -27,7 +40,7 @@ foo({x: 'abc'}); * * @param {Opts1} opts */ -function foo1(opts) { +function foo2(opts) { opts.x; } -foo1({x: 'abc'}); +foo2({x: 'abc'}); diff --git a/tests/cases/conformance/jsdoc/syntaxErrors.ts b/tests/cases/conformance/jsdoc/syntaxErrors.ts new file mode 100644 index 00000000000..4f9024810dd --- /dev/null +++ b/tests/cases/conformance/jsdoc/syntaxErrors.ts @@ -0,0 +1,20 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @Filename: foo.js +/** + * @param {(x)=>void} x + * @param {typeof String} y + * @param {string & number} z + **/ +function foo(x, y, z) { } + +// @Filename: skipped.js +// @ts-nocheck +/** + * @param {(x)=>void} x + * @param {typeof String} y + * @param {string & number} z + **/ +function bar(x, y, z) { }