diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 362e450466b66..6fdaac79cea00 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5,6 +5,12 @@ module ts { let nextNodeId = 1; let nextMergeId = 1; + // @internal + export function getNodeId(node: Node): number { + if (!node.id) node.id = nextNodeId++; + return node.id; + } + /* @internal */ export let checkTime = 0; /* @internal */ @@ -109,11 +115,17 @@ module ts { let globalIterableType: ObjectType; let anyArrayType: Type; - + let globalTypedPropertyDescriptorType: ObjectType; + let globalClassDecoratorType: ObjectType; + let globalParameterDecoratorType: ObjectType; + let globalPropertyDecoratorType: ObjectType; + let globalMethodDecoratorType: ObjectType; + let tupleTypes: Map = {}; let unionTypes: Map = {}; let stringLiteralTypes: Map = {}; let emitExtends = false; + let emitDecorate = false; let mergedSymbols: Symbol[] = []; let symbolLinks: SymbolLinks[] = []; @@ -264,8 +276,8 @@ module ts { } function getNodeLinks(node: Node): NodeLinks { - if (!node.id) node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); + let nodeId = getNodeId(node); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node: Node): SourceFile { @@ -318,6 +330,7 @@ module ts { let lastLocation: Node; let propertyWithInvalidInitializer: Node; let errorLocation = location; + let grandparent: Node; loop: while (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) @@ -383,7 +396,7 @@ module ts { // } // case SyntaxKind.ComputedPropertyName: - let grandparent = location.parent.parent; + grandparent = location.parent.parent; if (grandparent.kind === SyntaxKind.ClassDeclaration || grandparent.kind === SyntaxKind.InterfaceDeclaration) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) { @@ -415,6 +428,28 @@ module ts { break loop; } break; + case SyntaxKind.Decorator: + // Decorators are resolved at the class declaration. Resolving at the parameter + // or member would result in looking up locals in the method. + // + // function y() {} + // class C { + // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. + // } + // + if (location.parent && location.parent.kind === SyntaxKind.Parameter) { + location = location.parent; + } + // + // function y() {} + // class C { + // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. + // } + // + if (location.parent && isClassElement(location.parent)) { + location = location.parent; + } + break; } lastLocation = location; location = location.parent; @@ -7297,7 +7332,6 @@ module ts { case SyntaxKind.ElementAccessExpression: { let index = (n).argumentExpression; let symbol = findSymbol((n).expression); - if (symbol && index && index.kind === SyntaxKind.StringLiteral) { let name = (index).text; let prop = getPropertyOfType(getTypeOfSymbol(symbol), name); @@ -7312,14 +7346,37 @@ module ts { } } + function isImportedNameFromExternalModule(n: Node): boolean { + switch (n.kind) { + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.PropertyAccessExpression: { + // all bindings for external module should be immutable + // so attempt to use a.b or a[b] as lhs will always fail + // no matter what b is + let symbol = findSymbol((n).expression); + return symbol && symbol.flags & SymbolFlags.Alias && isExternalModuleSymbol(resolveAlias(symbol)); + } + case SyntaxKind.ParenthesizedExpression: + return isImportedNameFromExternalModule((n).expression); + default: + return false; + } + } + if (!isReferenceOrErrorExpression(n)) { error(n, invalidReferenceMessage); return false; } + if (isConstVariableReference(n)) { error(n, constantVariableMessage); return false; } + + if (isImportedNameFromExternalModule(n)) { + error(n, invalidReferenceMessage); + } + return true; } @@ -7968,7 +8025,7 @@ module ts { // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); let func = getContainingFunction(node); @@ -8070,7 +8127,7 @@ module ts { function checkPropertyDeclaration(node: PropertyDeclaration) { // Grammar checking - checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); } @@ -8209,6 +8266,10 @@ module ts { checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node: Node) { + checkDecorators(node); + } + function checkTypeReference(node: TypeReferenceNode) { // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); @@ -8600,6 +8661,60 @@ module ts { } } + /** Check a decorator */ + function checkDecorator(node: Decorator): void { + let expression: Expression = node.expression; + let exprType = checkExpression(expression); + + switch (node.parent.kind) { + case SyntaxKind.ClassDeclaration: + let classSymbol = getSymbolOfNode(node.parent); + let classConstructorType = getTypeOfSymbol(classSymbol); + let classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + checkTypeAssignableTo(exprType, classDecoratorType, node); + break; + + case SyntaxKind.PropertyDeclaration: + checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + break; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + let methodType = getTypeOfNode(node.parent); + let methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + checkTypeAssignableTo(exprType, methodDecoratorType, node); + break; + + case SyntaxKind.Parameter: + checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + break; + } + } + + /** Check the decorators of a node */ + function checkDecorators(node: Node): void { + if (!node.decorators) { + return; + } + + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.Parameter: + emitDecorate = true; + break; + + default: + return; + } + + forEach(node.decorators, checkDecorator); + } + function checkFunctionDeclaration(node: FunctionDeclaration): void { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || @@ -8614,6 +8729,7 @@ module ts { } function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { + checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -8896,6 +9012,7 @@ module ts { // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node: VariableLikeDeclaration) { + checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -8968,7 +9085,7 @@ module ts { function checkVariableStatement(node: VariableStatement) { // Grammar checking - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); + checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); forEach(node.declarationList.declarations, checkSourceElement); } @@ -9599,7 +9716,7 @@ module ts { function checkClassDeclaration(node: ClassDeclaration) { // Grammar checking checkGrammarClassDeclarationHeritageClauses(node); - + checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -9804,7 +9921,7 @@ module ts { function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { @@ -9841,7 +9958,7 @@ module ts { function checkTypeAliasDeclaration(node: TypeAliasDeclaration) { // Grammar checking - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); @@ -10023,7 +10140,7 @@ module ts { } // Grammar checking - checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -10089,7 +10206,7 @@ module ts { function checkModuleDeclaration(node: ModuleDeclaration) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarModifiers(node)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) { grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -10184,7 +10301,7 @@ module ts { } function checkImportDeclaration(node: ImportDeclaration) { - if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -10206,7 +10323,7 @@ module ts { } function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) { - checkGrammarModifiers(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & NodeFlags.Export) { @@ -10237,7 +10354,7 @@ module ts { } function checkExportDeclaration(node: ExportDeclaration) { - if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -10275,7 +10392,7 @@ module ts { return; } // Grammar checking - if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression) { @@ -10436,6 +10553,8 @@ module ts { case SyntaxKind.DebuggerStatement: checkGrammarStatementInAmbientContext(node); return; + case SyntaxKind.MissingDeclaration: + return checkMissingDeclaration(node); } } @@ -10562,6 +10681,10 @@ module ts { links.flags |= NodeCheckFlags.EmitExtends; } + if (emitDecorate) { + links.flags |= NodeCheckFlags.EmitDecorate; + } + links.flags |= NodeCheckFlags.TypeChecked; } } @@ -10605,7 +10728,55 @@ module ts { function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] { let symbols: SymbolTable = {}; let memberFlags: NodeFlags = 0; - function copySymbol(symbol: Symbol, meaning: SymbolFlags) { + + if (isInsideWithStatementBody(location)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return []; + } + + populateSymbols(); + + return symbolsToArray(symbols); + + function populateSymbols() { + while (location) { + if (location.locals && !isGlobalSourceFile(location)) { + copySymbols(location.locals, meaning); + } + + switch (location.kind) { + case SyntaxKind.SourceFile: + if (!isExternalModule(location)) { + break; + } + case SyntaxKind.ModuleDeclaration: + copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.ModuleMember); + break; + case SyntaxKind.EnumDeclaration: + copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember); + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + if (!(memberFlags & NodeFlags.Static)) { + copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type); + } + break; + case SyntaxKind.FunctionExpression: + if ((location).name) { + copySymbol(location.symbol, meaning); + } + break; + } + + memberFlags = location.flags; + location = location.parent; + } + + copySymbols(globals, meaning); + } + + // Returns 'true' if we should stop processing symbols. + function copySymbol(symbol: Symbol, meaning: SymbolFlags): void { if (symbol.flags & meaning) { let id = symbol.name; if (!isReservedMemberName(id) && !hasProperty(symbols, id)) { @@ -10613,7 +10784,8 @@ module ts { } } } - function copySymbols(source: SymbolTable, meaning: SymbolFlags) { + + function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { for (let id in source) { if (hasProperty(source, id)) { @@ -11009,134 +11181,7 @@ module ts { return symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length === 1 && symbol.declarations[0].kind === SyntaxKind.SourceFile; } - function isNodeDescendentOf(node: Node, ancestor: Node): boolean { - while (node) { - if (node === ancestor) return true; - node = node.parent; - } - return false; - } - - function isUniqueLocalName(name: string, container: Node): boolean { - for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { - return false; - } - } - } - return true; - } - - function getGeneratedNamesForSourceFile(sourceFile: SourceFile): Map { - let links = getNodeLinks(sourceFile); - let generatedNames = links.generatedNames; - if (!generatedNames) { - generatedNames = links.generatedNames = {}; - generateNames(sourceFile); - } - return generatedNames; - - function generateNames(node: Node) { - switch (node.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ClassDeclaration: - generateNameForFunctionOrClassDeclaration(node); - break; - case SyntaxKind.ModuleDeclaration: - generateNameForModuleOrEnum(node); - generateNames((node).body); - break; - case SyntaxKind.EnumDeclaration: - generateNameForModuleOrEnum(node); - break; - case SyntaxKind.ImportDeclaration: - generateNameForImportDeclaration(node); - break; - case SyntaxKind.ExportDeclaration: - generateNameForExportDeclaration(node); - break; - case SyntaxKind.ExportAssignment: - generateNameForExportAssignment(node); - break; - case SyntaxKind.SourceFile: - case SyntaxKind.ModuleBlock: - forEach((node).statements, generateNames); - break; - } - } - - function isExistingName(name: string) { - return hasProperty(globals, name) || hasProperty(sourceFile.identifiers, name) || hasProperty(generatedNames, name); - } - - function makeUniqueName(baseName: string): string { - let name = generateUniqueName(baseName, isExistingName); - return generatedNames[name] = name; - } - - function assignGeneratedName(node: Node, name: string) { - getNodeLinks(node).generatedName = unescapeIdentifier(name); - } - - function generateNameForFunctionOrClassDeclaration(node: Declaration) { - if (!node.name) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - - function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { - if (node.name.kind === SyntaxKind.Identifier) { - let name = node.name.text; - // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name)); - } - } - - function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { - let expr = getExternalModuleName(node); - let baseName = expr.kind === SyntaxKind.StringLiteral ? - escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; - assignGeneratedName(node, makeUniqueName(baseName)); - } - - function generateNameForImportDeclaration(node: ImportDeclaration) { - if (node.importClause) { - generateNameForImportOrExportDeclaration(node); - } - } - - function generateNameForExportDeclaration(node: ExportDeclaration) { - if (node.moduleSpecifier) { - generateNameForImportOrExportDeclaration(node); - } - } - - function generateNameForExportAssignment(node: ExportAssignment) { - if (node.expression && node.expression.kind !== SyntaxKind.Identifier) { - assignGeneratedName(node, makeUniqueName("default")); - } - } - } - - function getGeneratedNameForNode(node: Node) { - let links = getNodeLinks(node); - if (!links.generatedName) { - getGeneratedNamesForSourceFile(getSourceFile(node)); - } - return links.generatedName; - } - - function getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string { - return getGeneratedNameForNode(container); - } - - function getLocalNameForImportDeclaration(node: ImportDeclaration): string { - return getGeneratedNameForNode(node); - } - - function getAliasNameSubstitution(symbol: Symbol): string { + function getAliasNameSubstitution(symbol: Symbol, getGeneratedNameForNode: (node: Node) => string): string { // If this is es6 or higher, just use the name of the export // no need to qualify it. if (languageVersion >= ScriptTarget.ES6) { @@ -11156,7 +11201,7 @@ module ts { } } - function getExportNameSubstitution(symbol: Symbol, location: Node): string { + function getExportNameSubstitution(symbol: Symbol, location: Node, getGeneratedNameForNode: (Node: Node) => string): string { if (isExternalModuleSymbol(symbol.parent)) { // If this is es6 or higher, just use the name of the export // no need to qualify it. @@ -11175,24 +11220,24 @@ module ts { } } - function getExpressionNameSubstitution(node: Identifier): string { + function getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (Node: Node) => string): string { let symbol = getNodeLinks(node).resolvedSymbol || (isDeclarationName(node) ? getSymbolOfNode(node.parent) : undefined); if (symbol) { // Whan an identifier resolves to a parented symbol, it references an exported entity from // another declaration of the same internal module. if (symbol.parent) { - return getExportNameSubstitution(symbol, node.parent); + return getExportNameSubstitution(symbol, node.parent, getGeneratedNameForNode); } // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. let exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (symbol !== exportSymbol && !(exportSymbol.flags & SymbolFlags.ExportHasLocal)) { - return getExportNameSubstitution(exportSymbol, node.parent); + return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } // Named imports from ES6 import declarations are rewritten if (symbol.flags & SymbolFlags.Alias) { - return getAliasNameSubstitution(symbol); + return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } @@ -11312,10 +11357,13 @@ module ts { getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } - function isUnknownIdentifier(location: Node, name: string): boolean { - Debug.assert(!nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); - return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) && - !hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); + function hasGlobalName(name: string): boolean { + return hasProperty(globals, name); + } + + function resolvesToSomeValue(location: Node, name: string): boolean { + Debug.assert(!nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location"); + return !!resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getBlockScopedVariableId(n: Identifier): number { @@ -11343,11 +11391,25 @@ module ts { return undefined; } + function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type { + if (functionType === unknownType) { + return unknownType; + } + + let signature = getSingleCallSignature(functionType); + if (!signature) { + return unknownType; + } + + let instantiatedSignature = getSignatureInstantiation(signature, typeArguments); + return getOrCreateTypeFromSignature(instantiatedSignature); + } + function createResolver(): EmitResolver { return { - getGeneratedNameForNode, getExpressionNameSubstitution, isValueAliasDeclaration, + hasGlobalName, isReferencedAliasDeclaration, getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName, @@ -11359,7 +11421,7 @@ module ts { isSymbolAccessible, isEntityNameVisible, getConstantValue, - isUnknownIdentifier, + resolvesToSomeValue, collectLinkedAliases, getBlockScopedVariableId, }; @@ -11392,6 +11454,11 @@ module ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); + globalClassDecoratorType = getGlobalType("ClassDecorator"); + globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); + globalMethodDecoratorType = getGlobalType("MethodDecorator"); + globalParameterDecoratorType = getGlobalType("ParameterDecorator"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. @@ -11416,6 +11483,25 @@ module ts { // GRAMMAR CHECKING + function checkGrammarDecorators(node: Node): boolean { + if (!node.decorators) { + return false; + } + if (!nodeCanBeDecorated(node)) { + return grammarErrorOnNode(node, Diagnostics.Decorators_are_not_valid_here); + } + else if (languageVersion < ScriptTarget.ES5) { + return grammarErrorOnNode(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) { + let accessors = getAllAccessorDeclarations((node.parent).members, node); + if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + return grammarErrorOnNode(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); + } + } + return false; + } + function checkGrammarModifiers(node: Node): boolean { switch (node.kind) { case SyntaxKind.GetAccessor: @@ -11612,7 +11698,7 @@ module ts { function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { // Prevent cascading error by short-circuit let file = getSourceFileOfNode(node); - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } @@ -11669,7 +11755,7 @@ module ts { function checkGrammarIndexSignature(node: SignatureDeclaration) { // Prevent cascading error by short-circuit - checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node: Node, typeArguments: NodeArray): boolean { @@ -11718,7 +11804,7 @@ module ts { let seenExtendsClause = false; let seenImplementsClause = false; - if (!checkGrammarModifiers(node) && node.heritageClauses) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (let heritageClause of node.heritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d25cb5637ca8f..4b93081dc3133 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -162,6 +162,39 @@ module ts { return ~low; } + export function reduceLeft(array: T[], f: (a: T, x: T) => T): T; + export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial: U): U; + export function reduceLeft(array: T[], f: (a: U, x: T) => U, initial?: U): U { + if (array) { + var count = array.length; + if (count > 0) { + var pos = 0; + var result = arguments.length <= 2 ? array[pos++] : initial; + while (pos < count) { + result = f(result, array[pos++]); + } + return result; + } + } + return initial; + } + + export function reduceRight(array: T[], f: (a: T, x: T) => T): T; + export function reduceRight(array: T[], f: (a: U, x: T) => U, initial: U): U; + export function reduceRight(array: T[], f: (a: U, x: T) => U, initial?: U): U { + if (array) { + var pos = array.length - 1; + if (pos >= 0) { + var result = arguments.length <= 2 ? array[pos--] : initial; + while (pos >= 0) { + result = f(result, array[pos--]); + } + return result; + } + } + return initial; + } + let hasOwnProperty = Object.prototype.hasOwnProperty; export function hasProperty(map: Map, key: string): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d4b5f8230b695..967afd171bac8 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -162,6 +162,9 @@ module ts { Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, + Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." }, + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5c4aea844b994..6e24afad80c4a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -639,6 +639,18 @@ "category": "Error", "code": 1204 }, + "Decorators are only available when targeting ECMAScript 5 and higher.": { + "category": "Error", + "code": 1205 + }, + "Decorators are not valid here.": { + "category": "Error", + "code": 1206 + }, + "Decorators cannot be applied to multiple get/set accessors of the same name.": { + "category": "Error", + "code": 1207 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1b939980e9ab0..02531593de6ff 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -12,6 +12,14 @@ module ts { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } + // flag enum used to request and track usages of few dedicated temp variables + // enum values are used to set/check bit values and thus should not have bit collisions. + const enum TempVariableKind { + auto = 0, + _i = 1, + _n = 2, + } + // @internal // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { @@ -53,6 +61,26 @@ module ts { sourceMaps: sourceMapDataList }; + function isNodeDescendentOf(node: Node, ancestor: Node): boolean { + while (node) { + if (node === ancestor) return true; + node = node.parent; + } + return false; + } + + function isUniqueLocalName(name: string, container: Node): boolean { + for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath: string, root?: SourceFile) { let writer = createTextWriter(newLine); let write = writer.write; @@ -64,16 +92,18 @@ module ts { let currentSourceFile: SourceFile; - let lastFrame: ScopeFrame; - let currentScopeNames: Map; - - let generatedBlockScopeNames: string[]; + let generatedNameSet: Map; + let nodeToGeneratedName: string[]; + let blockScopedVariableToGeneratedName: string[]; + let computedPropertyNamesToGeneratedNames: string[]; let extendsEmitted = false; + let decorateEmitted = false; let tempCount = 0; let tempVariables: Identifier[]; let tempParameters: Identifier[]; let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; + let predefinedTempsInUse = TempVariableKind.auto; let exportSpecifiers: Map; let exportEquals: ExportAssignment; let hasExportStars: boolean; @@ -138,81 +168,197 @@ module ts { emit(sourceFile); } - // enters the new lexical environment - // return value should be passed to matching call to exitNameScope. - function enterNameScope(): boolean { - let names = currentScopeNames; - currentScopeNames = undefined; - if (names) { - lastFrame = { names, previous: lastFrame }; - return true; + function generateNameForNode(node: Node) { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + generateNameForFunctionOrClassDeclaration(node); + break; + case SyntaxKind.ModuleDeclaration: + generateNameForModuleOrEnum(node); + generateNameForNode((node).body); + break; + case SyntaxKind.EnumDeclaration: + generateNameForModuleOrEnum(node); + break; + case SyntaxKind.ImportDeclaration: + generateNameForImportDeclaration(node); + break; + case SyntaxKind.ExportDeclaration: + generateNameForExportDeclaration(node); + break; + case SyntaxKind.ExportAssignment: + generateNameForExportAssignment(node); + break; + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleBlock: + forEach((node).statements, generateNameForNode); + break; } - return false; } - function exitNameScope(popFrame: boolean): void { - if (popFrame) { - currentScopeNames = lastFrame.names; - lastFrame = lastFrame.previous; + function isUniqueName(name: string): boolean { + return !resolver.hasGlobalName(name) && + !hasProperty(currentSourceFile.identifiers, name) && + (!generatedNameSet || !hasProperty(generatedNameSet, name)) + } + + // in cases like + // for (var x of []) { + // _i; + // } + // we should be able to detect if let _i was shadowed by some temp variable that was allocated in scope + function nameConflictsWithSomeTempVariable(name: string): boolean { + // temp variable names always start with '_' + if (name.length < 2 || name.charCodeAt(0) !== CharacterCodes._) { + return false; + } + + if (name === "_i") { + return !!(predefinedTempsInUse & TempVariableKind._i); + } + + if (name === "_n") { + return !!(predefinedTempsInUse & TempVariableKind._n); + } + + if (name.length === 2 && name.charCodeAt(1) >= CharacterCodes.a && name.charCodeAt(1) <= CharacterCodes.z) { + // handles _a .. _z + let n = name.charCodeAt(1) - CharacterCodes.a; + return n < tempCount; } else { - currentScopeNames = undefined; + // handles _1, _2... + let n = +name.substring(1); + return !isNaN(n) && n >= 0 && n < (tempCount - 26); } } - function generateUniqueNameForLocation(location: Node, baseName: string): string { - let name: string - // first try to check if base name can be used as is - if (!isExistingName(location, baseName)) { - name = baseName; + // This function generates a name using the following pattern: + // _a .. _h, _j ... _z, _0, _1, ... + // It is guaranteed that generated name will not shadow any existing user-defined names, + // however it can hide another name generated by this function higher in the scope. + // NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict. + // see comment for 'makeTempVariableName' for more information. + function makeTempVariableName(location: Node, tempVariableKind: TempVariableKind): string { + let tempName: string; + if (tempVariableKind !== TempVariableKind.auto && !(predefinedTempsInUse & tempVariableKind)) { + tempName = tempVariableKind === TempVariableKind._i ? "_i" : "_n"; + if (!resolver.resolvesToSomeValue(location, tempName)) { + predefinedTempsInUse |= tempVariableKind; + return tempName; + } } - else { - name = generateUniqueName(baseName, n => isExistingName(location, n)); + + do { + // Note: we avoid generating _i and _n as those are common names we want in other places. + var char = CharacterCodes.a + tempCount; + if (char !== CharacterCodes.i && char !== CharacterCodes.n) { + if (tempCount < 26) { + tempName = "_" + String.fromCharCode(char); + } + else { + tempName = "_" + (tempCount - 26); + } + } + + tempCount++; } + while (resolver.resolvesToSomeValue(location, tempName)); - return recordNameInCurrentScope(name); + return tempName; } - function recordNameInCurrentScope(name: string): string { - if (!currentScopeNames) { - currentScopeNames = {}; + // Generates a name that is unique within current file and does not collide with + // any names in global scope. + // NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict + // because of the way how these names are generated + // - makeUniqueName builds a name by picking a base name (which should not be empty string) + // and appending suffix '_' + // - makeTempVariableName creates a name using the following pattern: + // _a .. _h, _j ... _z, _0, _1, ... + // This means that names from 'makeTempVariableName' will have only one underscore at the beginning + // and names from 'makeUniqieName' will have at least one underscore in the middle + // so they will never collide. + function makeUniqueName(baseName: string): string { + Debug.assert(!!baseName); + + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { + baseName += "_"; } - return currentScopeNames[name] = name; + let i = 1; + let generatedName: string; + while (true) { + generatedName = baseName + i; + if (isUniqueName(generatedName)) { + break; + } + i++; + } + + if (!generatedNameSet) { + generatedNameSet = {}; + } + return generatedNameSet[generatedName] = generatedName; } - function isExistingName(location: Node, name: string) { - // check if resolver is aware of this name (if name was seen during the typecheck) - if (!resolver.isUnknownIdentifier(location, name)) { - return true; + function renameNode(node: Node, name: string): string { + var nodeId = getNodeId(node); + + if (!nodeToGeneratedName) { + nodeToGeneratedName = []; } - // check if name is present in generated names that were introduced by the emitter - if (currentScopeNames && hasProperty(currentScopeNames, name)) { - return true; + return nodeToGeneratedName[nodeId] = unescapeIdentifier(name); + } + + function generateNameForFunctionOrClassDeclaration(node: Declaration) { + if (!node.name) { + renameNode(node, makeUniqueName("default")); } + } - // check generated names in outer scopes - // let x; - // function foo() { - // let x; // 1 - // function bar() { - // { - // let x; // 2 - // } - // console.log(x); // 3 - // } - //} - // here both x(1) and x(2) should be renamed and their names should be different - // so x in (3) will refer to x(1) - let frame = lastFrame; - while (frame) { - if (hasProperty(frame.names, name)) { - return true; - } - frame = frame.previous; + function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { + if (node.name.kind === SyntaxKind.Identifier) { + let name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + renameNode(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name)); } - return false; + } + + function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { + let expr = getExternalModuleName(node); + let baseName = expr.kind === SyntaxKind.StringLiteral ? + escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; + renameNode(node, makeUniqueName(baseName)); + } + + function generateNameForImportDeclaration(node: ImportDeclaration) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + + function generateNameForExportDeclaration(node: ExportDeclaration) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + + function generateNameForExportAssignment(node: ExportAssignment) { + if (node.expression && node.expression.kind !== SyntaxKind.Identifier) { + renameNode(node, makeUniqueName("default")); + } + } + + function getGeneratedNameForNode(node: Node) { + let nodeId = getNodeId(node); + if (!nodeToGeneratedName || !nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName ? nodeToGeneratedName[nodeId] : undefined; } function initializeEmitterWithSourceMaps() { @@ -579,32 +725,10 @@ module ts { writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } - // Create a temporary variable with a unique unused name. The forLoopVariable parameter signals that the - // name should be one that is appropriate for a for loop variable. - function createTempVariable(location: Node, preferredName?: string): Identifier { - for (var name = preferredName; !name || isExistingName(location, name); tempCount++) { - // _a .. _h, _j ... _z, _0, _1, ... - - // Note: we avoid generating _i and _n as those are common names we want in other places. - var char = CharacterCodes.a + tempCount; - if (char === CharacterCodes.i || char === CharacterCodes.n) { - continue; - } - - if (tempCount < 26) { - name = "_" + String.fromCharCode(char); - } - else { - name = "_" + (tempCount - 26); - } - } - - // This is necessary so that a name generated via renameNonTopLevelLetAndConst will see the name - // we just generated. - recordNameInCurrentScope(name); - + // Create a temporary variable with a unique unused name. + function createTempVariable(location: Node, tempVariableKind = TempVariableKind.auto): Identifier { let result = createSynthesizedNode(SyntaxKind.Identifier); - result.text = name; + result.text = makeTempVariableName(location, tempVariableKind); return result; } @@ -615,8 +739,8 @@ module ts { tempVariables.push(name); } - function createAndRecordTempVariable(location: Node, preferredName?: string): Identifier { - let temp = createTempVariable(location, preferredName); + function createAndRecordTempVariable(location: Node, tempVariableKind?: TempVariableKind): Identifier { + let temp = createTempVariable(location, tempVariableKind); recordTempDeclaration(temp); return temp; @@ -1030,6 +1154,38 @@ module ts { emitLiteral(node); } else if (node.kind === SyntaxKind.ComputedPropertyName) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); + // + if (nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + + let generatedName = computedPropertyNamesToGeneratedNames[node.id]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + + let generatedVariable = createTempVariable(node); + generatedName = generatedVariable.text; + recordTempDeclaration(generatedVariable); + computedPropertyNamesToGeneratedNames[node.id] = generatedName; + write(generatedName); + write(" = "); + } + emit((node).expression); } else { @@ -1084,7 +1240,7 @@ module ts { } function emitExpressionIdentifier(node: Identifier) { - let substitution = resolver.getExpressionNameSubstitution(node); + let substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); if (substitution) { write(substitution); } @@ -1094,7 +1250,7 @@ module ts { } function getGeneratedNameForIdentifier(node: Identifier): string { - if (nodeIsSynthesized(node) || !generatedBlockScopeNames) { + if (nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { return undefined; } @@ -1103,7 +1259,7 @@ module ts { return undefined; } - return generatedBlockScopeNames[variableId]; + return blockScopedVariableToGeneratedName[variableId]; } function emitIdentifier(node: Identifier, allowGeneratedIdentifiers: boolean) { @@ -1331,7 +1487,7 @@ module ts { // manage by just emitting strings (which is a lot more performant). //let prefix = createIdentifier(resolver.getExpressionNamePrefix((property).name)); //return createPropertyAccessExpression(prefix, (property).name); - return createIdentifier(resolver.getExpressionNameSubstitution((property).name)); + return createIdentifier(resolver.getExpressionNameSubstitution((property).name, getGeneratedNameForNode)); case SyntaxKind.MethodDeclaration: return createFunctionExpression((property).parameters, (property).body); @@ -1504,7 +1660,7 @@ module ts { function emitComputedPropertyName(node: ComputedPropertyName) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } @@ -1545,7 +1701,7 @@ module ts { emitExpressionIdentifier(node.name); } } - else if (resolver.getExpressionNameSubstitution(node.name)) { + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { // Emit identifier as an identifier write(": "); // Even though this is stored as identifier treat it as an expression @@ -2078,10 +2234,10 @@ module ts { // // we don't want to emit a temporary variable for the RHS, just use it directly. let rhsIsIdentifier = node.expression.kind === SyntaxKind.Identifier; - let counter = createTempVariable(node, /*preferredName*/ "_i"); + let counter = createTempVariable(node, TempVariableKind._i); let rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node); - var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, /*preferredName:*/ "_n") : undefined; + var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, TempVariableKind._n) : undefined; // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. @@ -2322,7 +2478,7 @@ module ts { function emitContainingModuleName(node: Node) { let container = getContainingModule(node); - write(container ? resolver.getGeneratedNameForNode(container) : "exports"); + write(container ? getGeneratedNameForNode(container) : "exports"); } function emitModuleMemberName(node: Declaration) { @@ -2330,7 +2486,7 @@ module ts { if (getCombinedNodeFlags(node) & NodeFlags.Export) { var container = getContainingModule(node); if (container) { - write(resolver.getGeneratedNameForNode(container)); + write(getGeneratedNameForNode(container)); write("."); } else if (languageVersion < ScriptTarget.ES6) { @@ -2689,9 +2845,14 @@ module ts { // here it is known that node is a block scoped variable let list = getAncestor(node, SyntaxKind.VariableDeclarationList); - if (list.parent.kind === SyntaxKind.VariableStatement && list.parent.parent.kind === SyntaxKind.SourceFile) { - // do not rename variables that are defined on source file level - return; + if (list.parent.kind === SyntaxKind.VariableStatement) { + let isSourceFileLevelBinding = list.parent.parent.kind === SyntaxKind.SourceFile; + let isModuleLevelBinding = list.parent.parent.kind === SyntaxKind.ModuleBlock; + let isFunctionLevelBinding = + list.parent.parent.kind === SyntaxKind.Block && isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } } let blockScopeContainer = getEnclosingBlockScopeContainer(node); @@ -2699,12 +2860,19 @@ module ts { ? blockScopeContainer : blockScopeContainer.parent; - let generatedName = generateUniqueNameForLocation(parent, (node).text); - let variableId = resolver.getBlockScopedVariableId(node); - if (!generatedBlockScopeNames) { - generatedBlockScopeNames = []; + var hasConflictsInEnclosingScope = + resolver.resolvesToSomeValue(parent, (node).text) || + nameConflictsWithSomeTempVariable((node).text); + + if (hasConflictsInEnclosingScope) { + let variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + + let generatedName = makeUniqueName((node).text); + blockScopedVariableToGeneratedName[variableId] = generatedName; } - generatedBlockScopeNames[variableId] = generatedName; } function isES6ExportedDeclaration(node: Node) { @@ -2786,7 +2954,7 @@ module ts { if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) { let restIndex = node.parameters.length - 1; let restParam = node.parameters[restIndex]; - let tempName = createTempVariable(node, /*preferredName:*/ "_i").text; + let tempName = createTempVariable(node, TempVariableKind._i).text; writeLine(); emitLeadingComments(restParam); emitStart(restParam); @@ -2836,7 +3004,7 @@ module ts { emitNodeWithoutSourceMap(node.name); } else { - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); } } @@ -2922,11 +3090,12 @@ module ts { let saveTempCount = tempCount; let saveTempVariables = tempVariables; let saveTempParameters = tempParameters; + let savePredefinedTempsInUse = predefinedTempsInUse; + tempCount = 0; tempVariables = undefined; tempParameters = undefined; - - let popFrame = enterNameScope() + predefinedTempsInUse = TempVariableKind.auto; // When targeting ES6, emit arrow function natively in ES6 if (shouldEmitAsArrowFunction(node)) { @@ -2953,8 +3122,7 @@ module ts { emitExportMemberAssignment(node); } - exitNameScope(popFrame); - + predefinedTempsInUse = savePredefinedTempsInUse; tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; @@ -3155,10 +3323,7 @@ module ts { emitLeadingComments(member); emitStart(member); emitStart((member).name); - emitDeclarationName(node); - if (!(member.flags & NodeFlags.Static)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); emitMemberAccessForPropertyName((member).name); emitEnd((member).name); write(" = "); @@ -3176,10 +3341,7 @@ module ts { emitStart(member); write("Object.defineProperty("); emitStart((member).name); - emitDeclarationName(node); - if (!(member.flags & NodeFlags.Static)) { - write(".prototype"); - } + emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName((member).name); emitEnd((member).name); @@ -3251,11 +3413,12 @@ module ts { let saveTempCount = tempCount; let saveTempVariables = tempVariables; let saveTempParameters = tempParameters; + let savePredefinedTempsInUse = predefinedTempsInUse; tempCount = 0; tempVariables = undefined; tempParameters = undefined; + predefinedTempsInUse = TempVariableKind.auto; - let popFrame = enterNameScope(); // Check if we have property assignment inside class declaration. // If there is property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it @@ -3364,32 +3527,105 @@ module ts { emitTrailingComments(ctor); } - exitNameScope(popFrame); - + predefinedTempsInUse = savePredefinedTempsInUse; tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; } + function emitClassDeclaration(node: ClassDeclaration) { + if (languageVersion < ScriptTarget.ES6) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { - if (isES6ExportedDeclaration(node)) { - write("export "); + let thisNodeIsDecorated = nodeIsDecorated(node); + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & NodeFlags.Default)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); if (node.flags & NodeFlags.Default) { write("default "); } } - write("class "); - // check if this is an "export default class" as it may not have a name - if (node.name || !(node.flags & NodeFlags.Default)) { + write("class"); + + // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. + if ((node.name || !(node.flags & NodeFlags.Default)) && !thisNodeIsDecorated) { + write(" "); emitDeclarationName(node); } + var baseTypeNode = getClassBaseTypeNode(node); if (baseTypeNode) { write(" extends "); emit(baseTypeNode.typeName); } + write(" {"); increaseIndent(); scopeEmitStart(node); @@ -3401,6 +3637,26 @@ module ts { emitToken(SyntaxKind.CloseBraceToken, node.members.end); scopeEmitEnd(); + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration // From ES6 specification: @@ -3408,6 +3664,7 @@ module ts { // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. writeLine(); emitMemberAssignments(node, NodeFlags.Static); + emitDecoratorsOfClass(node); // If this is an exported class, but not on the top level (i.e. on an internal // module), export it @@ -3420,6 +3677,13 @@ module ts { emitEnd(node); write(";"); } + else if (isES6ExportedDeclaration(node) && (node.flags & NodeFlags.Default) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } } function emitClassDeclarationBelowES6(node: ClassDeclaration) { @@ -3431,6 +3695,14 @@ module ts { write("_super"); } write(") {"); + let saveTempCount = tempCount; + let saveTempVariables = tempVariables; + let saveTempParameters = tempParameters; + let saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; increaseIndent(); scopeEmitStart(node); if (baseTypeNode) { @@ -3446,11 +3718,18 @@ module ts { emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, NodeFlags.Static); writeLine(); + emitDecoratorsOfClass(node); + writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => { write("return "); emitDeclarationName(node); }); write(";"); + emitTempDeclarations(/*newLine*/ true); + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end); @@ -3470,6 +3749,225 @@ module ts { } } + function emitClassMemberPrefix(node: ClassDeclaration, member: Node) { + emitDeclarationName(node); + if (!(member.flags & NodeFlags.Static)) { + write(".prototype"); + } + } + + function emitDecoratorsOfClass(node: ClassDeclaration) { + if (languageVersion < ScriptTarget.ES5) { + return; + } + + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); + emitDecoratorsOfMembers(node, NodeFlags.Static); + emitDecoratorsOfConstructor(node); + } + + function emitDecoratorsOfConstructor(node: ClassDeclaration) { + let constructor = getFirstConstructorWithBody(node); + if (constructor) { + emitDecoratorsOfParameters(node, constructor); + } + + if (!nodeIsDecorated(node)) { + return; + } + + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = "); + emitDecorateStart(node.decorators); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + + function emitDecoratorsOfMembers(node: ClassDeclaration, staticFlag: NodeFlags) { + forEach(node.members, member => { + if ((member.flags & NodeFlags.Static) !== staticFlag) { + return; + } + + let decorators: NodeArray; + switch (member.kind) { + case SyntaxKind.MethodDeclaration: + // emit decorators of the method's parameters + emitDecoratorsOfParameters(node, member); + decorators = member.decorators; + break; + + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + let accessors = getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + // skip the second accessor as we processed it with the first. + return; + } + + if (accessors.setAccessor) { + // emit decorators of the set accessor parameter + emitDecoratorsOfParameters(node, accessors.setAccessor); + } + + // get the decorators from the first decorated accessor. + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + break; + + case SyntaxKind.PropertyDeclaration: + decorators = member.decorators; + break; + + default: + // Constructor cannot be decorated, and its parameters are handled in emitDecoratorsOfConstructor + // Other members (i.e. IndexSignature) cannot be decorated. + return; + } + + if (!decorators) { + return; + } + + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method() {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + // + // The emit for an accessor is: + // + // Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + // + // The emit for a property is: + // + // __decorate([dec], C.prototype, "prop"); + // + + writeLine(); + emitStart(member); + if (member.kind !== SyntaxKind.PropertyDeclaration) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", "); + } + + emitDecorateStart(decorators); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + + if (member.kind !== SyntaxKind.PropertyDeclaration) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + } + + write(");"); + emitEnd(member); + writeLine(); + }); + } + + function emitDecoratorsOfParameters(node: ClassDeclaration, member: FunctionLikeDeclaration) { + forEach(member.parameters, (parameter, parameterIndex) => { + if (!nodeIsDecorated(parameter)) { + return; + } + + // Emit the decorators for a parameter. Given the following: + // + // class C { + // constructor(@dec p) { } + // method(@dec p) { } + // set accessor(@dec value) { } + // } + // + // The emit for a constructor is: + // + // __decorate([dec], C, void 0, 0); + // + // The emit for a parameter is: + // + // __decorate([dec], C.prototype, "method", 0); + // + // The emit for an accessor is: + // + // __decorate([dec], C.prototype, "accessor", 0); + // + + writeLine(); + emitStart(parameter); + emitDecorateStart(parameter.decorators); + emitStart(parameter.name); + + if (member.kind === SyntaxKind.Constructor) { + emitDeclarationName(node); + write(", void 0"); + } + else { + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + } + + write(", "); + write(String(parameterIndex)); + emitEnd(parameter.name); + write(");"); + emitEnd(parameter); + writeLine(); + }); + } + + function emitDecorateStart(decorators: Decorator[]): void { + write("__decorate(["); + let decoratorCount = decorators.length; + for (let i = 0; i < decoratorCount; i++) { + if (i > 0) { + write(", "); + } + let decorator = decorators[i]; + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + } + write("], "); + } + function emitInterfaceDeclaration(node: InterfaceDeclaration) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -3499,7 +3997,7 @@ module ts { emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") {"); increaseIndent(); @@ -3533,9 +4031,9 @@ module ts { function emitEnumMember(node: EnumMember) { let enumParent = node.parent; emitStart(node); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); - write(resolver.getGeneratedNameForNode(enumParent)); + write(getGeneratedNameForNode(enumParent)); write("["); emitExpressionForPropertyName(node.name); write("] = "); @@ -3591,19 +4089,20 @@ module ts { emitStart(node); write("(function ("); emitStart(node.name); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); if (node.body.kind === SyntaxKind.ModuleBlock) { let saveTempCount = tempCount; let saveTempVariables = tempVariables; + let savePredefinedTempsInUse = predefinedTempsInUse; tempCount = 0; tempVariables = undefined; - let popFrame = enterNameScope(); + predefinedTempsInUse = TempVariableKind.auto; emit(node.body); - exitNameScope(popFrame); + predefinedTempsInUse = savePredefinedTempsInUse; tempCount = saveTempCount; tempVariables = saveTempVariables; } @@ -3741,7 +4240,7 @@ module ts { let isNakedImport = SyntaxKind.ImportDeclaration && !(node).importClause; if (!isNakedImport) { write("var "); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); write(" = "); } } @@ -3751,7 +4250,7 @@ module ts { write(", "); emitModuleMemberName(namespaceDeclaration); write(" = "); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); } write(";"); emitEnd(node); @@ -3770,7 +4269,7 @@ module ts { write("var "); emitModuleMemberName(namespaceDeclaration); write(" = "); - write(resolver.getGeneratedNameForNode(node)); + write(getGeneratedNameForNode(node)); write(";"); } emitExportImportAssignments(node); @@ -3811,7 +4310,7 @@ module ts { if (languageVersion < ScriptTarget.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); - let generatedName = resolver.getGeneratedNameForNode(node); + let generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" if (compilerOptions.module !== ModuleKind.AMD) { @@ -4033,7 +4532,7 @@ module ts { emit(namespaceDeclaration.name); } else { - write(resolver.getGeneratedNameForNode(importNode)); + write(getGeneratedNameForNode(importNode)); } } for (let amdDependency of node.amdDependencies) { @@ -4102,6 +4601,17 @@ module ts { return statements.length; } + function writeHelper(text: string): void { + let lines = text.split(/\r\n|\r|\n/g); + for (let i = 0; i < lines.length; ++i) { + let line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitSourceFileNode(node: SourceFile) { // Start new file on new line writeLine(); @@ -4128,6 +4638,23 @@ module ts { write("};"); extendsEmitted = true; } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) { + writeHelper(` +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +};`); + decorateEmitted = true; + } if (isExternalModule(node)) { if (languageVersion >= ScriptTarget.ES6) { emitES6Module(node, startIndex); @@ -4347,7 +4874,7 @@ module ts { case SyntaxKind.VariableDeclaration: return emitVariableDeclaration(node); case SyntaxKind.ClassDeclaration: - return languageVersion < ScriptTarget.ES6 ? emitClassDeclarationBelowES6(node) : emitClassDeclarationForES6AndHigher(node); + return emitClassDeclaration(node); case SyntaxKind.InterfaceDeclaration: return emitInterfaceDeclaration(node); case SyntaxKind.EnumDeclaration: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ea767b258a51f..14311ccbc52bc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -64,7 +64,8 @@ module ts { case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).propertyName) || visitNode(cbNode, (node).dotDotDotToken) || visitNode(cbNode, (node).name) || @@ -76,7 +77,8 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, (node).typeParameters) || visitNodes(cbNodes, (node).parameters) || visitNode(cbNode, (node).type); @@ -88,7 +90,8 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).asteriskToken) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).questionToken) || @@ -171,7 +174,8 @@ module ts { return visitNodes(cbNodes, (node).statements) || visitNode(cbNode, (node).endOfFileToken); case SyntaxKind.VariableStatement: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).declarationList); case SyntaxKind.VariableDeclarationList: return visitNodes(cbNodes, (node).declarations); @@ -230,39 +234,48 @@ module ts { case SyntaxKind.CatchClause: return visitNode(cbNode, (node).variableDeclaration) || visitNode(cbNode, (node).block); + case SyntaxKind.Decorator: + return visitNode(cbNode, (node).expression); case SyntaxKind.ClassDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNodes(cbNodes, (node).typeParameters) || visitNodes(cbNodes, (node).heritageClauses) || visitNodes(cbNodes, (node).members); case SyntaxKind.InterfaceDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNodes(cbNodes, (node).typeParameters) || visitNodes(cbNodes, (node).heritageClauses) || visitNodes(cbNodes, (node).members); case SyntaxKind.TypeAliasDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).type); case SyntaxKind.EnumDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNodes(cbNodes, (node).members); case SyntaxKind.EnumMember: return visitNode(cbNode, (node).name) || visitNode(cbNode, (node).initializer); case SyntaxKind.ModuleDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).body); case SyntaxKind.ImportEqualsDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).moduleReference); case SyntaxKind.ImportDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).importClause) || visitNode(cbNode, (node).moduleSpecifier); case SyntaxKind.ImportClause: @@ -274,7 +287,8 @@ module ts { case SyntaxKind.NamedExports: return visitNodes(cbNodes, (node).elements); case SyntaxKind.ExportDeclaration: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).exportClause) || visitNode(cbNode, (node).moduleSpecifier); case SyntaxKind.ImportSpecifier: @@ -282,7 +296,8 @@ module ts { return visitNode(cbNode, (node).propertyName) || visitNode(cbNode, (node).name); case SyntaxKind.ExportAssignment: - return visitNodes(cbNodes, node.modifiers) || + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, (node).expression) || visitNode(cbNode, (node).type); case SyntaxKind.TemplateExpression: @@ -295,6 +310,8 @@ module ts { return visitNodes(cbNodes, (node).types); case SyntaxKind.ExternalModuleReference: return visitNode(cbNode, (node).expression); + case SyntaxKind.MissingDeclaration: + return visitNodes(cbNodes, node.decorators); } } @@ -987,6 +1004,8 @@ module ts { } function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile { + const disallowInAndDecoratorContext = ParserContextFlags.DisallowIn | ParserContextFlags.Decorator; + let parsingContext: ParsingContext = 0; let identifiers: Map = {}; let identifierCount = 0; @@ -1130,6 +1149,23 @@ module ts { setContextFlag(val, ParserContextFlags.GeneratorParameter); } + function setDecoratorContext(val: boolean) { + setContextFlag(val, ParserContextFlags.Decorator); + } + + function doOutsideOfContext(flags: ParserContextFlags, func: () => T): T { + let currentContextFlags = contextFlags & flags; + if (currentContextFlags) { + setContextFlag(false, currentContextFlags); + let result = func(); + setContextFlag(true, currentContextFlags); + return result; + } + + // no need to do anything special as we are not in any of the requested contexts + return func(); + } + function allowInAnd(func: () => T): T { if (contextFlags & ParserContextFlags.DisallowIn) { setDisallowInContext(false); @@ -1178,6 +1214,18 @@ module ts { return func(); } + function doInDecoratorContext(func: () => T): T { + if (contextFlags & ParserContextFlags.Decorator) { + // no need to do anything special if we're already in the [Decorator] context. + return func(); + } + + setDecoratorContext(true); + let result = func(); + setDecoratorContext(false); + return result; + } + function inYieldContext() { return (contextFlags & ParserContextFlags.Yield) !== 0; } @@ -1194,6 +1242,10 @@ module ts { return (contextFlags & ParserContextFlags.DisallowIn) !== 0; } + function inDecoratorContext() { + return (contextFlags & ParserContextFlags.Decorator) !== 0; + } + function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { let start = scanner.getTokenPos(); let length = scanner.getTextPos() - start; @@ -1403,7 +1455,7 @@ module ts { return node; } - + function createMissingNode(kind: SyntaxKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Node { if (reportAtCurrentPosition) { parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); @@ -2273,7 +2325,7 @@ module ts { } function isStartOfParameter(): boolean { - return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifier(token); + return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifier(token) || token === SyntaxKind.AtToken; } function setModifiers(node: Node, modifiers: ModifiersArray) { @@ -2285,6 +2337,7 @@ module ts { function parseParameter(): ParameterDeclaration { let node = createNode(SyntaxKind.Parameter); + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); @@ -2473,9 +2526,9 @@ module ts { return token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBracketToken; } - function parseIndexSignatureDeclaration(modifiers: ModifiersArray): IndexSignatureDeclaration { - let fullStart = modifiers ? modifiers.pos : scanner.getStartPos(); + function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): IndexSignatureDeclaration { let node = createNode(SyntaxKind.IndexSignature, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); @@ -2552,7 +2605,7 @@ module ts { case SyntaxKind.OpenBracketToken: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(/*modifiers:*/ undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined) : parsePropertyOrMethodSignature(); case SyntaxKind.NewKeyword: if (lookAhead(isStartOfConstructSignature)) { @@ -2583,9 +2636,11 @@ module ts { } function parseIndexSignatureWithModifiers() { + let fullStart = scanner.getStartPos(); + let decorators = parseDecorators(); let modifiers = parseModifiers(); return isIndexSignature() - ? parseIndexSignatureDeclaration(modifiers) + ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) : undefined; } @@ -2841,7 +2896,7 @@ module ts { function isStartOfExpressionStatement(): boolean { // As per the grammar, neither '{' nor 'function' can start an expression statement. - return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && isStartOfExpression(); + return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && token !== SyntaxKind.AtToken && isStartOfExpression(); } function parseExpression(): Expression { @@ -2849,11 +2904,21 @@ module ts { // AssignmentExpression[in] // Expression[in] , AssignmentExpression[in] + // clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator + let saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + let expr = parseAssignmentExpressionOrHigher(); let operatorToken: Node; while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + + if (saveDecoratorContext) { + setDecoratorContext(true); + } return expr; } @@ -3209,7 +3274,7 @@ module ts { let node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition:*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)); node.whenFalse = parseAssignmentExpressionOrHigher(); @@ -3500,7 +3565,8 @@ module ts { continue; } - if (parseOptional(SyntaxKind.OpenBracketToken)) { + // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName + if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) { let indexedAccess = createNode(SyntaxKind.ElementAccessExpression, expression.pos); indexedAccess.expression = expression; @@ -3536,7 +3602,6 @@ module ts { function parseCallExpressionRest(expression: LeftHandSideExpression): LeftHandSideExpression { while (true) { expression = parseMemberExpressionRest(expression); - if (token === SyntaxKind.LessThanToken) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's @@ -3683,7 +3748,7 @@ module ts { } function parseArgumentExpression(): Expression { - return allowInAnd(parseArgumentOrArrayLiteralElement); + return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression(): ArrayLiteralExpression { @@ -3695,12 +3760,12 @@ module ts { return finishNode(node); } - function tryParseAccessorDeclaration(fullStart: number, modifiers: ModifiersArray): AccessorDeclaration { + function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): AccessorDeclaration { if (parseContextualModifier(SyntaxKind.GetKeyword)) { - return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, modifiers); + return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers); } else if (parseContextualModifier(SyntaxKind.SetKeyword)) { - return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, modifiers); + return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers); } return undefined; @@ -3708,9 +3773,10 @@ module ts { function parseObjectLiteralElement(): ObjectLiteralElement { let fullStart = scanner.getStartPos(); + let decorators = parseDecorators(); let modifiers = parseModifiers(); - let accessor = tryParseAccessorDeclaration(fullStart, modifiers); + let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } @@ -3723,7 +3789,7 @@ module ts { // Disallowing of optional property assignments happens in the grammar checker. let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment @@ -3760,12 +3826,19 @@ module ts { // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } // FunctionExpression: // function BindingIdentifieropt(FormalParameters) { FunctionBody } + let saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } let node = createNode(SyntaxKind.FunctionExpression); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ !!node.asteriskToken, /*requireCompleteParameterList:*/ false, node); node.body = parseFunctionBlock(/*allowYield:*/ !!node.asteriskToken, /* ignoreMissingOpenBrace */ false); + if (saveDecoratorContext) { + setDecoratorContext(true); + } return finishNode(node); } @@ -3802,8 +3875,19 @@ module ts { let savedYieldContext = inYieldContext(); setYieldContext(allowYield); + // We may be in a [Decorator] context when parsing a function expression or + // arrow function. The body of the function is not in [Decorator] context. + let saveDecoratorContext = inDecoratorContext(); + if (saveDecoratorContext) { + setDecoratorContext(false); + } + let block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true, diagnosticMessage); + if (saveDecoratorContext) { + setDecoratorContext(true); + } + setYieldContext(savedYieldContext); return block; @@ -4051,7 +4135,7 @@ module ts { // as the parser will produce the same FunctionDeclaraiton or VariableStatement if it has // the same text regardless of whether it is inside a block or not. if (isModifier(token)) { - let result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers); + let result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return true; } @@ -4135,9 +4219,9 @@ module ts { case SyntaxKind.VarKeyword: case SyntaxKind.ConstKeyword: // const here should always be parsed as const declaration because of check in 'isStatement' - return parseVariableStatement(scanner.getStartPos(), /*modifiers:*/ undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined); case SyntaxKind.FunctionKeyword: - return parseFunctionDeclaration(scanner.getStartPos(), /*modifiers:*/ undefined); + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined); case SyntaxKind.SemicolonToken: return parseEmptyStatement(); case SyntaxKind.IfKeyword: @@ -4170,7 +4254,7 @@ module ts { case SyntaxKind.LetKeyword: // If let follows identifier on the same line, it is declaration parse it as variable statement if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), /*modifiers:*/ undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined); } // Else parse it like identifier - fall through default: @@ -4180,8 +4264,10 @@ module ts { // work properly when incrementally parsing as the parser will produce the // same FunctionDeclaraiton or VariableStatement if it has the same text // regardless of whether it is inside a block or not. - if (isModifier(token)) { - let result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers); + // Even though variable statements and function declarations cannot have decorators, + // we parse them here to provide better error recovery. + if (isModifier(token) || token === SyntaxKind.AtToken) { + let result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers); if (result) { return result; } @@ -4191,8 +4277,9 @@ module ts { } } - function parseVariableStatementOrFunctionDeclarationWithModifiers(): FunctionDeclaration | VariableStatement { + function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers(): FunctionDeclaration | VariableStatement { let start = scanner.getStartPos(); + let decorators = parseDecorators(); let modifiers = parseModifiers(); switch (token) { case SyntaxKind.ConstKeyword: @@ -4200,18 +4287,18 @@ module ts { if (nextTokenIsEnum) { return undefined; } - return parseVariableStatement(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); case SyntaxKind.LetKeyword: if (!isLetDeclaration()) { return undefined; } - return parseVariableStatement(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); case SyntaxKind.VarKeyword: - return parseVariableStatement(start, modifiers); + return parseVariableStatement(start, decorators, modifiers); case SyntaxKind.FunctionKeyword: - return parseFunctionDeclaration(start, modifiers); + return parseFunctionDeclaration(start, decorators, modifiers); } return undefined; @@ -4341,16 +4428,18 @@ module ts { return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken; } - function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement { + function parseVariableStatement(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): VariableStatement { let node = createNode(SyntaxKind.VariableStatement, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer:*/ false); parseSemicolon(); return finishNode(node); } - function parseFunctionDeclaration(fullStart: number, modifiers: ModifiersArray): FunctionDeclaration { + function parseFunctionDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): FunctionDeclaration { let node = createNode(SyntaxKind.FunctionDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); @@ -4360,8 +4449,9 @@ module ts { return finishNode(node); } - function parseConstructorDeclaration(pos: number, modifiers: ModifiersArray): ConstructorDeclaration { + function parseConstructorDeclaration(pos: number, decorators: NodeArray, modifiers: ModifiersArray): ConstructorDeclaration { let node = createNode(SyntaxKind.Constructor, pos); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); @@ -4369,8 +4459,9 @@ module ts { return finishNode(node); } - function parseMethodDeclaration(fullStart: number, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { + function parseMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { let method = createNode(SyntaxKind.MethodDeclaration, fullStart); + method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; @@ -4380,25 +4471,30 @@ module ts { return finishNode(method); } - function parsePropertyOrMethodDeclaration(fullStart: number, modifiers: ModifiersArray): ClassElement { + function parsePropertyDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, name: DeclarationName, questionToken: Node): ClassElement { + let property = createNode(SyntaxKind.PropertyDeclaration, fullStart); + property.decorators = decorators; + setModifiers(property, modifiers); + property.name = name; + property.questionToken = questionToken; + property.type = parseTypeAnnotation(); + property.initializer = allowInAnd(parseNonParameterInitializer); + parseSemicolon(); + return finishNode(property); + } + + function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassElement { let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); let name = parsePropertyName(); - + // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected); + return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected); } else { - let property = createNode(SyntaxKind.PropertyDeclaration, fullStart); - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); } } @@ -4406,8 +4502,9 @@ module ts { return parseInitializer(/*inParameter*/ false); } - function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, modifiers: ModifiersArray): AccessorDeclaration { + function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): AccessorDeclaration { let node = createNode(kind, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node); @@ -4418,6 +4515,10 @@ module ts { function isClassMemberStart(): boolean { let idToken: SyntaxKind; + if (token === SyntaxKind.AtToken) { + return true; + } + // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. while (isModifier(token)) { idToken = token; @@ -4469,6 +4570,29 @@ module ts { return false; } + function parseDecorators(): NodeArray { + let decorators: NodeArray; + while (true) { + let decoratorStart = getNodePos(); + if (!parseOptional(SyntaxKind.AtToken)) { + break; + } + + if (!decorators) { + decorators = >[]; + decorators.pos = scanner.getStartPos(); + } + + let decorator = createNode(SyntaxKind.Decorator, decoratorStart); + decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + decorators.push(finishNode(decorator)); + } + if (decorators) { + decorators.end = getNodeEnd(); + } + return decorators; + } + function parseModifiers(): ModifiersArray { let flags = 0; let modifiers: ModifiersArray; @@ -4496,19 +4620,20 @@ module ts { function parseClassElement(): ClassElement { let fullStart = getNodePos(); + let decorators = parseDecorators(); let modifiers = parseModifiers(); - let accessor = tryParseAccessorDeclaration(fullStart, modifiers); + let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { return accessor; } if (token === SyntaxKind.ConstructorKeyword) { - return parseConstructorDeclaration(fullStart, modifiers); + return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(modifiers); + return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } // It is very important that we check this *after* checking indexers because @@ -4519,14 +4644,20 @@ module ts { token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBracketToken) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); + return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + } + + if (decorators) { + // treat this as a property declaration with a missing name. + let name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. Debug.fail("Should not have attempted to parse class member declaration."); } - function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration { + function parseClassDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassDeclaration { // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code let savedStrictModeContext = inStrictModeContext(); if (languageVersion >= ScriptTarget.ES6) { @@ -4534,6 +4665,7 @@ module ts { } var node = createNode(SyntaxKind.ClassDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); @@ -4597,8 +4729,9 @@ module ts { return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassElement); } - function parseInterfaceDeclaration(fullStart: number, modifiers: ModifiersArray): InterfaceDeclaration { + function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): InterfaceDeclaration { let node = createNode(SyntaxKind.InterfaceDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.InterfaceKeyword); node.name = parseIdentifier(); @@ -4608,8 +4741,9 @@ module ts { return finishNode(node); } - function parseTypeAliasDeclaration(fullStart: number, modifiers: ModifiersArray): TypeAliasDeclaration { + function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): TypeAliasDeclaration { let node = createNode(SyntaxKind.TypeAliasDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.TypeKeyword); node.name = parseIdentifier(); @@ -4630,8 +4764,9 @@ module ts { return finishNode(node); } - function parseEnumDeclaration(fullStart: number, modifiers: ModifiersArray): EnumDeclaration { + function parseEnumDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): EnumDeclaration { let node = createNode(SyntaxKind.EnumDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.EnumKeyword); node.name = parseIdentifier(); @@ -4657,30 +4792,32 @@ module ts { return finishNode(node); } - function parseInternalModuleTail(fullStart: number, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { + function parseInternalModuleTail(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) - ? parseInternalModuleTail(getNodePos(), /*modifiers:*/undefined, NodeFlags.Export) + ? parseInternalModuleTail(getNodePos(), /*decorators*/ undefined, /*modifiers:*/undefined, NodeFlags.Export) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart: number, modifiers: ModifiersArray): ModuleDeclaration { + function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ModuleDeclaration { let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(/*internName:*/ true); node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart: number, modifiers: ModifiersArray): ModuleDeclaration { + function parseModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ModuleDeclaration { parseExpected(SyntaxKind.ModuleKeyword); return token === SyntaxKind.StringLiteral - ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + ? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) + : parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { @@ -4698,7 +4835,7 @@ module ts { token === SyntaxKind.FromKeyword; } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration { + function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration { parseExpected(SyntaxKind.ImportKeyword); let afterImportPos = scanner.getStartPos(); @@ -4710,6 +4847,7 @@ module ts { // import x = require("mod"); or // import x = M.x; let importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); + importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; parseExpected(SyntaxKind.EqualsToken); @@ -4721,6 +4859,7 @@ module ts { // Import statement let importDeclaration = createNode(SyntaxKind.ImportDeclaration, fullStart); + importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -4856,8 +4995,9 @@ module ts { return finishNode(node); } - function parseExportDeclaration(fullStart: number, modifiers: ModifiersArray): ExportDeclaration { + function parseExportDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ExportDeclaration { let node = createNode(SyntaxKind.ExportDeclaration, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(SyntaxKind.AsteriskToken)) { parseExpected(SyntaxKind.FromKeyword); @@ -4873,8 +5013,9 @@ module ts { return finishNode(node); } - function parseExportAssignment(fullStart: number, modifiers: ModifiersArray): ExportAssignment { + function parseExportAssignment(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ExportAssignment { let node = createNode(SyntaxKind.ExportAssignment, fullStart); + node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(SyntaxKind.EqualsToken)) { node.isExportEquals = true; @@ -4899,7 +5040,7 @@ module ts { return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); } - function isDeclarationStart(): boolean { + function isDeclarationStart(followsModifier?: boolean): boolean { switch (token) { case SyntaxKind.VarKeyword: case SyntaxKind.ConstKeyword: @@ -4929,6 +5070,10 @@ module ts { case SyntaxKind.StaticKeyword: // Check for modifier on source element return lookAhead(nextTokenIsDeclarationStart); + case SyntaxKind.AtToken: + // a lookahead here is too costly, and decorators are only valid on a declaration. + // We will assume we are parsing a declaration here and report an error later + return !followsModifier; } } @@ -4955,12 +5100,12 @@ module ts { function nextTokenCanFollowExportKeyword() { nextToken(); return token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken || - token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword || isDeclarationStart(); + token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword || isDeclarationStart(/*followsModifier*/ true); } function nextTokenIsDeclarationStart() { nextToken(); - return isDeclarationStart(); + return isDeclarationStart(/*followsModifier*/ true); } function nextTokenIsAsKeyword() { @@ -4969,14 +5114,15 @@ module ts { function parseDeclaration(): ModuleElement { let fullStart = getNodePos(); + let decorators = parseDecorators(); let modifiers = parseModifiers(); if (token === SyntaxKind.ExportKeyword) { nextToken(); if (token === SyntaxKind.DefaultKeyword || token === SyntaxKind.EqualsToken) { - return parseExportAssignment(fullStart, modifiers); + return parseExportAssignment(fullStart, decorators, modifiers); } if (token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBraceToken) { - return parseExportDeclaration(fullStart, modifiers); + return parseExportDeclaration(fullStart, decorators, modifiers); } } @@ -4984,22 +5130,31 @@ module ts { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: - return parseVariableStatement(fullStart, modifiers); + return parseVariableStatement(fullStart, decorators, modifiers); case SyntaxKind.FunctionKeyword: - return parseFunctionDeclaration(fullStart, modifiers); + return parseFunctionDeclaration(fullStart, decorators, modifiers); case SyntaxKind.ClassKeyword: - return parseClassDeclaration(fullStart, modifiers); + return parseClassDeclaration(fullStart, decorators, modifiers); case SyntaxKind.InterfaceKeyword: - return parseInterfaceDeclaration(fullStart, modifiers); + return parseInterfaceDeclaration(fullStart, decorators, modifiers); case SyntaxKind.TypeKeyword: - return parseTypeAliasDeclaration(fullStart, modifiers); + return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case SyntaxKind.EnumKeyword: - return parseEnumDeclaration(fullStart, modifiers); + return parseEnumDeclaration(fullStart, decorators, modifiers); case SyntaxKind.ModuleKeyword: - return parseModuleDeclaration(fullStart, modifiers); + return parseModuleDeclaration(fullStart, decorators, modifiers); case SyntaxKind.ImportKeyword: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers); + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); default: + if (decorators) { + // We reached this point because we encountered an AtToken and assumed a declaration would + // follow. For recovery and error reporting purposes, return an incomplete declaration. + let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + node.pos = fullStart; + node.decorators = decorators; + setModifiers(node, modifiers); + return finishNode(node); + } Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 9e5e65db935f2..3a208698c25f4 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -148,6 +148,7 @@ module ts { "&=": SyntaxKind.AmpersandEqualsToken, "|=": SyntaxKind.BarEqualsToken, "^=": SyntaxKind.CaretEqualsToken, + "@": SyntaxKind.AtToken, }; /* @@ -256,6 +257,11 @@ module ts { return tokenStrings[t]; } + /* @internal */ + export function stringToToken(s: string): SyntaxKind { + return textToToken[s]; + } + export function computeLineStarts(text: string): number[] { let result: number[] = new Array(); let pos = 0; @@ -1279,6 +1285,8 @@ module ts { return pos++, token = SyntaxKind.CloseBraceToken; case CharacterCodes.tilde: return pos++, token = SyntaxKind.TildeToken; + case CharacterCodes.at: + return pos++, token = SyntaxKind.AtToken; case CharacterCodes.backslash: let cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 63db8e6be0a81..e5697f9f37239 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -67,6 +67,7 @@ module ts { BarBarToken, QuestionToken, ColonToken, + AtToken, // Assignments EqualsToken, PlusEqualsToken, @@ -154,6 +155,7 @@ module ts { // Signature elements TypeParameter, Parameter, + Decorator, // TypeMember PropertySignature, PropertyDeclaration, @@ -244,6 +246,7 @@ module ts { ExportDeclaration, NamedExports, ExportSpecifier, + MissingDeclaration, // Module references ExternalModuleReference, @@ -328,22 +331,25 @@ module ts { // If this node was parsed in the parameters of a generator. GeneratorParameter = 1 << 3, + // If this node was parsed as part of a decorator + Decorator = 1 << 4, + // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ThisNodeHasError = 1 << 4, + ThisNodeHasError = 1 << 5, // Context flags set directly by the parser. - ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | ThisNodeHasError, + ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ThisNodeOrAnySubNodesHasError = 1 << 5, + ThisNodeOrAnySubNodesHasError = 1 << 6, // Used to know if we've computed data from children and cached it in this node. - HasAggregatedChildData = 1 << 6 + HasAggregatedChildData = 1 << 7 } export const enum RelationComparisonResult { @@ -358,13 +364,14 @@ module ts { // Specific context the parser was in when this node was created. Normally undefined. // Only set when the parser was in some interesting context (like async/yield). parserContextFlags?: ParserContextFlags; - modifiers?: ModifiersArray; // Array of modifiers - id?: number; // Unique id (used to look up NodeLinks) - parent?: Node; // Parent node (initialized by binding) - symbol?: Symbol; // Symbol declared by node (initialized by binding) - locals?: SymbolTable; // Locals associated with node (initialized by binding) - nextContainer?: Node; // Next container in declaration order (initialized by binding) - localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes) + decorators?: NodeArray; // Array of decorators (in document order) + modifiers?: ModifiersArray; // Array of modifiers + id?: number; // Unique id (used to look up NodeLinks) + parent?: Node; // Parent node (initialized by binding) + symbol?: Symbol; // Symbol declared by node (initialized by binding) + locals?: SymbolTable; // Locals associated with node (initialized by binding) + nextContainer?: Node; // Next container in declaration order (initialized by binding) + localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes) } export interface NodeArray extends Array, TextRange { @@ -398,6 +405,10 @@ module ts { expression: Expression; } + export interface Decorator extends Node { + expression: LeftHandSideExpression; + } + export interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -1093,6 +1104,9 @@ module ts { getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getReturnTypeOfSignature(signature: Signature): Type; + + // If 'predicate' is supplied, then only the first symbol in scope matching the predicate + // will be returned. Otherwise, all symbols in scope will be returned. getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; getShorthandAssignmentValueSymbol(location: Node): Symbol; @@ -1204,8 +1218,8 @@ module ts { } export interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; @@ -1220,7 +1234,7 @@ module ts { isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } @@ -1335,17 +1349,18 @@ module ts { } export const enum NodeCheckFlags { - TypeChecked = 0x00000001, // Node has been type checked - LexicalThis = 0x00000002, // Lexical 'this' reference - CaptureThis = 0x00000004, // Lexical 'this' used in body - EmitExtends = 0x00000008, // Emit __extends - SuperInstance = 0x00000010, // Instance 'super' reference - SuperStatic = 0x00000020, // Static 'super' reference - ContextChecked = 0x00000040, // Contextual types have been assigned + TypeChecked = 0x00000001, // Node has been type checked + LexicalThis = 0x00000002, // Lexical 'this' reference + CaptureThis = 0x00000004, // Lexical 'this' used in body + EmitExtends = 0x00000008, // Emit __extends + SuperInstance = 0x00000010, // Instance 'super' reference + SuperStatic = 0x00000020, // Static 'super' reference + ContextChecked = 0x00000040, // Contextual types have been assigned // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00000080, - BlockScopedBindingInLoop = 0x00000100, + EnumValuesComputed = 0x00000080, + BlockScopedBindingInLoop = 0x00000100, + EmitDecorate = 0x00000200, // Emit __decorate } export interface NodeLinks { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5e72529a48027..9fa0674c25c07 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// module ts { export interface ReferencePathMatchResult { @@ -575,6 +575,83 @@ module ts { return (node).expression; } + export function nodeCanBeDecorated(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + // classes are valid targets + return true; + + case SyntaxKind.PropertyDeclaration: + // property declarations are valid if their parent is a class declaration. + return node.parent.kind === SyntaxKind.ClassDeclaration; + + case SyntaxKind.Parameter: + // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; + return (node.parent).body && node.parent.parent.kind === SyntaxKind.ClassDeclaration; + + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodDeclaration: + // if this method has a body and its parent is a class declaration, this is a valid target. + return (node).body && node.parent.kind === SyntaxKind.ClassDeclaration; + } + + return false; + } + + export function nodeIsDecorated(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + if (node.decorators) { + return true; + } + + return false; + + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.Parameter: + if (node.decorators) { + return true; + } + + return false; + + case SyntaxKind.GetAccessor: + if ((node).body && node.decorators) { + return true; + } + + return false; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.SetAccessor: + if ((node).body && node.decorators) { + return true; + } + + return false; + } + + return false; + } + + export function childIsDecorated(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + return forEach((node).members, nodeOrChildIsDecorated); + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.SetAccessor: + return forEach((node).parameters, nodeIsDecorated); + } + + return false; + } + + export function nodeOrChildIsDecorated(node: Node): boolean { + return nodeIsDecorated(node) || childIsDecorated(node); + } + export function isExpression(node: Node): boolean { switch (node.kind) { case SyntaxKind.ThisKeyword: @@ -814,6 +891,20 @@ module ts { } } + export function isClassElement(n: Node): boolean { + switch (n.kind) { + case SyntaxKind.Constructor: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.IndexSignature: + return true; + default: + return false; + } + } + // True if the given identifier, string literal, or number literal is the name of a declaration node export function isDeclarationName(name: Node): boolean { if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) { @@ -1229,28 +1320,6 @@ module ts { return node; } - export function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string { - // First try '_name' - if (baseName.charCodeAt(0) !== CharacterCodes._) { - baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return baseName; - } - } - // Find the first unique '_name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { - baseName += "_"; - } - let i = 1; - while (true) { - let name = baseName + i; - if (!isExistingName(name)) { - return name; - } - i++; - } - } - // @internal export function createDiagnosticCollection(): DiagnosticCollection { let nonFileDiagnostics: Diagnostic[] = []; @@ -1524,6 +1593,7 @@ module ts { export function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration) { let firstAccessor: AccessorDeclaration; + let secondAccessor: AccessorDeclaration; let getAccessor: AccessorDeclaration; let setAccessor: AccessorDeclaration; if (hasDynamicName(accessor)) { @@ -1548,6 +1618,9 @@ module ts { if (!firstAccessor) { firstAccessor = member; } + else if (!secondAccessor) { + secondAccessor = member; + } if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { getAccessor = member; @@ -1562,6 +1635,7 @@ module ts { } return { firstAccessor, + secondAccessor, getAccessor, setAccessor }; diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 040eb69ae9613..2096fa839dfcc 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1155,3 +1155,17 @@ interface ArrayConstructor { } declare var Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void; diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 23a392d7718c2..6a5ed25459e9d 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -419,6 +419,29 @@ module ts.formatting { } } + function getFirstNonDecoratorTokenOfNode(node: Node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; + } + switch (node.kind) { + case SyntaxKind.ClassDeclaration: return SyntaxKind.ClassKeyword; + case SyntaxKind.InterfaceDeclaration: return SyntaxKind.InterfaceKeyword; + case SyntaxKind.FunctionDeclaration: return SyntaxKind.FunctionKeyword; + case SyntaxKind.EnumDeclaration: return SyntaxKind.EnumDeclaration; + case SyntaxKind.GetAccessor: return SyntaxKind.GetKeyword; + case SyntaxKind.SetAccessor: return SyntaxKind.SetKeyword; + case SyntaxKind.MethodDeclaration: + if ((node).asteriskToken) { + return SyntaxKind.AsteriskToken; + } + // fall-through + + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.Parameter: + return (node).name.kind; + } + } + function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation { return { getIndentationForComment: kind => { @@ -434,6 +457,12 @@ module ts.formatting { return indentation; }, getIndentationForToken: (line, kind) => { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + // if this token is the first token following the list of decorators, we do not need to indent + return indentation; + } + } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case SyntaxKind.OpenBraceToken: @@ -442,6 +471,7 @@ module ts.formatting { case SyntaxKind.CloseBracketToken: case SyntaxKind.ElseKeyword: case SyntaxKind.WhileKeyword: + case SyntaxKind.AtToken: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation diff --git a/src/services/services.ts b/src/services/services.ts index 658f29f5ae78a..58fba22a71f07 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -418,7 +418,10 @@ module ts { function pushDocCommentLineText(docComments: SymbolDisplayPart[], text: string, blankLineCount: number) { // Add the empty lines in between texts - while (blankLineCount--) docComments.push(textPart("")); + while (blankLineCount--) { + docComments.push(textPart("")); + } + docComments.push(textPart(text)); } @@ -1415,14 +1418,6 @@ module ts { /// Language Service - interface CompletionSession { - fileName: string; // the file where the completion was requested - position: number; // position in the file where the completion was requested - entries: CompletionEntry[]; // entries for this completion - symbols: Map; // symbols by entry name map - typeChecker: TypeChecker; // the typeChecker used to generate this completion - } - interface FormattingOptions { useTabs: boolean; spacesPerTab: number; @@ -2186,7 +2181,6 @@ module ts { let typeInfoResolver: TypeChecker; let useCaseSensitivefileNames = false; let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - let activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details // Check if the localized messages json is set, otherwise query the host for it if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { @@ -2404,43 +2398,51 @@ module ts { } /// Completion - function getValidCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget): string { + function getCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string { let displayName = symbol.getName(); - if (displayName && displayName.length > 0) { - let firstCharCode = displayName.charCodeAt(0); - // First check of the displayName is not external module; if it is an external module, it is not valid entry - if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { - // If the symbol is external module, don't show it in the completion list - // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) - return undefined; - } + if (!displayName) { + return undefined; + } - if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - displayName = displayName.substring(1, displayName.length - 1); - } + let firstCharCode = displayName.charCodeAt(0); + // First check of the displayName is not external module; if it is an external module, it is not valid entry + if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { + // If the symbol is external module, don't show it in the completion list + // (i.e declare module "http" { let x; } | // <= request completion here, "http" should not be there) + return undefined; + } - let isValid = isIdentifierStart(displayName.charCodeAt(0), target); - for (let i = 1, n = displayName.length; isValid && i < n; i++) { - isValid = isIdentifierPart(displayName.charCodeAt(i), target); - } + if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && + (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + displayName = displayName.substring(1, displayName.length - 1); + } + if (!displayName) { + return undefined; + } - if (isValid) { - return unescapeIdentifier(displayName); + if (performCharacterChecks) { + if (!isIdentifierStart(displayName.charCodeAt(0), target)) { + return undefined; + } + + for (let i = 1, n = displayName.length; i < n; i++) { + if (!isIdentifierPart(displayName.charCodeAt(i), target)) { + return undefined; + } } } - return undefined; + return unescapeIdentifier(displayName); } function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker, location: Node): CompletionEntry { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - let displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target); + let displayName = getCompletionEntryDisplayName(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true); if (!displayName) { return undefined; } @@ -2456,20 +2458,18 @@ module ts { }; } - function getCompletionsAtPosition(fileName: string, position: number) { - synchronizeHostData(); - + function getCompletionData(fileName: string, position: number) { let syntacticStart = new Date().getTime(); let sourceFile = getValidSourceFile(fileName); let start = new Date().getTime(); let currentToken = getTokenAtPosition(sourceFile, position); - log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + log("getCompletionData: Get current token: " + (new Date().getTime() - start)); start = new Date().getTime(); // Completion not allowed inside comments, bail out if this is the case let insideComment = isInsideComment(sourceFile, currentToken, position); - log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { log("Returning an empty list because completion was inside a comment."); @@ -2480,14 +2480,14 @@ module ts { // Note: previousToken can be undefined if we are the beginning of the file start = new Date().getTime(); let previousToken = findPrecedingToken(position, sourceFile); - log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); + log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); // The caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier to the previous token if (previousToken && position <= previousToken.end && previousToken.kind === SyntaxKind.Identifier) { let start = new Date().getTime(); previousToken = findPrecedingToken(previousToken.pos, sourceFile); - log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - start)); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } // Check if this is a valid completion location @@ -2498,8 +2498,8 @@ module ts { // Find the node where completion is requested on, in the case of a completion after a dot, it is the member access expression // other wise, it is a request for all visible symbols in the scope, and the node is the current location - let node: Node; - let isRightOfDot: boolean; + let node = currentToken; + let isRightOfDot = false; if (previousToken && previousToken.kind === SyntaxKind.DotToken && previousToken.parent.kind === SyntaxKind.PropertyAccessExpression) { node = (previousToken.parent).expression; isRightOfDot = true; @@ -2508,30 +2508,18 @@ module ts { node = (previousToken.parent).left; isRightOfDot = true; } - else { - node = currentToken; - isRightOfDot = false; - } - - // Clear the current activeCompletionSession for this session - activeCompletionSession = { - fileName: fileName, - position: position, - entries: [], - symbols: {}, - typeChecker: typeInfoResolver - }; - log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); let location = getTouchingPropertyName(sourceFile, position); - // Populate the completion list + var target = program.getCompilerOptions().target; + let semanticStart = new Date().getTime(); let isMemberCompletion: boolean; let isNewIdentifierLocation: boolean; + let symbols: Symbol[]; if (isRightOfDot) { // Right of dot member completion list - let symbols: Symbol[] = []; + symbols = []; isMemberCompletion = true; isNewIdentifierLocation = false; @@ -2562,8 +2550,6 @@ module ts { } }); } - - getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } else { let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(previousToken); @@ -2580,8 +2566,7 @@ module ts { let contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType); if (contextualTypeMembers && contextualTypeMembers.length > 0) { // Add filtered items to the completion list - let filteredMembers = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - getCompletionEntriesFromSymbols(filteredMembers, activeCompletionSession); + symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } else if (getAncestor(previousToken, SyntaxKind.ImportClause)) { @@ -2593,8 +2578,7 @@ module ts { let importDeclaration = getAncestor(previousToken, SyntaxKind.ImportDeclaration); Debug.assert(importDeclaration !== undefined); let exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration); - let filteredExports = filterModuleExports(exports, importDeclaration); - getCompletionEntriesFromSymbols(filteredExports, activeCompletionSession); + symbols = filterModuleExports(exports, importDeclaration); } } else { @@ -2605,24 +2589,14 @@ module ts { /// TODO filter meaning based on the current context let scopeNode = getScopeNode(previousToken, position, sourceFile); let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - let symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); - - getCompletionEntriesFromSymbols(symbols, activeCompletionSession); + + symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); } } - // Add keywords if this is not a member completion list - if (!isMemberCompletion) { - Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); - } - log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); + log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { - isMemberCompletion, - isNewIdentifierLocation, - isBuilder: isNewIdentifierDefinitionLocation, // temporary property used to match VS implementation - entries: activeCompletionSession.entries - }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location }; /** * Finds the first node that "embraces" the position, so that one may @@ -2636,21 +2610,6 @@ module ts { return scope; } - function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void { - let start = new Date().getTime(); - forEach(symbols, symbol => { - let entry = createCompletionEntry(symbol, session.typeChecker, location); - if (entry) { - let id = escapeIdentifier(entry.name); - if (!lookUp(session.symbols, id)) { - session.entries.push(entry); - session.symbols[id] = symbol; - } - } - }); - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); - } - function isCompletionListBlocker(previousToken: Node): boolean { let start = new Date().getTime(); let result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || @@ -2704,7 +2663,7 @@ module ts { case SyntaxKind.EqualsToken: return containingNodeKind === SyntaxKind.VariableDeclaration // let x = a| - || containingNodeKind === SyntaxKind.BinaryExpression; // x = a| + || containingNodeKind === SyntaxKind.BinaryExpression; // x = a| case SyntaxKind.TemplateHead: return containingNodeKind === SyntaxKind.TemplateExpression; // `aa ${| @@ -2821,7 +2780,7 @@ module ts { case SyntaxKind.SemicolonToken: return containingNodeKind === SyntaxKind.PropertySignature && (previousToken.parent.parent.kind === SyntaxKind.InterfaceDeclaration || // interface a { f; | - previousToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; | + previousToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; | case SyntaxKind.LessThanToken: return containingNodeKind === SyntaxKind.ClassDeclaration || // class A< | @@ -2937,38 +2896,78 @@ module ts { } } - function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { - // Note: No need to call synchronizeHostData, as we have captured all the data we need - // in the getCompletionsAtPosition earlier - let sourceFile = getValidSourceFile(fileName); - - let session = activeCompletionSession; + function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { + synchronizeHostData(); + + let completionData = getCompletionData(fileName, position); + if (!completionData) { + return undefined; + } - // Ensure that the current active completion session is still valid for this request - if (!session || session.fileName !== fileName || session.position !== position) { + let { symbols, isMemberCompletion, isNewIdentifierLocation, location } = completionData; + if (!symbols || symbols.length === 0) { return undefined; } - let symbol = lookUp(activeCompletionSession.symbols, escapeIdentifier(entryName)); - if (symbol) { - let location = getTouchingPropertyName(sourceFile, position); - let completionEntry = createCompletionEntry(symbol, session.typeChecker, location); - // TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind' - // which is permissible given that it is backwards compatible; but really we should consider - // passing the meaning for the node so that we don't report that a suggestion for a value is an interface. - // We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration. - Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, location) !== undefined, "Could not find type for symbol"); - let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, session.typeChecker, location, SemanticMeaning.All); - return { - name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, - kindModifiers: completionEntry.kindModifiers, - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation - }; + var entries = getCompletionEntriesFromSymbols(symbols); + + // Add keywords if this is not a member completion list + if (!isMemberCompletion) { + addRange(entries, keywordCompletions); } - else { - // No symbol, it is a keyword + + return { isMemberCompletion, isNewIdentifierLocation, entries }; + + function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] { + let start = new Date().getTime(); + var entries: CompletionEntry[] = []; + var nameToSymbol: Map = {}; + + for (let symbol of symbols) { + let entry = createCompletionEntry(symbol, typeInfoResolver, location); + if (entry) { + let id = escapeIdentifier(entry.name); + if (!lookUp(nameToSymbol, id)) { + entries.push(entry); + nameToSymbol[id] = symbol; + } + } + } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start)); + return entries; + } + } + + function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { + synchronizeHostData(); + + // Compute all the completion symbols again. + let completionData = getCompletionData(fileName, position); + if (completionData) { + let { symbols, location } = completionData; + + // Find the symbol with the matching entry name. + let target = program.getCompilerOptions().target; + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new + // completion entry. + let symbol = forEach(symbols, s => getCompletionEntryDisplayName(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined); + + if (symbol) { + let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, typeInfoResolver, location, SemanticMeaning.All); + return { + name: entryName, + kind: displayPartsDocumentationsAndSymbolKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, + documentation: displayPartsDocumentationsAndSymbolKind.documentation + }; + } + } + + // Didn't find a symbol with this name. See if we can find a keyword instead. + let keywordCompletion = forEach(keywordCompletions, c => c.name === entryName); + if (keywordCompletion) { return { name: entryName, kind: ScriptElementKind.keyword, @@ -2977,6 +2976,8 @@ module ts { documentation: undefined }; } + + return undefined; } // TODO(drosen): use contextual SemanticMeaning. @@ -3075,12 +3076,14 @@ module ts { typeResolver: TypeChecker, location: Node, // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location semanticMeaning = getMeaningFromLocation(location)) { + let displayParts: SymbolDisplayPart[] = []; let documentation: SymbolDisplayPart[]; let symbolFlags = symbol.flags; let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location); let hasAddedSymbolInfo: boolean; let type: Type; + // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Alias) { // If it is accessor they are allowed only if location is at name of the accessor @@ -3132,9 +3135,7 @@ module ts { } else if (symbolFlags & SymbolFlags.Alias) { symbolKind = ScriptElementKind.alias; - displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + pushTypePart(symbolKind); displayParts.push(spacePart()); if (useConstructSignatures) { displayParts.push(keywordPart(SyntaxKind.NewKeyword)); @@ -3370,14 +3371,29 @@ module ts { function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + pushTypePart(symbolKind); displayParts.push(spacePart()); addFullSymbolName(symbol); } } + function pushTypePart(symbolKind: string) { + switch (symbolKind) { + case ScriptElementKind.variableElement: + case ScriptElementKind.functionElement: + case ScriptElementKind.letElement: + case ScriptElementKind.constElement: + case ScriptElementKind.constructorImplementationElement: + displayParts.push(textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + displayParts.push(textOrKeywordPart(symbolKind)); + displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + return; + } + } + function addSignatureDisplayParts(signature: Signature, allSignatures: Signature[], flags?: TypeFormatFlags) { displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature)); if (allSignatures.length > 1) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 2a9af04409e89..756fbb42597f6 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -611,6 +611,13 @@ module ts { return displayPart(tokenToString(kind), SymbolDisplayPartKind.operator); } + export function textOrKeywordPart(text: string) { + var kind = stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + export function textPart(text: string) { return displayPart(text, SymbolDisplayPartKind.text); } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 6508de7a92520..07d5e4337a69e 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -111,192 +111,195 @@ declare module "typescript" { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -304,8 +307,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -331,10 +334,11 @@ declare module "typescript" { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -345,6 +349,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -375,6 +380,9 @@ declare module "typescript" { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -939,8 +947,8 @@ declare module "typescript" { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; @@ -954,7 +962,7 @@ declare module "typescript" { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1061,6 +1069,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 28f10e7bf780a..eff47a4cb7bf1 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -351,562 +351,571 @@ declare module "typescript" { ColonToken = 51, >ColonToken : SyntaxKind - EqualsToken = 52, + AtToken = 52, +>AtToken : SyntaxKind + + EqualsToken = 53, >EqualsToken : SyntaxKind - PlusEqualsToken = 53, + PlusEqualsToken = 54, >PlusEqualsToken : SyntaxKind - MinusEqualsToken = 54, + MinusEqualsToken = 55, >MinusEqualsToken : SyntaxKind - AsteriskEqualsToken = 55, + AsteriskEqualsToken = 56, >AsteriskEqualsToken : SyntaxKind - SlashEqualsToken = 56, + SlashEqualsToken = 57, >SlashEqualsToken : SyntaxKind - PercentEqualsToken = 57, + PercentEqualsToken = 58, >PercentEqualsToken : SyntaxKind - LessThanLessThanEqualsToken = 58, + LessThanLessThanEqualsToken = 59, >LessThanLessThanEqualsToken : SyntaxKind - GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, >GreaterThanGreaterThanEqualsToken : SyntaxKind - GreaterThanGreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, >GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind - AmpersandEqualsToken = 61, + AmpersandEqualsToken = 62, >AmpersandEqualsToken : SyntaxKind - BarEqualsToken = 62, + BarEqualsToken = 63, >BarEqualsToken : SyntaxKind - CaretEqualsToken = 63, + CaretEqualsToken = 64, >CaretEqualsToken : SyntaxKind - Identifier = 64, + Identifier = 65, >Identifier : SyntaxKind - BreakKeyword = 65, + BreakKeyword = 66, >BreakKeyword : SyntaxKind - CaseKeyword = 66, + CaseKeyword = 67, >CaseKeyword : SyntaxKind - CatchKeyword = 67, + CatchKeyword = 68, >CatchKeyword : SyntaxKind - ClassKeyword = 68, + ClassKeyword = 69, >ClassKeyword : SyntaxKind - ConstKeyword = 69, + ConstKeyword = 70, >ConstKeyword : SyntaxKind - ContinueKeyword = 70, + ContinueKeyword = 71, >ContinueKeyword : SyntaxKind - DebuggerKeyword = 71, + DebuggerKeyword = 72, >DebuggerKeyword : SyntaxKind - DefaultKeyword = 72, + DefaultKeyword = 73, >DefaultKeyword : SyntaxKind - DeleteKeyword = 73, + DeleteKeyword = 74, >DeleteKeyword : SyntaxKind - DoKeyword = 74, + DoKeyword = 75, >DoKeyword : SyntaxKind - ElseKeyword = 75, + ElseKeyword = 76, >ElseKeyword : SyntaxKind - EnumKeyword = 76, + EnumKeyword = 77, >EnumKeyword : SyntaxKind - ExportKeyword = 77, + ExportKeyword = 78, >ExportKeyword : SyntaxKind - ExtendsKeyword = 78, + ExtendsKeyword = 79, >ExtendsKeyword : SyntaxKind - FalseKeyword = 79, + FalseKeyword = 80, >FalseKeyword : SyntaxKind - FinallyKeyword = 80, + FinallyKeyword = 81, >FinallyKeyword : SyntaxKind - ForKeyword = 81, + ForKeyword = 82, >ForKeyword : SyntaxKind - FunctionKeyword = 82, + FunctionKeyword = 83, >FunctionKeyword : SyntaxKind - IfKeyword = 83, + IfKeyword = 84, >IfKeyword : SyntaxKind - ImportKeyword = 84, + ImportKeyword = 85, >ImportKeyword : SyntaxKind - InKeyword = 85, + InKeyword = 86, >InKeyword : SyntaxKind - InstanceOfKeyword = 86, + InstanceOfKeyword = 87, >InstanceOfKeyword : SyntaxKind - NewKeyword = 87, + NewKeyword = 88, >NewKeyword : SyntaxKind - NullKeyword = 88, + NullKeyword = 89, >NullKeyword : SyntaxKind - ReturnKeyword = 89, + ReturnKeyword = 90, >ReturnKeyword : SyntaxKind - SuperKeyword = 90, + SuperKeyword = 91, >SuperKeyword : SyntaxKind - SwitchKeyword = 91, + SwitchKeyword = 92, >SwitchKeyword : SyntaxKind - ThisKeyword = 92, + ThisKeyword = 93, >ThisKeyword : SyntaxKind - ThrowKeyword = 93, + ThrowKeyword = 94, >ThrowKeyword : SyntaxKind - TrueKeyword = 94, + TrueKeyword = 95, >TrueKeyword : SyntaxKind - TryKeyword = 95, + TryKeyword = 96, >TryKeyword : SyntaxKind - TypeOfKeyword = 96, + TypeOfKeyword = 97, >TypeOfKeyword : SyntaxKind - VarKeyword = 97, + VarKeyword = 98, >VarKeyword : SyntaxKind - VoidKeyword = 98, + VoidKeyword = 99, >VoidKeyword : SyntaxKind - WhileKeyword = 99, + WhileKeyword = 100, >WhileKeyword : SyntaxKind - WithKeyword = 100, + WithKeyword = 101, >WithKeyword : SyntaxKind - AsKeyword = 101, + AsKeyword = 102, >AsKeyword : SyntaxKind - ImplementsKeyword = 102, + ImplementsKeyword = 103, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 103, + InterfaceKeyword = 104, >InterfaceKeyword : SyntaxKind - LetKeyword = 104, + LetKeyword = 105, >LetKeyword : SyntaxKind - PackageKeyword = 105, + PackageKeyword = 106, >PackageKeyword : SyntaxKind - PrivateKeyword = 106, + PrivateKeyword = 107, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 107, + ProtectedKeyword = 108, >ProtectedKeyword : SyntaxKind - PublicKeyword = 108, + PublicKeyword = 109, >PublicKeyword : SyntaxKind - StaticKeyword = 109, + StaticKeyword = 110, >StaticKeyword : SyntaxKind - YieldKeyword = 110, + YieldKeyword = 111, >YieldKeyword : SyntaxKind - AnyKeyword = 111, + AnyKeyword = 112, >AnyKeyword : SyntaxKind - BooleanKeyword = 112, + BooleanKeyword = 113, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 113, + ConstructorKeyword = 114, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 114, + DeclareKeyword = 115, >DeclareKeyword : SyntaxKind - GetKeyword = 115, + GetKeyword = 116, >GetKeyword : SyntaxKind - ModuleKeyword = 116, + ModuleKeyword = 117, >ModuleKeyword : SyntaxKind - RequireKeyword = 117, + RequireKeyword = 118, >RequireKeyword : SyntaxKind - NumberKeyword = 118, + NumberKeyword = 119, >NumberKeyword : SyntaxKind - SetKeyword = 119, + SetKeyword = 120, >SetKeyword : SyntaxKind - StringKeyword = 120, + StringKeyword = 121, >StringKeyword : SyntaxKind - SymbolKeyword = 121, + SymbolKeyword = 122, >SymbolKeyword : SyntaxKind - TypeKeyword = 122, + TypeKeyword = 123, >TypeKeyword : SyntaxKind - FromKeyword = 123, + FromKeyword = 124, >FromKeyword : SyntaxKind - OfKeyword = 124, + OfKeyword = 125, >OfKeyword : SyntaxKind - QualifiedName = 125, + QualifiedName = 126, >QualifiedName : SyntaxKind - ComputedPropertyName = 126, + ComputedPropertyName = 127, >ComputedPropertyName : SyntaxKind - TypeParameter = 127, + TypeParameter = 128, >TypeParameter : SyntaxKind - Parameter = 128, + Parameter = 129, >Parameter : SyntaxKind - PropertySignature = 129, + Decorator = 130, +>Decorator : SyntaxKind + + PropertySignature = 131, >PropertySignature : SyntaxKind - PropertyDeclaration = 130, + PropertyDeclaration = 132, >PropertyDeclaration : SyntaxKind - MethodSignature = 131, + MethodSignature = 133, >MethodSignature : SyntaxKind - MethodDeclaration = 132, + MethodDeclaration = 134, >MethodDeclaration : SyntaxKind - Constructor = 133, + Constructor = 135, >Constructor : SyntaxKind - GetAccessor = 134, + GetAccessor = 136, >GetAccessor : SyntaxKind - SetAccessor = 135, + SetAccessor = 137, >SetAccessor : SyntaxKind - CallSignature = 136, + CallSignature = 138, >CallSignature : SyntaxKind - ConstructSignature = 137, + ConstructSignature = 139, >ConstructSignature : SyntaxKind - IndexSignature = 138, + IndexSignature = 140, >IndexSignature : SyntaxKind - TypeReference = 139, + TypeReference = 141, >TypeReference : SyntaxKind - FunctionType = 140, + FunctionType = 142, >FunctionType : SyntaxKind - ConstructorType = 141, + ConstructorType = 143, >ConstructorType : SyntaxKind - TypeQuery = 142, + TypeQuery = 144, >TypeQuery : SyntaxKind - TypeLiteral = 143, + TypeLiteral = 145, >TypeLiteral : SyntaxKind - ArrayType = 144, + ArrayType = 146, >ArrayType : SyntaxKind - TupleType = 145, + TupleType = 147, >TupleType : SyntaxKind - UnionType = 146, + UnionType = 148, >UnionType : SyntaxKind - ParenthesizedType = 147, + ParenthesizedType = 149, >ParenthesizedType : SyntaxKind - ObjectBindingPattern = 148, + ObjectBindingPattern = 150, >ObjectBindingPattern : SyntaxKind - ArrayBindingPattern = 149, + ArrayBindingPattern = 151, >ArrayBindingPattern : SyntaxKind - BindingElement = 150, + BindingElement = 152, >BindingElement : SyntaxKind - ArrayLiteralExpression = 151, + ArrayLiteralExpression = 153, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 152, + ObjectLiteralExpression = 154, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 153, + PropertyAccessExpression = 155, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 154, + ElementAccessExpression = 156, >ElementAccessExpression : SyntaxKind - CallExpression = 155, + CallExpression = 157, >CallExpression : SyntaxKind - NewExpression = 156, + NewExpression = 158, >NewExpression : SyntaxKind - TaggedTemplateExpression = 157, + TaggedTemplateExpression = 159, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 158, + TypeAssertionExpression = 160, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 159, + ParenthesizedExpression = 161, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 160, + FunctionExpression = 162, >FunctionExpression : SyntaxKind - ArrowFunction = 161, + ArrowFunction = 163, >ArrowFunction : SyntaxKind - DeleteExpression = 162, + DeleteExpression = 164, >DeleteExpression : SyntaxKind - TypeOfExpression = 163, + TypeOfExpression = 165, >TypeOfExpression : SyntaxKind - VoidExpression = 164, + VoidExpression = 166, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 165, + PrefixUnaryExpression = 167, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 166, + PostfixUnaryExpression = 168, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 167, + BinaryExpression = 169, >BinaryExpression : SyntaxKind - ConditionalExpression = 168, + ConditionalExpression = 170, >ConditionalExpression : SyntaxKind - TemplateExpression = 169, + TemplateExpression = 171, >TemplateExpression : SyntaxKind - YieldExpression = 170, + YieldExpression = 172, >YieldExpression : SyntaxKind - SpreadElementExpression = 171, + SpreadElementExpression = 173, >SpreadElementExpression : SyntaxKind - OmittedExpression = 172, + OmittedExpression = 174, >OmittedExpression : SyntaxKind - TemplateSpan = 173, + TemplateSpan = 175, >TemplateSpan : SyntaxKind - Block = 174, + Block = 176, >Block : SyntaxKind - VariableStatement = 175, + VariableStatement = 177, >VariableStatement : SyntaxKind - EmptyStatement = 176, + EmptyStatement = 178, >EmptyStatement : SyntaxKind - ExpressionStatement = 177, + ExpressionStatement = 179, >ExpressionStatement : SyntaxKind - IfStatement = 178, + IfStatement = 180, >IfStatement : SyntaxKind - DoStatement = 179, + DoStatement = 181, >DoStatement : SyntaxKind - WhileStatement = 180, + WhileStatement = 182, >WhileStatement : SyntaxKind - ForStatement = 181, + ForStatement = 183, >ForStatement : SyntaxKind - ForInStatement = 182, + ForInStatement = 184, >ForInStatement : SyntaxKind - ForOfStatement = 183, + ForOfStatement = 185, >ForOfStatement : SyntaxKind - ContinueStatement = 184, + ContinueStatement = 186, >ContinueStatement : SyntaxKind - BreakStatement = 185, + BreakStatement = 187, >BreakStatement : SyntaxKind - ReturnStatement = 186, + ReturnStatement = 188, >ReturnStatement : SyntaxKind - WithStatement = 187, + WithStatement = 189, >WithStatement : SyntaxKind - SwitchStatement = 188, + SwitchStatement = 190, >SwitchStatement : SyntaxKind - LabeledStatement = 189, + LabeledStatement = 191, >LabeledStatement : SyntaxKind - ThrowStatement = 190, + ThrowStatement = 192, >ThrowStatement : SyntaxKind - TryStatement = 191, + TryStatement = 193, >TryStatement : SyntaxKind - DebuggerStatement = 192, + DebuggerStatement = 194, >DebuggerStatement : SyntaxKind - VariableDeclaration = 193, + VariableDeclaration = 195, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 194, + VariableDeclarationList = 196, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 195, + FunctionDeclaration = 197, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 196, + ClassDeclaration = 198, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 197, + InterfaceDeclaration = 199, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 198, + TypeAliasDeclaration = 200, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 199, + EnumDeclaration = 201, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 200, + ModuleDeclaration = 202, >ModuleDeclaration : SyntaxKind - ModuleBlock = 201, + ModuleBlock = 203, >ModuleBlock : SyntaxKind - CaseBlock = 202, + CaseBlock = 204, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 203, + ImportEqualsDeclaration = 205, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 204, + ImportDeclaration = 206, >ImportDeclaration : SyntaxKind - ImportClause = 205, + ImportClause = 207, >ImportClause : SyntaxKind - NamespaceImport = 206, + NamespaceImport = 208, >NamespaceImport : SyntaxKind - NamedImports = 207, + NamedImports = 209, >NamedImports : SyntaxKind - ImportSpecifier = 208, + ImportSpecifier = 210, >ImportSpecifier : SyntaxKind - ExportAssignment = 209, + ExportAssignment = 211, >ExportAssignment : SyntaxKind - ExportDeclaration = 210, + ExportDeclaration = 212, >ExportDeclaration : SyntaxKind - NamedExports = 211, + NamedExports = 213, >NamedExports : SyntaxKind - ExportSpecifier = 212, + ExportSpecifier = 214, >ExportSpecifier : SyntaxKind - ExternalModuleReference = 213, + MissingDeclaration = 215, +>MissingDeclaration : SyntaxKind + + ExternalModuleReference = 216, >ExternalModuleReference : SyntaxKind - CaseClause = 214, + CaseClause = 217, >CaseClause : SyntaxKind - DefaultClause = 215, + DefaultClause = 218, >DefaultClause : SyntaxKind - HeritageClause = 216, + HeritageClause = 219, >HeritageClause : SyntaxKind - CatchClause = 217, + CatchClause = 220, >CatchClause : SyntaxKind - PropertyAssignment = 218, + PropertyAssignment = 221, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 219, + ShorthandPropertyAssignment = 222, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 220, + EnumMember = 223, >EnumMember : SyntaxKind - SourceFile = 221, + SourceFile = 224, >SourceFile : SyntaxKind - SyntaxList = 222, + SyntaxList = 225, >SyntaxList : SyntaxKind - Count = 223, + Count = 226, >Count : SyntaxKind - FirstAssignment = 52, + FirstAssignment = 53, >FirstAssignment : SyntaxKind - LastAssignment = 63, + LastAssignment = 64, >LastAssignment : SyntaxKind - FirstReservedWord = 65, + FirstReservedWord = 66, >FirstReservedWord : SyntaxKind - LastReservedWord = 100, + LastReservedWord = 101, >LastReservedWord : SyntaxKind - FirstKeyword = 65, + FirstKeyword = 66, >FirstKeyword : SyntaxKind - LastKeyword = 124, + LastKeyword = 125, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 102, + FirstFutureReservedWord = 103, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 110, + LastFutureReservedWord = 111, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 139, + FirstTypeNode = 141, >FirstTypeNode : SyntaxKind - LastTypeNode = 147, + LastTypeNode = 149, >LastTypeNode : SyntaxKind FirstPunctuation = 14, >FirstPunctuation : SyntaxKind - LastPunctuation = 63, + LastPunctuation = 64, >LastPunctuation : SyntaxKind FirstToken = 0, >FirstToken : SyntaxKind - LastToken = 124, + LastToken = 125, >LastToken : SyntaxKind FirstTriviaToken = 2, @@ -930,10 +939,10 @@ declare module "typescript" { FirstBinaryOperator = 24, >FirstBinaryOperator : SyntaxKind - LastBinaryOperator = 63, + LastBinaryOperator = 64, >LastBinaryOperator : SyntaxKind - FirstNode = 125, + FirstNode = 126, >FirstNode : SyntaxKind } const enum NodeFlags { @@ -1005,16 +1014,19 @@ declare module "typescript" { GeneratorParameter = 8, >GeneratorParameter : ParserContextFlags - ThisNodeHasError = 16, + Decorator = 16, +>Decorator : ParserContextFlags + + ThisNodeHasError = 32, >ThisNodeHasError : ParserContextFlags - ParserGeneratedFlags = 31, + ParserGeneratedFlags = 63, >ParserGeneratedFlags : ParserContextFlags - ThisNodeOrAnySubNodesHasError = 32, + ThisNodeOrAnySubNodesHasError = 64, >ThisNodeOrAnySubNodesHasError : ParserContextFlags - HasAggregatedChildData = 64, + HasAggregatedChildData = 128, >HasAggregatedChildData : ParserContextFlags } const enum RelationComparisonResult { @@ -1045,6 +1057,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1139,6 +1156,14 @@ declare module "typescript" { expression: Expression; >expression : Expression >Expression : Expression + } + interface Decorator extends Node { +>Decorator : Decorator +>Node : Node + + expression: LeftHandSideExpression; +>expression : LeftHandSideExpression +>LeftHandSideExpression : LeftHandSideExpression } interface TypeParameterDeclaration extends Declaration { >TypeParameterDeclaration : TypeParameterDeclaration @@ -3006,15 +3031,17 @@ declare module "typescript" { interface EmitResolver { >EmitResolver : EmitResolver - getGeneratedNameForNode(node: Node): string; ->getGeneratedNameForNode : (node: Node) => string ->node : Node ->Node : Node + hasGlobalName(name: string): boolean; +>hasGlobalName : (name: string) => boolean +>name : string - getExpressionNameSubstitution(node: Identifier): string; ->getExpressionNameSubstitution : (node: Identifier) => string + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; +>getExpressionNameSubstitution : (node: Identifier, getGeneratedNameForNode: (node: Node) => string) => string >node : Identifier >Identifier : Identifier +>getGeneratedNameForNode : (node: Node) => string +>node : Node +>Node : Node isValueAliasDeclaration(node: Node): boolean; >isValueAliasDeclaration : (node: Node) => boolean @@ -3113,8 +3140,8 @@ declare module "typescript" { >PropertyAccessExpression : PropertyAccessExpression >ElementAccessExpression : ElementAccessExpression - isUnknownIdentifier(location: Node, name: string): boolean; ->isUnknownIdentifier : (location: Node, name: string) => boolean + resolvesToSomeValue(location: Node, name: string): boolean; +>resolvesToSomeValue : (location: Node, name: string) => boolean >location : Node >Node : Node >name : string @@ -3436,6 +3463,9 @@ declare module "typescript" { BlockScopedBindingInLoop = 256, >BlockScopedBindingInLoop : NodeCheckFlags + + EmitDecorate = 512, +>EmitDecorate : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 6ac65082be027..b57acaf0e9c1b 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -142,192 +142,195 @@ declare module "typescript" { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -335,8 +338,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -362,10 +365,11 @@ declare module "typescript" { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -376,6 +380,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -406,6 +411,9 @@ declare module "typescript" { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -970,8 +978,8 @@ declare module "typescript" { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; @@ -985,7 +993,7 @@ declare module "typescript" { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1092,6 +1100,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; @@ -2033,24 +2042,24 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 181 /* ForStatement */: - case 182 /* ForInStatement */: - case 180 /* WhileStatement */: - case 179 /* DoStatement */: - if (node.statement.kind !== 174 /* Block */) { + case 183 /* ForStatement */: + case 184 /* ForInStatement */: + case 182 /* WhileStatement */: + case 181 /* DoStatement */: + if (node.statement.kind !== 176 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 178 /* IfStatement */: + case 180 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 174 /* Block */) { + if (ifStatement.thenStatement.kind !== 176 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } - if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 174 /* Block */ && ifStatement.elseStatement.kind !== 178 /* IfStatement */) { + if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 176 /* Block */ && ifStatement.elseStatement.kind !== 180 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 167 /* BinaryExpression */: + case 169 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 28 /* EqualsEqualsToken */ || op === 29 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index ba374d4599248..600bf5c6adc72 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -497,562 +497,571 @@ declare module "typescript" { ColonToken = 51, >ColonToken : SyntaxKind - EqualsToken = 52, + AtToken = 52, +>AtToken : SyntaxKind + + EqualsToken = 53, >EqualsToken : SyntaxKind - PlusEqualsToken = 53, + PlusEqualsToken = 54, >PlusEqualsToken : SyntaxKind - MinusEqualsToken = 54, + MinusEqualsToken = 55, >MinusEqualsToken : SyntaxKind - AsteriskEqualsToken = 55, + AsteriskEqualsToken = 56, >AsteriskEqualsToken : SyntaxKind - SlashEqualsToken = 56, + SlashEqualsToken = 57, >SlashEqualsToken : SyntaxKind - PercentEqualsToken = 57, + PercentEqualsToken = 58, >PercentEqualsToken : SyntaxKind - LessThanLessThanEqualsToken = 58, + LessThanLessThanEqualsToken = 59, >LessThanLessThanEqualsToken : SyntaxKind - GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, >GreaterThanGreaterThanEqualsToken : SyntaxKind - GreaterThanGreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, >GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind - AmpersandEqualsToken = 61, + AmpersandEqualsToken = 62, >AmpersandEqualsToken : SyntaxKind - BarEqualsToken = 62, + BarEqualsToken = 63, >BarEqualsToken : SyntaxKind - CaretEqualsToken = 63, + CaretEqualsToken = 64, >CaretEqualsToken : SyntaxKind - Identifier = 64, + Identifier = 65, >Identifier : SyntaxKind - BreakKeyword = 65, + BreakKeyword = 66, >BreakKeyword : SyntaxKind - CaseKeyword = 66, + CaseKeyword = 67, >CaseKeyword : SyntaxKind - CatchKeyword = 67, + CatchKeyword = 68, >CatchKeyword : SyntaxKind - ClassKeyword = 68, + ClassKeyword = 69, >ClassKeyword : SyntaxKind - ConstKeyword = 69, + ConstKeyword = 70, >ConstKeyword : SyntaxKind - ContinueKeyword = 70, + ContinueKeyword = 71, >ContinueKeyword : SyntaxKind - DebuggerKeyword = 71, + DebuggerKeyword = 72, >DebuggerKeyword : SyntaxKind - DefaultKeyword = 72, + DefaultKeyword = 73, >DefaultKeyword : SyntaxKind - DeleteKeyword = 73, + DeleteKeyword = 74, >DeleteKeyword : SyntaxKind - DoKeyword = 74, + DoKeyword = 75, >DoKeyword : SyntaxKind - ElseKeyword = 75, + ElseKeyword = 76, >ElseKeyword : SyntaxKind - EnumKeyword = 76, + EnumKeyword = 77, >EnumKeyword : SyntaxKind - ExportKeyword = 77, + ExportKeyword = 78, >ExportKeyword : SyntaxKind - ExtendsKeyword = 78, + ExtendsKeyword = 79, >ExtendsKeyword : SyntaxKind - FalseKeyword = 79, + FalseKeyword = 80, >FalseKeyword : SyntaxKind - FinallyKeyword = 80, + FinallyKeyword = 81, >FinallyKeyword : SyntaxKind - ForKeyword = 81, + ForKeyword = 82, >ForKeyword : SyntaxKind - FunctionKeyword = 82, + FunctionKeyword = 83, >FunctionKeyword : SyntaxKind - IfKeyword = 83, + IfKeyword = 84, >IfKeyword : SyntaxKind - ImportKeyword = 84, + ImportKeyword = 85, >ImportKeyword : SyntaxKind - InKeyword = 85, + InKeyword = 86, >InKeyword : SyntaxKind - InstanceOfKeyword = 86, + InstanceOfKeyword = 87, >InstanceOfKeyword : SyntaxKind - NewKeyword = 87, + NewKeyword = 88, >NewKeyword : SyntaxKind - NullKeyword = 88, + NullKeyword = 89, >NullKeyword : SyntaxKind - ReturnKeyword = 89, + ReturnKeyword = 90, >ReturnKeyword : SyntaxKind - SuperKeyword = 90, + SuperKeyword = 91, >SuperKeyword : SyntaxKind - SwitchKeyword = 91, + SwitchKeyword = 92, >SwitchKeyword : SyntaxKind - ThisKeyword = 92, + ThisKeyword = 93, >ThisKeyword : SyntaxKind - ThrowKeyword = 93, + ThrowKeyword = 94, >ThrowKeyword : SyntaxKind - TrueKeyword = 94, + TrueKeyword = 95, >TrueKeyword : SyntaxKind - TryKeyword = 95, + TryKeyword = 96, >TryKeyword : SyntaxKind - TypeOfKeyword = 96, + TypeOfKeyword = 97, >TypeOfKeyword : SyntaxKind - VarKeyword = 97, + VarKeyword = 98, >VarKeyword : SyntaxKind - VoidKeyword = 98, + VoidKeyword = 99, >VoidKeyword : SyntaxKind - WhileKeyword = 99, + WhileKeyword = 100, >WhileKeyword : SyntaxKind - WithKeyword = 100, + WithKeyword = 101, >WithKeyword : SyntaxKind - AsKeyword = 101, + AsKeyword = 102, >AsKeyword : SyntaxKind - ImplementsKeyword = 102, + ImplementsKeyword = 103, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 103, + InterfaceKeyword = 104, >InterfaceKeyword : SyntaxKind - LetKeyword = 104, + LetKeyword = 105, >LetKeyword : SyntaxKind - PackageKeyword = 105, + PackageKeyword = 106, >PackageKeyword : SyntaxKind - PrivateKeyword = 106, + PrivateKeyword = 107, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 107, + ProtectedKeyword = 108, >ProtectedKeyword : SyntaxKind - PublicKeyword = 108, + PublicKeyword = 109, >PublicKeyword : SyntaxKind - StaticKeyword = 109, + StaticKeyword = 110, >StaticKeyword : SyntaxKind - YieldKeyword = 110, + YieldKeyword = 111, >YieldKeyword : SyntaxKind - AnyKeyword = 111, + AnyKeyword = 112, >AnyKeyword : SyntaxKind - BooleanKeyword = 112, + BooleanKeyword = 113, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 113, + ConstructorKeyword = 114, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 114, + DeclareKeyword = 115, >DeclareKeyword : SyntaxKind - GetKeyword = 115, + GetKeyword = 116, >GetKeyword : SyntaxKind - ModuleKeyword = 116, + ModuleKeyword = 117, >ModuleKeyword : SyntaxKind - RequireKeyword = 117, + RequireKeyword = 118, >RequireKeyword : SyntaxKind - NumberKeyword = 118, + NumberKeyword = 119, >NumberKeyword : SyntaxKind - SetKeyword = 119, + SetKeyword = 120, >SetKeyword : SyntaxKind - StringKeyword = 120, + StringKeyword = 121, >StringKeyword : SyntaxKind - SymbolKeyword = 121, + SymbolKeyword = 122, >SymbolKeyword : SyntaxKind - TypeKeyword = 122, + TypeKeyword = 123, >TypeKeyword : SyntaxKind - FromKeyword = 123, + FromKeyword = 124, >FromKeyword : SyntaxKind - OfKeyword = 124, + OfKeyword = 125, >OfKeyword : SyntaxKind - QualifiedName = 125, + QualifiedName = 126, >QualifiedName : SyntaxKind - ComputedPropertyName = 126, + ComputedPropertyName = 127, >ComputedPropertyName : SyntaxKind - TypeParameter = 127, + TypeParameter = 128, >TypeParameter : SyntaxKind - Parameter = 128, + Parameter = 129, >Parameter : SyntaxKind - PropertySignature = 129, + Decorator = 130, +>Decorator : SyntaxKind + + PropertySignature = 131, >PropertySignature : SyntaxKind - PropertyDeclaration = 130, + PropertyDeclaration = 132, >PropertyDeclaration : SyntaxKind - MethodSignature = 131, + MethodSignature = 133, >MethodSignature : SyntaxKind - MethodDeclaration = 132, + MethodDeclaration = 134, >MethodDeclaration : SyntaxKind - Constructor = 133, + Constructor = 135, >Constructor : SyntaxKind - GetAccessor = 134, + GetAccessor = 136, >GetAccessor : SyntaxKind - SetAccessor = 135, + SetAccessor = 137, >SetAccessor : SyntaxKind - CallSignature = 136, + CallSignature = 138, >CallSignature : SyntaxKind - ConstructSignature = 137, + ConstructSignature = 139, >ConstructSignature : SyntaxKind - IndexSignature = 138, + IndexSignature = 140, >IndexSignature : SyntaxKind - TypeReference = 139, + TypeReference = 141, >TypeReference : SyntaxKind - FunctionType = 140, + FunctionType = 142, >FunctionType : SyntaxKind - ConstructorType = 141, + ConstructorType = 143, >ConstructorType : SyntaxKind - TypeQuery = 142, + TypeQuery = 144, >TypeQuery : SyntaxKind - TypeLiteral = 143, + TypeLiteral = 145, >TypeLiteral : SyntaxKind - ArrayType = 144, + ArrayType = 146, >ArrayType : SyntaxKind - TupleType = 145, + TupleType = 147, >TupleType : SyntaxKind - UnionType = 146, + UnionType = 148, >UnionType : SyntaxKind - ParenthesizedType = 147, + ParenthesizedType = 149, >ParenthesizedType : SyntaxKind - ObjectBindingPattern = 148, + ObjectBindingPattern = 150, >ObjectBindingPattern : SyntaxKind - ArrayBindingPattern = 149, + ArrayBindingPattern = 151, >ArrayBindingPattern : SyntaxKind - BindingElement = 150, + BindingElement = 152, >BindingElement : SyntaxKind - ArrayLiteralExpression = 151, + ArrayLiteralExpression = 153, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 152, + ObjectLiteralExpression = 154, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 153, + PropertyAccessExpression = 155, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 154, + ElementAccessExpression = 156, >ElementAccessExpression : SyntaxKind - CallExpression = 155, + CallExpression = 157, >CallExpression : SyntaxKind - NewExpression = 156, + NewExpression = 158, >NewExpression : SyntaxKind - TaggedTemplateExpression = 157, + TaggedTemplateExpression = 159, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 158, + TypeAssertionExpression = 160, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 159, + ParenthesizedExpression = 161, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 160, + FunctionExpression = 162, >FunctionExpression : SyntaxKind - ArrowFunction = 161, + ArrowFunction = 163, >ArrowFunction : SyntaxKind - DeleteExpression = 162, + DeleteExpression = 164, >DeleteExpression : SyntaxKind - TypeOfExpression = 163, + TypeOfExpression = 165, >TypeOfExpression : SyntaxKind - VoidExpression = 164, + VoidExpression = 166, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 165, + PrefixUnaryExpression = 167, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 166, + PostfixUnaryExpression = 168, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 167, + BinaryExpression = 169, >BinaryExpression : SyntaxKind - ConditionalExpression = 168, + ConditionalExpression = 170, >ConditionalExpression : SyntaxKind - TemplateExpression = 169, + TemplateExpression = 171, >TemplateExpression : SyntaxKind - YieldExpression = 170, + YieldExpression = 172, >YieldExpression : SyntaxKind - SpreadElementExpression = 171, + SpreadElementExpression = 173, >SpreadElementExpression : SyntaxKind - OmittedExpression = 172, + OmittedExpression = 174, >OmittedExpression : SyntaxKind - TemplateSpan = 173, + TemplateSpan = 175, >TemplateSpan : SyntaxKind - Block = 174, + Block = 176, >Block : SyntaxKind - VariableStatement = 175, + VariableStatement = 177, >VariableStatement : SyntaxKind - EmptyStatement = 176, + EmptyStatement = 178, >EmptyStatement : SyntaxKind - ExpressionStatement = 177, + ExpressionStatement = 179, >ExpressionStatement : SyntaxKind - IfStatement = 178, + IfStatement = 180, >IfStatement : SyntaxKind - DoStatement = 179, + DoStatement = 181, >DoStatement : SyntaxKind - WhileStatement = 180, + WhileStatement = 182, >WhileStatement : SyntaxKind - ForStatement = 181, + ForStatement = 183, >ForStatement : SyntaxKind - ForInStatement = 182, + ForInStatement = 184, >ForInStatement : SyntaxKind - ForOfStatement = 183, + ForOfStatement = 185, >ForOfStatement : SyntaxKind - ContinueStatement = 184, + ContinueStatement = 186, >ContinueStatement : SyntaxKind - BreakStatement = 185, + BreakStatement = 187, >BreakStatement : SyntaxKind - ReturnStatement = 186, + ReturnStatement = 188, >ReturnStatement : SyntaxKind - WithStatement = 187, + WithStatement = 189, >WithStatement : SyntaxKind - SwitchStatement = 188, + SwitchStatement = 190, >SwitchStatement : SyntaxKind - LabeledStatement = 189, + LabeledStatement = 191, >LabeledStatement : SyntaxKind - ThrowStatement = 190, + ThrowStatement = 192, >ThrowStatement : SyntaxKind - TryStatement = 191, + TryStatement = 193, >TryStatement : SyntaxKind - DebuggerStatement = 192, + DebuggerStatement = 194, >DebuggerStatement : SyntaxKind - VariableDeclaration = 193, + VariableDeclaration = 195, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 194, + VariableDeclarationList = 196, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 195, + FunctionDeclaration = 197, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 196, + ClassDeclaration = 198, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 197, + InterfaceDeclaration = 199, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 198, + TypeAliasDeclaration = 200, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 199, + EnumDeclaration = 201, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 200, + ModuleDeclaration = 202, >ModuleDeclaration : SyntaxKind - ModuleBlock = 201, + ModuleBlock = 203, >ModuleBlock : SyntaxKind - CaseBlock = 202, + CaseBlock = 204, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 203, + ImportEqualsDeclaration = 205, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 204, + ImportDeclaration = 206, >ImportDeclaration : SyntaxKind - ImportClause = 205, + ImportClause = 207, >ImportClause : SyntaxKind - NamespaceImport = 206, + NamespaceImport = 208, >NamespaceImport : SyntaxKind - NamedImports = 207, + NamedImports = 209, >NamedImports : SyntaxKind - ImportSpecifier = 208, + ImportSpecifier = 210, >ImportSpecifier : SyntaxKind - ExportAssignment = 209, + ExportAssignment = 211, >ExportAssignment : SyntaxKind - ExportDeclaration = 210, + ExportDeclaration = 212, >ExportDeclaration : SyntaxKind - NamedExports = 211, + NamedExports = 213, >NamedExports : SyntaxKind - ExportSpecifier = 212, + ExportSpecifier = 214, >ExportSpecifier : SyntaxKind - ExternalModuleReference = 213, + MissingDeclaration = 215, +>MissingDeclaration : SyntaxKind + + ExternalModuleReference = 216, >ExternalModuleReference : SyntaxKind - CaseClause = 214, + CaseClause = 217, >CaseClause : SyntaxKind - DefaultClause = 215, + DefaultClause = 218, >DefaultClause : SyntaxKind - HeritageClause = 216, + HeritageClause = 219, >HeritageClause : SyntaxKind - CatchClause = 217, + CatchClause = 220, >CatchClause : SyntaxKind - PropertyAssignment = 218, + PropertyAssignment = 221, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 219, + ShorthandPropertyAssignment = 222, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 220, + EnumMember = 223, >EnumMember : SyntaxKind - SourceFile = 221, + SourceFile = 224, >SourceFile : SyntaxKind - SyntaxList = 222, + SyntaxList = 225, >SyntaxList : SyntaxKind - Count = 223, + Count = 226, >Count : SyntaxKind - FirstAssignment = 52, + FirstAssignment = 53, >FirstAssignment : SyntaxKind - LastAssignment = 63, + LastAssignment = 64, >LastAssignment : SyntaxKind - FirstReservedWord = 65, + FirstReservedWord = 66, >FirstReservedWord : SyntaxKind - LastReservedWord = 100, + LastReservedWord = 101, >LastReservedWord : SyntaxKind - FirstKeyword = 65, + FirstKeyword = 66, >FirstKeyword : SyntaxKind - LastKeyword = 124, + LastKeyword = 125, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 102, + FirstFutureReservedWord = 103, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 110, + LastFutureReservedWord = 111, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 139, + FirstTypeNode = 141, >FirstTypeNode : SyntaxKind - LastTypeNode = 147, + LastTypeNode = 149, >LastTypeNode : SyntaxKind FirstPunctuation = 14, >FirstPunctuation : SyntaxKind - LastPunctuation = 63, + LastPunctuation = 64, >LastPunctuation : SyntaxKind FirstToken = 0, >FirstToken : SyntaxKind - LastToken = 124, + LastToken = 125, >LastToken : SyntaxKind FirstTriviaToken = 2, @@ -1076,10 +1085,10 @@ declare module "typescript" { FirstBinaryOperator = 24, >FirstBinaryOperator : SyntaxKind - LastBinaryOperator = 63, + LastBinaryOperator = 64, >LastBinaryOperator : SyntaxKind - FirstNode = 125, + FirstNode = 126, >FirstNode : SyntaxKind } const enum NodeFlags { @@ -1151,16 +1160,19 @@ declare module "typescript" { GeneratorParameter = 8, >GeneratorParameter : ParserContextFlags - ThisNodeHasError = 16, + Decorator = 16, +>Decorator : ParserContextFlags + + ThisNodeHasError = 32, >ThisNodeHasError : ParserContextFlags - ParserGeneratedFlags = 31, + ParserGeneratedFlags = 63, >ParserGeneratedFlags : ParserContextFlags - ThisNodeOrAnySubNodesHasError = 32, + ThisNodeOrAnySubNodesHasError = 64, >ThisNodeOrAnySubNodesHasError : ParserContextFlags - HasAggregatedChildData = 64, + HasAggregatedChildData = 128, >HasAggregatedChildData : ParserContextFlags } const enum RelationComparisonResult { @@ -1191,6 +1203,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1285,6 +1302,14 @@ declare module "typescript" { expression: Expression; >expression : Expression >Expression : Expression + } + interface Decorator extends Node { +>Decorator : Decorator +>Node : Node + + expression: LeftHandSideExpression; +>expression : LeftHandSideExpression +>LeftHandSideExpression : LeftHandSideExpression } interface TypeParameterDeclaration extends Declaration { >TypeParameterDeclaration : TypeParameterDeclaration @@ -3152,15 +3177,17 @@ declare module "typescript" { interface EmitResolver { >EmitResolver : EmitResolver - getGeneratedNameForNode(node: Node): string; ->getGeneratedNameForNode : (node: Node) => string ->node : Node ->Node : Node + hasGlobalName(name: string): boolean; +>hasGlobalName : (name: string) => boolean +>name : string - getExpressionNameSubstitution(node: Identifier): string; ->getExpressionNameSubstitution : (node: Identifier) => string + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; +>getExpressionNameSubstitution : (node: Identifier, getGeneratedNameForNode: (node: Node) => string) => string >node : Identifier >Identifier : Identifier +>getGeneratedNameForNode : (node: Node) => string +>node : Node +>Node : Node isValueAliasDeclaration(node: Node): boolean; >isValueAliasDeclaration : (node: Node) => boolean @@ -3259,8 +3286,8 @@ declare module "typescript" { >PropertyAccessExpression : PropertyAccessExpression >ElementAccessExpression : ElementAccessExpression - isUnknownIdentifier(location: Node, name: string): boolean; ->isUnknownIdentifier : (location: Node, name: string) => boolean + resolvesToSomeValue(location: Node, name: string): boolean; +>resolvesToSomeValue : (location: Node, name: string) => boolean >location : Node >Node : Node >name : string @@ -3582,6 +3609,9 @@ declare module "typescript" { BlockScopedBindingInLoop = 256, >BlockScopedBindingInLoop : NodeCheckFlags + + EmitDecorate = 512, +>EmitDecorate : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index ce17389a4fe4c..4004007508ab0 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -143,192 +143,195 @@ declare module "typescript" { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -336,8 +339,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -363,10 +366,11 @@ declare module "typescript" { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -377,6 +381,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -407,6 +412,9 @@ declare module "typescript" { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -971,8 +979,8 @@ declare module "typescript" { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; @@ -986,7 +994,7 @@ declare module "typescript" { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1093,6 +1101,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 39a3fdd948226..4ea9c49d7587d 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -447,562 +447,571 @@ declare module "typescript" { ColonToken = 51, >ColonToken : SyntaxKind - EqualsToken = 52, + AtToken = 52, +>AtToken : SyntaxKind + + EqualsToken = 53, >EqualsToken : SyntaxKind - PlusEqualsToken = 53, + PlusEqualsToken = 54, >PlusEqualsToken : SyntaxKind - MinusEqualsToken = 54, + MinusEqualsToken = 55, >MinusEqualsToken : SyntaxKind - AsteriskEqualsToken = 55, + AsteriskEqualsToken = 56, >AsteriskEqualsToken : SyntaxKind - SlashEqualsToken = 56, + SlashEqualsToken = 57, >SlashEqualsToken : SyntaxKind - PercentEqualsToken = 57, + PercentEqualsToken = 58, >PercentEqualsToken : SyntaxKind - LessThanLessThanEqualsToken = 58, + LessThanLessThanEqualsToken = 59, >LessThanLessThanEqualsToken : SyntaxKind - GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, >GreaterThanGreaterThanEqualsToken : SyntaxKind - GreaterThanGreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, >GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind - AmpersandEqualsToken = 61, + AmpersandEqualsToken = 62, >AmpersandEqualsToken : SyntaxKind - BarEqualsToken = 62, + BarEqualsToken = 63, >BarEqualsToken : SyntaxKind - CaretEqualsToken = 63, + CaretEqualsToken = 64, >CaretEqualsToken : SyntaxKind - Identifier = 64, + Identifier = 65, >Identifier : SyntaxKind - BreakKeyword = 65, + BreakKeyword = 66, >BreakKeyword : SyntaxKind - CaseKeyword = 66, + CaseKeyword = 67, >CaseKeyword : SyntaxKind - CatchKeyword = 67, + CatchKeyword = 68, >CatchKeyword : SyntaxKind - ClassKeyword = 68, + ClassKeyword = 69, >ClassKeyword : SyntaxKind - ConstKeyword = 69, + ConstKeyword = 70, >ConstKeyword : SyntaxKind - ContinueKeyword = 70, + ContinueKeyword = 71, >ContinueKeyword : SyntaxKind - DebuggerKeyword = 71, + DebuggerKeyword = 72, >DebuggerKeyword : SyntaxKind - DefaultKeyword = 72, + DefaultKeyword = 73, >DefaultKeyword : SyntaxKind - DeleteKeyword = 73, + DeleteKeyword = 74, >DeleteKeyword : SyntaxKind - DoKeyword = 74, + DoKeyword = 75, >DoKeyword : SyntaxKind - ElseKeyword = 75, + ElseKeyword = 76, >ElseKeyword : SyntaxKind - EnumKeyword = 76, + EnumKeyword = 77, >EnumKeyword : SyntaxKind - ExportKeyword = 77, + ExportKeyword = 78, >ExportKeyword : SyntaxKind - ExtendsKeyword = 78, + ExtendsKeyword = 79, >ExtendsKeyword : SyntaxKind - FalseKeyword = 79, + FalseKeyword = 80, >FalseKeyword : SyntaxKind - FinallyKeyword = 80, + FinallyKeyword = 81, >FinallyKeyword : SyntaxKind - ForKeyword = 81, + ForKeyword = 82, >ForKeyword : SyntaxKind - FunctionKeyword = 82, + FunctionKeyword = 83, >FunctionKeyword : SyntaxKind - IfKeyword = 83, + IfKeyword = 84, >IfKeyword : SyntaxKind - ImportKeyword = 84, + ImportKeyword = 85, >ImportKeyword : SyntaxKind - InKeyword = 85, + InKeyword = 86, >InKeyword : SyntaxKind - InstanceOfKeyword = 86, + InstanceOfKeyword = 87, >InstanceOfKeyword : SyntaxKind - NewKeyword = 87, + NewKeyword = 88, >NewKeyword : SyntaxKind - NullKeyword = 88, + NullKeyword = 89, >NullKeyword : SyntaxKind - ReturnKeyword = 89, + ReturnKeyword = 90, >ReturnKeyword : SyntaxKind - SuperKeyword = 90, + SuperKeyword = 91, >SuperKeyword : SyntaxKind - SwitchKeyword = 91, + SwitchKeyword = 92, >SwitchKeyword : SyntaxKind - ThisKeyword = 92, + ThisKeyword = 93, >ThisKeyword : SyntaxKind - ThrowKeyword = 93, + ThrowKeyword = 94, >ThrowKeyword : SyntaxKind - TrueKeyword = 94, + TrueKeyword = 95, >TrueKeyword : SyntaxKind - TryKeyword = 95, + TryKeyword = 96, >TryKeyword : SyntaxKind - TypeOfKeyword = 96, + TypeOfKeyword = 97, >TypeOfKeyword : SyntaxKind - VarKeyword = 97, + VarKeyword = 98, >VarKeyword : SyntaxKind - VoidKeyword = 98, + VoidKeyword = 99, >VoidKeyword : SyntaxKind - WhileKeyword = 99, + WhileKeyword = 100, >WhileKeyword : SyntaxKind - WithKeyword = 100, + WithKeyword = 101, >WithKeyword : SyntaxKind - AsKeyword = 101, + AsKeyword = 102, >AsKeyword : SyntaxKind - ImplementsKeyword = 102, + ImplementsKeyword = 103, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 103, + InterfaceKeyword = 104, >InterfaceKeyword : SyntaxKind - LetKeyword = 104, + LetKeyword = 105, >LetKeyword : SyntaxKind - PackageKeyword = 105, + PackageKeyword = 106, >PackageKeyword : SyntaxKind - PrivateKeyword = 106, + PrivateKeyword = 107, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 107, + ProtectedKeyword = 108, >ProtectedKeyword : SyntaxKind - PublicKeyword = 108, + PublicKeyword = 109, >PublicKeyword : SyntaxKind - StaticKeyword = 109, + StaticKeyword = 110, >StaticKeyword : SyntaxKind - YieldKeyword = 110, + YieldKeyword = 111, >YieldKeyword : SyntaxKind - AnyKeyword = 111, + AnyKeyword = 112, >AnyKeyword : SyntaxKind - BooleanKeyword = 112, + BooleanKeyword = 113, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 113, + ConstructorKeyword = 114, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 114, + DeclareKeyword = 115, >DeclareKeyword : SyntaxKind - GetKeyword = 115, + GetKeyword = 116, >GetKeyword : SyntaxKind - ModuleKeyword = 116, + ModuleKeyword = 117, >ModuleKeyword : SyntaxKind - RequireKeyword = 117, + RequireKeyword = 118, >RequireKeyword : SyntaxKind - NumberKeyword = 118, + NumberKeyword = 119, >NumberKeyword : SyntaxKind - SetKeyword = 119, + SetKeyword = 120, >SetKeyword : SyntaxKind - StringKeyword = 120, + StringKeyword = 121, >StringKeyword : SyntaxKind - SymbolKeyword = 121, + SymbolKeyword = 122, >SymbolKeyword : SyntaxKind - TypeKeyword = 122, + TypeKeyword = 123, >TypeKeyword : SyntaxKind - FromKeyword = 123, + FromKeyword = 124, >FromKeyword : SyntaxKind - OfKeyword = 124, + OfKeyword = 125, >OfKeyword : SyntaxKind - QualifiedName = 125, + QualifiedName = 126, >QualifiedName : SyntaxKind - ComputedPropertyName = 126, + ComputedPropertyName = 127, >ComputedPropertyName : SyntaxKind - TypeParameter = 127, + TypeParameter = 128, >TypeParameter : SyntaxKind - Parameter = 128, + Parameter = 129, >Parameter : SyntaxKind - PropertySignature = 129, + Decorator = 130, +>Decorator : SyntaxKind + + PropertySignature = 131, >PropertySignature : SyntaxKind - PropertyDeclaration = 130, + PropertyDeclaration = 132, >PropertyDeclaration : SyntaxKind - MethodSignature = 131, + MethodSignature = 133, >MethodSignature : SyntaxKind - MethodDeclaration = 132, + MethodDeclaration = 134, >MethodDeclaration : SyntaxKind - Constructor = 133, + Constructor = 135, >Constructor : SyntaxKind - GetAccessor = 134, + GetAccessor = 136, >GetAccessor : SyntaxKind - SetAccessor = 135, + SetAccessor = 137, >SetAccessor : SyntaxKind - CallSignature = 136, + CallSignature = 138, >CallSignature : SyntaxKind - ConstructSignature = 137, + ConstructSignature = 139, >ConstructSignature : SyntaxKind - IndexSignature = 138, + IndexSignature = 140, >IndexSignature : SyntaxKind - TypeReference = 139, + TypeReference = 141, >TypeReference : SyntaxKind - FunctionType = 140, + FunctionType = 142, >FunctionType : SyntaxKind - ConstructorType = 141, + ConstructorType = 143, >ConstructorType : SyntaxKind - TypeQuery = 142, + TypeQuery = 144, >TypeQuery : SyntaxKind - TypeLiteral = 143, + TypeLiteral = 145, >TypeLiteral : SyntaxKind - ArrayType = 144, + ArrayType = 146, >ArrayType : SyntaxKind - TupleType = 145, + TupleType = 147, >TupleType : SyntaxKind - UnionType = 146, + UnionType = 148, >UnionType : SyntaxKind - ParenthesizedType = 147, + ParenthesizedType = 149, >ParenthesizedType : SyntaxKind - ObjectBindingPattern = 148, + ObjectBindingPattern = 150, >ObjectBindingPattern : SyntaxKind - ArrayBindingPattern = 149, + ArrayBindingPattern = 151, >ArrayBindingPattern : SyntaxKind - BindingElement = 150, + BindingElement = 152, >BindingElement : SyntaxKind - ArrayLiteralExpression = 151, + ArrayLiteralExpression = 153, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 152, + ObjectLiteralExpression = 154, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 153, + PropertyAccessExpression = 155, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 154, + ElementAccessExpression = 156, >ElementAccessExpression : SyntaxKind - CallExpression = 155, + CallExpression = 157, >CallExpression : SyntaxKind - NewExpression = 156, + NewExpression = 158, >NewExpression : SyntaxKind - TaggedTemplateExpression = 157, + TaggedTemplateExpression = 159, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 158, + TypeAssertionExpression = 160, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 159, + ParenthesizedExpression = 161, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 160, + FunctionExpression = 162, >FunctionExpression : SyntaxKind - ArrowFunction = 161, + ArrowFunction = 163, >ArrowFunction : SyntaxKind - DeleteExpression = 162, + DeleteExpression = 164, >DeleteExpression : SyntaxKind - TypeOfExpression = 163, + TypeOfExpression = 165, >TypeOfExpression : SyntaxKind - VoidExpression = 164, + VoidExpression = 166, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 165, + PrefixUnaryExpression = 167, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 166, + PostfixUnaryExpression = 168, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 167, + BinaryExpression = 169, >BinaryExpression : SyntaxKind - ConditionalExpression = 168, + ConditionalExpression = 170, >ConditionalExpression : SyntaxKind - TemplateExpression = 169, + TemplateExpression = 171, >TemplateExpression : SyntaxKind - YieldExpression = 170, + YieldExpression = 172, >YieldExpression : SyntaxKind - SpreadElementExpression = 171, + SpreadElementExpression = 173, >SpreadElementExpression : SyntaxKind - OmittedExpression = 172, + OmittedExpression = 174, >OmittedExpression : SyntaxKind - TemplateSpan = 173, + TemplateSpan = 175, >TemplateSpan : SyntaxKind - Block = 174, + Block = 176, >Block : SyntaxKind - VariableStatement = 175, + VariableStatement = 177, >VariableStatement : SyntaxKind - EmptyStatement = 176, + EmptyStatement = 178, >EmptyStatement : SyntaxKind - ExpressionStatement = 177, + ExpressionStatement = 179, >ExpressionStatement : SyntaxKind - IfStatement = 178, + IfStatement = 180, >IfStatement : SyntaxKind - DoStatement = 179, + DoStatement = 181, >DoStatement : SyntaxKind - WhileStatement = 180, + WhileStatement = 182, >WhileStatement : SyntaxKind - ForStatement = 181, + ForStatement = 183, >ForStatement : SyntaxKind - ForInStatement = 182, + ForInStatement = 184, >ForInStatement : SyntaxKind - ForOfStatement = 183, + ForOfStatement = 185, >ForOfStatement : SyntaxKind - ContinueStatement = 184, + ContinueStatement = 186, >ContinueStatement : SyntaxKind - BreakStatement = 185, + BreakStatement = 187, >BreakStatement : SyntaxKind - ReturnStatement = 186, + ReturnStatement = 188, >ReturnStatement : SyntaxKind - WithStatement = 187, + WithStatement = 189, >WithStatement : SyntaxKind - SwitchStatement = 188, + SwitchStatement = 190, >SwitchStatement : SyntaxKind - LabeledStatement = 189, + LabeledStatement = 191, >LabeledStatement : SyntaxKind - ThrowStatement = 190, + ThrowStatement = 192, >ThrowStatement : SyntaxKind - TryStatement = 191, + TryStatement = 193, >TryStatement : SyntaxKind - DebuggerStatement = 192, + DebuggerStatement = 194, >DebuggerStatement : SyntaxKind - VariableDeclaration = 193, + VariableDeclaration = 195, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 194, + VariableDeclarationList = 196, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 195, + FunctionDeclaration = 197, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 196, + ClassDeclaration = 198, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 197, + InterfaceDeclaration = 199, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 198, + TypeAliasDeclaration = 200, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 199, + EnumDeclaration = 201, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 200, + ModuleDeclaration = 202, >ModuleDeclaration : SyntaxKind - ModuleBlock = 201, + ModuleBlock = 203, >ModuleBlock : SyntaxKind - CaseBlock = 202, + CaseBlock = 204, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 203, + ImportEqualsDeclaration = 205, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 204, + ImportDeclaration = 206, >ImportDeclaration : SyntaxKind - ImportClause = 205, + ImportClause = 207, >ImportClause : SyntaxKind - NamespaceImport = 206, + NamespaceImport = 208, >NamespaceImport : SyntaxKind - NamedImports = 207, + NamedImports = 209, >NamedImports : SyntaxKind - ImportSpecifier = 208, + ImportSpecifier = 210, >ImportSpecifier : SyntaxKind - ExportAssignment = 209, + ExportAssignment = 211, >ExportAssignment : SyntaxKind - ExportDeclaration = 210, + ExportDeclaration = 212, >ExportDeclaration : SyntaxKind - NamedExports = 211, + NamedExports = 213, >NamedExports : SyntaxKind - ExportSpecifier = 212, + ExportSpecifier = 214, >ExportSpecifier : SyntaxKind - ExternalModuleReference = 213, + MissingDeclaration = 215, +>MissingDeclaration : SyntaxKind + + ExternalModuleReference = 216, >ExternalModuleReference : SyntaxKind - CaseClause = 214, + CaseClause = 217, >CaseClause : SyntaxKind - DefaultClause = 215, + DefaultClause = 218, >DefaultClause : SyntaxKind - HeritageClause = 216, + HeritageClause = 219, >HeritageClause : SyntaxKind - CatchClause = 217, + CatchClause = 220, >CatchClause : SyntaxKind - PropertyAssignment = 218, + PropertyAssignment = 221, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 219, + ShorthandPropertyAssignment = 222, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 220, + EnumMember = 223, >EnumMember : SyntaxKind - SourceFile = 221, + SourceFile = 224, >SourceFile : SyntaxKind - SyntaxList = 222, + SyntaxList = 225, >SyntaxList : SyntaxKind - Count = 223, + Count = 226, >Count : SyntaxKind - FirstAssignment = 52, + FirstAssignment = 53, >FirstAssignment : SyntaxKind - LastAssignment = 63, + LastAssignment = 64, >LastAssignment : SyntaxKind - FirstReservedWord = 65, + FirstReservedWord = 66, >FirstReservedWord : SyntaxKind - LastReservedWord = 100, + LastReservedWord = 101, >LastReservedWord : SyntaxKind - FirstKeyword = 65, + FirstKeyword = 66, >FirstKeyword : SyntaxKind - LastKeyword = 124, + LastKeyword = 125, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 102, + FirstFutureReservedWord = 103, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 110, + LastFutureReservedWord = 111, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 139, + FirstTypeNode = 141, >FirstTypeNode : SyntaxKind - LastTypeNode = 147, + LastTypeNode = 149, >LastTypeNode : SyntaxKind FirstPunctuation = 14, >FirstPunctuation : SyntaxKind - LastPunctuation = 63, + LastPunctuation = 64, >LastPunctuation : SyntaxKind FirstToken = 0, >FirstToken : SyntaxKind - LastToken = 124, + LastToken = 125, >LastToken : SyntaxKind FirstTriviaToken = 2, @@ -1026,10 +1035,10 @@ declare module "typescript" { FirstBinaryOperator = 24, >FirstBinaryOperator : SyntaxKind - LastBinaryOperator = 63, + LastBinaryOperator = 64, >LastBinaryOperator : SyntaxKind - FirstNode = 125, + FirstNode = 126, >FirstNode : SyntaxKind } const enum NodeFlags { @@ -1101,16 +1110,19 @@ declare module "typescript" { GeneratorParameter = 8, >GeneratorParameter : ParserContextFlags - ThisNodeHasError = 16, + Decorator = 16, +>Decorator : ParserContextFlags + + ThisNodeHasError = 32, >ThisNodeHasError : ParserContextFlags - ParserGeneratedFlags = 31, + ParserGeneratedFlags = 63, >ParserGeneratedFlags : ParserContextFlags - ThisNodeOrAnySubNodesHasError = 32, + ThisNodeOrAnySubNodesHasError = 64, >ThisNodeOrAnySubNodesHasError : ParserContextFlags - HasAggregatedChildData = 64, + HasAggregatedChildData = 128, >HasAggregatedChildData : ParserContextFlags } const enum RelationComparisonResult { @@ -1141,6 +1153,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1235,6 +1252,14 @@ declare module "typescript" { expression: Expression; >expression : Expression >Expression : Expression + } + interface Decorator extends Node { +>Decorator : Decorator +>Node : Node + + expression: LeftHandSideExpression; +>expression : LeftHandSideExpression +>LeftHandSideExpression : LeftHandSideExpression } interface TypeParameterDeclaration extends Declaration { >TypeParameterDeclaration : TypeParameterDeclaration @@ -3102,15 +3127,17 @@ declare module "typescript" { interface EmitResolver { >EmitResolver : EmitResolver - getGeneratedNameForNode(node: Node): string; ->getGeneratedNameForNode : (node: Node) => string ->node : Node ->Node : Node + hasGlobalName(name: string): boolean; +>hasGlobalName : (name: string) => boolean +>name : string - getExpressionNameSubstitution(node: Identifier): string; ->getExpressionNameSubstitution : (node: Identifier) => string + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; +>getExpressionNameSubstitution : (node: Identifier, getGeneratedNameForNode: (node: Node) => string) => string >node : Identifier >Identifier : Identifier +>getGeneratedNameForNode : (node: Node) => string +>node : Node +>Node : Node isValueAliasDeclaration(node: Node): boolean; >isValueAliasDeclaration : (node: Node) => boolean @@ -3209,8 +3236,8 @@ declare module "typescript" { >PropertyAccessExpression : PropertyAccessExpression >ElementAccessExpression : ElementAccessExpression - isUnknownIdentifier(location: Node, name: string): boolean; ->isUnknownIdentifier : (location: Node, name: string) => boolean + resolvesToSomeValue(location: Node, name: string): boolean; +>resolvesToSomeValue : (location: Node, name: string) => boolean >location : Node >Node : Node >name : string @@ -3532,6 +3559,9 @@ declare module "typescript" { BlockScopedBindingInLoop = 256, >BlockScopedBindingInLoop : NodeCheckFlags + + EmitDecorate = 512, +>EmitDecorate : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 32cac96694831..34503a0d81a22 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -180,192 +180,195 @@ declare module "typescript" { BarBarToken = 49, QuestionToken = 50, ColonToken = 51, - EqualsToken = 52, - PlusEqualsToken = 53, - MinusEqualsToken = 54, - AsteriskEqualsToken = 55, - SlashEqualsToken = 56, - PercentEqualsToken = 57, - LessThanLessThanEqualsToken = 58, - GreaterThanGreaterThanEqualsToken = 59, - GreaterThanGreaterThanGreaterThanEqualsToken = 60, - AmpersandEqualsToken = 61, - BarEqualsToken = 62, - CaretEqualsToken = 63, - Identifier = 64, - BreakKeyword = 65, - CaseKeyword = 66, - CatchKeyword = 67, - ClassKeyword = 68, - ConstKeyword = 69, - ContinueKeyword = 70, - DebuggerKeyword = 71, - DefaultKeyword = 72, - DeleteKeyword = 73, - DoKeyword = 74, - ElseKeyword = 75, - EnumKeyword = 76, - ExportKeyword = 77, - ExtendsKeyword = 78, - FalseKeyword = 79, - FinallyKeyword = 80, - ForKeyword = 81, - FunctionKeyword = 82, - IfKeyword = 83, - ImportKeyword = 84, - InKeyword = 85, - InstanceOfKeyword = 86, - NewKeyword = 87, - NullKeyword = 88, - ReturnKeyword = 89, - SuperKeyword = 90, - SwitchKeyword = 91, - ThisKeyword = 92, - ThrowKeyword = 93, - TrueKeyword = 94, - TryKeyword = 95, - TypeOfKeyword = 96, - VarKeyword = 97, - VoidKeyword = 98, - WhileKeyword = 99, - WithKeyword = 100, - AsKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AnyKeyword = 111, - BooleanKeyword = 112, - ConstructorKeyword = 113, - DeclareKeyword = 114, - GetKeyword = 115, - ModuleKeyword = 116, - RequireKeyword = 117, - NumberKeyword = 118, - SetKeyword = 119, - StringKeyword = 120, - SymbolKeyword = 121, - TypeKeyword = 122, - FromKeyword = 123, - OfKeyword = 124, - QualifiedName = 125, - ComputedPropertyName = 126, - TypeParameter = 127, - Parameter = 128, - PropertySignature = 129, - PropertyDeclaration = 130, - MethodSignature = 131, - MethodDeclaration = 132, - Constructor = 133, - GetAccessor = 134, - SetAccessor = 135, - CallSignature = 136, - ConstructSignature = 137, - IndexSignature = 138, - TypeReference = 139, - FunctionType = 140, - ConstructorType = 141, - TypeQuery = 142, - TypeLiteral = 143, - ArrayType = 144, - TupleType = 145, - UnionType = 146, - ParenthesizedType = 147, - ObjectBindingPattern = 148, - ArrayBindingPattern = 149, - BindingElement = 150, - ArrayLiteralExpression = 151, - ObjectLiteralExpression = 152, - PropertyAccessExpression = 153, - ElementAccessExpression = 154, - CallExpression = 155, - NewExpression = 156, - TaggedTemplateExpression = 157, - TypeAssertionExpression = 158, - ParenthesizedExpression = 159, - FunctionExpression = 160, - ArrowFunction = 161, - DeleteExpression = 162, - TypeOfExpression = 163, - VoidExpression = 164, - PrefixUnaryExpression = 165, - PostfixUnaryExpression = 166, - BinaryExpression = 167, - ConditionalExpression = 168, - TemplateExpression = 169, - YieldExpression = 170, - SpreadElementExpression = 171, - OmittedExpression = 172, - TemplateSpan = 173, - Block = 174, - VariableStatement = 175, - EmptyStatement = 176, - ExpressionStatement = 177, - IfStatement = 178, - DoStatement = 179, - WhileStatement = 180, - ForStatement = 181, - ForInStatement = 182, - ForOfStatement = 183, - ContinueStatement = 184, - BreakStatement = 185, - ReturnStatement = 186, - WithStatement = 187, - SwitchStatement = 188, - LabeledStatement = 189, - ThrowStatement = 190, - TryStatement = 191, - DebuggerStatement = 192, - VariableDeclaration = 193, - VariableDeclarationList = 194, - FunctionDeclaration = 195, - ClassDeclaration = 196, - InterfaceDeclaration = 197, - TypeAliasDeclaration = 198, - EnumDeclaration = 199, - ModuleDeclaration = 200, - ModuleBlock = 201, - CaseBlock = 202, - ImportEqualsDeclaration = 203, - ImportDeclaration = 204, - ImportClause = 205, - NamespaceImport = 206, - NamedImports = 207, - ImportSpecifier = 208, - ExportAssignment = 209, - ExportDeclaration = 210, - NamedExports = 211, - ExportSpecifier = 212, - ExternalModuleReference = 213, - CaseClause = 214, - DefaultClause = 215, - HeritageClause = 216, - CatchClause = 217, - PropertyAssignment = 218, - ShorthandPropertyAssignment = 219, - EnumMember = 220, - SourceFile = 221, - SyntaxList = 222, - Count = 223, - FirstAssignment = 52, - LastAssignment = 63, - FirstReservedWord = 65, - LastReservedWord = 100, - FirstKeyword = 65, - LastKeyword = 124, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 139, - LastTypeNode = 147, + AtToken = 52, + EqualsToken = 53, + PlusEqualsToken = 54, + MinusEqualsToken = 55, + AsteriskEqualsToken = 56, + SlashEqualsToken = 57, + PercentEqualsToken = 58, + LessThanLessThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, + AmpersandEqualsToken = 62, + BarEqualsToken = 63, + CaretEqualsToken = 64, + Identifier = 65, + BreakKeyword = 66, + CaseKeyword = 67, + CatchKeyword = 68, + ClassKeyword = 69, + ConstKeyword = 70, + ContinueKeyword = 71, + DebuggerKeyword = 72, + DefaultKeyword = 73, + DeleteKeyword = 74, + DoKeyword = 75, + ElseKeyword = 76, + EnumKeyword = 77, + ExportKeyword = 78, + ExtendsKeyword = 79, + FalseKeyword = 80, + FinallyKeyword = 81, + ForKeyword = 82, + FunctionKeyword = 83, + IfKeyword = 84, + ImportKeyword = 85, + InKeyword = 86, + InstanceOfKeyword = 87, + NewKeyword = 88, + NullKeyword = 89, + ReturnKeyword = 90, + SuperKeyword = 91, + SwitchKeyword = 92, + ThisKeyword = 93, + ThrowKeyword = 94, + TrueKeyword = 95, + TryKeyword = 96, + TypeOfKeyword = 97, + VarKeyword = 98, + VoidKeyword = 99, + WhileKeyword = 100, + WithKeyword = 101, + AsKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AnyKeyword = 112, + BooleanKeyword = 113, + ConstructorKeyword = 114, + DeclareKeyword = 115, + GetKeyword = 116, + ModuleKeyword = 117, + RequireKeyword = 118, + NumberKeyword = 119, + SetKeyword = 120, + StringKeyword = 121, + SymbolKeyword = 122, + TypeKeyword = 123, + FromKeyword = 124, + OfKeyword = 125, + QualifiedName = 126, + ComputedPropertyName = 127, + TypeParameter = 128, + Parameter = 129, + Decorator = 130, + PropertySignature = 131, + PropertyDeclaration = 132, + MethodSignature = 133, + MethodDeclaration = 134, + Constructor = 135, + GetAccessor = 136, + SetAccessor = 137, + CallSignature = 138, + ConstructSignature = 139, + IndexSignature = 140, + TypeReference = 141, + FunctionType = 142, + ConstructorType = 143, + TypeQuery = 144, + TypeLiteral = 145, + ArrayType = 146, + TupleType = 147, + UnionType = 148, + ParenthesizedType = 149, + ObjectBindingPattern = 150, + ArrayBindingPattern = 151, + BindingElement = 152, + ArrayLiteralExpression = 153, + ObjectLiteralExpression = 154, + PropertyAccessExpression = 155, + ElementAccessExpression = 156, + CallExpression = 157, + NewExpression = 158, + TaggedTemplateExpression = 159, + TypeAssertionExpression = 160, + ParenthesizedExpression = 161, + FunctionExpression = 162, + ArrowFunction = 163, + DeleteExpression = 164, + TypeOfExpression = 165, + VoidExpression = 166, + PrefixUnaryExpression = 167, + PostfixUnaryExpression = 168, + BinaryExpression = 169, + ConditionalExpression = 170, + TemplateExpression = 171, + YieldExpression = 172, + SpreadElementExpression = 173, + OmittedExpression = 174, + TemplateSpan = 175, + Block = 176, + VariableStatement = 177, + EmptyStatement = 178, + ExpressionStatement = 179, + IfStatement = 180, + DoStatement = 181, + WhileStatement = 182, + ForStatement = 183, + ForInStatement = 184, + ForOfStatement = 185, + ContinueStatement = 186, + BreakStatement = 187, + ReturnStatement = 188, + WithStatement = 189, + SwitchStatement = 190, + LabeledStatement = 191, + ThrowStatement = 192, + TryStatement = 193, + DebuggerStatement = 194, + VariableDeclaration = 195, + VariableDeclarationList = 196, + FunctionDeclaration = 197, + ClassDeclaration = 198, + InterfaceDeclaration = 199, + TypeAliasDeclaration = 200, + EnumDeclaration = 201, + ModuleDeclaration = 202, + ModuleBlock = 203, + CaseBlock = 204, + ImportEqualsDeclaration = 205, + ImportDeclaration = 206, + ImportClause = 207, + NamespaceImport = 208, + NamedImports = 209, + ImportSpecifier = 210, + ExportAssignment = 211, + ExportDeclaration = 212, + NamedExports = 213, + ExportSpecifier = 214, + MissingDeclaration = 215, + ExternalModuleReference = 216, + CaseClause = 217, + DefaultClause = 218, + HeritageClause = 219, + CatchClause = 220, + PropertyAssignment = 221, + ShorthandPropertyAssignment = 222, + EnumMember = 223, + SourceFile = 224, + SyntaxList = 225, + Count = 226, + FirstAssignment = 53, + LastAssignment = 64, + FirstReservedWord = 66, + LastReservedWord = 101, + FirstKeyword = 66, + LastKeyword = 125, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 141, + LastTypeNode = 149, FirstPunctuation = 14, - LastPunctuation = 63, + LastPunctuation = 64, FirstToken = 0, - LastToken = 124, + LastToken = 125, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -373,8 +376,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 63, - FirstNode = 125, + LastBinaryOperator = 64, + FirstNode = 126, } const enum NodeFlags { Export = 1, @@ -400,10 +403,11 @@ declare module "typescript" { DisallowIn = 2, Yield = 4, GeneratorParameter = 8, - ThisNodeHasError = 16, - ParserGeneratedFlags = 31, - ThisNodeOrAnySubNodesHasError = 32, - HasAggregatedChildData = 64, + Decorator = 16, + ThisNodeHasError = 32, + ParserGeneratedFlags = 63, + ThisNodeOrAnySubNodesHasError = 64, + HasAggregatedChildData = 128, } const enum RelationComparisonResult { Succeeded = 1, @@ -414,6 +418,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -444,6 +449,9 @@ declare module "typescript" { interface ComputedPropertyName extends Node { expression: Expression; } + interface Decorator extends Node { + expression: LeftHandSideExpression; + } interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -1008,8 +1016,8 @@ declare module "typescript" { errorModuleName?: string; } interface EmitResolver { - getGeneratedNameForNode(node: Node): string; - getExpressionNameSubstitution(node: Identifier): string; + hasGlobalName(name: string): boolean; + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; isValueAliasDeclaration(node: Node): boolean; isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; @@ -1023,7 +1031,7 @@ declare module "typescript" { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isUnknownIdentifier(location: Node, name: string): boolean; + resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { @@ -1130,6 +1138,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 716fe5394879a..3903e169b4e3b 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -620,562 +620,571 @@ declare module "typescript" { ColonToken = 51, >ColonToken : SyntaxKind - EqualsToken = 52, + AtToken = 52, +>AtToken : SyntaxKind + + EqualsToken = 53, >EqualsToken : SyntaxKind - PlusEqualsToken = 53, + PlusEqualsToken = 54, >PlusEqualsToken : SyntaxKind - MinusEqualsToken = 54, + MinusEqualsToken = 55, >MinusEqualsToken : SyntaxKind - AsteriskEqualsToken = 55, + AsteriskEqualsToken = 56, >AsteriskEqualsToken : SyntaxKind - SlashEqualsToken = 56, + SlashEqualsToken = 57, >SlashEqualsToken : SyntaxKind - PercentEqualsToken = 57, + PercentEqualsToken = 58, >PercentEqualsToken : SyntaxKind - LessThanLessThanEqualsToken = 58, + LessThanLessThanEqualsToken = 59, >LessThanLessThanEqualsToken : SyntaxKind - GreaterThanGreaterThanEqualsToken = 59, + GreaterThanGreaterThanEqualsToken = 60, >GreaterThanGreaterThanEqualsToken : SyntaxKind - GreaterThanGreaterThanGreaterThanEqualsToken = 60, + GreaterThanGreaterThanGreaterThanEqualsToken = 61, >GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind - AmpersandEqualsToken = 61, + AmpersandEqualsToken = 62, >AmpersandEqualsToken : SyntaxKind - BarEqualsToken = 62, + BarEqualsToken = 63, >BarEqualsToken : SyntaxKind - CaretEqualsToken = 63, + CaretEqualsToken = 64, >CaretEqualsToken : SyntaxKind - Identifier = 64, + Identifier = 65, >Identifier : SyntaxKind - BreakKeyword = 65, + BreakKeyword = 66, >BreakKeyword : SyntaxKind - CaseKeyword = 66, + CaseKeyword = 67, >CaseKeyword : SyntaxKind - CatchKeyword = 67, + CatchKeyword = 68, >CatchKeyword : SyntaxKind - ClassKeyword = 68, + ClassKeyword = 69, >ClassKeyword : SyntaxKind - ConstKeyword = 69, + ConstKeyword = 70, >ConstKeyword : SyntaxKind - ContinueKeyword = 70, + ContinueKeyword = 71, >ContinueKeyword : SyntaxKind - DebuggerKeyword = 71, + DebuggerKeyword = 72, >DebuggerKeyword : SyntaxKind - DefaultKeyword = 72, + DefaultKeyword = 73, >DefaultKeyword : SyntaxKind - DeleteKeyword = 73, + DeleteKeyword = 74, >DeleteKeyword : SyntaxKind - DoKeyword = 74, + DoKeyword = 75, >DoKeyword : SyntaxKind - ElseKeyword = 75, + ElseKeyword = 76, >ElseKeyword : SyntaxKind - EnumKeyword = 76, + EnumKeyword = 77, >EnumKeyword : SyntaxKind - ExportKeyword = 77, + ExportKeyword = 78, >ExportKeyword : SyntaxKind - ExtendsKeyword = 78, + ExtendsKeyword = 79, >ExtendsKeyword : SyntaxKind - FalseKeyword = 79, + FalseKeyword = 80, >FalseKeyword : SyntaxKind - FinallyKeyword = 80, + FinallyKeyword = 81, >FinallyKeyword : SyntaxKind - ForKeyword = 81, + ForKeyword = 82, >ForKeyword : SyntaxKind - FunctionKeyword = 82, + FunctionKeyword = 83, >FunctionKeyword : SyntaxKind - IfKeyword = 83, + IfKeyword = 84, >IfKeyword : SyntaxKind - ImportKeyword = 84, + ImportKeyword = 85, >ImportKeyword : SyntaxKind - InKeyword = 85, + InKeyword = 86, >InKeyword : SyntaxKind - InstanceOfKeyword = 86, + InstanceOfKeyword = 87, >InstanceOfKeyword : SyntaxKind - NewKeyword = 87, + NewKeyword = 88, >NewKeyword : SyntaxKind - NullKeyword = 88, + NullKeyword = 89, >NullKeyword : SyntaxKind - ReturnKeyword = 89, + ReturnKeyword = 90, >ReturnKeyword : SyntaxKind - SuperKeyword = 90, + SuperKeyword = 91, >SuperKeyword : SyntaxKind - SwitchKeyword = 91, + SwitchKeyword = 92, >SwitchKeyword : SyntaxKind - ThisKeyword = 92, + ThisKeyword = 93, >ThisKeyword : SyntaxKind - ThrowKeyword = 93, + ThrowKeyword = 94, >ThrowKeyword : SyntaxKind - TrueKeyword = 94, + TrueKeyword = 95, >TrueKeyword : SyntaxKind - TryKeyword = 95, + TryKeyword = 96, >TryKeyword : SyntaxKind - TypeOfKeyword = 96, + TypeOfKeyword = 97, >TypeOfKeyword : SyntaxKind - VarKeyword = 97, + VarKeyword = 98, >VarKeyword : SyntaxKind - VoidKeyword = 98, + VoidKeyword = 99, >VoidKeyword : SyntaxKind - WhileKeyword = 99, + WhileKeyword = 100, >WhileKeyword : SyntaxKind - WithKeyword = 100, + WithKeyword = 101, >WithKeyword : SyntaxKind - AsKeyword = 101, + AsKeyword = 102, >AsKeyword : SyntaxKind - ImplementsKeyword = 102, + ImplementsKeyword = 103, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 103, + InterfaceKeyword = 104, >InterfaceKeyword : SyntaxKind - LetKeyword = 104, + LetKeyword = 105, >LetKeyword : SyntaxKind - PackageKeyword = 105, + PackageKeyword = 106, >PackageKeyword : SyntaxKind - PrivateKeyword = 106, + PrivateKeyword = 107, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 107, + ProtectedKeyword = 108, >ProtectedKeyword : SyntaxKind - PublicKeyword = 108, + PublicKeyword = 109, >PublicKeyword : SyntaxKind - StaticKeyword = 109, + StaticKeyword = 110, >StaticKeyword : SyntaxKind - YieldKeyword = 110, + YieldKeyword = 111, >YieldKeyword : SyntaxKind - AnyKeyword = 111, + AnyKeyword = 112, >AnyKeyword : SyntaxKind - BooleanKeyword = 112, + BooleanKeyword = 113, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 113, + ConstructorKeyword = 114, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 114, + DeclareKeyword = 115, >DeclareKeyword : SyntaxKind - GetKeyword = 115, + GetKeyword = 116, >GetKeyword : SyntaxKind - ModuleKeyword = 116, + ModuleKeyword = 117, >ModuleKeyword : SyntaxKind - RequireKeyword = 117, + RequireKeyword = 118, >RequireKeyword : SyntaxKind - NumberKeyword = 118, + NumberKeyword = 119, >NumberKeyword : SyntaxKind - SetKeyword = 119, + SetKeyword = 120, >SetKeyword : SyntaxKind - StringKeyword = 120, + StringKeyword = 121, >StringKeyword : SyntaxKind - SymbolKeyword = 121, + SymbolKeyword = 122, >SymbolKeyword : SyntaxKind - TypeKeyword = 122, + TypeKeyword = 123, >TypeKeyword : SyntaxKind - FromKeyword = 123, + FromKeyword = 124, >FromKeyword : SyntaxKind - OfKeyword = 124, + OfKeyword = 125, >OfKeyword : SyntaxKind - QualifiedName = 125, + QualifiedName = 126, >QualifiedName : SyntaxKind - ComputedPropertyName = 126, + ComputedPropertyName = 127, >ComputedPropertyName : SyntaxKind - TypeParameter = 127, + TypeParameter = 128, >TypeParameter : SyntaxKind - Parameter = 128, + Parameter = 129, >Parameter : SyntaxKind - PropertySignature = 129, + Decorator = 130, +>Decorator : SyntaxKind + + PropertySignature = 131, >PropertySignature : SyntaxKind - PropertyDeclaration = 130, + PropertyDeclaration = 132, >PropertyDeclaration : SyntaxKind - MethodSignature = 131, + MethodSignature = 133, >MethodSignature : SyntaxKind - MethodDeclaration = 132, + MethodDeclaration = 134, >MethodDeclaration : SyntaxKind - Constructor = 133, + Constructor = 135, >Constructor : SyntaxKind - GetAccessor = 134, + GetAccessor = 136, >GetAccessor : SyntaxKind - SetAccessor = 135, + SetAccessor = 137, >SetAccessor : SyntaxKind - CallSignature = 136, + CallSignature = 138, >CallSignature : SyntaxKind - ConstructSignature = 137, + ConstructSignature = 139, >ConstructSignature : SyntaxKind - IndexSignature = 138, + IndexSignature = 140, >IndexSignature : SyntaxKind - TypeReference = 139, + TypeReference = 141, >TypeReference : SyntaxKind - FunctionType = 140, + FunctionType = 142, >FunctionType : SyntaxKind - ConstructorType = 141, + ConstructorType = 143, >ConstructorType : SyntaxKind - TypeQuery = 142, + TypeQuery = 144, >TypeQuery : SyntaxKind - TypeLiteral = 143, + TypeLiteral = 145, >TypeLiteral : SyntaxKind - ArrayType = 144, + ArrayType = 146, >ArrayType : SyntaxKind - TupleType = 145, + TupleType = 147, >TupleType : SyntaxKind - UnionType = 146, + UnionType = 148, >UnionType : SyntaxKind - ParenthesizedType = 147, + ParenthesizedType = 149, >ParenthesizedType : SyntaxKind - ObjectBindingPattern = 148, + ObjectBindingPattern = 150, >ObjectBindingPattern : SyntaxKind - ArrayBindingPattern = 149, + ArrayBindingPattern = 151, >ArrayBindingPattern : SyntaxKind - BindingElement = 150, + BindingElement = 152, >BindingElement : SyntaxKind - ArrayLiteralExpression = 151, + ArrayLiteralExpression = 153, >ArrayLiteralExpression : SyntaxKind - ObjectLiteralExpression = 152, + ObjectLiteralExpression = 154, >ObjectLiteralExpression : SyntaxKind - PropertyAccessExpression = 153, + PropertyAccessExpression = 155, >PropertyAccessExpression : SyntaxKind - ElementAccessExpression = 154, + ElementAccessExpression = 156, >ElementAccessExpression : SyntaxKind - CallExpression = 155, + CallExpression = 157, >CallExpression : SyntaxKind - NewExpression = 156, + NewExpression = 158, >NewExpression : SyntaxKind - TaggedTemplateExpression = 157, + TaggedTemplateExpression = 159, >TaggedTemplateExpression : SyntaxKind - TypeAssertionExpression = 158, + TypeAssertionExpression = 160, >TypeAssertionExpression : SyntaxKind - ParenthesizedExpression = 159, + ParenthesizedExpression = 161, >ParenthesizedExpression : SyntaxKind - FunctionExpression = 160, + FunctionExpression = 162, >FunctionExpression : SyntaxKind - ArrowFunction = 161, + ArrowFunction = 163, >ArrowFunction : SyntaxKind - DeleteExpression = 162, + DeleteExpression = 164, >DeleteExpression : SyntaxKind - TypeOfExpression = 163, + TypeOfExpression = 165, >TypeOfExpression : SyntaxKind - VoidExpression = 164, + VoidExpression = 166, >VoidExpression : SyntaxKind - PrefixUnaryExpression = 165, + PrefixUnaryExpression = 167, >PrefixUnaryExpression : SyntaxKind - PostfixUnaryExpression = 166, + PostfixUnaryExpression = 168, >PostfixUnaryExpression : SyntaxKind - BinaryExpression = 167, + BinaryExpression = 169, >BinaryExpression : SyntaxKind - ConditionalExpression = 168, + ConditionalExpression = 170, >ConditionalExpression : SyntaxKind - TemplateExpression = 169, + TemplateExpression = 171, >TemplateExpression : SyntaxKind - YieldExpression = 170, + YieldExpression = 172, >YieldExpression : SyntaxKind - SpreadElementExpression = 171, + SpreadElementExpression = 173, >SpreadElementExpression : SyntaxKind - OmittedExpression = 172, + OmittedExpression = 174, >OmittedExpression : SyntaxKind - TemplateSpan = 173, + TemplateSpan = 175, >TemplateSpan : SyntaxKind - Block = 174, + Block = 176, >Block : SyntaxKind - VariableStatement = 175, + VariableStatement = 177, >VariableStatement : SyntaxKind - EmptyStatement = 176, + EmptyStatement = 178, >EmptyStatement : SyntaxKind - ExpressionStatement = 177, + ExpressionStatement = 179, >ExpressionStatement : SyntaxKind - IfStatement = 178, + IfStatement = 180, >IfStatement : SyntaxKind - DoStatement = 179, + DoStatement = 181, >DoStatement : SyntaxKind - WhileStatement = 180, + WhileStatement = 182, >WhileStatement : SyntaxKind - ForStatement = 181, + ForStatement = 183, >ForStatement : SyntaxKind - ForInStatement = 182, + ForInStatement = 184, >ForInStatement : SyntaxKind - ForOfStatement = 183, + ForOfStatement = 185, >ForOfStatement : SyntaxKind - ContinueStatement = 184, + ContinueStatement = 186, >ContinueStatement : SyntaxKind - BreakStatement = 185, + BreakStatement = 187, >BreakStatement : SyntaxKind - ReturnStatement = 186, + ReturnStatement = 188, >ReturnStatement : SyntaxKind - WithStatement = 187, + WithStatement = 189, >WithStatement : SyntaxKind - SwitchStatement = 188, + SwitchStatement = 190, >SwitchStatement : SyntaxKind - LabeledStatement = 189, + LabeledStatement = 191, >LabeledStatement : SyntaxKind - ThrowStatement = 190, + ThrowStatement = 192, >ThrowStatement : SyntaxKind - TryStatement = 191, + TryStatement = 193, >TryStatement : SyntaxKind - DebuggerStatement = 192, + DebuggerStatement = 194, >DebuggerStatement : SyntaxKind - VariableDeclaration = 193, + VariableDeclaration = 195, >VariableDeclaration : SyntaxKind - VariableDeclarationList = 194, + VariableDeclarationList = 196, >VariableDeclarationList : SyntaxKind - FunctionDeclaration = 195, + FunctionDeclaration = 197, >FunctionDeclaration : SyntaxKind - ClassDeclaration = 196, + ClassDeclaration = 198, >ClassDeclaration : SyntaxKind - InterfaceDeclaration = 197, + InterfaceDeclaration = 199, >InterfaceDeclaration : SyntaxKind - TypeAliasDeclaration = 198, + TypeAliasDeclaration = 200, >TypeAliasDeclaration : SyntaxKind - EnumDeclaration = 199, + EnumDeclaration = 201, >EnumDeclaration : SyntaxKind - ModuleDeclaration = 200, + ModuleDeclaration = 202, >ModuleDeclaration : SyntaxKind - ModuleBlock = 201, + ModuleBlock = 203, >ModuleBlock : SyntaxKind - CaseBlock = 202, + CaseBlock = 204, >CaseBlock : SyntaxKind - ImportEqualsDeclaration = 203, + ImportEqualsDeclaration = 205, >ImportEqualsDeclaration : SyntaxKind - ImportDeclaration = 204, + ImportDeclaration = 206, >ImportDeclaration : SyntaxKind - ImportClause = 205, + ImportClause = 207, >ImportClause : SyntaxKind - NamespaceImport = 206, + NamespaceImport = 208, >NamespaceImport : SyntaxKind - NamedImports = 207, + NamedImports = 209, >NamedImports : SyntaxKind - ImportSpecifier = 208, + ImportSpecifier = 210, >ImportSpecifier : SyntaxKind - ExportAssignment = 209, + ExportAssignment = 211, >ExportAssignment : SyntaxKind - ExportDeclaration = 210, + ExportDeclaration = 212, >ExportDeclaration : SyntaxKind - NamedExports = 211, + NamedExports = 213, >NamedExports : SyntaxKind - ExportSpecifier = 212, + ExportSpecifier = 214, >ExportSpecifier : SyntaxKind - ExternalModuleReference = 213, + MissingDeclaration = 215, +>MissingDeclaration : SyntaxKind + + ExternalModuleReference = 216, >ExternalModuleReference : SyntaxKind - CaseClause = 214, + CaseClause = 217, >CaseClause : SyntaxKind - DefaultClause = 215, + DefaultClause = 218, >DefaultClause : SyntaxKind - HeritageClause = 216, + HeritageClause = 219, >HeritageClause : SyntaxKind - CatchClause = 217, + CatchClause = 220, >CatchClause : SyntaxKind - PropertyAssignment = 218, + PropertyAssignment = 221, >PropertyAssignment : SyntaxKind - ShorthandPropertyAssignment = 219, + ShorthandPropertyAssignment = 222, >ShorthandPropertyAssignment : SyntaxKind - EnumMember = 220, + EnumMember = 223, >EnumMember : SyntaxKind - SourceFile = 221, + SourceFile = 224, >SourceFile : SyntaxKind - SyntaxList = 222, + SyntaxList = 225, >SyntaxList : SyntaxKind - Count = 223, + Count = 226, >Count : SyntaxKind - FirstAssignment = 52, + FirstAssignment = 53, >FirstAssignment : SyntaxKind - LastAssignment = 63, + LastAssignment = 64, >LastAssignment : SyntaxKind - FirstReservedWord = 65, + FirstReservedWord = 66, >FirstReservedWord : SyntaxKind - LastReservedWord = 100, + LastReservedWord = 101, >LastReservedWord : SyntaxKind - FirstKeyword = 65, + FirstKeyword = 66, >FirstKeyword : SyntaxKind - LastKeyword = 124, + LastKeyword = 125, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 102, + FirstFutureReservedWord = 103, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 110, + LastFutureReservedWord = 111, >LastFutureReservedWord : SyntaxKind - FirstTypeNode = 139, + FirstTypeNode = 141, >FirstTypeNode : SyntaxKind - LastTypeNode = 147, + LastTypeNode = 149, >LastTypeNode : SyntaxKind FirstPunctuation = 14, >FirstPunctuation : SyntaxKind - LastPunctuation = 63, + LastPunctuation = 64, >LastPunctuation : SyntaxKind FirstToken = 0, >FirstToken : SyntaxKind - LastToken = 124, + LastToken = 125, >LastToken : SyntaxKind FirstTriviaToken = 2, @@ -1199,10 +1208,10 @@ declare module "typescript" { FirstBinaryOperator = 24, >FirstBinaryOperator : SyntaxKind - LastBinaryOperator = 63, + LastBinaryOperator = 64, >LastBinaryOperator : SyntaxKind - FirstNode = 125, + FirstNode = 126, >FirstNode : SyntaxKind } const enum NodeFlags { @@ -1274,16 +1283,19 @@ declare module "typescript" { GeneratorParameter = 8, >GeneratorParameter : ParserContextFlags - ThisNodeHasError = 16, + Decorator = 16, +>Decorator : ParserContextFlags + + ThisNodeHasError = 32, >ThisNodeHasError : ParserContextFlags - ParserGeneratedFlags = 31, + ParserGeneratedFlags = 63, >ParserGeneratedFlags : ParserContextFlags - ThisNodeOrAnySubNodesHasError = 32, + ThisNodeOrAnySubNodesHasError = 64, >ThisNodeOrAnySubNodesHasError : ParserContextFlags - HasAggregatedChildData = 64, + HasAggregatedChildData = 128, >HasAggregatedChildData : ParserContextFlags } const enum RelationComparisonResult { @@ -1314,6 +1326,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1408,6 +1425,14 @@ declare module "typescript" { expression: Expression; >expression : Expression >Expression : Expression + } + interface Decorator extends Node { +>Decorator : Decorator +>Node : Node + + expression: LeftHandSideExpression; +>expression : LeftHandSideExpression +>LeftHandSideExpression : LeftHandSideExpression } interface TypeParameterDeclaration extends Declaration { >TypeParameterDeclaration : TypeParameterDeclaration @@ -3275,15 +3300,17 @@ declare module "typescript" { interface EmitResolver { >EmitResolver : EmitResolver - getGeneratedNameForNode(node: Node): string; ->getGeneratedNameForNode : (node: Node) => string ->node : Node ->Node : Node + hasGlobalName(name: string): boolean; +>hasGlobalName : (name: string) => boolean +>name : string - getExpressionNameSubstitution(node: Identifier): string; ->getExpressionNameSubstitution : (node: Identifier) => string + getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; +>getExpressionNameSubstitution : (node: Identifier, getGeneratedNameForNode: (node: Node) => string) => string >node : Identifier >Identifier : Identifier +>getGeneratedNameForNode : (node: Node) => string +>node : Node +>Node : Node isValueAliasDeclaration(node: Node): boolean; >isValueAliasDeclaration : (node: Node) => boolean @@ -3382,8 +3409,8 @@ declare module "typescript" { >PropertyAccessExpression : PropertyAccessExpression >ElementAccessExpression : ElementAccessExpression - isUnknownIdentifier(location: Node, name: string): boolean; ->isUnknownIdentifier : (location: Node, name: string) => boolean + resolvesToSomeValue(location: Node, name: string): boolean; +>resolvesToSomeValue : (location: Node, name: string) => boolean >location : Node >Node : Node >name : string @@ -3705,6 +3732,9 @@ declare module "typescript" { BlockScopedBindingInLoop = 256, >BlockScopedBindingInLoop : NodeCheckFlags + + EmitDecorate = 512, +>EmitDecorate : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/ES5For-of15.js b/tests/baselines/reference/ES5For-of15.js index 46d3dbd1d6e3e..5a1b8327107c7 100644 --- a/tests/baselines/reference/ES5For-of15.js +++ b/tests/baselines/reference/ES5For-of15.js @@ -11,7 +11,7 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { var v = _a[_i]; v; for (var _b = 0, _c = []; _b < _c.length; _b++) { - var _v = _c[_b]; - var x = _v; + var v_1 = _c[_b]; + var x = v_1; } } diff --git a/tests/baselines/reference/ES5For-of16.js b/tests/baselines/reference/ES5For-of16.js index 1649e4481f27d..88f2c39414aa4 100644 --- a/tests/baselines/reference/ES5For-of16.js +++ b/tests/baselines/reference/ES5For-of16.js @@ -12,8 +12,8 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { var v = _a[_i]; v; for (var _b = 0, _c = []; _b < _c.length; _b++) { - var _v = _c[_b]; - var x = _v; - _v++; + var v_1 = _c[_b]; + var x = v_1; + v_1++; } } diff --git a/tests/baselines/reference/ES5For-of17.js b/tests/baselines/reference/ES5For-of17.js index b728074ae939d..4752f1be90f30 100644 --- a/tests/baselines/reference/ES5For-of17.js +++ b/tests/baselines/reference/ES5For-of17.js @@ -14,8 +14,8 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { for (var _b = 0, _c = [ v ]; _b < _c.length; _b++) { - var _v = _c[_b]; - var x = _v; - _v++; + var v_1 = _c[_b]; + var x = v_1; + v_1++; } } diff --git a/tests/baselines/reference/ES5For-of18.js b/tests/baselines/reference/ES5For-of18.js index a135b8b04639e..0d4809ed72d06 100644 --- a/tests/baselines/reference/ES5For-of18.js +++ b/tests/baselines/reference/ES5For-of18.js @@ -13,6 +13,6 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { v; } for (var _b = 0, _c = []; _b < _c.length; _b++) { - var _v = _c[_b]; - _v; + var v = _c[_b]; + v; } diff --git a/tests/baselines/reference/ES5For-of19.js b/tests/baselines/reference/ES5For-of19.js index 7af9418f04f69..2714574ab5bc8 100644 --- a/tests/baselines/reference/ES5For-of19.js +++ b/tests/baselines/reference/ES5For-of19.js @@ -14,9 +14,9 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { var v = _a[_i]; v; function foo() { - for (var _b = 0, _c = []; _b < _c.length; _b++) { - var _v = _c[_b]; - _v; + for (var _i = 0, _a = []; _i < _a.length; _i++) { + var v_1 = _a[_i]; + v_1; } } } diff --git a/tests/baselines/reference/ES5For-of20.js b/tests/baselines/reference/ES5For-of20.js index 3dd707805d8bc..d3f44e4922a1e 100644 --- a/tests/baselines/reference/ES5For-of20.js +++ b/tests/baselines/reference/ES5For-of20.js @@ -9,11 +9,11 @@ for (let v of []) { //// [ES5For-of20.js] for (var _i = 0, _a = []; _i < _a.length; _i++) { var v = _a[_i]; - var _v; + var v_1; for (var _b = 0, _c = [ v ]; _b < _c.length; _b++) { - var _v_1 = _c[_b]; - var _v_2; + var v_2 = _c[_b]; + var v_3; } } diff --git a/tests/baselines/reference/ES5For-of24.js b/tests/baselines/reference/ES5For-of24.js index 418ccc2005c47..00cd24ea28062 100644 --- a/tests/baselines/reference/ES5For-of24.js +++ b/tests/baselines/reference/ES5For-of24.js @@ -12,5 +12,5 @@ var a = [ ]; for (var _i = 0; _i < a.length; _i++) { var v = a[_i]; - var _a = 0; + var a_1 = 0; } diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js index 7555ae217e575..06e5427a87958 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js @@ -35,19 +35,19 @@ var ag2 = new A.A2(); //// [ModuleWithExportedAndNonExportedClasses.js] var A; -(function (_A) { +(function (A_1) { var A = (function () { function A() { } return A; })(); - _A.A = A; + A_1.A = A; var AG = (function () { function AG() { } return AG; })(); - _A.AG = AG; + A_1.AG = AG; var A2 = (function () { function A2() { } diff --git a/tests/baselines/reference/cloduleWithRecursiveReference.js b/tests/baselines/reference/cloduleWithRecursiveReference.js index 1b8a91b3c6817..1a688712270e1 100644 --- a/tests/baselines/reference/cloduleWithRecursiveReference.js +++ b/tests/baselines/reference/cloduleWithRecursiveReference.js @@ -17,7 +17,7 @@ var M; })(); M.C = C; var C; - (function (_C) { - _C.C = M.C; + (function (C_1) { + C_1.C = M.C; })(C = M.C || (M.C = {})); })(M || (M = {})); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js index 141ef285f037a..8152a9c27215e 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js @@ -47,14 +47,14 @@ module M { // Shouldnt be _M //// [collisionCodeGenModuleWithAccessorChildren.js] var M; -(function (_M) { - _M.x = 3; +(function (M_1) { + M_1.x = 3; var c = (function () { function c() { } Object.defineProperty(c.prototype, "Z", { set: function (M) { - this.y = _M.x; + this.y = M_1.x; }, enumerable: true, configurable: true @@ -63,14 +63,14 @@ var M; })(); })(M || (M = {})); var M; -(function (_M_1) { +(function (M_2) { var d = (function () { function d() { } Object.defineProperty(d.prototype, "Z", { set: function (p) { var M = 10; - this.y = _M_1.x; + this.y = M_2.x; }, enumerable: true, configurable: true @@ -94,14 +94,14 @@ var M; })(); })(M || (M = {})); var M; -(function (_M_2) { +(function (M_3) { var f = (function () { function f() { } Object.defineProperty(f.prototype, "Z", { get: function () { var M = 10; - return _M_2.x; + return M_3.x; }, enumerable: true, configurable: true diff --git a/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.js index 2158a0562ea2d..2aa705c914123 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.js @@ -25,31 +25,31 @@ module M { //// [collisionCodeGenModuleWithConstructorChildren.js] var M; -(function (_M) { - _M.x = 3; +(function (M_1) { + M_1.x = 3; var c = (function () { function c(M, p) { - if (p === void 0) { p = _M.x; } + if (p === void 0) { p = M_1.x; } } return c; })(); })(M || (M = {})); var M; -(function (_M_1) { +(function (M_2) { var d = (function () { function d(M, p) { - if (p === void 0) { p = _M_1.x; } + if (p === void 0) { p = M_2.x; } this.M = M; } return d; })(); })(M || (M = {})); var M; -(function (_M_2) { +(function (M_3) { var d2 = (function () { function d2() { var M = 10; - var p = _M_2.x; + var p = M_3.x; } return d2; })(); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.js index caaa6a59da525..252ad2c63dc65 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.js @@ -21,24 +21,24 @@ module M { //// [collisionCodeGenModuleWithFunctionChildren.js] var M; -(function (_M) { - _M.x = 3; +(function (M_1) { + M_1.x = 3; function fn(M, p) { - if (p === void 0) { p = _M.x; } + if (p === void 0) { p = M_1.x; } } })(M || (M = {})); var M; -(function (_M_1) { +(function (M_2) { function fn2() { var M; - var p = _M_1.x; + var p = M_2.x; } })(M || (M = {})); var M; -(function (_M_2) { +(function (M_3) { function fn3() { function M() { - var p = _M_2.x; + var p = M_3.x; } } })(M || (M = {})); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithMemberClassConflict.js b/tests/baselines/reference/collisionCodeGenModuleWithMemberClassConflict.js index 59c2ebf295d52..05ae475e7d234 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithMemberClassConflict.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithMemberClassConflict.js @@ -17,29 +17,29 @@ var foo = new m2._m2(); //// [collisionCodeGenModuleWithMemberClassConflict.js] var m1; -(function (_m1) { +(function (m1_1) { var m1 = (function () { function m1() { } return m1; })(); - _m1.m1 = m1; + m1_1.m1 = m1; })(m1 || (m1 = {})); var foo = new m1.m1(); var m2; -(function (_m2_1) { +(function (m2_1) { var m2 = (function () { function m2() { } return m2; })(); - _m2_1.m2 = m2; + m2_1.m2 = m2; var _m2 = (function () { function _m2() { } return _m2; })(); - _m2_1._m2 = _m2; + m2_1._m2 = _m2; })(m2 || (m2 = {})); var foo = new m2.m2(); var foo = new m2._m2(); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.js b/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.js index d57de06dfa73d..1a23b81c139e2 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.js @@ -7,8 +7,8 @@ var foo = m1.m1; //// [collisionCodeGenModuleWithMemberVariable.js] var m1; -(function (_m1) { - _m1.m1 = 10; - var b = _m1.m1; +(function (m1_1) { + m1_1.m1 = 10; + var b = m1_1.m1; })(m1 || (m1 = {})); var foo = m1.m1; diff --git a/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.js index 212364ed30b00..53807f1cabd52 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.js @@ -34,37 +34,37 @@ module M { // Shouldnt bn _M //// [collisionCodeGenModuleWithMethodChildren.js] var M; -(function (_M) { - _M.x = 3; +(function (M_1) { + M_1.x = 3; var c = (function () { function c() { } c.prototype.fn = function (M, p) { - if (p === void 0) { p = _M.x; } + if (p === void 0) { p = M_1.x; } }; return c; })(); })(M || (M = {})); var M; -(function (_M_1) { +(function (M_2) { var d = (function () { function d() { } d.prototype.fn2 = function () { var M; - var p = _M_1.x; + var p = M_2.x; }; return d; })(); })(M || (M = {})); var M; -(function (_M_2) { +(function (M_3) { var e = (function () { function e() { } e.prototype.fn3 = function () { function M() { - var p = _M_2.x; + var p = M_3.x; } }; return e; diff --git a/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.js index 3c8b17deadd68..2862a84406786 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.js @@ -44,16 +44,16 @@ module M { //// [collisionCodeGenModuleWithModuleChildren.js] var M; -(function (_M) { - _M.x = 3; +(function (M_1) { + M_1.x = 3; var m1; (function (m1) { var M = 10; - var p = _M.x; + var p = M_1.x; })(m1 || (m1 = {})); })(M || (M = {})); var M; -(function (_M_1) { +(function (M_2) { var m2; (function (m2) { var M = (function () { @@ -61,17 +61,17 @@ var M; } return M; })(); - var p = _M_1.x; + var p = M_2.x; var p2 = new M(); })(m2 || (m2 = {})); })(M || (M = {})); var M; -(function (_M_2) { +(function (M_3) { var m3; (function (m3) { function M() { } - var p = _M_2.x; + var p = M_3.x; var p2 = M(); })(m3 || (m3 = {})); })(M || (M = {})); @@ -84,12 +84,12 @@ var M; })(m3 || (m3 = {})); })(M || (M = {})); var M; -(function (_M_3) { +(function (M_4) { var m4; (function (m4) { var M; (function (M) { - var p = _M_3.x; + var p = M_4.x; })(M || (M = {})); })(m4 || (m4 = {})); })(M || (M = {})); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.js b/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.js index 4c3d60230635d..710c09e4558ae 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.js @@ -31,13 +31,13 @@ var foo2 = new m2.m2(); //// [collisionCodeGenModuleWithModuleReopening.js] var m1; -(function (_m1) { +(function (m1_1) { var m1 = (function () { function m1() { } return m1; })(); - _m1.m1 = m1; + m1_1.m1 = m1; })(m1 || (m1 = {})); var foo = new m1.m1(); var m1; @@ -65,16 +65,16 @@ var m2; })(m2 || (m2 = {})); var foo3 = new m2.c1(); var m2; -(function (_m2) { +(function (m2_1) { var m2 = (function () { function m2() { } return m2; })(); - _m2.m2 = m2; + m2_1.m2 = m2; var b = new m2(); - var d = _m2.b10; - var c = new _m2.c1(); + var d = m2_1.b10; + var c = new m2_1.c1(); })(m2 || (m2 = {})); var foo3 = new m2.c1(); var foo2 = new m2.m2(); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithPrivateMember.js b/tests/baselines/reference/collisionCodeGenModuleWithPrivateMember.js index 28901bd11e829..4b4d6aa7afb1b 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithPrivateMember.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithPrivateMember.js @@ -10,7 +10,7 @@ var foo = new m1.c1(); //// [collisionCodeGenModuleWithPrivateMember.js] var m1; -(function (_m1) { +(function (m1_1) { var m1 = (function () { function m1() { } @@ -22,6 +22,6 @@ var m1; } return c1; })(); - _m1.c1 = c1; + m1_1.c1 = c1; })(m1 || (m1 = {})); var foo = new m1.c1(); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithUnicodeNames.js b/tests/baselines/reference/collisionCodeGenModuleWithUnicodeNames.js index d4e919e0a17ae..3204a05bc7575 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithUnicodeNames.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithUnicodeNames.js @@ -11,12 +11,12 @@ var x = new 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكو //// [collisionCodeGenModuleWithUnicodeNames.js] var 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123; -(function (_才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123) { +(function (才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123_1) { var 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 = (function () { function 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123() { } return 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123; })(); - _才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123.才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 = 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123; + 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123_1.才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 = 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123; })(才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 || (才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 = {})); var x = new 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123.才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123(); diff --git a/tests/baselines/reference/computedPropertyNames23_ES5.js b/tests/baselines/reference/computedPropertyNames23_ES5.js index c3024a7fbbfde..34eb0896376df 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES5.js +++ b/tests/baselines/reference/computedPropertyNames23_ES5.js @@ -20,5 +20,5 @@ var C = (function () { _a)[0]] = function () { }; return C; + var _a; })(); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 5651ee266c94e..cac71f734a693 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -35,5 +35,5 @@ var C = (function (_super) { _a)[0]] = function () { }; return C; + var _a; })(Base); -var _a; diff --git a/tests/baselines/reference/declFileImportChainInExportAssignment.js b/tests/baselines/reference/declFileImportChainInExportAssignment.js index c8773889a7d0b..4ec3893d02fa8 100644 --- a/tests/baselines/reference/declFileImportChainInExportAssignment.js +++ b/tests/baselines/reference/declFileImportChainInExportAssignment.js @@ -13,13 +13,13 @@ export = b; var m; (function (m) { var c; - (function (_c) { + (function (c_1) { var c = (function () { function c() { } return c; })(); - _c.c = c; + c_1.c = c; })(c = m.c || (m.c = {})); })(m || (m = {})); var a = m.c; diff --git a/tests/baselines/reference/declarationEmitDefaultExport2.js b/tests/baselines/reference/declarationEmitDefaultExport2.js index 388bd41e4f885..687c6d67cdbaf 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport2.js +++ b/tests/baselines/reference/declarationEmitDefaultExport2.js @@ -3,7 +3,7 @@ export default class { } //// [declarationEmitDefaultExport2.js] -export default class { +export default class { } diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js index de3045be1ccc5..9b48f418f5ad5 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js @@ -73,8 +73,8 @@ function f15() { var _f = f15(), a4 = _f.a4, b4 = _f.b4, c4 = _f.c4; var m; (function (m) { - _g = f15(), m.a4 = _g.a4, m.b4 = _g.b4, m.c4 = _g.c4; - var _g; + _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; + var _a; })(m || (m = {})); diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js index 509edfa6c87f1..140fc03780a05 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js @@ -37,8 +37,8 @@ function f15() { var _c = f15(), a4 = _c.a4, b4 = _c.b4, c4 = _c.c4; var m; (function (m) { - _d = f15(), m.a4 = _d.a4, m.b4 = _d.b4, m.c4 = _d.c4; - var _d; + _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; + var _a; })(m || (m = {})); diff --git a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js index b41ca177b0558..9b580bcd7a4e3 100644 --- a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js +++ b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js @@ -14,13 +14,13 @@ export = m; var m; (function (m) { var c; - (function (_c) { + (function (c_1) { var c = (function () { function c() { } return c; })(); - _c.c = c; + c_1.c = c; })(c = m.c || (m.c = {})); m.a; })(m || (m = {})); diff --git a/tests/baselines/reference/decoratorOnArrowFunction.errors.txt b/tests/baselines/reference/decoratorOnArrowFunction.errors.txt new file mode 100644 index 0000000000000..14bde1e49bf27 --- /dev/null +++ b/tests/baselines/reference/decoratorOnArrowFunction.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,9): error TS1109: Expression expected. +tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,16): error TS1146: Declaration expected. +tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,17): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts (3 errors) ==== + declare function dec(target: T): T; + + var F = @dec () => { + ~ +!!! error TS1109: Expression expected. + +!!! error TS1146: Declaration expected. + ~~ +!!! error TS1128: Declaration or statement expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnArrowFunction.js b/tests/baselines/reference/decoratorOnArrowFunction.js new file mode 100644 index 0000000000000..1a327e7fc9a9b --- /dev/null +++ b/tests/baselines/reference/decoratorOnArrowFunction.js @@ -0,0 +1,10 @@ +//// [decoratorOnArrowFunction.ts] +declare function dec(target: T): T; + +var F = @dec () => { +} + +//// [decoratorOnArrowFunction.js] +var F = ; +{ +} diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js new file mode 100644 index 0000000000000..24be2517469fc --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -0,0 +1,27 @@ +//// [decoratorOnClass1.ts] +declare function dec(target: T): T; + +@dec +class C { +} + +//// [decoratorOnClass1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec], C); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClass1.types b/tests/baselines/reference/decoratorOnClass1.types new file mode 100644 index 0000000000000..19e066586da2c --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass1.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/decorators/class/decoratorOnClass1.ts === +declare function dec(target: T): T; +>dec : (target: T) => T +>T : T +>target : T +>T : T +>T : T + +@dec +>dec : unknown + +class C { +>C : C +} diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js new file mode 100644 index 0000000000000..92741819e9449 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -0,0 +1,28 @@ +//// [decoratorOnClass2.ts] +declare function dec(target: T): T; + +@dec +export class C { +} + +//// [decoratorOnClass2.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec], C); + return C; +})(); +exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClass2.types b/tests/baselines/reference/decoratorOnClass2.types new file mode 100644 index 0000000000000..43102ee912299 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass2.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/decorators/class/decoratorOnClass2.ts === +declare function dec(target: T): T; +>dec : (target: T) => T +>T : T +>target : T +>T : T +>T : T + +@dec +>dec : unknown + +export class C { +>C : C +} diff --git a/tests/baselines/reference/decoratorOnClass3.errors.txt b/tests/baselines/reference/decoratorOnClass3.errors.txt new file mode 100644 index 0000000000000..dfa430dec0cd7 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/decorators/class/decoratorOnClass3.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/class/decoratorOnClass3.ts (1 errors) ==== + declare function dec(target: T): T; + + export + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + @dec + class C { + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js new file mode 100644 index 0000000000000..766acc42072ed --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -0,0 +1,28 @@ +//// [decoratorOnClass3.ts] +declare function dec(target: T): T; + +export +@dec +class C { +} + +//// [decoratorOnClass3.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec], C); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js new file mode 100644 index 0000000000000..95bde549379e8 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -0,0 +1,27 @@ +//// [decoratorOnClass4.ts] +declare function dec(): (target: T) => T; + +@dec() +class C { +} + +//// [decoratorOnClass4.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec()], C); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClass4.types b/tests/baselines/reference/decoratorOnClass4.types new file mode 100644 index 0000000000000..425aa63ac213d --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass4.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/decorators/class/decoratorOnClass4.ts === +declare function dec(): (target: T) => T; +>dec : () => (target: T) => T +>T : T +>target : T +>T : T +>T : T + +@dec() +>dec() : (target: T) => T +>dec : () => (target: T) => T + +class C { +>C : C +} diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js new file mode 100644 index 0000000000000..a93d625f49136 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -0,0 +1,27 @@ +//// [decoratorOnClass5.ts] +declare function dec(): (target: T) => T; + +@dec() +class C { +} + +//// [decoratorOnClass5.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec()], C); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClass5.types b/tests/baselines/reference/decoratorOnClass5.types new file mode 100644 index 0000000000000..1c967ffcc0011 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass5.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/decorators/class/decoratorOnClass5.ts === +declare function dec(): (target: T) => T; +>dec : () => (target: T) => T +>T : T +>target : T +>T : T +>T : T + +@dec() +>dec() : (target: T) => T +>dec : () => (target: T) => T + +class C { +>C : C +} diff --git a/tests/baselines/reference/decoratorOnClass8.errors.txt b/tests/baselines/reference/decoratorOnClass8.errors.txt new file mode 100644 index 0000000000000..0a9fbf2956c11 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass8.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'. + + +==== tests/cases/conformance/decorators/class/decoratorOnClass8.ts (1 errors) ==== + declare function dec(): (target: Function, paramIndex: number) => void; + + @dec() + ~~~~~~ +!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'. + class C { + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js new file mode 100644 index 0000000000000..0e782d45e1158 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -0,0 +1,27 @@ +//// [decoratorOnClass8.ts] +declare function dec(): (target: Function, paramIndex: number) => void; + +@dec() +class C { +} + +//// [decoratorOnClass8.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C = __decorate([dec()], C); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js new file mode 100644 index 0000000000000..d78e776cb96bc --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -0,0 +1,34 @@ +//// [decoratorOnClassAccessor1.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec get accessor() { return 1; } +} + +//// [decoratorOnClassAccessor1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "accessor", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.types b/tests/baselines/reference/decoratorOnClassAccessor1.types new file mode 100644 index 0000000000000..fd592d7d29449 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor1.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec get accessor() { return 1; } +>dec : unknown +>accessor : number +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js new file mode 100644 index 0000000000000..f1bfce9ea6dce --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -0,0 +1,34 @@ +//// [decoratorOnClassAccessor2.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec public get accessor() { return 1; } +} + +//// [decoratorOnClassAccessor2.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "accessor", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.types b/tests/baselines/reference/decoratorOnClassAccessor2.types new file mode 100644 index 0000000000000..32bb503d889ee --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor2.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec public get accessor() { return 1; } +>dec : unknown +>accessor : number +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt new file mode 100644 index 0000000000000..b75b7e0d8b63a --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS2304: Cannot find name 'public'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,16): error TS1146: Declaration expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,17): error TS2304: Cannot find name 'get'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS2304: Cannot find name 'accessor'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,32): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (9 errors) ==== + declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + + class C { + public @dec get accessor() { return 1; } + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1146: Declaration expected. + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~~~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'accessor'. + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js new file mode 100644 index 0000000000000..f48a755953f3d --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -0,0 +1,19 @@ +//// [decoratorOnClassAccessor3.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + public @dec get accessor() { return 1; } +} + +//// [decoratorOnClassAccessor3.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +get; +accessor(); +{ + return 1; +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js new file mode 100644 index 0000000000000..77dbc569e5aaa --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -0,0 +1,33 @@ +//// [decoratorOnClassAccessor4.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec set accessor(value: number) { } +} + +//// [decoratorOnClassAccessor4.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "accessor", { + set: function (value) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.types b/tests/baselines/reference/decoratorOnClassAccessor4.types new file mode 100644 index 0000000000000..40dd43d7e6227 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor4.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec set accessor(value: number) { } +>dec : unknown +>accessor : number +>value : number +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js new file mode 100644 index 0000000000000..bfd6518c59bd6 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -0,0 +1,33 @@ +//// [decoratorOnClassAccessor5.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec public set accessor(value: number) { } +} + +//// [decoratorOnClassAccessor5.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "accessor", { + set: function (value) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.types b/tests/baselines/reference/decoratorOnClassAccessor5.types new file mode 100644 index 0000000000000..4b167fe8df17c --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor5.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec public set accessor(value: number) { } +>dec : unknown +>accessor : number +>value : number +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt new file mode 100644 index 0000000000000..ec22ae0b3e139 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS2304: Cannot find name 'public'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,16): error TS1146: Declaration expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,17): error TS2304: Cannot find name 'set'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS2304: Cannot find name 'accessor'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,30): error TS2304: Cannot find name 'value'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,35): error TS1005: ',' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,37): error TS2304: Cannot find name 'number'. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,45): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (12 errors) ==== + declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + + class C { + public @dec set accessor(value: number) { } + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1146: Declaration expected. + ~~~ +!!! error TS2304: Cannot find name 'set'. + ~~~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'accessor'. + ~~~~~ +!!! error TS2304: Cannot find name 'value'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'number'. + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js new file mode 100644 index 0000000000000..905e3d3b2db96 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -0,0 +1,18 @@ +//// [decoratorOnClassAccessor6.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + public @dec set accessor(value: number) { } +} + +//// [decoratorOnClassAccessor6.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +set; +accessor(value, number); +{ +} diff --git a/tests/baselines/reference/decoratorOnClassConstructor1.errors.txt b/tests/baselines/reference/decoratorOnClassConstructor1.errors.txt new file mode 100644 index 0000000000000..14a164eccb429 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts(4,5): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts (1 errors) ==== + declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + + class C { + @dec constructor() {} + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1206: Decorators are not valid here. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassConstructor1.js b/tests/baselines/reference/decoratorOnClassConstructor1.js new file mode 100644 index 0000000000000..c61d1d218a5de --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor1.js @@ -0,0 +1,13 @@ +//// [decoratorOnClassConstructor1.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec constructor() {} +} + +//// [decoratorOnClassConstructor1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js new file mode 100644 index 0000000000000..0c86a1ccf7aa7 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassConstructorParameter1.ts] +declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + constructor(@dec p: number) {} +} + +//// [decoratorOnClassConstructorParameter1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C(p) { + } + __decorate([dec], C, void 0, 0); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.types b/tests/baselines/reference/decoratorOnClassConstructorParameter1.types new file mode 100644 index 0000000000000..d5ce51269bc3d --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts === +declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; +>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void +>target : Function +>Function : Function +>propertyKey : string | symbol +>parameterIndex : number + +class C { +>C : C + + constructor(@dec p: number) {} +>dec : unknown +>p : number +} diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.errors.txt b/tests/baselines/reference/decoratorOnClassConstructorParameter4.errors.txt new file mode 100644 index 0000000000000..5969cfca06973 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,24): error TS1005: ',' expected. + + +==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (1 errors) ==== + declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; + + class C { + constructor(public @dec p: number) {} + ~ +!!! error TS1005: ',' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js new file mode 100644 index 0000000000000..07dc7cae0750a --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassConstructorParameter4.ts] +declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + constructor(public @dec p: number) {} +} + +//// [decoratorOnClassConstructorParameter4.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C(public, p) { + } + __decorate([dec], C, void 0, 1); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js new file mode 100644 index 0000000000000..be9c00290fbb9 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -0,0 +1,29 @@ +//// [decoratorOnClassMethod1.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec method() {} +} + +//// [decoratorOnClassMethod1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C.prototype.method = function () { + }; + Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod1.types b/tests/baselines/reference/decoratorOnClassMethod1.types new file mode 100644 index 0000000000000..760f758bbff17 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod1.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec method() {} +>dec : unknown +>method : () => void +} diff --git a/tests/baselines/reference/decoratorOnClassMethod10.errors.txt b/tests/baselines/reference/decoratorOnClassMethod10.errors.txt new file mode 100644 index 0000000000000..cd331473b7cda --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod10.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'. + Types of parameters 'paramIndex' and 'propertyKey' are incompatible. + Type 'number' is not assignable to type 'string | symbol'. + Type 'number' is not assignable to type 'symbol'. + + +==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts (1 errors) ==== + declare function dec(target: Function, paramIndex: number): void; + + class C { + @dec method() {} + ~~~~ +!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'. +!!! error TS2322: Types of parameters 'paramIndex' and 'propertyKey' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string | symbol'. +!!! error TS2322: Type 'number' is not assignable to type 'symbol'. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js new file mode 100644 index 0000000000000..3dd38f806bdc6 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -0,0 +1,29 @@ +//// [decoratorOnClassMethod10.ts] +declare function dec(target: Function, paramIndex: number): void; + +class C { + @dec method() {} +} + +//// [decoratorOnClassMethod10.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C.prototype.method = function () { + }; + Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js new file mode 100644 index 0000000000000..b7df7b9ba9c4e --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -0,0 +1,29 @@ +//// [decoratorOnClassMethod2.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec public method() {} +} + +//// [decoratorOnClassMethod2.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C.prototype.method = function () { + }; + Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.types b/tests/baselines/reference/decoratorOnClassMethod2.types new file mode 100644 index 0000000000000..98539648cd03c --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod2.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec public method() {} +>dec : unknown +>method : () => void +} diff --git a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt new file mode 100644 index 0000000000000..b2173dedf9ef9 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS2304: Cannot find name 'public'. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,16): error TS1146: Declaration expected. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,17): error TS2304: Cannot find name 'method'. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,26): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (7 errors) ==== + declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + + class C { + public @dec method() {} + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1146: Declaration expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'method'. + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js new file mode 100644 index 0000000000000..3a01184527531 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -0,0 +1,17 @@ +//// [decoratorOnClassMethod3.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + public @dec method() {} +} + +//// [decoratorOnClassMethod3.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +method(); +{ +} diff --git a/tests/baselines/reference/decoratorOnClassMethod4.js b/tests/baselines/reference/decoratorOnClassMethod4.js new file mode 100644 index 0000000000000..7021e5af32836 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod4.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassMethod4.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec ["method"]() {} +} + +//// [decoratorOnClassMethod4.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +class C { + [_a = "method"]() { + } +} +Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod4.types b/tests/baselines/reference/decoratorOnClassMethod4.types new file mode 100644 index 0000000000000..6d55e01e97a86 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod4.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec ["method"]() {} +>dec : unknown +} diff --git a/tests/baselines/reference/decoratorOnClassMethod5.js b/tests/baselines/reference/decoratorOnClassMethod5.js new file mode 100644 index 0000000000000..3bde0968eab7b --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod5.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassMethod5.ts] +declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; + +class C { + @dec() ["method"]() {} +} + +//// [decoratorOnClassMethod5.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +class C { + [_a = "method"]() { + } +} +Object.defineProperty(C.prototype, _a, __decorate([dec()], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod5.types b/tests/baselines/reference/decoratorOnClassMethod5.types new file mode 100644 index 0000000000000..d87de2b351add --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod5.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts === +declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; +>dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec() ["method"]() {} +>dec() : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +} diff --git a/tests/baselines/reference/decoratorOnClassMethod6.js b/tests/baselines/reference/decoratorOnClassMethod6.js new file mode 100644 index 0000000000000..126dc47ad2f7b --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod6.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassMethod6.ts] +declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; + +class C { + @dec ["method"]() {} +} + +//// [decoratorOnClassMethod6.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +class C { + [_a = "method"]() { + } +} +Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod6.types b/tests/baselines/reference/decoratorOnClassMethod6.types new file mode 100644 index 0000000000000..4e6629cd60aeb --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts === +declare function dec(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor; +>dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec ["method"]() {} +>dec : unknown +} diff --git a/tests/baselines/reference/decoratorOnClassMethod7.js b/tests/baselines/reference/decoratorOnClassMethod7.js new file mode 100644 index 0000000000000..34fbdb53ca5dd --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod7.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassMethod7.ts] +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; + +class C { + @dec public ["method"]() {} +} + +//// [decoratorOnClassMethod7.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +class C { + [_a = "method"]() { + } +} +Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod7.types b/tests/baselines/reference/decoratorOnClassMethod7.types new file mode 100644 index 0000000000000..7e426cb773c15 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod7.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts === +declare function dec(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; +>dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor +>T : T +>target : any +>propertyKey : string +>descriptor : TypedPropertyDescriptor +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T +>TypedPropertyDescriptor : TypedPropertyDescriptor +>T : T + +class C { +>C : C + + @dec public ["method"]() {} +>dec : unknown +} diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js new file mode 100644 index 0000000000000..629ff4e253bba --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -0,0 +1,29 @@ +//// [decoratorOnClassMethod8.ts] +declare function dec(target: T): T; + +class C { + @dec method() {} +} + +//// [decoratorOnClassMethod8.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C.prototype.method = function () { + }; + Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod8.types b/tests/baselines/reference/decoratorOnClassMethod8.types new file mode 100644 index 0000000000000..f932ab8696fba --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethod8.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts === +declare function dec(target: T): T; +>dec : (target: T) => T +>T : T +>target : T +>T : T +>T : T + +class C { +>C : C + + @dec method() {} +>dec : unknown +>method : () => void +} diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js new file mode 100644 index 0000000000000..1dcb057e53038 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -0,0 +1,29 @@ +//// [decoratorOnClassMethodParameter1.ts] +declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + method(@dec p: number) {} +} + +//// [decoratorOnClassMethodParameter1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + C.prototype.method = function (p) { + }; + __decorate([dec], C.prototype, "method", 0); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.types b/tests/baselines/reference/decoratorOnClassMethodParameter1.types new file mode 100644 index 0000000000000..cf7bfd352bfee --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts === +declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void; +>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void +>target : Function +>Function : Function +>propertyKey : string | symbol +>parameterIndex : number + +class C { +>C : C + + method(@dec p: number) {} +>method : (p: number) => void +>dec : unknown +>p : number +} diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js new file mode 100644 index 0000000000000..efc6a2c04dbf5 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty1.ts] +declare function dec(target: any, propertyKey: string): void; + +class C { + @dec prop; +} + +//// [decoratorOnClassProperty1.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassProperty1.types b/tests/baselines/reference/decoratorOnClassProperty1.types new file mode 100644 index 0000000000000..651085c7ac49b --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty1.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts === +declare function dec(target: any, propertyKey: string): void; +>dec : (target: any, propertyKey: string) => void +>target : any +>propertyKey : string + +class C { +>C : C + + @dec prop; +>dec : unknown +>prop : any +} diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js new file mode 100644 index 0000000000000..d55eb71e3c637 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty10.ts] +declare function dec(): (target: any, propertyKey: string) => void; + +class C { + @dec() prop; +} + +//// [decoratorOnClassProperty10.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec()], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.types b/tests/baselines/reference/decoratorOnClassProperty10.types new file mode 100644 index 0000000000000..d0aa05589ff13 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty10.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts === +declare function dec(): (target: any, propertyKey: string) => void; +>dec : () => (target: any, propertyKey: string) => void +>T : T +>target : any +>propertyKey : string + +class C { +>C : C + + @dec() prop; +>dec() : (target: any, propertyKey: string) => void +>dec : () => (target: any, propertyKey: string) => void +>prop : any +} diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js new file mode 100644 index 0000000000000..63e5f8d02e94c --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty11.ts] +declare function dec(): (target: any, propertyKey: string) => void; + +class C { + @dec prop; +} + +//// [decoratorOnClassProperty11.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.types b/tests/baselines/reference/decoratorOnClassProperty11.types new file mode 100644 index 0000000000000..5377e53c31c4a --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty11.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts === +declare function dec(): (target: any, propertyKey: string) => void; +>dec : () => (target: any, propertyKey: string) => void +>T : T +>target : any +>propertyKey : string + +class C { +>C : C + + @dec prop; +>dec : unknown +>prop : any +} diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js new file mode 100644 index 0000000000000..d52baa7920273 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty2.ts] +declare function dec(target: any, propertyKey: string): void; + +class C { + @dec public prop; +} + +//// [decoratorOnClassProperty2.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.types b/tests/baselines/reference/decoratorOnClassProperty2.types new file mode 100644 index 0000000000000..2d5c9fe07d770 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty2.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts === +declare function dec(target: any, propertyKey: string): void; +>dec : (target: any, propertyKey: string) => void +>target : any +>propertyKey : string + +class C { +>C : C + + @dec public prop; +>dec : unknown +>prop : any +} diff --git a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt new file mode 100644 index 0000000000000..29438bd67a9e5 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS2304: Cannot find name 'public'. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,16): error TS1146: Declaration expected. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,17): error TS2304: Cannot find name 'prop'. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (6 errors) ==== + declare function dec(target: any, propertyKey: string): void; + + class C { + public @dec prop; + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + ~ +!!! error TS1005: ';' expected. + +!!! error TS1146: Declaration expected. + ~~~~ +!!! error TS2304: Cannot find name 'prop'. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js new file mode 100644 index 0000000000000..6c9945677ca51 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -0,0 +1,15 @@ +//// [decoratorOnClassProperty3.ts] +declare function dec(target: any, propertyKey: string): void; + +class C { + public @dec prop; +} + +//// [decoratorOnClassProperty3.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +prop; diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js new file mode 100644 index 0000000000000..7f087156bc7a1 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty6.ts] +declare function dec(target: Function): void; + +class C { + @dec prop; +} + +//// [decoratorOnClassProperty6.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.types b/tests/baselines/reference/decoratorOnClassProperty6.types new file mode 100644 index 0000000000000..2c8c41abf78e9 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty6.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts === +declare function dec(target: Function): void; +>dec : (target: Function) => void +>target : Function +>Function : Function + +class C { +>C : C + + @dec prop; +>dec : unknown +>prop : any +} diff --git a/tests/baselines/reference/decoratorOnClassProperty7.errors.txt b/tests/baselines/reference/decoratorOnClassProperty7.errors.txt new file mode 100644 index 0000000000000..8b93d0ab38ebc --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty7.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'. + + +==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts (1 errors) ==== + declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void; + + class C { + @dec prop; + ~~~~ +!!! error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js new file mode 100644 index 0000000000000..ba2c8383a2cce --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -0,0 +1,27 @@ +//// [decoratorOnClassProperty7.ts] +declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void; + +class C { + @dec prop; +} + +//// [decoratorOnClassProperty7.js] +var __decorate = this.__decorate || function (decorators, target, key, value) { + var kind = typeof (arguments.length == 2 ? value = target : value); + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + switch (kind) { + case "function": value = decorator(value) || value; break; + case "number": decorator(target, key, value); break; + case "undefined": decorator(target, key); break; + case "object": value = decorator(target, key, value) || value; break; + } + } + return value; +}; +var C = (function () { + function C() { + } + __decorate([dec], C.prototype, "prop"); + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnEnum.errors.txt b/tests/baselines/reference/decoratorOnEnum.errors.txt new file mode 100644 index 0000000000000..21a6d39aab501 --- /dev/null +++ b/tests/baselines/reference/decoratorOnEnum.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(4,6): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + enum E { + ~ +!!! error TS1206: Decorators are not valid here. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnEnum.js b/tests/baselines/reference/decoratorOnEnum.js new file mode 100644 index 0000000000000..14651b6592834 --- /dev/null +++ b/tests/baselines/reference/decoratorOnEnum.js @@ -0,0 +1,11 @@ +//// [decoratorOnEnum.ts] +declare function dec(target: T): T; + +@dec +enum E { +} + +//// [decoratorOnEnum.js] +var E; +(function (E) { +})(E || (E = {})); diff --git a/tests/baselines/reference/decoratorOnEnum2.errors.txt b/tests/baselines/reference/decoratorOnEnum2.errors.txt new file mode 100644 index 0000000000000..3a643bc861ada --- /dev/null +++ b/tests/baselines/reference/decoratorOnEnum2.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,5): error TS1132: Enum member expected. +tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,9): error TS1146: Declaration expected. +tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,10): error TS2304: Cannot find name 'A'. +tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts (4 errors) ==== + declare function dec(target: T): T; + + enum E { + @dec A + ~ +!!! error TS1132: Enum member expected. + +!!! error TS1146: Declaration expected. + ~ +!!! error TS2304: Cannot find name 'A'. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnEnum2.js b/tests/baselines/reference/decoratorOnEnum2.js new file mode 100644 index 0000000000000..fecff1f3413be --- /dev/null +++ b/tests/baselines/reference/decoratorOnEnum2.js @@ -0,0 +1,12 @@ +//// [decoratorOnEnum2.ts] +declare function dec(target: T): T; + +enum E { + @dec A +} + +//// [decoratorOnEnum2.js] +var E; +(function (E) { +})(E || (E = {})); +A; diff --git a/tests/baselines/reference/decoratorOnFunctionDeclaration.errors.txt b/tests/baselines/reference/decoratorOnFunctionDeclaration.errors.txt new file mode 100644 index 0000000000000..bda00f1a85f82 --- /dev/null +++ b/tests/baselines/reference/decoratorOnFunctionDeclaration.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(4,10): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + function F() { + ~ +!!! error TS1206: Decorators are not valid here. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnFunctionDeclaration.js b/tests/baselines/reference/decoratorOnFunctionDeclaration.js new file mode 100644 index 0000000000000..7c1a1ff5bfe69 --- /dev/null +++ b/tests/baselines/reference/decoratorOnFunctionDeclaration.js @@ -0,0 +1,10 @@ +//// [decoratorOnFunctionDeclaration.ts] +declare function dec(target: T): T; + +@dec +function F() { +} + +//// [decoratorOnFunctionDeclaration.js] +function F() { +} diff --git a/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt b/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt new file mode 100644 index 0000000000000..71aae3e13eb23 --- /dev/null +++ b/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts(3,9): error TS1109: Expression expected. +tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts(3,23): error TS1003: Identifier expected. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts (2 errors) ==== + declare function dec(target: T): T; + + var F = @dec function () { + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1003: Identifier expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnFunctionExpression.js b/tests/baselines/reference/decoratorOnFunctionExpression.js new file mode 100644 index 0000000000000..f6808674ed4e7 --- /dev/null +++ b/tests/baselines/reference/decoratorOnFunctionExpression.js @@ -0,0 +1,10 @@ +//// [decoratorOnFunctionExpression.ts] +declare function dec(target: T): T; + +var F = @dec function () { +} + +//// [decoratorOnFunctionExpression.js] +var F = ; +function () { +} diff --git a/tests/baselines/reference/decoratorOnImportEquals1.errors.txt b/tests/baselines/reference/decoratorOnImportEquals1.errors.txt new file mode 100644 index 0000000000000..a09a0b014278d --- /dev/null +++ b/tests/baselines/reference/decoratorOnImportEquals1.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts(8,5): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts (1 errors) ==== + declare function dec(target: T): T; + + module M1 { + export var X: number; + } + + module M2 { + @dec + ~~~~ + import X = M1.X; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1206: Decorators are not valid here. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnImportEquals1.js b/tests/baselines/reference/decoratorOnImportEquals1.js new file mode 100644 index 0000000000000..440fdb99bce3b --- /dev/null +++ b/tests/baselines/reference/decoratorOnImportEquals1.js @@ -0,0 +1,17 @@ +//// [decoratorOnImportEquals1.ts] +declare function dec(target: T): T; + +module M1 { + export var X: number; +} + +module M2 { + @dec + import X = M1.X; +} + +//// [decoratorOnImportEquals1.js] +var M1; +(function (M1) { + M1.X; +})(M1 || (M1 = {})); diff --git a/tests/baselines/reference/decoratorOnImportEquals2.errors.txt b/tests/baselines/reference/decoratorOnImportEquals2.errors.txt new file mode 100644 index 0000000000000..5701afe569be2 --- /dev/null +++ b/tests/baselines/reference/decoratorOnImportEquals2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts(1,1): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts (1 errors) ==== + @dec + ~~~~ + import lib = require('./decoratorOnImportEquals2_0'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1206: Decorators are not valid here. + + declare function dec(target: T): T; +==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_0.ts (0 errors) ==== + export var X; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnImportEquals2.js b/tests/baselines/reference/decoratorOnImportEquals2.js new file mode 100644 index 0000000000000..7db2da6b2c2b9 --- /dev/null +++ b/tests/baselines/reference/decoratorOnImportEquals2.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2.ts] //// + +//// [decoratorOnImportEquals2_0.ts] +export var X; + +//// [decoratorOnImportEquals2_1.ts] +@dec +import lib = require('./decoratorOnImportEquals2_0'); + +declare function dec(target: T): T; + +//// [decoratorOnImportEquals2_0.js] +exports.X; +//// [decoratorOnImportEquals2_1.js] diff --git a/tests/baselines/reference/decoratorOnInterface.errors.txt b/tests/baselines/reference/decoratorOnInterface.errors.txt new file mode 100644 index 0000000000000..055b43fa877a4 --- /dev/null +++ b/tests/baselines/reference/decoratorOnInterface.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(4,11): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + interface I { + ~ +!!! error TS1206: Decorators are not valid here. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnInterface.js b/tests/baselines/reference/decoratorOnInterface.js new file mode 100644 index 0000000000000..10b01f299bfab --- /dev/null +++ b/tests/baselines/reference/decoratorOnInterface.js @@ -0,0 +1,8 @@ +//// [decoratorOnInterface.ts] +declare function dec(target: T): T; + +@dec +interface I { +} + +//// [decoratorOnInterface.js] diff --git a/tests/baselines/reference/decoratorOnInternalModule.errors.txt b/tests/baselines/reference/decoratorOnInternalModule.errors.txt new file mode 100644 index 0000000000000..2fd92dfb2500a --- /dev/null +++ b/tests/baselines/reference/decoratorOnInternalModule.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts(4,8): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + module M { + ~ +!!! error TS1206: Decorators are not valid here. + + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnInternalModule.js b/tests/baselines/reference/decoratorOnInternalModule.js new file mode 100644 index 0000000000000..d69ab6f1a5622 --- /dev/null +++ b/tests/baselines/reference/decoratorOnInternalModule.js @@ -0,0 +1,9 @@ +//// [decoratorOnInternalModule.ts] +declare function dec(target: T): T; + +@dec +module M { + +} + +//// [decoratorOnInternalModule.js] diff --git a/tests/baselines/reference/decoratorOnTypeAlias.errors.txt b/tests/baselines/reference/decoratorOnTypeAlias.errors.txt new file mode 100644 index 0000000000000..0d3109fe463f2 --- /dev/null +++ b/tests/baselines/reference/decoratorOnTypeAlias.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/invalid/decoratorOnTypeAlias.ts(3,1): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnTypeAlias.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + ~~~~ + type T = number; + ~~~~~~~~~~~~~~~~ +!!! error TS1206: Decorators are not valid here. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnTypeAlias.js b/tests/baselines/reference/decoratorOnTypeAlias.js new file mode 100644 index 0000000000000..ef4fc51034f91 --- /dev/null +++ b/tests/baselines/reference/decoratorOnTypeAlias.js @@ -0,0 +1,7 @@ +//// [decoratorOnTypeAlias.ts] +declare function dec(target: T): T; + +@dec +type T = number; + +//// [decoratorOnTypeAlias.js] diff --git a/tests/baselines/reference/decoratorOnVar.errors.txt b/tests/baselines/reference/decoratorOnVar.errors.txt new file mode 100644 index 0000000000000..bd87357edad6a --- /dev/null +++ b/tests/baselines/reference/decoratorOnVar.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/decorators/invalid/decoratorOnVar.ts(3,1): error TS1206: Decorators are not valid here. + + +==== tests/cases/conformance/decorators/invalid/decoratorOnVar.ts (1 errors) ==== + declare function dec(target: T): T; + + @dec + ~~~~ + var x: number; + ~~~~~~~~~~~~~~ +!!! error TS1206: Decorators are not valid here. \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnVar.js b/tests/baselines/reference/decoratorOnVar.js new file mode 100644 index 0000000000000..5240d59fda041 --- /dev/null +++ b/tests/baselines/reference/decoratorOnVar.js @@ -0,0 +1,8 @@ +//// [decoratorOnVar.ts] +declare function dec(target: T): T; + +@dec +var x: number; + +//// [decoratorOnVar.js] +var x; diff --git a/tests/baselines/reference/downlevelLetConst14.js b/tests/baselines/reference/downlevelLetConst14.js index ffe667eda3f4c..ac9444f9facca 100644 --- a/tests/baselines/reference/downlevelLetConst14.js +++ b/tests/baselines/reference/downlevelLetConst14.js @@ -59,24 +59,24 @@ use(y); var x = 10; var z0, z1, z2, z3; { - var _x = 20; - use(_x); - var _z0 = ([ + var x_1 = 20; + use(x_1); + var z0_1 = ([ 1 ])[0]; - use(_z0); - var _z1 = ([ + use(z0_1); + var z1_1 = ([ 1 ])[0]; - use(_z1); - var _z2 = ({ + use(z1_1); + var z2_1 = ({ a: 1 }).a; - use(_z2); - var _z3 = ({ + use(z2_1); + var z3_1 = ({ a: 1 }).a; - use(_z3); + use(z3_1); } use(x); use(z0); @@ -86,38 +86,38 @@ use(z3); var z6; var y = true; { - var _y = ""; - var _z6 = ([ + var y_1 = ""; + var z6_1 = ([ true ])[0]; { - var _y_1 = 1; - var _z6_1 = ({ + var y_2 = 1; + var z6_2 = ({ a: 1 }).a; - use(_y_1); - use(_z6_1); + use(y_2); + use(z6_2); } - use(_y); - use(_z6); + use(y_1); + use(z6_1); } use(y); use(z6); var z = false; var z5 = 1; { - var _z = ""; - var _z5 = ([ + var z_1 = ""; + var z5_1 = ([ 5 ])[0]; { - var _z_1 = 1; - var _z5_1 = ({ + var _z = 1; + var _z5 = ({ a: 1 }).a; // try to step on generated name - use(_z_1); + use(_z); } - use(_z); + use(z_1); } use(y); diff --git a/tests/baselines/reference/downlevelLetConst15.js b/tests/baselines/reference/downlevelLetConst15.js index 94fcb1b03a008..f1b476c017612 100644 --- a/tests/baselines/reference/downlevelLetConst15.js +++ b/tests/baselines/reference/downlevelLetConst15.js @@ -59,28 +59,28 @@ use(y); var x = 10; var z0, z1, z2, z3; { - var _x = 20; - use(_x); - var _z0 = ([ + var x_1 = 20; + use(x_1); + var z0_1 = ([ 1 ])[0]; - use(_z0); - var _z1 = ([ + use(z0_1); + var z1_1 = ([ { a: 1 } ])[0].a; - use(_z1); - var _z2 = ({ + use(z1_1); + var z2_1 = ({ a: 1 }).a; - use(_z2); - var _z3 = ({ + use(z2_1); + var z3_1 = ({ a: { b: 1 } }).a.b; - use(_z3); + use(z3_1); } use(x); use(z0); @@ -90,38 +90,38 @@ use(z3); var z6; var y = true; { - var _y = ""; - var _z6 = ([ + var y_1 = ""; + var z6_1 = ([ true ])[0]; { - var _y_1 = 1; - var _z6_1 = ({ + var y_2 = 1; + var z6_2 = ({ a: 1 }).a; - use(_y_1); - use(_z6_1); + use(y_2); + use(z6_2); } - use(_y); - use(_z6); + use(y_1); + use(z6_1); } use(y); use(z6); var z = false; var z5 = 1; { - var _z = ""; - var _z5 = ([ + var z_1 = ""; + var z5_1 = ([ 5 ])[0]; { - var _z_1 = 1; - var _z5_1 = ({ + var _z = 1; + var _z5 = ({ a: 1 }).a; // try to step on generated name - use(_z_1); + use(_z); } - use(_z); + use(z_1); } use(y); diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js index f83e745c55403..aefe2830adc2f 100644 --- a/tests/baselines/reference/downlevelLetConst16.js +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -236,29 +236,29 @@ use(x); use(y); use(z); function foo1() { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); } function foo2() { { - var _x = 1; - use(_x); - var _y = ([ + var x_1 = 1; + use(x_1); + var y_1 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_1); + var z_1 = ({ a: 1 }).a; - use(_z); + use(z_1); } use(x); } @@ -266,29 +266,29 @@ var A = (function () { function A() { } A.prototype.m1 = function () { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); }; A.prototype.m2 = function () { { - var _x = 1; - use(_x); - var _y = ([ + var x_2 = 1; + use(x_2); + var y_2 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_2); + var z_2 = ({ a: 1 }).a; - use(_z); + use(z_2); } use(x); }; @@ -298,200 +298,200 @@ var B = (function () { function B() { } B.prototype.m1 = function () { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); }; B.prototype.m2 = function () { { - var _x = 1; - use(_x); - var _y = ([ + var x_3 = 1; + use(x_3); + var y_3 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_3); + var z_3 = ({ a: 1 }).a; - use(_z); + use(z_3); } use(x); }; return B; })(); function bar1() { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); } function bar2() { { - var _x = 1; - use(_x); - var _y = ([ + var x_4 = 1; + use(x_4); + var y_4 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_4); + var z_4 = ({ a: 1 }).a; - use(_z); + use(z_4); } use(x); } var M1; (function (M1) { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); })(M1 || (M1 = {})); var M2; (function (M2) { { - var _x = 1; - use(_x); - var _y = ([ + var x_5 = 1; + use(x_5); + var y_5 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_5); + var z_5 = ({ a: 1 }).a; - use(_z); + use(z_5); } use(x); })(M2 || (M2 = {})); var M3; (function (M3) { - var _x = 1; - use(_x); - var _y = ([ + var x = 1; + use(x); + var y = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y); + var z = ({ a: 1 }).a; - use(_z); + use(z); })(M3 || (M3 = {})); var M4; (function (M4) { { - var _x = 1; - use(_x); - var _y = ([ + var x_6 = 1; + use(x_6); + var y_6 = ([ 1 ])[0]; - use(_y); - var _z = ({ + use(y_6); + var z_6 = ({ a: 1 }).a; - use(_z); + use(z_6); } use(x); use(y); use(z); })(M4 || (M4 = {})); function foo3() { - for (var _x = void 0;;) { - use(_x); + for (var x_7 = void 0;;) { + use(x_7); } - for (var _y = ([])[0];;) { - use(_y); + for (var y_7 = ([])[0];;) { + use(y_7); } - for (var _z = ({ + for (var z_7 = ({ a: 1 }).a;;) { - use(_z); + use(z_7); } use(x); } function foo4() { - for (var _x = 1;;) { - use(_x); + for (var x_8 = 1;;) { + use(x_8); } - for (var _y = ([])[0];;) { - use(_y); + for (var y_8 = ([])[0];;) { + use(y_8); } - for (var _z = ({ + for (var z_8 = ({ a: 1 }).a;;) { - use(_z); + use(z_8); } use(x); } function foo5() { - for (var _x in []) { - use(_x); + for (var x_9 in []) { + use(x_9); } use(x); } function foo6() { - for (var _x in []) { - use(_x); + for (var x_10 in []) { + use(x_10); } use(x); } function foo7() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i]; - use(_x); + var x_11 = _a[_i]; + use(x_11); } use(x); } function foo8() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i][0]; - use(_x); + var x_12 = _a[_i][0]; + use(x_12); } use(x); } function foo9() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i].a; - use(_x); + var x_13 = _a[_i].a; + use(x_13); } use(x); } function foo10() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i]; - use(_x); + var x_14 = _a[_i]; + use(x_14); } use(x); } function foo11() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i][0]; - use(_x); + var x_15 = _a[_i][0]; + use(x_15); } use(x); } function foo12() { for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x = _a[_i].a; - use(_x); + var x_16 = _a[_i].a; + use(x_16); } use(x); } diff --git a/tests/baselines/reference/downlevelLetConst17.js b/tests/baselines/reference/downlevelLetConst17.js index d38ec3fde08c8..56ab1e6df54c6 100644 --- a/tests/baselines/reference/downlevelLetConst17.js +++ b/tests/baselines/reference/downlevelLetConst17.js @@ -70,54 +70,54 @@ for (const x of []) { //// [downlevelLetConst17.js] 'use strict'; var x; -for (var _x = 10;;) { - use(_x); +for (var x_1 = 10;;) { + use(x_1); } use(x); -for (var _x_1 = 10;;) { - use(_x_1); +for (var x_2 = 10;;) { + use(x_2); } for (;;) { - var _x_2 = 10; - use(_x_2); - _x_2 = 1; + var x_3 = 10; + use(x_3); + x_3 = 1; } for (;;) { - var _x_3 = 10; - use(_x_3); + var x_4 = 10; + use(x_4); } -for (var _x_4 = void 0;;) { - use(_x_4); - _x_4 = 1; +for (var x_5 = void 0;;) { + use(x_5); + x_5 = 1; } for (;;) { - var _x_5 = void 0; - use(_x_5); - _x_5 = 1; + var x_6 = void 0; + use(x_6); + x_6 = 1; } while (true) { - var _x_6 = void 0; - use(_x_6); + var x_7 = void 0; + use(x_7); } while (true) { - var _x_7 = true; - use(_x_7); + var x_8 = true; + use(x_8); } do { - var _x_8 = void 0; - use(_x_8); + var x_9 = void 0; + use(x_9); } while (true); do { - var _x_9 = void 0; - use(_x_9); + var x_10 = void 0; + use(x_10); } while (true); -for (var _x_10 in []) { - use(_x_10); +for (var x_11 in []) { + use(x_11); } -for (var _x_11 in []) { - use(_x_11); +for (var x_12 in []) { + use(x_12); } for (var _i = 0, _a = []; _i < _a.length; _i++) { - var _x_12 = _a[_i]; - use(_x_12); + var x_13 = _a[_i]; + use(x_13); } diff --git a/tests/baselines/reference/downlevelLetConst18.js b/tests/baselines/reference/downlevelLetConst18.js index 0c025573e209b..f3b2306d62b33 100644 --- a/tests/baselines/reference/downlevelLetConst18.js +++ b/tests/baselines/reference/downlevelLetConst18.js @@ -38,40 +38,40 @@ for (var x = void 0;;) { } ; } -for (var _x = void 0;;) { +for (var x = void 0;;) { function foo() { - _x; + x; } ; } -for (var _x_1 = void 0;;) { +for (var x = void 0;;) { (function () { - _x_1; + x; })(); } -for (var _x_2 = 1;;) { +for (var x = 1;;) { (function () { - _x_2; + x; })(); } -for (var _x_3 = void 0;;) { +for (var x = void 0;;) { ({ foo: function () { - _x_3; + x; } }); } -for (var _x_4 = void 0;;) { +for (var x = void 0;;) { ({ get foo() { - return _x_4; + return x; } }); } -for (var _x_5 = void 0;;) { +for (var x = void 0;;) { ({ set foo(v) { - _x_5; + x; } }); } diff --git a/tests/baselines/reference/downlevelLetConst19.js b/tests/baselines/reference/downlevelLetConst19.js index adcc2e256a81d..2b3ec8036cbdb 100644 --- a/tests/baselines/reference/downlevelLetConst19.js +++ b/tests/baselines/reference/downlevelLetConst19.js @@ -24,14 +24,14 @@ use(x) var x; function a() { { - var _x; - use(_x); + var x_1; + use(x_1); function b() { { - var _x_1; - use(_x_1); + var x_2; + use(x_2); } - use(_x); + use(x_1); } } use(x); diff --git a/tests/baselines/reference/duplicateExportAssignments.js b/tests/baselines/reference/duplicateExportAssignments.js index 7d2776962f7ad..3742a5f1fe54f 100644 --- a/tests/baselines/reference/duplicateExportAssignments.js +++ b/tests/baselines/reference/duplicateExportAssignments.js @@ -56,8 +56,8 @@ var y = (function () { module.exports = x; //// [foo3.js] var x; -(function (_x) { - _x.x = 10; +(function (x_1) { + x_1.x = 10; })(x || (x = {})); var y = (function () { function y() { diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js index 3ac993c612b10..4d29fce3c10d9 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -6,14 +6,14 @@ export default class { //// [es5ExportDefaultClassDeclaration2.js] -var _default = (function () { - function _default() { +var default_1 = (function () { + function default_1() { } - _default.prototype.method = function () { + default_1.prototype.method = function () { }; - return _default; + return default_1; })(); -exports.default = _default; +exports.default = default_1; //// [es5ExportDefaultClassDeclaration2.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js index 4cfb4dcd6179d..61f167619eb9c 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -6,7 +6,7 @@ export default function () { } //// [es5ExportDefaultFunctionDeclaration2.js] function () { } -exports.default = _default; +exports.default = default_1; //// [es5ExportDefaultFunctionDeclaration2.d.ts] diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index 95fcd77e42deb..6250e0ce3264b 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -33,14 +33,14 @@ var m; })(m = exports.m || (exports.m = {})); exports.x = 10; //// [client.js] -var _server = require("server"); -exports.c = _server.c; -var _server_1 = require("server"); -exports.c2 = _server_1.c; -var _server_2 = require("server"); -exports.instantiatedModule = _server_2.m; -var _server_4 = require("server"); -exports.x = _server_4.x; +var server_1 = require("server"); +exports.c = server_1.c; +var server_2 = require("server"); +exports.c2 = server_2.c; +var server_3 = require("server"); +exports.instantiatedModule = server_3.m; +var server_4 = require("server"); +exports.x = server_4.x; //// [server.d.ts] diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js index 045de615c8666..ac5d92b6c129d 100644 --- a/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js @@ -6,7 +6,7 @@ export default class { //// [es6ExportDefaultClassDeclaration2.js] -export default class { +export default class { method() { } } diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 6775bb8c6bbe6..747b0b2beb808 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -253,41 +253,41 @@ y8.a; y9.a; y0.a; // named import -var _interface_2 = require("interface"); -var _variable_2 = require("variable"); -var _interface_variable_2 = require("interface-variable"); -var _module_2 = require("module"); -var _interface_module_2 = require("interface-module"); -var _variable_module_2 = require("variable-module"); -var _function_2 = require("function"); -var _function_module_2 = require("function-module"); -var _class_2 = require("class"); -var _class_module_2 = require("class-module"); -_interface_2.a; -_variable_2.a; -_interface_variable_2.a; -_module_2.a; -_interface_module_2.a; -_variable_module_2.a; -_function_2.a; -_function_module_2.a; -_class_2.a; -_class_module_2.a; +var interface_1 = require("interface"); +var variable_1 = require("variable"); +var interface_variable_1 = require("interface-variable"); +var module_1 = require("module"); +var interface_module_1 = require("interface-module"); +var variable_module_1 = require("variable-module"); +var function_1 = require("function"); +var function_module_1 = require("function-module"); +var class_1 = require("class"); +var class_module_1 = require("class-module"); +interface_1.a; +variable_1.a; +interface_variable_1.a; +module_1.a; +interface_module_1.a; +variable_module_1.a; +function_1.a; +function_module_1.a; +class_1.a; +class_module_1.a; // named export -var _variable_3 = require("variable"); -exports.a2 = _variable_3.a; -var _interface_variable_3 = require("interface-variable"); -exports.a3 = _interface_variable_3.a; -var _module_3 = require("module"); -exports.a4 = _module_3.a; -var _interface_module_3 = require("interface-module"); -exports.a5 = _interface_module_3.a; -var _variable_module_3 = require("variable-module"); -exports.a6 = _variable_module_3.a; -var _function_module_3 = require("function-module"); -exports.a8 = _function_module_3.a; -var _class_module_3 = require("class-module"); -exports.a0 = _class_module_3.a; +var variable_2 = require("variable"); +exports.a2 = variable_2.a; +var interface_variable_2 = require("interface-variable"); +exports.a3 = interface_variable_2.a; +var module_2 = require("module"); +exports.a4 = module_2.a; +var interface_module_2 = require("interface-module"); +exports.a5 = interface_module_2.a; +var variable_module_2 = require("variable-module"); +exports.a6 = variable_module_2.a; +var function_module_2 = require("function-module"); +exports.a8 = function_module_2.a; +var class_module_2 = require("class-module"); +exports.a0 = class_module_2.a; // export-star __export(require("interface")); __export(require("variable")); diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index 094e971ecb411..70e4f7e2f57a1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -17,8 +17,8 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] -define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, _es6ImportDefaultBindingAmd_0) { - var x = _es6ImportDefaultBindingAmd_0.default; +define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, es6ImportDefaultBindingAmd_0_1) { + var x = es6ImportDefaultBindingAmd_0_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index 8aa195533eb1d..caa46ed30efe2 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -19,8 +19,8 @@ var c = (function () { })(); exports.default = c; //// [client.js] -var _server = require("server"); -exports.x = new _server.default(); +var server_1 = require("server"); +exports.x = new server_1.default(); //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index b0523e9f1d579..15ca1284a1e0b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -24,18 +24,18 @@ var x: number = defaultBinding6; var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.default; -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -var _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = _es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index ed6b672ee7b1e..b6b03176df115 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -24,18 +24,18 @@ export var x1: number = defaultBinding6; var a = 10; exports.default = a; //// [client.js] -var _server = require("server"); -exports.x1 = _server.default; -var _server_1 = require("server"); -exports.x1 = _server_1.default; -var _server_2 = require("server"); -exports.x1 = _server_2.default; -var _server_3 = require("server"); -exports.x1 = _server_3.default; -var _server_4 = require("server"); -exports.x1 = _server_4.default; -var _server_5 = require("server"); -exports.x1 = _server_5.default; +var server_1 = require("server"); +exports.x1 = server_1.default; +var server_2 = require("server"); +exports.x1 = server_2.default; +var server_3 = require("server"); +exports.x1 = server_3.default; +var server_4 = require("server"); +exports.x1 = server_4.default; +var server_5 = require("server"); +exports.x1 = server_5.default; +var server_6 = require("server"); +exports.x1 = server_6.default; //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js index 6c85e281150de..8cf9ab1ffb129 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -62,17 +62,17 @@ var x11 = (function () { })(); exports.x11 = x11; //// [client.js] -var _server_1 = require("server"); -exports.x1 = new _server_1.a(); -var _server_2 = require("server"); -exports.x2 = new _server_2.a11(); -var _server_3 = require("server"); -exports.x4 = new _server_3.x(); -exports.x5 = new _server_3.a12(); -var _server_4 = require("server"); -exports.x3 = new _server_4.x11(); -var _server_5 = require("server"); -exports.x6 = new _server_5.m(); +var server_1 = require("server"); +exports.x1 = new server_1.a(); +var server_2 = require("server"); +exports.x2 = new server_2.a11(); +var server_3 = require("server"); +exports.x4 = new server_3.x(); +exports.x5 = new server_3.a12(); +var server_4 = require("server"); +exports.x3 = new server_4.x11(); +var server_5 = require("server"); +exports.x6 = new server_5.m(); //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index 3fe7532009895..e6211ac1ebec0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -27,18 +27,18 @@ var a = (function () { })(); exports.default = a; //// [client.js] -var _server = require("server"); -exports.x1 = new _server.default(); -var _server_1 = require("server"); -exports.x2 = new _server_1.default(); -var _server_2 = require("server"); -exports.x3 = new _server_2.default(); -var _server_3 = require("server"); -exports.x4 = new _server_3.default(); -var _server_4 = require("server"); -exports.x5 = new _server_4.default(); -var _server_5 = require("server"); -exports.x6 = new _server_5.default(); +var server_1 = require("server"); +exports.x1 = new server_1.default(); +var server_2 = require("server"); +exports.x2 = new server_2.default(); +var server_3 = require("server"); +exports.x3 = new server_3.default(); +var server_4 = require("server"); +exports.x4 = new server_4.default(); +var server_5 = require("server"); +exports.x5 = new server_5.default(); +var server_6 = require("server"); +exports.x6 = new server_6.default(); //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index 1c63005bb0680..1c65fadbe1d43 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -26,17 +26,17 @@ exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] -var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; -var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; -var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; -var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; -var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js index c6d487ace472a..0d5f38c0be43c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -30,13 +30,13 @@ define(["require", "exports"], function (require, exports) { exports.default = {}; }); //// [client.js] -define(["require", "exports", "server", "server", "server", "server", "server"], function (require, exports, _server_1, _server_2, _server_3, _server_4, _server_5) { - exports.x1 = _server_1.a; - exports.x1 = _server_2.a; - exports.x1 = _server_3.x; - exports.x1 = _server_3.a; - exports.x1 = _server_4.x; - exports.x1 = _server_5.m; +define(["require", "exports", "server", "server", "server", "server", "server"], function (require, exports, server_1, server_2, server_3, server_4, server_5) { + exports.x1 = server_1.a; + exports.x1 = server_2.a; + exports.x1 = server_3.x; + exports.x1 = server_3.a; + exports.x1 = server_4.x; + exports.x1 = server_5.m; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 8481420ac9415..c2bd5476a7c4e 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -13,8 +13,8 @@ var x: number = defaultBinding; var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var _es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = _es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0; -var x = _es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.default; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index e676554e8c621..ed40582e9231d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -15,9 +15,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, _server) { - var nameSpaceBinding = _server; - exports.x = _server.default; +define(["require", "exports", "server"], function (require, exports, server_1) { + var nameSpaceBinding = server_1; + exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index dc068451677c2..31ef01c464c80 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -16,7 +16,7 @@ var a = (function () { })(); exports.a = a; //// [client.js] -var _server = require("server"), nameSpaceBinding = _server; +var server_1 = require("server"), nameSpaceBinding = server_1; exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index 2d4eec9e4127f..e03ded5fd5aaf 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -19,9 +19,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, _server) { - var nameSpaceBinding = _server; - exports.x = new _server.default(); +define(["require", "exports", "server"], function (require, exports, server_1) { + var nameSpaceBinding = server_1; + exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index a37e732ca40db..4a49d3c2d6fd5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -11,7 +11,7 @@ var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var _es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = _es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index 27bde8dde01a5..df233fe18a5b3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -11,7 +11,7 @@ export var x: number = nameSpaceBinding.a; //// [server.js] exports.a = 10; //// [client.js] -var _server = require("server"), nameSpaceBinding = _server; +var server_1 = require("server"), nameSpaceBinding = server_1; exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 9cacd1837923f..1208ace5ddef4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -20,6 +20,6 @@ import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] -var _es6ImportDefaultBindingMergeErrors_0 = require("es6ImportDefaultBindingMergeErrors_0"); -var x = _es6ImportDefaultBindingMergeErrors_0.default; +var es6ImportDefaultBindingMergeErrors_0_1 = require("es6ImportDefaultBindingMergeErrors_0"); +var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index e68daef500953..e2c5fab4c94b6 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -16,8 +16,8 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, _server) { - exports.x = _server.default; +define(["require", "exports", "server"], function (require, exports, server_1) { + exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportNamedImportAmd.js b/tests/baselines/reference/es6ImportNamedImportAmd.js index 5e3ddc433083a..c335337325e51 100644 --- a/tests/baselines/reference/es6ImportNamedImportAmd.js +++ b/tests/baselines/reference/es6ImportNamedImportAmd.js @@ -53,19 +53,19 @@ define(["require", "exports"], function (require, exports) { exports.aaaa = 10; }); //// [es6ImportNamedImportAmd_1.js] -define(["require", "exports", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0"], function (require, exports, _es6ImportNamedImportAmd_0_1, _es6ImportNamedImportAmd_0_2, _es6ImportNamedImportAmd_0_3, _es6ImportNamedImportAmd_0_4, _es6ImportNamedImportAmd_0_5, _es6ImportNamedImportAmd_0_6, _es6ImportNamedImportAmd_0_7, _es6ImportNamedImportAmd_0_8, _es6ImportNamedImportAmd_0_9) { - var xxxx = _es6ImportNamedImportAmd_0_1.a; - var xxxx = _es6ImportNamedImportAmd_0_2.a; - var xxxx = _es6ImportNamedImportAmd_0_3.x; - var xxxx = _es6ImportNamedImportAmd_0_3.a; - var xxxx = _es6ImportNamedImportAmd_0_4.x; - var xxxx = _es6ImportNamedImportAmd_0_5.m; - var xxxx = _es6ImportNamedImportAmd_0_6.a1; - var xxxx = _es6ImportNamedImportAmd_0_6.x1; - var xxxx = _es6ImportNamedImportAmd_0_7.a1; - var xxxx = _es6ImportNamedImportAmd_0_7.x1; - var z111 = _es6ImportNamedImportAmd_0_8.z1; - var z2 = _es6ImportNamedImportAmd_0_9.z2; // z2 shouldn't give redeclare error +define(["require", "exports", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0"], function (require, exports, es6ImportNamedImportAmd_0_1, es6ImportNamedImportAmd_0_2, es6ImportNamedImportAmd_0_3, es6ImportNamedImportAmd_0_4, es6ImportNamedImportAmd_0_5, es6ImportNamedImportAmd_0_6, es6ImportNamedImportAmd_0_7, es6ImportNamedImportAmd_0_8, es6ImportNamedImportAmd_0_9) { + var xxxx = es6ImportNamedImportAmd_0_1.a; + var xxxx = es6ImportNamedImportAmd_0_2.a; + var xxxx = es6ImportNamedImportAmd_0_3.x; + var xxxx = es6ImportNamedImportAmd_0_3.a; + var xxxx = es6ImportNamedImportAmd_0_4.x; + var xxxx = es6ImportNamedImportAmd_0_5.m; + var xxxx = es6ImportNamedImportAmd_0_6.a1; + var xxxx = es6ImportNamedImportAmd_0_6.x1; + var xxxx = es6ImportNamedImportAmd_0_7.a1; + var xxxx = es6ImportNamedImportAmd_0_7.x1; + var z111 = es6ImportNamedImportAmd_0_8.z1; + var z2 = es6ImportNamedImportAmd_0_9.z2; // z2 shouldn't give redeclare error }); diff --git a/tests/baselines/reference/es6ImportNamedImportDts.js b/tests/baselines/reference/es6ImportNamedImportDts.js index 877ae6fab74f3..a72632a737e7a 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.js +++ b/tests/baselines/reference/es6ImportNamedImportDts.js @@ -132,27 +132,27 @@ var aaaa1 = (function () { })(); exports.aaaa1 = aaaa1; //// [client.js] -var _server_1 = require("server"); -exports.xxxx = new _server_1.a(); -var _server_2 = require("server"); -exports.xxxx1 = new _server_2.a11(); -var _server_3 = require("server"); -exports.xxxx2 = new _server_3.x(); -exports.xxxx3 = new _server_3.a12(); -var _server_4 = require("server"); -exports.xxxx4 = new _server_4.x11(); -var _server_5 = require("server"); -exports.xxxx5 = new _server_5.m(); -var _server_6 = require("server"); -exports.xxxx6 = new _server_6.a1(); -exports.xxxx7 = new _server_6.x1(); -var _server_7 = require("server"); -exports.xxxx8 = new _server_7.a111(); -exports.xxxx9 = new _server_7.x111(); -var _server_8 = require("server"); -exports.z111 = new _server_8.z1(); -var _server_9 = require("server"); -exports.z2 = new _server_9.z2(); // z2 shouldn't give redeclare error +var server_1 = require("server"); +exports.xxxx = new server_1.a(); +var server_2 = require("server"); +exports.xxxx1 = new server_2.a11(); +var server_3 = require("server"); +exports.xxxx2 = new server_3.x(); +exports.xxxx3 = new server_3.a12(); +var server_4 = require("server"); +exports.xxxx4 = new server_4.x11(); +var server_5 = require("server"); +exports.xxxx5 = new server_5.m(); +var server_6 = require("server"); +exports.xxxx6 = new server_6.a1(); +exports.xxxx7 = new server_6.x1(); +var server_7 = require("server"); +exports.xxxx8 = new server_7.a111(); +exports.xxxx9 = new server_7.x111(); +var server_8 = require("server"); +exports.z111 = new server_8.z1(); +var server_9 = require("server"); +exports.z2 = new server_9.z2(); // z2 shouldn't give redeclare error //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.js b/tests/baselines/reference/es6ImportNamedImportInEs5.js index fcb88d55b333a..9992508c00be5 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.js @@ -51,27 +51,27 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [es6ImportNamedImportInEs5_1.js] -var _es6ImportNamedImportInEs5_0_1 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_1.a; -var _es6ImportNamedImportInEs5_0_2 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_2.a; -var _es6ImportNamedImportInEs5_0_3 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_3.x; -var xxxx = _es6ImportNamedImportInEs5_0_3.a; -var _es6ImportNamedImportInEs5_0_4 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_4.x; -var _es6ImportNamedImportInEs5_0_5 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_5.m; -var _es6ImportNamedImportInEs5_0_6 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_6.a1; -var xxxx = _es6ImportNamedImportInEs5_0_6.x1; -var _es6ImportNamedImportInEs5_0_7 = require("es6ImportNamedImportInEs5_0"); -var xxxx = _es6ImportNamedImportInEs5_0_7.a1; -var xxxx = _es6ImportNamedImportInEs5_0_7.x1; -var _es6ImportNamedImportInEs5_0_8 = require("es6ImportNamedImportInEs5_0"); -var z111 = _es6ImportNamedImportInEs5_0_8.z1; -var _es6ImportNamedImportInEs5_0_9 = require("es6ImportNamedImportInEs5_0"); -var z2 = _es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error +var es6ImportNamedImportInEs5_0_1 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_1.a; +var es6ImportNamedImportInEs5_0_2 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_2.a; +var es6ImportNamedImportInEs5_0_3 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_3.x; +var xxxx = es6ImportNamedImportInEs5_0_3.a; +var es6ImportNamedImportInEs5_0_4 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_4.x; +var es6ImportNamedImportInEs5_0_5 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_5.m; +var es6ImportNamedImportInEs5_0_6 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_6.a1; +var xxxx = es6ImportNamedImportInEs5_0_6.x1; +var es6ImportNamedImportInEs5_0_7 = require("es6ImportNamedImportInEs5_0"); +var xxxx = es6ImportNamedImportInEs5_0_7.a1; +var xxxx = es6ImportNamedImportInEs5_0_7.x1; +var es6ImportNamedImportInEs5_0_8 = require("es6ImportNamedImportInEs5_0"); +var z111 = es6ImportNamedImportInEs5_0_8.z1; +var es6ImportNamedImportInEs5_0_9 = require("es6ImportNamedImportInEs5_0"); +var z2 = es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error //// [es6ImportNamedImportInEs5_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js index 9c383ab3e3b36..f457e31f53c82 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -23,8 +23,8 @@ var a; a.c = c; })(a = exports.a || (exports.a = {})); //// [es6ImportNamedImportInIndirectExportAssignment_1.js] -var _es6ImportNamedImportInIndirectExportAssignment_0 = require("es6ImportNamedImportInIndirectExportAssignment_0"); -var x = _es6ImportNamedImportInIndirectExportAssignment_0.a; +var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("es6ImportNamedImportInIndirectExportAssignment_0"); +var x = es6ImportNamedImportInIndirectExportAssignment_0_1.a; module.exports = x; diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.js b/tests/baselines/reference/es6ImportNamedImportWithExport.js index 71f4af721788c..60ba6bf706be4 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.js @@ -50,27 +50,27 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [client.js] -var _server_1 = require("server"); -exports.xxxx = _server_1.a; -var _server_2 = require("server"); -exports.xxxx = _server_2.a; -var _server_3 = require("server"); -exports.xxxx = _server_3.x; -exports.xxxx = _server_3.a; -var _server_4 = require("server"); -exports.xxxx = _server_4.x; -var _server_5 = require("server"); -exports.xxxx = _server_5.m; -var _server_6 = require("server"); -exports.xxxx = _server_6.a1; -exports.xxxx = _server_6.x1; -var _server_7 = require("server"); -exports.xxxx = _server_7.a1; -exports.xxxx = _server_7.x1; -var _server_8 = require("server"); -exports.z111 = _server_8.z1; -var _server_9 = require("server"); -exports.z2 = _server_9.z2; // z2 shouldn't give redeclare error +var server_1 = require("server"); +exports.xxxx = server_1.a; +var server_2 = require("server"); +exports.xxxx = server_2.a; +var server_3 = require("server"); +exports.xxxx = server_3.x; +exports.xxxx = server_3.a; +var server_4 = require("server"); +exports.xxxx = server_4.x; +var server_5 = require("server"); +exports.xxxx = server_5.m; +var server_6 = require("server"); +exports.xxxx = server_6.a1; +exports.xxxx = server_6.x1; +var server_7 = require("server"); +exports.xxxx = server_7.a1; +exports.xxxx = server_7.x1; +var server_8 = require("server"); +exports.z111 = server_8.z1; +var server_9 = require("server"); +exports.z2 = server_9.z2; // z2 shouldn't give redeclare error //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js index 7852d2991bc8a..dcf99c5359a81 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js @@ -36,8 +36,8 @@ var C2 = (function () { })(); exports.C2 = C2; //// [client.js] -var _server = require("server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file -exports.cVal = new _server.C(); +var server_1 = require("server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +exports.cVal = new server_1.C(); //// [server.d.ts] diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation3.js b/tests/baselines/reference/exportDefaultTypeAnnoation3.js index 77cb7937712c2..1f95e669de5d9 100644 --- a/tests/baselines/reference/exportDefaultTypeAnnoation3.js +++ b/tests/baselines/reference/exportDefaultTypeAnnoation3.js @@ -15,8 +15,8 @@ import { default as d } from "mod"; var s: string = d; // Error //// [reference1.js] -var _mod = require("mod"); -var s = _mod.default; // Error +var mod_1 = require("mod"); +var s = mod_1.default; // Error //// [reference2.js] -var _mod = require("mod"); -var s = _mod.default; // Error +var mod_1 = require("mod"); +var s = mod_1.default; // Error diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 36d0904a1860d..fb04aa208b22b 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -51,19 +51,19 @@ define(["require", "exports"], function (require, exports) { exports.z = z; }); //// [t4.js] -define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, _t1, _t2, _t3) { +define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, t1_1, t2_1, t3_1) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } - __export(_t1); - __export(_t2); - __export(_t3); + __export(t1_1); + __export(t2_1); + __export(t3_1); }); //// [main.js] -define(["require", "exports", "./t4"], function (require, exports, _t4) { - _t4.default; - _t4.x; - _t4.y; - _t4.z; - _t4.foo; +define(["require", "exports", "./t4"], function (require, exports, t4_1) { + t4_1.default; + t4_1.x; + t4_1.y; + t4_1.z; + t4_1.foo; }); diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 070dd90b1dbd2..9fca12af8b153 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -52,9 +52,9 @@ __export(require("./t1")); __export(require("./t2")); __export(require("./t3")); //// [main.js] -var _t4 = require("./t4"); -_t4.default; -_t4.x; -_t4.y; -_t4.z; -_t4.foo; +var t4_1 = require("./t4"); +t4_1.default; +t4_1.x; +t4_1.y; +t4_1.z; +t4_1.foo; diff --git a/tests/baselines/reference/exportsAndImports1-amd.js b/tests/baselines/reference/exportsAndImports1-amd.js index ac0d56769bb42..99c6fe8d43fe4 100644 --- a/tests/baselines/reference/exportsAndImports1-amd.js +++ b/tests/baselines/reference/exportsAndImports1-amd.js @@ -63,20 +63,20 @@ define(["require", "exports"], function (require, exports) { exports.a = a; }); //// [t2.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.v = _t1.v; - exports.f = _t1.f; - exports.C = _t1.C; - exports.E = _t1.E; - exports.M = _t1.M; - exports.a = _t1.a; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.v = t1_1.v; + exports.f = t1_1.f; + exports.C = t1_1.C; + exports.E = t1_1.E; + exports.M = t1_1.M; + exports.a = t1_1.a; }); //// [t3.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.v = _t1.v; - exports.f = _t1.f; - exports.C = _t1.C; - exports.E = _t1.E; - exports.M = _t1.M; - exports.a = _t1.a; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.v = t1_1.v; + exports.f = t1_1.f; + exports.C = t1_1.C; + exports.E = t1_1.E; + exports.M = t1_1.M; + exports.a = t1_1.a; }); diff --git a/tests/baselines/reference/exportsAndImports1.js b/tests/baselines/reference/exportsAndImports1.js index 2e396c1c72b1a..f381e6b724212 100644 --- a/tests/baselines/reference/exportsAndImports1.js +++ b/tests/baselines/reference/exportsAndImports1.js @@ -61,18 +61,18 @@ exports.M = M; var a = M.x; exports.a = a; //// [t2.js] -var _t1 = require("./t1"); -exports.v = _t1.v; -exports.f = _t1.f; -exports.C = _t1.C; -exports.E = _t1.E; -exports.M = _t1.M; -exports.a = _t1.a; +var t1_1 = require("./t1"); +exports.v = t1_1.v; +exports.f = t1_1.f; +exports.C = t1_1.C; +exports.E = t1_1.E; +exports.M = t1_1.M; +exports.a = t1_1.a; //// [t3.js] -var _t1 = require("./t1"); -exports.v = _t1.v; -exports.f = _t1.f; -exports.C = _t1.C; -exports.E = _t1.E; -exports.M = _t1.M; -exports.a = _t1.a; +var t1_1 = require("./t1"); +exports.v = t1_1.v; +exports.f = t1_1.f; +exports.C = t1_1.C; +exports.E = t1_1.E; +exports.M = t1_1.M; +exports.a = t1_1.a; diff --git a/tests/baselines/reference/exportsAndImports2-amd.js b/tests/baselines/reference/exportsAndImports2-amd.js index a958c5dd77192..10f524de68441 100644 --- a/tests/baselines/reference/exportsAndImports2-amd.js +++ b/tests/baselines/reference/exportsAndImports2-amd.js @@ -19,12 +19,12 @@ define(["require", "exports"], function (require, exports) { exports.y = "y"; }); //// [t2.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.y = _t1.x; - exports.x = _t1.y; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.y = t1_1.x; + exports.x = t1_1.y; }); //// [t3.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.y = _t1.x; - exports.x = _t1.y; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.y = t1_1.x; + exports.x = t1_1.y; }); diff --git a/tests/baselines/reference/exportsAndImports2.js b/tests/baselines/reference/exportsAndImports2.js index 3773dc624c87b..96a3b838ed1ec 100644 --- a/tests/baselines/reference/exportsAndImports2.js +++ b/tests/baselines/reference/exportsAndImports2.js @@ -17,10 +17,10 @@ export { x as y, y as x }; exports.x = "x"; exports.y = "y"; //// [t2.js] -var _t1 = require("./t1"); -exports.y = _t1.x; -exports.x = _t1.y; +var t1_1 = require("./t1"); +exports.y = t1_1.x; +exports.x = t1_1.y; //// [t3.js] -var _t1 = require("./t1"); -exports.y = _t1.x; -exports.x = _t1.y; +var t1_1 = require("./t1"); +exports.y = t1_1.x; +exports.x = t1_1.y; diff --git a/tests/baselines/reference/exportsAndImports3-amd.js b/tests/baselines/reference/exportsAndImports3-amd.js index 443358eafd021..613598cc0ee77 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.js +++ b/tests/baselines/reference/exportsAndImports3-amd.js @@ -65,20 +65,20 @@ define(["require", "exports"], function (require, exports) { exports.a1 = exports.a; }); //// [t2.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.v = _t1.v1; - exports.f = _t1.f1; - exports.C = _t1.C1; - exports.E = _t1.E1; - exports.M = _t1.M1; - exports.a = _t1.a1; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.v = t1_1.v1; + exports.f = t1_1.f1; + exports.C = t1_1.C1; + exports.E = t1_1.E1; + exports.M = t1_1.M1; + exports.a = t1_1.a1; }); //// [t3.js] -define(["require", "exports", "./t1"], function (require, exports, _t1) { - exports.v = _t1.v1; - exports.f = _t1.f1; - exports.C = _t1.C1; - exports.E = _t1.E1; - exports.M = _t1.M1; - exports.a = _t1.a1; +define(["require", "exports", "./t1"], function (require, exports, t1_1) { + exports.v = t1_1.v1; + exports.f = t1_1.f1; + exports.C = t1_1.C1; + exports.E = t1_1.E1; + exports.M = t1_1.M1; + exports.a = t1_1.a1; }); diff --git a/tests/baselines/reference/exportsAndImports3.js b/tests/baselines/reference/exportsAndImports3.js index d4ebe982f895d..f06a6f684d0e4 100644 --- a/tests/baselines/reference/exportsAndImports3.js +++ b/tests/baselines/reference/exportsAndImports3.js @@ -63,18 +63,18 @@ exports.M1 = exports.M; exports.a = M.x; exports.a1 = exports.a; //// [t2.js] -var _t1 = require("./t1"); -exports.v = _t1.v1; -exports.f = _t1.f1; -exports.C = _t1.C1; -exports.E = _t1.E1; -exports.M = _t1.M1; -exports.a = _t1.a1; +var t1_1 = require("./t1"); +exports.v = t1_1.v1; +exports.f = t1_1.f1; +exports.C = t1_1.C1; +exports.E = t1_1.E1; +exports.M = t1_1.M1; +exports.a = t1_1.a1; //// [t3.js] -var _t1 = require("./t1"); -exports.v = _t1.v1; -exports.f = _t1.f1; -exports.C = _t1.C1; -exports.E = _t1.E1; -exports.M = _t1.M1; -exports.a = _t1.a1; +var t1_1 = require("./t1"); +exports.v = t1_1.v1; +exports.f = t1_1.f1; +exports.C = t1_1.C1; +exports.E = t1_1.E1; +exports.M = t1_1.M1; +exports.a = t1_1.a1; diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index 08342c566007b..db28ed5b35009 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -44,22 +44,22 @@ define(["require", "exports"], function (require, exports) { exports.default = "hello"; }); //// [t3.js] -define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, _t1, c, _t1_2, _t1_3, _t1_4) { +define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, t1_1, c, t1_2, t1_3, t1_4) { exports.a = a; a.default; - exports.b = _t1.default; - _t1.default; + exports.b = t1_1.default; + t1_1.default; exports.c = c; c.default; - exports.d = _t1_2.default; - _t1_2.default; - var e2 = _t1_3; - exports.e1 = _t1_3.default; + exports.d = t1_2.default; + t1_2.default; + var e2 = t1_3; + exports.e1 = t1_3.default; exports.e2 = e2; - _t1_3.default; + t1_3.default; e2.default; - exports.f1 = _t1_4.default; - exports.f2 = _t1_4.default; - _t1_4.default; - _t1_4.default; + exports.f1 = t1_4.default; + exports.f2 = t1_4.default; + t1_4.default; + t1_4.default; }); diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index 05f0285472964..ea5f34b882be8 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -45,22 +45,22 @@ exports.default = "hello"; var a = require("./t1"); exports.a = a; a.default; -var _t1 = require("./t1"); -exports.b = _t1.default; -_t1.default; +var t1_1 = require("./t1"); +exports.b = t1_1.default; +t1_1.default; var c = require("./t1"); exports.c = c; c.default; -var _t1_2 = require("./t1"); -exports.d = _t1_2.default; -_t1_2.default; -var _t1_3 = require("./t1"), e2 = _t1_3; -exports.e1 = _t1_3.default; +var t1_2 = require("./t1"); +exports.d = t1_2.default; +t1_2.default; +var t1_3 = require("./t1"), e2 = t1_3; +exports.e1 = t1_3.default; exports.e2 = e2; -_t1_3.default; +t1_3.default; e2.default; -var _t1_4 = require("./t1"); -exports.f1 = _t1_4.default; -exports.f2 = _t1_4.default; -_t1_4.default; -_t1_4.default; +var t1_4 = require("./t1"); +exports.f1 = t1_4.default; +exports.f2 = t1_4.default; +t1_4.default; +t1_4.default; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt new file mode 100644 index 0000000000000..09cc7b3329578 --- /dev/null +++ b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt @@ -0,0 +1,164 @@ +tests/cases/compiler/f2.ts(5,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(6,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(7,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(7,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(8,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(10,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(11,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(15,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(16,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(17,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/compiler/f2.ts(20,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(21,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(22,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(23,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. +tests/cases/compiler/f2.ts(25,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/compiler/f2.ts(26,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(27,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/compiler/f2.ts(28,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(29,6): error TS2406: Invalid left-hand side in 'for...in' statement. +tests/cases/compiler/f2.ts(29,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(30,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(30,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(31,6): error TS2406: Invalid left-hand side in 'for...in' statement. +tests/cases/compiler/f2.ts(32,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(34,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/compiler/f2.ts(35,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(36,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/compiler/f2.ts(37,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(38,6): error TS2406: Invalid left-hand side in 'for...in' statement. +tests/cases/compiler/f2.ts(38,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(39,6): error TS2487: Invalid left-hand side in 'for...of' statement. +tests/cases/compiler/f2.ts(39,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(40,6): error TS2406: Invalid left-hand side in 'for...in' statement. +tests/cases/compiler/f2.ts(41,6): error TS2487: Invalid left-hand side in 'for...of' statement. + + +==== tests/cases/compiler/f1.ts (0 errors) ==== + export var x = 1; + +==== tests/cases/compiler/f2.ts (38 errors) ==== + import * as stuff from 'f1'; + + var n = 'baz'; + + stuff.x = 0; + ~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + stuff['x'] = 1; + ~~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + stuff.blah = 2; + ~~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + stuff[n] = 3; + ~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + + stuff.x++; + ~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + stuff['x']++; + ~~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + stuff['blah']++; + ~~~~~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + stuff[n]++; + ~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + + (stuff.x) = 0; + ~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + (stuff['x']) = 1; + ~~~~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + (stuff.blah) = 2; + ~~~~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + (stuff[n]) = 3; + ~~~~~~~~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + + (stuff.x)++; + ~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + (stuff['x'])++; + ~~~~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + (stuff['blah'])++; + ~~~~~~~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + (stuff[n])++; + ~~~~~~~~~~ +!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer. + + for (stuff.x in []) {} + ~~~~~~~ +!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + for (stuff.x of []) {} + ~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + for (stuff['x'] in []) {} + ~~~~~~~~~~ +!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + for (stuff['x'] of []) {} + ~~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + for (stuff.blah in []) {} + ~~~~~~~~~~ +!!! error TS2406: Invalid left-hand side in 'for...in' statement. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + for (stuff.blah of []) {} + ~~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + for (stuff[n] in []) {} + ~~~~~~~~ +!!! error TS2406: Invalid left-hand side in 'for...in' statement. + for (stuff[n] of []) {} + ~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + + for ((stuff.x) in []) {} + ~~~~~~~~~ +!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + for ((stuff.x) of []) {} + ~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + for ((stuff['x']) in []) {} + ~~~~~~~~~~~~ +!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + for ((stuff['x']) of []) {} + ~~~~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + for ((stuff.blah) in []) {} + ~~~~~~~~~~~~ +!!! error TS2406: Invalid left-hand side in 'for...in' statement. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + for ((stuff.blah) of []) {} + ~~~~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. + for ((stuff[n]) in []) {} + ~~~~~~~~~~ +!!! error TS2406: Invalid left-hand side in 'for...in' statement. + for ((stuff[n]) of []) {} + ~~~~~~~~~~ +!!! error TS2487: Invalid left-hand side in 'for...of' statement. + + + \ No newline at end of file diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js new file mode 100644 index 0000000000000..546b593fa77b7 --- /dev/null +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -0,0 +1,112 @@ +//// [tests/cases/compiler/externalModuleImmutableBindings.ts] //// + +//// [f1.ts] +export var x = 1; + +//// [f2.ts] +import * as stuff from 'f1'; + +var n = 'baz'; + +stuff.x = 0; +stuff['x'] = 1; +stuff.blah = 2; +stuff[n] = 3; + +stuff.x++; +stuff['x']++; +stuff['blah']++; +stuff[n]++; + +(stuff.x) = 0; +(stuff['x']) = 1; +(stuff.blah) = 2; +(stuff[n]) = 3; + +(stuff.x)++; +(stuff['x'])++; +(stuff['blah'])++; +(stuff[n])++; + +for (stuff.x in []) {} +for (stuff.x of []) {} +for (stuff['x'] in []) {} +for (stuff['x'] of []) {} +for (stuff.blah in []) {} +for (stuff.blah of []) {} +for (stuff[n] in []) {} +for (stuff[n] of []) {} + +for ((stuff.x) in []) {} +for ((stuff.x) of []) {} +for ((stuff['x']) in []) {} +for ((stuff['x']) of []) {} +for ((stuff.blah) in []) {} +for ((stuff.blah) of []) {} +for ((stuff[n]) in []) {} +for ((stuff[n]) of []) {} + + + + +//// [f1.js] +exports.x = 1; +//// [f2.js] +var stuff = require('f1'); +var n = 'baz'; +stuff.x = 0; +stuff['x'] = 1; +stuff.blah = 2; +stuff[n] = 3; +stuff.x++; +stuff['x']++; +stuff['blah']++; +stuff[n]++; +(stuff.x) = 0; +(stuff['x']) = 1; +(stuff.blah) = 2; +(stuff[n]) = 3; +(stuff.x)++; +(stuff['x'])++; +(stuff['blah'])++; +(stuff[n])++; +for (stuff.x in []) { +} +for (var _i = 0, _a = []; _i < _a.length; _i++) { + stuff.x = _a[_i]; +} +for (stuff['x'] in []) { +} +for (var _b = 0, _c = []; _b < _c.length; _b++) { + stuff['x'] = _c[_b]; +} +for (stuff.blah in []) { +} +for (var _d = 0, _e = []; _d < _e.length; _d++) { + stuff.blah = _e[_d]; +} +for (stuff[n] in []) { +} +for (var _f = 0, _g = []; _f < _g.length; _f++) { + stuff[n] = _g[_f]; +} +for ((stuff.x) in []) { +} +for (var _h = 0, _j = []; _h < _j.length; _h++) { + (stuff.x) = _j[_h]; +} +for ((stuff['x']) in []) { +} +for (var _k = 0, _l = []; _k < _l.length; _k++) { + (stuff['x']) = _l[_k]; +} +for ((stuff.blah) in []) { +} +for (var _m = 0, _o = []; _m < _o.length; _m++) { + (stuff.blah) = _o[_m]; +} +for ((stuff[n]) in []) { +} +for (var _p = 0, _q = []; _p < _q.length; _p++) { + (stuff[n]) = _q[_p]; +} diff --git a/tests/baselines/reference/giant.js b/tests/baselines/reference/giant.js index 9de46f76b1bb8..cc532ff43d955 100644 --- a/tests/baselines/reference/giant.js +++ b/tests/baselines/reference/giant.js @@ -754,7 +754,7 @@ define(["require", "exports"], function (require, exports) { return C; })(); var M; - (function (_M) { + (function (M_1) { var V; function F() { } @@ -844,10 +844,10 @@ define(["require", "exports"], function (require, exports) { ; ; })(M || (M = {})); - _M.eV; + M_1.eV; function eF() { } - _M.eF = eF; + M_1.eF = eF; ; var eC = (function () { function eC() { @@ -902,7 +902,7 @@ define(["require", "exports"], function (require, exports) { }); return eC; })(); - _M.eC = eC; + M_1.eC = eC; var eM; (function (eM) { var V; @@ -934,7 +934,7 @@ define(["require", "exports"], function (require, exports) { ; ; ; - })(eM = _M.eM || (_M.eM = {})); + })(eM = M_1.eM || (M_1.eM = {})); ; })(M || (M = {})); exports.eV; @@ -997,7 +997,7 @@ define(["require", "exports"], function (require, exports) { })(); exports.eC = eC; var eM; - (function (_eM) { + (function (eM_1) { var V; function F() { } @@ -1087,10 +1087,10 @@ define(["require", "exports"], function (require, exports) { ; ; })(M || (M = {})); - _eM.eV; + eM_1.eV; function eF() { } - _eM.eF = eF; + eM_1.eF = eF; ; var eC = (function () { function eC() { @@ -1145,7 +1145,7 @@ define(["require", "exports"], function (require, exports) { }); return eC; })(); - _eM.eC = eC; + eM_1.eC = eC; var eM; (function (eM) { var V; @@ -1177,7 +1177,7 @@ define(["require", "exports"], function (require, exports) { ; ; ; - })(eM = _eM.eM || (_eM.eM = {})); + })(eM = eM_1.eM || (eM_1.eM = {})); ; })(eM = exports.eM || (exports.eM = {})); ; diff --git a/tests/baselines/reference/importAndVariableDeclarationConflict1.js b/tests/baselines/reference/importAndVariableDeclarationConflict1.js index 78484b2c295a1..b812deec0ef45 100644 --- a/tests/baselines/reference/importAndVariableDeclarationConflict1.js +++ b/tests/baselines/reference/importAndVariableDeclarationConflict1.js @@ -9,8 +9,8 @@ var x = ''; //// [importAndVariableDeclarationConflict1.js] var m; -(function (_m) { - _m.m = ''; +(function (m_1) { + m_1.m = ''; })(m || (m = {})); var x = m.m; var x = ''; diff --git a/tests/baselines/reference/importAndVariableDeclarationConflict2.js b/tests/baselines/reference/importAndVariableDeclarationConflict2.js index bea146fe9bf0e..6d188b373b74a 100644 --- a/tests/baselines/reference/importAndVariableDeclarationConflict2.js +++ b/tests/baselines/reference/importAndVariableDeclarationConflict2.js @@ -13,8 +13,8 @@ class C { //// [importAndVariableDeclarationConflict2.js] var m; -(function (_m) { - _m.m = ''; +(function (m_1) { + m_1.m = ''; })(m || (m = {})); var x = m.m; var C = (function () { diff --git a/tests/baselines/reference/importAndVariableDeclarationConflict3.js b/tests/baselines/reference/importAndVariableDeclarationConflict3.js index 426d44bab2173..887aec16c59b0 100644 --- a/tests/baselines/reference/importAndVariableDeclarationConflict3.js +++ b/tests/baselines/reference/importAndVariableDeclarationConflict3.js @@ -9,8 +9,8 @@ import x = m.m; //// [importAndVariableDeclarationConflict3.js] var m; -(function (_m) { - _m.m = ''; +(function (m_1) { + m_1.m = ''; })(m || (m = {})); var x = m.m; var x = m.m; diff --git a/tests/baselines/reference/importAndVariableDeclarationConflict4.js b/tests/baselines/reference/importAndVariableDeclarationConflict4.js index 2adb78594a23a..4949df6366a42 100644 --- a/tests/baselines/reference/importAndVariableDeclarationConflict4.js +++ b/tests/baselines/reference/importAndVariableDeclarationConflict4.js @@ -9,8 +9,8 @@ import x = m.m; //// [importAndVariableDeclarationConflict4.js] var m; -(function (_m) { - _m.m = ''; +(function (m_1) { + m_1.m = ''; })(m || (m = {})); var x = ''; var x = m.m; diff --git a/tests/baselines/reference/importedModuleAddToGlobal.js b/tests/baselines/reference/importedModuleAddToGlobal.js index 6685bec69e374..a848ccb504bde 100644 --- a/tests/baselines/reference/importedModuleAddToGlobal.js +++ b/tests/baselines/reference/importedModuleAddToGlobal.js @@ -18,13 +18,13 @@ module C { //// [importedModuleAddToGlobal.js] var B; -(function (_B) { +(function (B_1) { var B = (function () { function B() { } return B; })(); - _B.B = B; + B_1.B = B; })(B || (B = {})); var C; (function (C) { diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.js b/tests/baselines/reference/initializePropertiesWithRenamedLet.js index 902a23f5886e0..1d34d7c13fc86 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.js +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.js @@ -19,28 +19,28 @@ if (true) { //// [initializePropertiesWithRenamedLet.js] var x0; if (true) { - var _x0; + var x0_1; var obj1 = { - x0: _x0 + x0: x0_1 }; var obj2 = { - x0: _x0 + x0: x0_1 }; } var x, y, z; if (true) { - var _x = ({ + var x_1 = ({ x: 0 }).x; - var _y = ({ + var y_1 = ({ y: 0 }).y; - var _z; + var z_1; (_a = { z: 0 - }, _z = _a.z, _a); + }, z_1 = _a.z, _a); (_b = { z: 0 - }, _z = _b.z, _b); + }, z_1 = _b.z, _b); } var _a, _b; diff --git a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js index d357922f5bce6..8604ec493a2ab 100644 --- a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js +++ b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js @@ -72,67 +72,67 @@ module schema { //// [isDeclarationVisibleNodeKinds.js] // Function types var schema; -(function (_schema) { +(function (schema_1) { function createValidator1(schema) { return undefined; } - _schema.createValidator1 = createValidator1; + schema_1.createValidator1 = createValidator1; })(schema || (schema = {})); // Constructor types var schema; -(function (_schema_1) { +(function (schema_2) { function createValidator2(schema) { return undefined; } - _schema_1.createValidator2 = createValidator2; + schema_2.createValidator2 = createValidator2; })(schema || (schema = {})); // union types var schema; -(function (_schema_2) { +(function (schema_3) { function createValidator3(schema) { return undefined; } - _schema_2.createValidator3 = createValidator3; + schema_3.createValidator3 = createValidator3; })(schema || (schema = {})); // Array types var schema; -(function (_schema_3) { +(function (schema_4) { function createValidator4(schema) { return undefined; } - _schema_3.createValidator4 = createValidator4; + schema_4.createValidator4 = createValidator4; })(schema || (schema = {})); // TypeLiterals var schema; -(function (_schema_4) { +(function (schema_5) { function createValidator5(schema) { return undefined; } - _schema_4.createValidator5 = createValidator5; + schema_5.createValidator5 = createValidator5; })(schema || (schema = {})); // Tuple types var schema; -(function (_schema_5) { +(function (schema_6) { function createValidator6(schema) { return undefined; } - _schema_5.createValidator6 = createValidator6; + schema_6.createValidator6 = createValidator6; })(schema || (schema = {})); // Paren Types var schema; -(function (_schema_6) { +(function (schema_7) { function createValidator7(schema) { return undefined; } - _schema_6.createValidator7 = createValidator7; + schema_7.createValidator7 = createValidator7; })(schema || (schema = {})); // Type reference var schema; -(function (_schema_7) { +(function (schema_8) { function createValidator8(schema) { return undefined; } - _schema_7.createValidator8 = createValidator8; + schema_8.createValidator8 = createValidator8; })(schema || (schema = {})); var schema; (function (schema) { diff --git a/tests/baselines/reference/letConstInCaseClauses.js b/tests/baselines/reference/letConstInCaseClauses.js index 94840a11a2c74..33650dcaf4caf 100644 --- a/tests/baselines/reference/letConstInCaseClauses.js +++ b/tests/baselines/reference/letConstInCaseClauses.js @@ -34,28 +34,28 @@ var y = 20; var x = 10; var y = 20; { - var _x = 1; - var _y = 2; - console.log(_x); - switch (_x) { + var x_1 = 1; + var y_1 = 2; + console.log(x_1); + switch (x_1) { case 10: - var _x_1 = 20; + var x_2 = 20; } - switch (_y) { + switch (y_1) { case 10: - var _y_1 = 20; + var y_2 = 20; } } { - var _x_2 = 1; - var _y_2 = 2; - console.log(_x_2); - switch (_x_2) { + var x_3 = 1; + var y_3 = 2; + console.log(x_3); + switch (x_3) { case 10: - var _x_3 = 20; + var x_4 = 20; } - switch (_y_2) { + switch (y_3) { case 10: - var _y_3 = 20; + var y_4 = 20; } } diff --git a/tests/baselines/reference/letConstMatchingParameterNames.js b/tests/baselines/reference/letConstMatchingParameterNames.js index a11405b9f83c7..392f0e7ae943e 100644 --- a/tests/baselines/reference/letConstMatchingParameterNames.js +++ b/tests/baselines/reference/letConstMatchingParameterNames.js @@ -19,8 +19,8 @@ function a() { var parent = true; var parent2 = true; function a() { - var _parent = 1; - var _parent2 = 2; + var parent = 1; + var parent2 = 2; function b(parent, parent2) { use(parent); use(parent2); diff --git a/tests/baselines/reference/letDeclarations-es5.js b/tests/baselines/reference/letDeclarations-es5.js index 5246e91edfb76..1d4eb4afcbfef 100644 --- a/tests/baselines/reference/letDeclarations-es5.js +++ b/tests/baselines/reference/letDeclarations-es5.js @@ -20,7 +20,7 @@ var l3, l4, l5, l6; var l7 = false; var l8 = 23; var l9 = 0, l10 = "", l11 = null; -for (var _l11 in {}) { +for (var l11_1 in {}) { } for (var l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/letKeepNamesOfTopLevelItems.js b/tests/baselines/reference/letKeepNamesOfTopLevelItems.js new file mode 100644 index 0000000000000..96fd31ae536dd --- /dev/null +++ b/tests/baselines/reference/letKeepNamesOfTopLevelItems.js @@ -0,0 +1,19 @@ +//// [letKeepNamesOfTopLevelItems.ts] +let x; +function foo() { + let x; +} + +module A { + let x; +} + +//// [letKeepNamesOfTopLevelItems.js] +var x; +function foo() { + var x; +} +var A; +(function (A) { + var x; +})(A || (A = {})); diff --git a/tests/baselines/reference/letKeepNamesOfTopLevelItems.types b/tests/baselines/reference/letKeepNamesOfTopLevelItems.types new file mode 100644 index 0000000000000..952be1512a984 --- /dev/null +++ b/tests/baselines/reference/letKeepNamesOfTopLevelItems.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/letKeepNamesOfTopLevelItems.ts === +let x; +>x : any + +function foo() { +>foo : () => void + + let x; +>x : any +} + +module A { +>A : typeof A + + let x; +>x : any +} diff --git a/tests/baselines/reference/letShadowedByNameInNestedScope.errors.txt b/tests/baselines/reference/letShadowedByNameInNestedScope.errors.txt new file mode 100644 index 0000000000000..b47e194f93eb1 --- /dev/null +++ b/tests/baselines/reference/letShadowedByNameInNestedScope.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/letShadowedByNameInNestedScope.ts(6,9): error TS2304: Cannot find name 'console'. + + +==== tests/cases/compiler/letShadowedByNameInNestedScope.ts (1 errors) ==== + var x; + function foo() { + let x = 0; + (function () { + var _x = 1; + console.log(x); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. + })(); + } \ No newline at end of file diff --git a/tests/baselines/reference/letShadowedByNameInNestedScope.js b/tests/baselines/reference/letShadowedByNameInNestedScope.js new file mode 100644 index 0000000000000..648fe0b8e94df --- /dev/null +++ b/tests/baselines/reference/letShadowedByNameInNestedScope.js @@ -0,0 +1,19 @@ +//// [letShadowedByNameInNestedScope.ts] +var x; +function foo() { + let x = 0; + (function () { + var _x = 1; + console.log(x); + })(); +} + +//// [letShadowedByNameInNestedScope.js] +var x; +function foo() { + var x = 0; + (function () { + var _x = 1; + console.log(x); + })(); +} diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen.js index 88b949dd92023..d5cda7c91099d 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen.js @@ -19,10 +19,10 @@ export module X { var X; (function (X) { var Y; - (function (_Y) { + (function (Y_1) { var A = (function () { function A(Y) { - new _Y.B(); + new Y_1.B(); } return A; })(); diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen2.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen2.js index 457bd12b8f082..06a590194f5f5 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen2.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen2.js @@ -22,11 +22,11 @@ var my; })(data = my.data || (my.data = {})); })(my || (my = {})); var my; -(function (_my) { +(function (my_1) { var data; - (function (_data) { + (function (data_1) { function data(my) { - _data.foo.buz(); + data_1.foo.buz(); } - })(data = _my.data || (_my.data = {})); + })(data = my_1.data || (my_1.data = {})); })(my || (my = {})); diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen3.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen3.js index 0618346dd75ea..43c55ed8291af 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen3.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen3.js @@ -19,14 +19,14 @@ var my; })(data = my.data || (my.data = {})); })(my || (my = {})); var my; -(function (_my) { +(function (my_1) { var data; - (function (_data) { + (function (data_1) { var foo; - (function (_foo) { + (function (foo_1) { function data(my, foo) { - _data.buz(); + data_1.buz(); } - })(foo = _data.foo || (_data.foo = {})); - })(data = _my.data || (_my.data = {})); + })(foo = data_1.foo || (data_1.foo = {})); + })(data = my_1.data || (my_1.data = {})); })(my || (my = {})); diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen4.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen4.js index 2463c9cae906a..af7f5bacef73b 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen4.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen4.js @@ -20,7 +20,7 @@ module superContain { var superContain; (function (superContain) { var contain; - (function (_contain) { + (function (contain_1) { var my; (function (my) { var buz; @@ -32,19 +32,19 @@ var superContain; data.foo = foo; })(data = buz.data || (buz.data = {})); })(buz = my.buz || (my.buz = {})); - })(my = _contain.my || (_contain.my = {})); + })(my = contain_1.my || (contain_1.my = {})); var my; - (function (_my) { + (function (my_1) { var buz; - (function (_buz) { + (function (buz_1) { var data; - (function (_data) { + (function (data_1) { function bar(contain, my, buz, data) { - _data.foo(); + data_1.foo(); } - _data.bar = bar; - })(data = _buz.data || (_buz.data = {})); - })(buz = _my.buz || (_my.buz = {})); - })(my = _contain.my || (_contain.my = {})); + data_1.bar = bar; + })(data = buz_1.data || (buz_1.data = {})); + })(buz = my_1.buz || (my_1.buz = {})); + })(my = contain_1.my || (contain_1.my = {})); })(contain = superContain.contain || (superContain.contain = {})); })(superContain || (superContain = {})); diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen5.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen5.js index 2c8e0bb79e4fb..4bbad2e567868 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen5.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen5.js @@ -20,7 +20,7 @@ module M.buz.plop { //// [mergedModuleDeclarationCodeGen5.js] var M; -(function (_M) { +(function (M_1) { var buz; (function (buz) { var plop; @@ -32,14 +32,14 @@ var M; } plop.M = M; })(plop = buz.plop || (buz.plop = {})); - })(buz = _M.buz || (_M.buz = {})); + })(buz = M_1.buz || (M_1.buz = {})); })(M || (M = {})); var M; (function (M) { var buz; - (function (_buz) { + (function (buz_1) { var plop; - (function (_plop) { + (function (plop_1) { function gunk() { } function buz() { @@ -49,17 +49,17 @@ var M; } return fudge; })(); - _plop.fudge = fudge; + plop_1.fudge = fudge; (function (plop) { - })(_plop.plop || (_plop.plop = {})); - var plop = _plop.plop; + })(plop_1.plop || (plop_1.plop = {})); + var plop = plop_1.plop; // Emit these references as follows var v1 = gunk; // gunk var v2 = buz; // buz - _plop.v3 = _plop.doom; // _plop.doom - _plop.v4 = _plop.M; // _plop.M - _plop.v5 = fudge; // fudge - _plop.v6 = plop; // plop - })(plop = _buz.plop || (_buz.plop = {})); + plop_1.v3 = plop_1.doom; // _plop.doom + plop_1.v4 = plop_1.M; // _plop.M + plop_1.v5 = fudge; // fudge + plop_1.v6 = plop; // plop + })(plop = buz_1.plop || (buz_1.plop = {})); })(buz = M.buz || (M.buz = {})); })(M || (M = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js index 983dc004acf31..f9a90fd515155 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js @@ -25,11 +25,11 @@ var Z; var A; (function (A) { var M; - (function (_M) { + (function (M_1) { var M = Z.M; function bar() { } - _M.bar = bar; + M_1.bar = bar; M.bar(); // Should call Z.M.bar })(M = A.M || (A.M = {})); })(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js index c11b36f643a30..efdcebe84e96d 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js @@ -30,11 +30,11 @@ var Z; var A; (function (A) { var M; - (function (_M) { + (function (M_1) { var M = Z.M; function bar() { } - _M.bar = bar; + M_1.bar = bar; M.bar(); // Should call Z.M.bar })(M = A.M || (A.M = {})); })(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js index c61f3d4dd9d73..e9cd456f3f3f8 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js @@ -26,11 +26,11 @@ var Z; var A; (function (A) { var M; - (function (_M) { + (function (M_1) { var M = Z.M; function bar() { } - _M.bar = bar; + M_1.bar = bar; M.bar(); // Should call Z.M.bar })(M = A.M || (A.M = {})); })(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js index 0bc314ccc0706..72aa36022634d 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js @@ -30,10 +30,10 @@ var Z; var A; (function (A) { var M; - (function (_M) { + (function (M_1) { function bar() { } - _M.bar = bar; + M_1.bar = bar; M.bar(); // Should call Z.M.bar })(M = A.M || (A.M = {})); })(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js index 4ba0a33c29a0c..fbad13359b8eb 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js @@ -24,9 +24,9 @@ var Z; var A; (function (A) { var M; - (function (_M) { + (function (M_1) { function bar() { } - _M.bar = bar; + M_1.bar = bar; })(M = A.M || (A.M = {})); })(A || (A = {})); diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js index 5161f72d5f023..cab0d35aa5a20 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js @@ -66,7 +66,7 @@ var __extends = this.__extends || function (d, b) { d.prototype = new __(); }; var A; -(function (_A) { +(function (A_1) { var A = (function () { function A() { } diff --git a/tests/baselines/reference/nameCollision.js b/tests/baselines/reference/nameCollision.js index fe7bb3a891975..0e559b7091cc8 100644 --- a/tests/baselines/reference/nameCollision.js +++ b/tests/baselines/reference/nameCollision.js @@ -48,7 +48,7 @@ module D { //// [nameCollision.js] var A; -(function (_A_1) { +(function (A_1) { // these 2 statements force an underscore before the 'A' // in the generated function call. var A = 12; @@ -59,7 +59,7 @@ var B; var A = 12; })(B || (B = {})); var B; -(function (_B) { +(function (B_1) { // re-opened module with colliding name // this should add an underscore. var B = (function () { @@ -69,29 +69,29 @@ var B; })(); })(B || (B = {})); var X; -(function (_X) { +(function (X_1) { var X = 13; var Y; - (function (_Y) { + (function (Y_1) { var Y = 13; var Z; - (function (_Z) { + (function (Z_1) { var X = 12; var Y = 12; var Z = 12; - })(Z = _Y.Z || (_Y.Z = {})); - })(Y = _X.Y || (_X.Y = {})); + })(Z = Y_1.Z || (Y_1.Z = {})); + })(Y = X_1.Y || (X_1.Y = {})); })(X || (X = {})); var Y; -(function (_Y_1) { +(function (Y_2) { var Y; - (function (_Y_2) { + (function (Y_3) { (function (Y) { Y[Y["Red"] = 0] = "Red"; Y[Y["Blue"] = 1] = "Blue"; - })(_Y_2.Y || (_Y_2.Y = {})); - var Y = _Y_2.Y; - })(Y = _Y_1.Y || (_Y_1.Y = {})); + })(Y_3.Y || (Y_3.Y = {})); + var Y = Y_3.Y; + })(Y = Y_2.Y || (Y_2.Y = {})); })(Y || (Y = {})); // no collision, since interface doesn't // generate code. diff --git a/tests/baselines/reference/noDefaultLib.errors.txt b/tests/baselines/reference/noDefaultLib.errors.txt index b8f42ba7c331b..c73f3e0b9487e 100644 --- a/tests/baselines/reference/noDefaultLib.errors.txt +++ b/tests/baselines/reference/noDefaultLib.errors.txt @@ -1,9 +1,19 @@ +error TS2318: Cannot find global type 'TypedPropertyDescriptor'. +error TS2318: Cannot find global type 'PropertyDecorator'. +error TS2318: Cannot find global type 'ParameterDecorator'. +error TS2318: Cannot find global type 'MethodDecorator'. error TS2318: Cannot find global type 'IArguments'. +error TS2318: Cannot find global type 'ClassDecorator'. error TS2318: Cannot find global type 'Boolean'. tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s). +!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'. +!!! error TS2318: Cannot find global type 'PropertyDecorator'. +!!! error TS2318: Cannot find global type 'ParameterDecorator'. +!!! error TS2318: Cannot find global type 'MethodDecorator'. !!! error TS2318: Cannot find global type 'IArguments'. +!!! error TS2318: Cannot find global type 'ClassDecorator'. !!! error TS2318: Cannot find global type 'Boolean'. ==== tests/cases/compiler/noDefaultLib.ts (1 errors) ==== /// diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.js b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.js index d0ced9921469c..86e84ced58f0f 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.js +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.js @@ -39,8 +39,8 @@ var Bugs; } var result = message.replace(/\{(\d+)\}/g, function (match) { var rest = []; - for (var _a = 1; _a < arguments.length; _a++) { - rest[_a - 1] = arguments[_a]; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; } var index = rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; diff --git a/tests/baselines/reference/parser509698.errors.txt b/tests/baselines/reference/parser509698.errors.txt index 85485dd65012a..3dd70275e5c7a 100644 --- a/tests/baselines/reference/parser509698.errors.txt +++ b/tests/baselines/reference/parser509698.errors.txt @@ -1,21 +1,31 @@ +error TS2318: Cannot find global type 'Number'. +error TS2318: Cannot find global type 'TypedPropertyDescriptor'. +error TS2318: Cannot find global type 'Object'. +error TS2318: Cannot find global type 'Array'. +error TS2318: Cannot find global type 'ClassDecorator'. error TS2318: Cannot find global type 'String'. error TS2318: Cannot find global type 'RegExp'. -error TS2318: Cannot find global type 'Object'. -error TS2318: Cannot find global type 'Number'. -error TS2318: Cannot find global type 'IArguments'. +error TS2318: Cannot find global type 'PropertyDecorator'. +error TS2318: Cannot find global type 'ParameterDecorator'. error TS2318: Cannot find global type 'Function'. error TS2318: Cannot find global type 'Boolean'. -error TS2318: Cannot find global type 'Array'. +error TS2318: Cannot find global type 'MethodDecorator'. +error TS2318: Cannot find global type 'IArguments'. +!!! error TS2318: Cannot find global type 'Number'. +!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'. +!!! error TS2318: Cannot find global type 'Object'. +!!! error TS2318: Cannot find global type 'Array'. +!!! error TS2318: Cannot find global type 'ClassDecorator'. !!! error TS2318: Cannot find global type 'String'. !!! error TS2318: Cannot find global type 'RegExp'. -!!! error TS2318: Cannot find global type 'Object'. -!!! error TS2318: Cannot find global type 'Number'. -!!! error TS2318: Cannot find global type 'IArguments'. +!!! error TS2318: Cannot find global type 'PropertyDecorator'. +!!! error TS2318: Cannot find global type 'ParameterDecorator'. !!! error TS2318: Cannot find global type 'Function'. !!! error TS2318: Cannot find global type 'Boolean'. -!!! error TS2318: Cannot find global type 'Array'. +!!! error TS2318: Cannot find global type 'MethodDecorator'. +!!! error TS2318: Cannot find global type 'IArguments'. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ==== ///