diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3535aaffb27..304777e0401 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -123,7 +123,7 @@ module ts { case SyntaxKind.ExportDeclaration: return "__export"; case SyntaxKind.ExportAssignment: - return "default"; + return (node).isExportEquals ? "export=" : "default"; case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: return node.flags & NodeFlags.Default ? "default" : undefined; @@ -188,14 +188,6 @@ module ts { return symbol; } - function isAmbientContext(node: Node): boolean { - while (node) { - if (node.flags & NodeFlags.Ambient) return true; - node = node.parent; - } - return false; - } - function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) { let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export; if (symbolKind & SymbolFlags.Alias) { @@ -218,7 +210,7 @@ module ts { // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || isAmbientContext(container)) { + if (hasExportModifier || container.flags & NodeFlags.ExportContext) { let exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | (symbolKind & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | (symbolKind & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); @@ -311,7 +303,39 @@ module ts { bindChildren(node, symbolKind, isBlockScopeContainer); } + function isAmbientContext(node: Node): boolean { + while (node) { + if (node.flags & NodeFlags.Ambient) return true; + node = node.parent; + } + return false; + } + + function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { + var body = node.kind === SyntaxKind.SourceFile ? node : (node).body; + if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) { + for (let stat of (body).statements) { + if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) { + return true; + } + } + } + return false; + } + + function setExportContextFlag(node: ModuleDeclaration | SourceFile) { + // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular + // declarations with export modifiers) is an export context in which declarations are implicitly exported. + if (isAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= NodeFlags.ExportContext; + } + else { + node.flags &= ~NodeFlags.ExportContext; + } + } + function bindModuleDeclaration(node: ModuleDeclaration) { + setExportContextFlag(node); if (node.name.kind === SyntaxKind.StringLiteral) { bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); } @@ -508,15 +532,16 @@ module ts { case SyntaxKind.ExportAssignment: if ((node).expression && (node).expression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } else { // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } bindChildren(node, 0, /*isBlockScopeContainer*/ false); break; case SyntaxKind.SourceFile: + setExportContextFlag(node); if (isExternalModule(node)) { bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"', /*isBlockScopeContainer*/ true); break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 73bf603c682..e2d668b8055 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -118,11 +118,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[] = []; @@ -292,7 +298,6 @@ module ts { if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & SymbolFlags.Alias) { let target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors @@ -301,7 +306,6 @@ module ts { } } } - // return undefined if we can't find a symbol. } @@ -329,6 +333,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) @@ -342,7 +347,7 @@ module ts { if (!isExternalModule(location)) break; case SyntaxKind.ModuleDeclaration: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.ModuleMember)) { - if (!(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) { + if (result.flags & meaning || !(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) { break loop; } result = undefined; @@ -394,7 +399,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)) { @@ -426,6 +431,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; @@ -514,29 +541,13 @@ module ts { return false; } - // An alias symbol is created by one of the following declarations: - // import = ... - // import from ... - // import * as from ... - // import { x as } from ... - // export { x as } from ... - // export default ... - function isAliasSymbolDeclaration(node: Node): boolean { - return node.kind === SyntaxKind.ImportEqualsDeclaration || - node.kind === SyntaxKind.ImportClause && !!(node).name || - node.kind === SyntaxKind.NamespaceImport || - node.kind === SyntaxKind.ImportSpecifier || - node.kind === SyntaxKind.ExportSpecifier || - node.kind === SyntaxKind.ExportAssignment; - } - function getAnyImportSyntax(node: Node): AnyImportSyntax { if (isAliasSymbolDeclaration(node)) { if (node.kind === SyntaxKind.ImportEqualsDeclaration) { return node; } - while (node.kind !== SyntaxKind.ImportDeclaration) { + while (node && node.kind !== SyntaxKind.ImportDeclaration) { node = node.parent; } return node; @@ -549,9 +560,7 @@ module ts { function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol { if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { - let moduleSymbol = resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node)); - let exportAssignmentSymbol = moduleSymbol && getResolvedExportAssignmentSymbol(moduleSymbol); - return exportAssignmentSymbol || moduleSymbol; + return resolveExternalModuleSymbol(resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); } @@ -559,29 +568,92 @@ module ts { function getTargetOfImportClause(node: ImportClause): Symbol { let moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - let exportAssignmentSymbol = getResolvedExportAssignmentSymbol(moduleSymbol); - if (!exportAssignmentSymbol) { - error(node.name, Diagnostics.External_module_0_has_no_default_export_or_export_assignment, symbolToString(moduleSymbol)); + let exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]); + if (!exportDefaultSymbol) { + error(node.name, Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol)); } - return exportAssignmentSymbol; + return exportDefaultSymbol; } } function getTargetOfNamespaceImport(node: NamespaceImport): Symbol { - return resolveExternalModuleName(node, (node.parent.parent).moduleSpecifier); + var moduleSpecifier = (node.parent.parent).moduleSpecifier; + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + } + + function getMemberOfModuleVariable(moduleSymbol: Symbol, name: string): Symbol { + if (moduleSymbol.flags & SymbolFlags.Variable) { + let typeAnnotation = (moduleSymbol.valueDeclaration).type; + if (typeAnnotation) { + return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name); + } + } + } + + // This function creates a synthetic symbol that combines the value side of one symbol with the + // type/namespace side of another symbol. Consider this example: + // + // declare module graphics { + // interface Point { + // x: number; + // y: number; + // } + // } + // declare var graphics: { + // Point: new (x: number, y: number) => graphics.Point; + // } + // declare module "graphics" { + // export = graphics; + // } + // + // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' + // property with the type/namespace side interface 'Point'. + function combineValueAndTypeSymbols(valueSymbol: Symbol, typeSymbol: Symbol): Symbol { + if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) { + return valueSymbol; + } + let result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name); + result.declarations = concatenate(valueSymbol.declarations, typeSymbol.declarations); + result.parent = valueSymbol.parent || typeSymbol.parent; + if (valueSymbol.valueDeclaration) result.valueDeclaration = valueSymbol.valueDeclaration; + if (typeSymbol.members) result.members = typeSymbol.members; + if (valueSymbol.exports) result.exports = valueSymbol.exports; + return result; + } + + function getExportOfModule(symbol: Symbol, name: string): Symbol { + if (symbol.flags & SymbolFlags.Module) { + let exports = getExportsOfSymbol(symbol); + if (hasProperty(exports, name)) { + return resolveSymbol(exports[name]); + } + } + } + + function getPropertyOfVariable(symbol: Symbol, name: string): Symbol { + if (symbol.flags & SymbolFlags.Variable) { + var typeAnnotation = (symbol.valueDeclaration).type; + if (typeAnnotation) { + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + } + } } function getExternalModuleMember(node: ImportDeclaration | ExportDeclaration, specifier: ImportOrExportSpecifier): Symbol { let moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol) { + let targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + if (targetSymbol) { let name = specifier.propertyName || specifier.name; if (name.text) { - let symbol = getSymbol(getExportsOfSymbol(moduleSymbol), name.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); + let symbolFromModule = getExportOfModule(targetSymbol, name.text); + let symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); + let symbol = symbolFromModule && symbolFromVariable ? + combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : + symbolFromModule || symbolFromVariable; if (!symbol) { error(name, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), declarationNameToString(name)); - return; } - return symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace) ? symbol : resolveAlias(symbol); + return symbol; } } } @@ -600,7 +672,7 @@ module ts { return node.expression && resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); } - function getTargetOfImportDeclaration(node: Declaration): Symbol { + function getTargetOfAliasDeclaration(node: Declaration): Symbol { switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: return getTargetOfImportEqualsDeclaration(node); @@ -617,13 +689,17 @@ module ts { } } + function resolveSymbol(symbol: Symbol): Symbol { + return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol; + } + function resolveAlias(symbol: Symbol): Symbol { Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here."); let links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; let node = getDeclarationOfAliasSymbol(symbol); - let target = getTargetOfImportDeclaration(node); + let target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -754,7 +830,6 @@ module ts { return symbol; } } - let sourceFile: SourceFile; while (true) { let fileName = normalizePath(combinePaths(searchPath, moduleName)); @@ -762,12 +837,10 @@ module ts { if (sourceFile || isRelative) { break; } - let parentPath = getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } - searchPath = parentPath; } if (sourceFile) { @@ -780,25 +853,30 @@ module ts { error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName); } - function getExportAssignmentSymbol(moduleSymbol: Symbol): Symbol { - return moduleSymbol.exports["default"]; + // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, + // and an external module with no 'export =' declaration resolves to the module itself. + function resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol { + return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; } - function getResolvedExportAssignmentSymbol(moduleSymbol: Symbol): Symbol { - let symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) { - return symbol; - } - if (symbol.flags & SymbolFlags.Alias) { - return resolveAlias(symbol); - } + // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' + // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may + // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). + function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression): Symbol { + let symbol = resolveExternalModuleSymbol(moduleSymbol); + if (symbol && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { + error(moduleReferenceExpression, Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + symbol = undefined; } + return symbol; + } + + function getExportAssignmentSymbol(moduleSymbol: Symbol): Symbol { + return moduleSymbol.exports["export="]; } function getExportsOfSymbol(symbol: Symbol): SymbolTable { - // TODO (drosen): Why do we not use getExportsOfModule for exteral modules as weel? - return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol: Symbol): SymbolTable { @@ -815,15 +893,6 @@ module ts { } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { - if (languageVersion < ScriptTarget.ES6) { - // A default export hides all other exports in CommonJS and AMD modules - let defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - return { - "default": defaultSymbol - }; - } - } let result: SymbolTable; let visitedSymbols: Symbol[] = []; visit(moduleSymbol); @@ -832,7 +901,7 @@ module ts { // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. function visit(symbol: Symbol) { - if (!contains(visitedSymbols, symbol)) { + if (symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol)) { visitedSymbols.push(symbol); if (symbol !== moduleSymbol) { if (!result) { @@ -843,9 +912,9 @@ module ts { // All export * declarations are collected in an __export symbol by the binder let exportStars = symbol.exports["__export"]; if (exportStars) { - forEach(exportStars.declarations, node => { + for (let node of exportStars.declarations) { visit(resolveExternalModuleName(node, (node).moduleSpecifier)); - }); + } } } } @@ -2925,17 +2994,25 @@ module ts { return result; } + function symbolsToArray(symbols: SymbolTable): Symbol[] { + let result: Symbol[] = []; + for (let id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + function getExportsOfImportDeclaration(node: ImportDeclaration): Symbol[] { if (!node.moduleSpecifier) { return emptyArray; } - let module = resolveExternalModuleName(node, node.moduleSpecifier); - if (!module || !module.exports) { + if (!module) { return emptyArray; } - - return mapToArray(getExportsOfModule(module)) + return symbolsToArray(getExportsOfModule(module)); } function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { @@ -4511,7 +4588,7 @@ module ts { * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ - function isTupleType(type: Type) : boolean { + function isTupleType(type: Type): boolean { return (type.flags & TypeFlags.Tuple) && !!(type).elementTypes; } @@ -7650,7 +7727,7 @@ module ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -7951,7 +8028,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); @@ -8053,7 +8130,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); } @@ -8192,6 +8269,10 @@ module ts { checkFunctionLikeDeclaration(node); } + function checkMissingDeclaration(node: Node) { + checkDecorators(node); + } + function checkTypeReference(node: TypeReferenceNode) { // Grammar checking checkGrammarTypeArguments(node, node.typeArguments); @@ -8583,6 +8664,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) || @@ -8597,6 +8732,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. @@ -8879,6 +9015,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. @@ -8951,7 +9088,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); } @@ -9582,7 +9719,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); @@ -9677,7 +9814,7 @@ module ts { if (derived) { let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { + if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { // either base or derived property is private - not override, skip it continue; } @@ -9787,7 +9924,7 @@ module ts { function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking - checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { @@ -9808,7 +9945,7 @@ module ts { // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { forEach(type.baseTypes, baseType => { - checkTypeAssignableTo(type, baseType, node.name , Diagnostics.Interface_0_incorrectly_extends_interface_1); + checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); }); checkIndexConstraints(type); } @@ -9824,7 +9961,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); @@ -10006,7 +10143,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); @@ -10072,7 +10209,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); } @@ -10167,7 +10304,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)) { @@ -10189,7 +10326,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) { @@ -10220,12 +10357,26 @@ 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)) { if (node.exportClause) { + // export { x, y } + // export { x, y } from "foo" forEach(node.exportClause.elements, checkExportSpecifier); + + let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; + if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { + error(node, Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module); + } + } + else { + // export * from "foo" + let moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (moduleSymbol && moduleSymbol.exports["export="]) { + error(node.moduleSpecifier, Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); + } } } } @@ -10244,7 +10395,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) { @@ -10281,39 +10432,22 @@ module ts { } function hasExportedMembers(moduleSymbol: Symbol) { - let declarations = moduleSymbol.declarations; - for (let current of declarations) { - let statements = getModuleStatements(current); - for (let node of statements) { - if (node.kind === SyntaxKind.ExportDeclaration) { - let exportClause = (node).exportClause; - if (!exportClause) { - return true; - } - let specifiers = exportClause.elements; - for (let specifier of specifiers) { - if (!(specifier.propertyName && specifier.name && specifier.name.text === "default")) { - return true; - } - } - } - else if (node.kind !== SyntaxKind.ExportAssignment && node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { - return true; - } + for (var id in moduleSymbol.exports) { + if (id !== "export=") { + return true; } } + return false; } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { let moduleSymbol = getSymbolOfNode(node); let links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - let defaultSymbol = getExportAssignmentSymbol(moduleSymbol); - if (defaultSymbol) { - if (languageVersion < ScriptTarget.ES6 && hasExportedMembers(moduleSymbol)) { - let declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration; - error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } + let exportEqualsSymbol = moduleSymbol.exports["export="]; + if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { + let declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; + error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } links.exportsChecked = true; } @@ -10422,6 +10556,8 @@ module ts { case SyntaxKind.DebuggerStatement: checkGrammarStatementInAmbientContext(node); return; + case SyntaxKind.MissingDeclaration: + return checkMissingDeclaration(node); } } @@ -10548,6 +10684,10 @@ module ts { links.flags |= NodeCheckFlags.EmitExtends; } + if (emitDecorate) { + links.flags |= NodeCheckFlags.EmitDecorate; + } + links.flags |= NodeCheckFlags.TypeChecked; } } @@ -10599,7 +10739,7 @@ module ts { populateSymbols(); - return mapToArray(symbols); + return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -10657,6 +10797,42 @@ module ts { } } } + + if (isInsideWithStatementBody(location)) { + // We cannot answer semantic questions within a with block, do not proceed any further + return []; + } + + 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); + return symbolsToArray(symbols); } function isTypeDeclarationName(name: Node): boolean { @@ -11008,26 +11184,34 @@ module ts { return symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length === 1 && symbol.declarations[0].kind === SyntaxKind.SourceFile; } - function getAliasNameSubstitution(symbol: Symbol, getGeneratedNameForNode: (Node: Node) => string): string { - let declaration = getDeclarationOfAliasSymbol(symbol); - if (declaration && declaration.kind === SyntaxKind.ImportSpecifier) { - let moduleName = getGeneratedNameForNode(declaration.parent.parent.parent); - let propertyName = (declaration).propertyName || (declaration).name; - return moduleName + "." + unescapeIdentifier(propertyName.text); + 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) { + return undefined; + } + + let node = getDeclarationOfAliasSymbol(symbol); + if (node) { + if (node.kind === SyntaxKind.ImportClause) { + return getGeneratedNameForNode(node.parent) + ".default"; + } + if (node.kind === SyntaxKind.ImportSpecifier) { + let moduleName = getGeneratedNameForNode(node.parent.parent.parent); + let propertyName = (node).propertyName || (node).name; + return moduleName + "." + unescapeIdentifier(propertyName.text); + } } } function getExportNameSubstitution(symbol: Symbol, location: Node, getGeneratedNameForNode: (Node: Node) => string): string { if (isExternalModuleSymbol(symbol.parent)) { - var symbolName = unescapeIdentifier(symbol.name); // If this is es6 or higher, just use the name of the export // no need to qualify it. if (languageVersion >= ScriptTarget.ES6) { - return symbolName; - } - else { - return "exports." + symbolName; + return undefined; } + return "exports." + unescapeIdentifier(symbol.name); } let node = location; let containerSymbol = getParentOfSymbol(symbol); @@ -11040,7 +11224,7 @@ module ts { } function getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (Node: Node) => string): string { - let symbol = getNodeLinks(node).resolvedSymbol; + 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. @@ -11055,15 +11239,27 @@ module ts { return getExportNameSubstitution(exportSymbol, node.parent, getGeneratedNameForNode); } // Named imports from ES6 import declarations are rewritten - if (symbol.flags & SymbolFlags.Alias && languageVersion < ScriptTarget.ES6) { + if (symbol.flags & SymbolFlags.Alias) { return getAliasNameSubstitution(symbol, getGeneratedNameForNode); } } } - function hasExportDefaultValue(node: SourceFile): boolean { - let symbol = getResolvedExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbol !== unknownSymbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol); + function isValueAliasDeclaration(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ExportSpecifier: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case SyntaxKind.ExportDeclaration: + let exportClause = (node).exportClause; + return exportClause && forEach(exportClause.elements, isValueAliasDeclaration); + case SyntaxKind.ExportAssignment: + return (node).expression && (node).expression.kind === SyntaxKind.Identifier ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + } + return false; } function isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean { @@ -11084,13 +11280,18 @@ module ts { return isConstEnumSymbol(s) || s.constEnumOnlyModule; } - function isReferencedAliasDeclaration(node: Node): boolean { + function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean { if (isAliasSymbolDeclaration(node)) { let symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } } + + if (checkChildren) { + return forEachChild(node, node => isReferencedAliasDeclaration(node, checkChildren)); + } + return false; } function isImplementationOfOverload(node: FunctionLikeDeclaration) { @@ -11193,11 +11394,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 { getExpressionNameSubstitution, + isValueAliasDeclaration, hasGlobalName, - hasExportDefaultValue, isReferencedAliasDeclaration, getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName, @@ -11242,6 +11457,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. @@ -11266,6 +11486,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: @@ -11462,7 +11701,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); } @@ -11519,7 +11758,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 { @@ -11568,7 +11807,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 5433557bf84..4b93081dc31 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 { @@ -222,16 +255,6 @@ module ts { return hasProperty(map, key) ? map[key] : undefined; } - export function mapToArray(map: Map): T[] { - let result: T[] = []; - - for (let id in map) { - result.push(map[id]); - } - - return result; - } - export function copyMap(source: Map, target: Map): void { for (let p in source) { target[p] = source[p]; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 78afaa13a74..967afd171ba 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -149,7 +149,7 @@ module ts { The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, An_import_declaration_cannot_have_modifiers: { code: 1191, category: DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export or export assignment." }, + External_module_0_has_no_default_export: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, @@ -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." }, @@ -346,6 +349,8 @@ module ts { Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, + External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, + External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a565775907b..6e24afad80c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -587,7 +587,7 @@ "category": "Error", "code": 1191 }, - "External module '{0}' has no default export or export assignment.": { + "External module '{0}' has no default export.": { "category": "Error", "code": 1192 }, @@ -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", @@ -1376,6 +1388,14 @@ "category": "Error", "code": 2496 }, + "External module '{0}' resolves to a non-module entity and cannot be imported using this construct.": { + "category": "Error", + "code": 2497 + }, + "External module '{0}' uses 'export =' and cannot be used with 'export *'.": { + "category": "Error", + "code": 2498 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ad6c6d1c8b6..03b30755cf2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2,13 +2,6 @@ /// module ts { - - interface ExternalImportInfo { - rootNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration; - declarationNode?: ImportEqualsDeclaration | ImportClause | NamespaceImport; - namedImports?: NamedImports; - } - // represents one LexicalEnvironment frame to store unique generated names interface ScopeFrame { names: Map; @@ -102,17 +95,18 @@ module ts { 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 externalImports: ExternalImportInfo[]; let exportSpecifiers: Map; - let exportDefault: FunctionDeclaration | ClassDeclaration | ExportAssignment | ExportSpecifier; + let exportEquals: ExportAssignment; + let hasExportStars: boolean; /** write emitted output to disk*/ let writeEmittedFiles = writeJavaScriptFile; @@ -342,7 +336,7 @@ module ts { } function generateNameForImportDeclaration(node: ImportDeclaration) { - if (node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === SyntaxKind.NamedImports) { + if (node.importClause) { generateNameForImportOrExportDeclaration(node); } } @@ -894,13 +888,13 @@ module ts { return true; } } - + return false; } function emitLiteral(node: LiteralExpression) { let text = getLiteralText(node); - + if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -912,7 +906,7 @@ module ts { write(text); } } - + function getLiteralText(node: LiteralExpression) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. @@ -942,14 +936,14 @@ module ts { case SyntaxKind.NumericLiteral: return node.text; } - + Debug.fail(`Literal kind '${node.kind}' not accounted for.`); } - + function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } - + function emitDownlevelRawTemplateLiteral(node: LiteralExpression) { // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. @@ -968,10 +962,10 @@ module ts { // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = escapeString(text); - + write('"' + text + '"'); } - + function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, literalEmitter: (literal: LiteralExpression) => void) { write("["); if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { @@ -986,7 +980,7 @@ module ts { } write("]"); } - + function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { let tempVariable = createAndRecordTempVariable(node); write("("); @@ -994,12 +988,12 @@ module ts { write(" = "); emitDownlevelTaggedTemplateArray(node, emit); write(", "); - + emit(tempVariable); write(".raw = "); emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); write(", "); - + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); @@ -1160,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 { @@ -1198,7 +1224,12 @@ module ts { case SyntaxKind.EnumDeclaration: case SyntaxKind.ModuleDeclaration: case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceImport: return (parent).name === node; + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ExportSpecifier: + return (parent).name === node || (parent).propertyName === node; case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: case SyntaxKind.ExportAssignment: @@ -1381,7 +1412,7 @@ module ts { write("]"); } else { - emitListWithSpread(elements, /*multiLine*/ (node.flags & NodeFlags.MultiLine) !== 0, + emitListWithSpread(elements, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -1523,7 +1554,7 @@ module ts { return result; } - + function createExpressionStatement(expression: Expression): ExpressionStatement { let result = createSynthesizedNode(SyntaxKind.ExpressionStatement); result.expression = expression; @@ -1577,7 +1608,7 @@ module ts { return result; } - + function createIdentifier(name: string, startsOnNewLine?: boolean) { let result = createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine); result.text = name; @@ -1608,7 +1639,7 @@ module ts { break; } } - + let hasComputedProperty = numInitialNonComputedProperties !== properties.length; if (hasComputedProperty) { emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); @@ -1629,7 +1660,7 @@ module ts { function emitComputedPropertyName(node: ComputedPropertyName) { write("["); - emit(node.expression); + emitExpressionForPropertyName(node); write("]"); } @@ -2139,7 +2170,7 @@ module ts { if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.ForOfStatement) { return emitDownLevelForOfStatement(node); } - + let endPos = emitToken(SyntaxKind.ForKeyword, node.pos); write(" "); endPos = emitToken(SyntaxKind.OpenParenToken, endPos); @@ -2166,7 +2197,7 @@ module ts { emitToken(SyntaxKind.CloseParenToken, node.expression.end); emitEmbeddedStatement(node.statement); } - + function emitDownLevelForOfStatement(node: ForOfStatement) { // The following ES6 code: // @@ -2217,7 +2248,7 @@ module ts { emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - + if (!rhsIsIdentifier) { // , _a = expr write(", "); @@ -2311,7 +2342,7 @@ module ts { } emitEnd(node.initializer); write(";"); - + if (node.statement.kind === SyntaxKind.Block) { emitLines((node.statement).statements); } @@ -2319,7 +2350,7 @@ module ts { writeLine(); emit(node.statement); } - + writeLine(); decreaseIndent(); write("}"); @@ -2465,7 +2496,7 @@ module ts { emitNodeWithoutSourceMap(node.name); emitEnd(node.name); } - + function createVoidZero(): Expression { let zero = createSynthesizedNode(SyntaxKind.NumericLiteral); zero.text = "0"; @@ -2474,9 +2505,26 @@ module ts { return result; } + function emitExportMemberAssignment(node: FunctionLikeDeclaration | ClassDeclaration) { + if (node.flags & NodeFlags.Export) { + writeLine(); + emitStart(node); + if (node.name) { + emitModuleMemberName(node); + } + else { + write("exports.default"); + } + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name: Identifier) { - if (!exportDefault && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { - forEach(exportSpecifiers[name.text], specifier => { + if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { + for (let specifier of exportSpecifiers[name.text]) { writeLine(); emitStart(specifier.name); emitContainingModuleName(specifier); @@ -2484,9 +2532,9 @@ module ts { emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } @@ -2636,7 +2684,7 @@ module ts { function emitDestructuringAssignment(target: Expression, value: Expression) { if (target.kind === SyntaxKind.BinaryExpression && (target).operatorToken.kind === SyntaxKind.EqualsToken) { - value = createDefaultValueCheck(value,(target).right); + value = createDefaultValueCheck(value, (target).right); target = (target).left; } if (target.kind === SyntaxKind.ObjectLiteralExpression) { @@ -2766,7 +2814,7 @@ module ts { forEach((name).elements, emitExportVariableAssignments); } } - + function getCombinedFlagsForIdentifier(node: Identifier): NodeFlags { if (!node.parent || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { return 0; @@ -2827,7 +2875,7 @@ module ts { } } - function isES6ModuleMemberDeclaration(node: Node) { + function isES6ExportedDeclaration(node: Node) { return !!(node.flags & NodeFlags.Export) && languageVersion >= ScriptTarget.ES6 && node.parent.kind === SyntaxKind.SourceFile; @@ -2837,7 +2885,7 @@ module ts { if (!(node.flags & NodeFlags.Export)) { emitStartOfVariableDeclarationList(node.declarationList); } - else if (languageVersion >= ScriptTarget.ES6 && node.parent.kind === SyntaxKind.SourceFile) { + else if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); emitStartOfVariableDeclarationList(node.declarationList); @@ -2986,7 +3034,7 @@ module ts { // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { - if (isES6ModuleMemberDeclaration(node)) { + if (isES6ExportedDeclaration(node)) { write("export "); if (node.flags & NodeFlags.Default) { write("default "); @@ -3070,14 +3118,8 @@ module ts { emitExpressionFunctionBody(node, node.body); } - if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default) && !isES6ModuleMemberDeclaration(node)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); } predefinedTempsInUse = savePredefinedTempsInUse; @@ -3281,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(" = "); @@ -3302,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); @@ -3497,25 +3533,99 @@ module ts { tempParameters = saveTempParameters; } + function emitClassDeclaration(node: ClassDeclaration) { + if (languageVersion < ScriptTarget.ES6) { + emitClassDeclarationBelowES6(node); + } + else { + emitClassDeclarationForES6AndHigher(node); + } + } + function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { - if (isES6ModuleMemberDeclaration(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); @@ -3527,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: @@ -3534,10 +3664,11 @@ 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 - if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) { + if (!isES6ExportedDeclaration(node) && (node.flags & NodeFlags.Export)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -3546,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) { @@ -3557,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) { @@ -3572,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); @@ -3589,21 +3742,228 @@ module ts { write(");"); emitEnd(node); - if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); - } + emitExportMemberAssignment(node); if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } + function emitClassMemberPrefix(node: ClassDeclaration, member: Node) { + emitDeclarationName(node); + if (!(member.flags & NodeFlags.Static)) { + write(".prototype"); + } + } + + function emitDecoratorsOfClass(node: ClassDeclaration) { + 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); } @@ -3619,8 +3979,11 @@ module ts { return; } - if (!(node.flags & NodeFlags.Export) || isES6ModuleMemberDeclaration(node)) { + if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); emitEnd(node); @@ -3646,10 +4009,7 @@ module ts { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (isES6ModuleMemberDeclaration(node)) { - emitES6NamedExportForDeclaration(node); - } - else if (node.flags & NodeFlags.Export) { + if (!isES6ExportedDeclaration(node) && node.flags & NodeFlags.Export) { writeLine(); emitStart(node); write("var "); @@ -3714,6 +4074,9 @@ module ts { } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -3754,7 +4117,7 @@ module ts { } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & NodeFlags.Export) && !isES6ModuleMemberDeclaration(node)) { + if ((node.flags & NodeFlags.Export) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -3763,23 +4126,11 @@ module ts { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (isES6ModuleMemberDeclaration(node)) { - emitES6NamedExportForDeclaration(node); - } - else if (languageVersion < ScriptTarget.ES6 && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { emitExportMemberAssignments(node.name); } } - function emitES6NamedExportForDeclaration(node: Declaration) { - writeLine(); - emitStart(node); - write("export { "); - emit(node.name); - write(" };"); - emitEnd(node); - } - function emitRequire(moduleName: Expression) { if (moduleName.kind === SyntaxKind.StringLiteral) { write("require("); @@ -3787,13 +4138,33 @@ module ts { emitLiteral(moduleName); emitEnd(moduleName); emitToken(SyntaxKind.CloseParenToken, moduleName.end); - write(";"); } else { - write("require();"); + write("require()"); } } + function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) { + if (node.kind === SyntaxKind.ImportEqualsDeclaration) { + return node; + } + let importClause = (node).importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { + return importClause.namedBindings; + } + } + + function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) { + return node.kind === SyntaxKind.ImportDeclaration && (node).importClause && !!(node).importClause.name; + } + + function emitExportImportAssignments(node: Node) { + if (isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments((node).name); + } + forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node: ImportDeclaration) { if (languageVersion < ScriptTarget.ES6) { return emitExternalImportDeclaration(node); @@ -3801,8 +4172,8 @@ module ts { // ES6 import if (node.importClause) { - let shouldEmitDefaultBindings = hasReferencedDefaultName(node.importClause); - let shouldEmitNamedBindings = hasReferencedNamedBindings(node.importClause); + let shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + let shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -3821,18 +4192,7 @@ module ts { } else { write("{ "); - let importSpecifiers = (node.importClause.namedBindings).elements; - let currentTextPos = writer.getTextPos(); - let needsComma = false; - for (var i = 0, n = importSpecifiers.length; i < n; i++) { - if (resolver.isReferencedAliasDeclaration(importSpecifiers[i])) { - if (needsComma) { - write(", "); - } - needsComma = true; - emit(importSpecifiers[i]); - } - } + emitExportOrImportSpecifierList((node.importClause.namedBindings).elements, resolver.isReferencedAliasDeclaration); write(" }"); } emitEnd(node.importClause.namedBindings); @@ -3852,72 +4212,63 @@ module ts { } } - function hasReferencedDefaultName(importClause: ImportClause) { - // If the default import is used, the mark will be on the importClause, - // as the alias declaration. - // If there are other named bindings on the import clause, we will - // will mark either the namedBindings(import * as n) or the NamedImport - // in the case of import {a} - return resolver.isReferencedAliasDeclaration(importClause); - } - - function hasReferencedNamedBindings(importClause: ImportClause) { - if (importClause && importClause.namedBindings) { - if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { - return resolver.isReferencedAliasDeclaration(importClause.namedBindings); - } - else { - return forEach((importClause.namedBindings).elements, - namedImport => resolver.isReferencedAliasDeclaration(namedImport)); - } - } - } - - function emitImportOrExportSpecifier(node: ImportSpecifier) { - Debug.assert(languageVersion >= ScriptTarget.ES6); - if (node.propertyName) { - emit(node.propertyName); - write(" as "); - } - emit(node.name); - } - function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) { - let info = getExternalImportInfo(node); - if (info) { - let declarationNode = info.declarationNode; - let namedImports = info.namedImports; + if (contains(externalImports, node)) { + let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0; + let namespaceDeclaration = getNamespaceDeclarationNode(node); + if (compilerOptions.module !== ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); - let moduleName = getExternalModuleName(node); - if (declarationNode) { - if (!(declarationNode.flags & NodeFlags.Export)) write("var "); - emitModuleMemberName(declarationNode); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) write("var "); + emitModuleMemberName(namespaceDeclaration); write(" = "); - emitRequire(moduleName); - } - else if (namedImports) { - write("var "); - write(getGeneratedNameForNode(node)); - write(" = "); - emitRequire(moduleName); } else { - emitRequire(moduleName); + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + let isNakedImport = SyntaxKind.ImportDeclaration && !(node).importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } } + emitRequire(getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } else { - if (declarationNode) { - if (declarationNode.flags & NodeFlags.Export) { - emitModuleMemberName(declarationNode); - write(" = "); - emit(declarationNode.name); - write(";"); - } + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); } } } @@ -3934,7 +4285,7 @@ module ts { (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ModuleMemberDeclaration(node)) { + if (isES6ExportedDeclaration(node)) { write("export "); write("var "); } @@ -3946,174 +4297,175 @@ module ts { emit(node.moduleReference); write(";"); emitEnd(node); + emitExportImportAssignments(node); emitTrailingComments(node); } } function emitExportDeclaration(node: ExportDeclaration) { - if (languageVersion < ScriptTarget.ES6 || node.parent.kind !== SyntaxKind.SourceFile) { - if (node.moduleSpecifier) { + if (languageVersion < ScriptTarget.ES6) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); let generatedName = getGeneratedNameForNode(node); - if (compilerOptions.module !== ModuleKind.AMD) { - write("var "); - write(generatedName); - write(" = "); - emitRequire(getExternalModuleName(node)); - } if (node.exportClause) { - // export { x, y, ... } - forEach(node.exportClause.elements, specifier => { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); + // export { x, y, ... } from "foo" + if (compilerOptions.module !== ModuleKind.AMD) { + write("var "); write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(" = "); + emitRequire(getExternalModuleName(node)); write(";"); - emitEnd(specifier); - }); + } + for (let specifier of node.exportClause.elements) { + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } } else { - // export * - let tempName = createTempVariable(node).text; + // export * from "foo" writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); - emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); + write("__export("); + if (compilerOptions.module !== ModuleKind.AMD) { + emitRequire(getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + + function emitExportOrImportSpecifierList(specifiers: ImportOrExportSpecifier[], shouldEmit: (node: Node) => boolean) { + Debug.assert(languageVersion >= ScriptTarget.ES6); + + let needsComma = false; + for (let specifier of specifiers) { + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + + function emitExportAssignment(node: ExportAssignment) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= ScriptTarget.ES6) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== SyntaxKind.FunctionDeclaration && + expression.kind !== SyntaxKind.ClassDeclaration) { + write(";"); } emitEnd(node); } else { - // internal module - if (node.exportClause) { - // export { x, y, ... } - forEach(node.exportClause.elements, specifier => { - writeLine(); - emitStart(specifier); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - write(" = "); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - }); - } - } - } - else { - write("export "); - if (node.exportClause) { - // export { x, y, ... } - write("{ "); - emitCommaList(node.exportClause.elements); - write(" }"); - } - else { - write("*"); - } - if (node.moduleSpecifier) { - write(" from "); - emit(node.moduleSpecifier); - } - write(";"); - } - } - - function createExternalImportInfo(node: Node): ExternalImportInfo { - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference) { - if (resolver.isReferencedAliasDeclaration(node)) { - return { - rootNode: node, - declarationNode: node - }; - } - } - } - else if (node.kind === SyntaxKind.ImportDeclaration) { - let importClause = (node).importClause; - if (importClause) { - if (importClause.name && resolver.isReferencedAliasDeclaration(importClause)) { - return { - rootNode: node, - declarationNode: importClause - }; - } - if (hasReferencedNamedBindings(importClause)) { - if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; - } - else { - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: getGeneratedNameForNode(node) - }; - } - } - } - else { - return { - rootNode: node - }; - } - } - else if (node.kind === SyntaxKind.ExportDeclaration) { - if ((node).moduleSpecifier) { - return { - rootNode: node, - }; + writeLine(); + emitStart(node); + emitContainingModuleName(node); + write(".default = "); + emit(node.expression); + write(";"); + emitEnd(node); } } } - function createExternalModuleInfo(sourceFile: SourceFile) { + function collectExternalModuleInfo(sourceFile: SourceFile) { externalImports = []; exportSpecifiers = {}; - exportDefault = undefined; - forEach(sourceFile.statements, node => { - if (node.kind === SyntaxKind.ExportDeclaration && !(node).moduleSpecifier) { - forEach((node).exportClause.elements, specifier => { - if (specifier.name.text === "default") { - exportDefault = exportDefault || specifier; + exportEquals = undefined; + hasExportStars = false; + for (let node of sourceFile.statements) { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + if (!(node).importClause || + resolver.isReferencedAliasDeclaration((node).importClause, /*checkChildren*/ true)) { + // import "mod" + // import x from "mod" where x is referenced + // import * as x from "mod" where x is referenced + // import { x, y } from "mod" where at least one import is referenced + externalImports.push(node); } - let name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); - }); - } - else if (node.kind === SyntaxKind.ExportAssignment) { - exportDefault = exportDefault || node; - } - else if (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ClassDeclaration) { - if (node.flags & NodeFlags.Export && node.flags & NodeFlags.Default) { - exportDefault = exportDefault || node; - } - } - else { - let info = createExternalImportInfo(node); - if (info) { - externalImports.push(info); - } - } - }); - } - - function getExternalImportInfo(node: ImportDeclaration | ImportEqualsDeclaration): ExternalImportInfo { - if (externalImports) { - for (let info of externalImports) { - if (info.rootNode === node) { - return info; - } + break; + case SyntaxKind.ImportEqualsDeclaration: + if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case SyntaxKind.ExportDeclaration: + if ((node).moduleSpecifier) { + if (!(node).exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (let specifier of (node).exportClause.elements) { + let name = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); + } + } + break; + case SyntaxKind.ExportAssignment: + if ((node).isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; } } } @@ -4131,8 +4483,21 @@ module ts { }); } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAMDModule(node: SourceFile, startIndex: number) { - createExternalModuleInfo(node); + collectExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -4140,60 +4505,64 @@ module ts { write("\"" + node.amdModuleName + "\", "); } write("[\"require\", \"exports\""); - forEach(externalImports, info => { + for (let importNode of externalImports) { write(", "); - let moduleName = getExternalModuleName(info.rootNode); + let moduleName = getExternalModuleName(importNode); if (moduleName.kind === SyntaxKind.StringLiteral) { emitLiteral(moduleName); } else { write("\"\""); } - }); - forEach(node.amdDependencies, amdDependency => { + } + for (let amdDependency of node.amdDependencies) { let text = "\"" + amdDependency.path + "\""; write(", "); write(text); - }); + } write("], function (require, exports"); - forEach(externalImports, info => { + for (let importNode of externalImports) { write(", "); - if (info.declarationNode) { - emit(info.declarationNode.name); + let namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + emit(namespaceDeclaration.name); } else { - write(getGeneratedNameForNode(info.rootNode)); + write(getGeneratedNameForNode(importNode)); } - }); - forEach(node.amdDependencies, amdDependency => { + } + for (let amdDependency of node.amdDependencies) { if (amdDependency.name) { write(", "); write(amdDependency.name); } - }); + } write(") {"); increaseIndent(); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); - emitExportDefault(node, /*emitAsReturn*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node: SourceFile, startIndex: number) { - createExternalModuleInfo(node); + collectExternalModuleInfo(node); + emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); - emitExportDefault(node, /*emitAsReturn*/ false); + emitExportEquals(/*emitAsReturn*/ false); } function emitES6Module(node: SourceFile, startIndex: number) { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); @@ -4201,42 +4570,14 @@ module ts { // or normal statement emit. } - function emitExportAssignment(node: ExportAssignment) { - // Only emit exportAssignment/export default if we are in ES6 - // Other modules will handle it differently - if (languageVersion >= ScriptTarget.ES6) { + function emitExportEquals(emitAsReturn: boolean) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { writeLine(); - emitStart(node); - write("export default "); - var expression = node.expression; - emit(expression); - if (expression.kind !== SyntaxKind.FunctionDeclaration && - expression.kind !== SyntaxKind.ClassDeclaration) { - write(";"); - } - emitEnd(node); - } - } - - function emitExportDefault(sourceFile: SourceFile, emitAsReturn: boolean) { - // ES6 emit is handled in emitExportAssignment - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { - if (languageVersion < ScriptTarget.ES6) { - writeLine(); - emitStart(exportDefault); - write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === SyntaxKind.ExportAssignment) { - emit((exportDefault).expression); - } - else if (exportDefault.kind === SyntaxKind.ExportSpecifier) { - emit((exportDefault).propertyName); - } - else { - emitDeclarationName(exportDefault); - } - write(";"); - emitEnd(exportDefault); - } + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit((exportEquals).expression); + write(";"); + emitEnd(exportEquals); } } @@ -4256,6 +4597,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(); @@ -4282,6 +4634,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); @@ -4296,7 +4665,8 @@ module ts { else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); @@ -4500,7 +4870,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: @@ -4511,9 +4881,6 @@ module ts { return emitModuleDeclaration(node); case SyntaxKind.ImportDeclaration: return emitImportDeclaration(node); - case SyntaxKind.ImportSpecifier: - case SyntaxKind.ExportSpecifier: - return emitImportOrExportSpecifier(node); case SyntaxKind.ImportEqualsDeclaration: return emitImportEqualsDeclaration(node); case SyntaxKind.ExportDeclaration: @@ -4695,4 +5062,3 @@ module ts { } } } - diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9eae67a29b8..14311ccbc52 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: @@ -4829,34 +4968,36 @@ module ts { function parseImportOrExportSpecifier(kind: SyntaxKind): ImportOrExportSpecifier { let node = createNode(kind); // ImportSpecifier: - // ImportedBinding - // IdentifierName as ImportedBinding - let isFirstIdentifierNameNotAnIdentifier = isKeyword(token) && !isIdentifier(); - let start = scanner.getTokenPos(); + // BindingIdentifier + // IdentifierName as BindingIdentifier + // ExportSpecififer: + // IdentifierName + // IdentifierName as IdentifierName + let checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier(); + let checkIdentifierStart = scanner.getTokenPos(); + let checkIdentifierEnd = scanner.getTextPos(); let identifierName = parseIdentifierName(); if (token === SyntaxKind.AsKeyword) { node.propertyName = identifierName; parseExpected(SyntaxKind.AsKeyword); - if (isIdentifier()) { - node.name = parseIdentifierName(); - } - else { - parseErrorAtCurrentToken(Diagnostics.Identifier_expected); - } + checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + node.name = parseIdentifierName(); } else { node.name = identifierName; - if (isFirstIdentifierNameNotAnIdentifier) { - // Report error identifier expected - parseErrorAtPosition(start, identifierName.end - start, Diagnostics.Identifier_expected); - } } - + if (kind === SyntaxKind.ImportSpecifier && checkIdentifierIsKeyword) { + // Report error identifier expected + parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, Diagnostics.Identifier_expected); + } 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); @@ -4872,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; @@ -4898,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: @@ -4928,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; } } @@ -4954,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() { @@ -4968,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); } } @@ -4983,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 580d18317ca..3a208698c25 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, }; /* @@ -1284,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 d6edc5300d4..609baef833e 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, @@ -307,6 +310,7 @@ module ts { Let = 0x00001000, // Variable declaration Const = 0x00002000, // Variable declaration OctalLiteral = 0x00004000, + ExportContext = 0x00008000, // Export context (initialized by binding) Modifier = Export | Ambient | Public | Private | Protected | Static | Default, AccessibilityModifier = Public | Private | Protected, @@ -327,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 { @@ -357,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 { @@ -397,6 +405,10 @@ module ts { expression: Expression; } + export interface Decorator extends Node { + expression: LeftHandSideExpression; + } + export interface TypeParameterDeclaration extends Declaration { name: Identifier; constraint?: TypeNode; @@ -1209,8 +1221,8 @@ module ts { export interface EmitResolver { hasGlobalName(name: string): boolean; getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; @@ -1338,17 +1350,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 a6febeab016..9fa0674c25c 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) { @@ -834,6 +925,23 @@ module ts { return false; } + // An alias symbol is created by one of the following declarations: + // import = ... + // import from ... + // import * as from ... + // import { x as } from ... + // export { x as } from ... + // export = ... + // export default ... + export function isAliasSymbolDeclaration(node: Node): boolean { + return node.kind === SyntaxKind.ImportEqualsDeclaration || + node.kind === SyntaxKind.ImportClause && !!(node).name || + node.kind === SyntaxKind.NamespaceImport || + node.kind === SyntaxKind.ImportSpecifier || + node.kind === SyntaxKind.ExportSpecifier || + node.kind === SyntaxKind.ExportAssignment && (node).expression.kind === SyntaxKind.Identifier; + } + export function getClassBaseTypeNode(node: ClassDeclaration) { let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; @@ -1485,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)) { @@ -1509,6 +1618,9 @@ module ts { if (!firstAccessor) { firstAccessor = member; } + else if (!secondAccessor) { + secondAccessor = member; + } if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { getAccessor = member; @@ -1523,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 040eb69ae96..2096fa839df 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/server/client.ts b/src/server/client.ts index 875e3ffdb5b..60421421780 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -433,7 +433,35 @@ module ts.server { } getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems { - throw new Error("Not Implemented Yet."); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); + var args: protocol.SignatureHelpRequestArgs = { + file: fileName, + line: lineOffset.line, + offset: lineOffset.offset + }; + + var request = this.processRequest(CommandNames.SignatureHelp, args); + var response = this.processResponse(request); + + if (!response.body) { + return undefined; + } + var helpItems: protocol.SignatureHelpItems = response.body; + var span = helpItems.applicableSpan; + var start = this.lineOffsetToPosition(fileName, span.start); + var end = this.lineOffsetToPosition(fileName, span.end); + + var result: SignatureHelpItems = { + items: helpItems.items, + applicableSpan: { + start: start, + length: end - start + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount, + } + return result; } getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index d63aa53ba12..cad008c3a73 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -592,6 +592,122 @@ declare module ts.server.protocol { body?: CompletionEntryDetails[]; } + /** + * Signature help information for a single parameter + */ + export interface SignatureHelpParameter { + + /** + * The parameter's name + */ + name: string; + + /** + * Documentation of the parameter. + */ + documentation: SymbolDisplayPart[]; + + /** + * Display parts of the parameter. + */ + displayParts: SymbolDisplayPart[]; + + /** + * Whether the parameter is optional or not. + */ + isOptional: boolean; + } + + /** + * Represents a single signature to show in signature help. + */ + export interface SignatureHelpItem { + + /** + * Whether the signature accepts a variable number of arguments. + */ + isVariadic: boolean; + + /** + * The prefix display parts. + */ + prefixDisplayParts: SymbolDisplayPart[]; + + /** + * The suffix disaply parts. + */ + suffixDisplayParts: SymbolDisplayPart[]; + + /** + * The separator display parts. + */ + separatorDisplayParts: SymbolDisplayPart[]; + + /** + * The signature helps items for the parameters. + */ + parameters: SignatureHelpParameter[]; + + /** + * The signature's documentation + */ + documentation: SymbolDisplayPart[]; + } + + /** + * Signature help items found in the response of a signature help request. + */ + export interface SignatureHelpItems { + + /** + * The signature help items. + */ + items: SignatureHelpItem[]; + + /** + * The span for which signature help should appear on a signature + */ + applicableSpan: TextSpan; + + /** + * The item selected in the set of available help items. + */ + selectedItemIndex: number; + + /** + * The argument selected in the set of parameters. + */ + argumentIndex: number; + + /** + * The argument count + */ + argumentCount: number; + } + + /** + * Arguments of a signature help request. + */ + export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + + } + + /** + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ + export interface SignatureHelpRequest extends FileLocationRequest { + arguments: SignatureHelpRequestArgs; + } + + /** + * Repsonse object for a SignatureHelpRequest. + */ + export interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + /** * Arguments for geterr messages. */ diff --git a/src/server/session.ts b/src/server/session.ts index 47ef40a8809..70d301d8ecc 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -80,6 +80,7 @@ module ts.server { export var Close = "close"; export var Completions = "completions"; export var CompletionDetails = "completionEntryDetails"; + export var SignatureHelp = "signatureHelp"; export var Configure = "configure"; export var Definition = "definition"; export var Format = "format"; @@ -577,6 +578,35 @@ module ts.server { }, []); } + getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems { + var file = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + + var span = helpItems.applicableSpan; + var result: protocol.SignatureHelpItems = { + items: helpItems.items, + applicableSpan: { + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount, + } + + return result; + } + getDiagnostics(delay: number, fileNames: string[]) { var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => { fileName = ts.normalizePath(fileName); @@ -790,6 +820,11 @@ module ts.server { completionDetailsArgs.entryNames,completionDetailsArgs.file); break; } + case CommandNames.SignatureHelp: { + var signatureHelpArgs = request.arguments; + response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file); + break; + } case CommandNames.Geterr: { var geterrArgs = request.arguments; response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 23a392d7718..6a5ed25459e 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 980c79c231f..cd62d7fce88 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2476,36 +2476,38 @@ module ts { return undefined; } - // The decision to provide completion depends on the previous token, so find it - // Note: previousToken can be undefined if we are the beginning of the file start = new Date().getTime(); let previousToken = findPrecedingToken(position, sourceFile); 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) { + // The decision to provide completion depends on the contextToken, which is determined through the previousToken. + // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file + let contextToken = previousToken; + + // Check if 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 and adjust the contextToken to the token that precedes it. + if (contextToken && position <= contextToken.end && isWord(contextToken.kind)) { let start = new Date().getTime(); - previousToken = findPrecedingToken(previousToken.pos, sourceFile); + contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile); log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } // Check if this is a valid completion location - if (previousToken && isCompletionListBlocker(previousToken)) { + if (contextToken && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } // 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 + // otherwise, it is a request for all visible symbols in the scope, and the node is the current location let node = currentToken; let isRightOfDot = false; - if (previousToken && previousToken.kind === SyntaxKind.DotToken && previousToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (previousToken.parent).expression; + if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; isRightOfDot = true; } - else if (previousToken && previousToken.kind === SyntaxKind.DotToken && previousToken.parent.kind === SyntaxKind.QualifiedName) { - node = (previousToken.parent).left; + else if (contextToken && contextToken.kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; isRightOfDot = true; } @@ -2554,7 +2556,7 @@ module ts { } } else { - let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(previousToken); + let containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); if (containingObjectLiteral) { // Object literal expression, look up possible property names from contextual type isMemberCompletion = true; @@ -2571,13 +2573,13 @@ module ts { symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); } } - else if (getAncestor(previousToken, SyntaxKind.ImportClause)) { + else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { // cursor is in import clause // try to show exported member for imported module isMemberCompletion = true; isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(previousToken)) { - let importDeclaration = getAncestor(previousToken, SyntaxKind.ImportDeclaration); + if (showCompletionsInImportsClause(contextToken)) { + let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); Debug.assert(importDeclaration !== undefined); let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); @@ -2585,14 +2587,46 @@ module ts { } } else { - // Get scope members + // Get all entities in the current scope. isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(previousToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + + if (previousToken !== contextToken) { + Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); + } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + let adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + + let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile); /// TODO filter meaning based on the current context - let scopeNode = getScopeNode(previousToken, position, sourceFile); let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 756fbb42597..719aa658724 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -450,7 +450,7 @@ module ts { return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; } - function isWord(kind: SyntaxKind): boolean { + export function isWord(kind: SyntaxKind): boolean { return kind === SyntaxKind.Identifier || isKeyword(kind); } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 4254ddec7d4..07d5e4337a6 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, @@ -321,6 +324,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -330,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, @@ -344,6 +349,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -374,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; @@ -940,8 +949,8 @@ declare module "typescript" { interface EmitResolver { hasGlobalName(name: string): boolean; getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; @@ -1060,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 a6b7feae6d3..eff47a4cb7b 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 { @@ -978,6 +987,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -1002,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 { @@ -1042,6 +1057,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1136,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 @@ -3015,16 +3043,17 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile - - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean >node : Node >Node : Node + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; +>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean +>node : Node +>Node : Node +>checkChildren : boolean + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; >isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean >node : ImportEqualsDeclaration @@ -3434,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 220a84a5e97..b57acaf0e9c 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, @@ -352,6 +355,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -361,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, @@ -375,6 +380,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -405,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; @@ -971,8 +980,8 @@ declare module "typescript" { interface EmitResolver { hasGlobalName(name: string): boolean; getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; @@ -1091,6 +1100,7 @@ declare module "typescript" { ContextChecked = 64, EnumValuesComputed = 128, BlockScopedBindingInLoop = 256, + EmitDecorate = 512, } interface NodeLinks { resolvedType?: Type; @@ -2032,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 1e883ef82d3..600bf5c6adc 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 { @@ -1124,6 +1133,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -1148,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 { @@ -1188,6 +1203,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1282,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 @@ -3161,16 +3189,17 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile - - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean >node : Node >Node : Node + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; +>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean +>node : Node +>Node : Node +>checkChildren : boolean + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; >isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean >node : ImportEqualsDeclaration @@ -3580,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 fd570b9c042..4004007508a 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, @@ -353,6 +356,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -362,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, @@ -376,6 +381,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -406,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; @@ -972,8 +981,8 @@ declare module "typescript" { interface EmitResolver { hasGlobalName(name: string): boolean; getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; @@ -1092,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 b363fbfb781..4ea9c49d758 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 { @@ -1074,6 +1083,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -1098,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 { @@ -1138,6 +1153,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1232,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 @@ -3111,16 +3139,17 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile - - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean >node : Node >Node : Node + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; +>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean +>node : Node +>Node : Node +>checkChildren : boolean + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; >isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean >node : ImportEqualsDeclaration @@ -3530,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 54e9ed7373a..34503a0d81a 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, @@ -390,6 +393,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -399,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, @@ -413,6 +418,7 @@ declare module "typescript" { kind: SyntaxKind; flags: NodeFlags; parserContextFlags?: ParserContextFlags; + decorators?: NodeArray; modifiers?: ModifiersArray; id?: number; parent?: Node; @@ -443,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; @@ -1009,8 +1018,8 @@ declare module "typescript" { interface EmitResolver { hasGlobalName(name: string): boolean; getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string; - hasExportDefaultValue(node: SourceFile): boolean; - isReferencedAliasDeclaration(node: Node): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; @@ -1129,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 a136cd6f59b..3903e169b4e 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 { @@ -1247,6 +1256,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -1271,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 { @@ -1311,6 +1326,11 @@ declare module "typescript" { >parserContextFlags : ParserContextFlags >ParserContextFlags : ParserContextFlags + decorators?: NodeArray; +>decorators : NodeArray +>NodeArray : NodeArray +>Decorator : Decorator + modifiers?: ModifiersArray; >modifiers : ModifiersArray >ModifiersArray : ModifiersArray @@ -1405,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 @@ -3284,16 +3312,17 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile - - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean >node : Node >Node : Node + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; +>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean +>node : Node +>Node : Node +>checkChildren : boolean + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; >isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean >node : ImportEqualsDeclaration @@ -3703,6 +3732,9 @@ declare module "typescript" { BlockScopedBindingInLoop = 256, >BlockScopedBindingInLoop : NodeCheckFlags + + EmitDecorate = 512, +>EmitDecorate : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types index 22e4b19fb25..4e9043d1b75 100644 --- a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types @@ -11,23 +11,23 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithInternalImportDeclaration_0.ts === declare module 'M' { module C { ->C : typeof X +>C : typeof C export var f: number; >f : number } class C { ->C : X +>C : C foo(): void; >foo : () => void } import X = C; ->X : typeof X ->C : X +>X : typeof C +>C : C export = X; ->X : X +>X : C } diff --git a/tests/baselines/reference/computedPropertyNames23_ES5.js b/tests/baselines/reference/computedPropertyNames23_ES5.js index c3024a7fbbf..34eb0896376 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 5651ee266c9..cac71f734a6 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/declFileImportModuleWithExportAssignment.types b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types index 94f3e57b1a6..a2ae5c07687 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.types +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types @@ -42,23 +42,23 @@ module m2 { } var m2: { ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } (): m2.connectExport; >m2 : unknown ->connectExport : default.connectExport +>connectExport : export=.connectExport test1: m2.connectModule; ->test1 : default.connectModule +>test1 : export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule test2(): m2.connectModule; ->test2 : () => default.connectModule +>test2 : () => export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule }; export = m2; ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } diff --git a/tests/baselines/reference/declarationEmitDefaultExport2.js b/tests/baselines/reference/declarationEmitDefaultExport2.js index 388bd41e4f8..687c6d67cdb 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/declareExternalModuleWithExportAssignedFundule.types b/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types index ff496f678f2..e861059af75 100644 --- a/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types +++ b/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types @@ -7,7 +7,7 @@ declare module "express" { function express(): express.ExpressServer; >express : typeof express >express : unknown ->ExpressServer : default.ExpressServer +>ExpressServer : export=.ExpressServer module express { >express : typeof express diff --git a/tests/baselines/reference/declareFileExportAssignment.types b/tests/baselines/reference/declareFileExportAssignment.types index 5853663634c..80cfbf82387 100644 --- a/tests/baselines/reference/declareFileExportAssignment.types +++ b/tests/baselines/reference/declareFileExportAssignment.types @@ -27,24 +27,24 @@ module m2 { } var m2: { ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } (): m2.connectExport; >m2 : unknown ->connectExport : default.connectExport +>connectExport : export=.connectExport test1: m2.connectModule; ->test1 : default.connectModule +>test1 : export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule test2(): m2.connectModule; ->test2 : () => default.connectModule +>test2 : () => export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule }; export = m2; ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } diff --git a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types index baa9fa1170c..376a9d7ba6f 100644 --- a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types +++ b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types @@ -28,24 +28,24 @@ module m2 { var x = 10, m2: { >x : number ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } (): m2.connectExport; >m2 : unknown ->connectExport : default.connectExport +>connectExport : export=.connectExport test1: m2.connectModule; ->test1 : default.connectModule +>test1 : export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule test2(): m2.connectModule; ->test2 : () => default.connectModule +>test2 : () => export=.connectModule >m2 : unknown ->connectModule : default.connectModule +>connectModule : export=.connectModule }; export = m2; ->m2 : { (): default.connectExport; test1: default.connectModule; test2(): default.connectModule; } +>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; } diff --git a/tests/baselines/reference/decoratorOnArrowFunction.errors.txt b/tests/baselines/reference/decoratorOnArrowFunction.errors.txt new file mode 100644 index 00000000000..14bde1e49bf --- /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 00000000000..1a327e7fc9a --- /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 00000000000..24be2517469 --- /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 00000000000..19e066586da --- /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 00000000000..92741819e94 --- /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 00000000000..43102ee9122 --- /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 00000000000..dfa430dec0c --- /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 00000000000..766acc42072 --- /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 00000000000..95bde549379 --- /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 00000000000..425aa63ac21 --- /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 00000000000..a93d625f491 --- /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 00000000000..1c967ffcc00 --- /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 00000000000..0a9fbf2956c --- /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 00000000000..0e782d45e11 --- /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 00000000000..d78e776cb96 --- /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 00000000000..fd592d7d294 --- /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 00000000000..f1bfce9ea6d --- /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 00000000000..32bb503d889 --- /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 00000000000..b75b7e0d8b6 --- /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 00000000000..f48a755953f --- /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 00000000000..77dbc569e5a --- /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 00000000000..40dd43d7e62 --- /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 00000000000..bfd6518c59b --- /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 00000000000..4b167fe8df1 --- /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 00000000000..ec22ae0b3e1 --- /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 00000000000..905e3d3b2db --- /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 00000000000..14a164eccb4 --- /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 00000000000..c61d1d218a5 --- /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 00000000000..0c86a1ccf7a --- /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 00000000000..d5ce51269bc --- /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 00000000000..5969cfca069 --- /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 00000000000..07dc7cae075 --- /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 00000000000..be9c00290fb --- /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 00000000000..760f758bbff --- /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 00000000000..cd331473b7c --- /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 00000000000..3dd38f806bd --- /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 00000000000..b7df7b9ba9c --- /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 00000000000..98539648cd0 --- /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 00000000000..b2173dedf9e --- /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 00000000000..3a011845275 --- /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 00000000000..7021e5af328 --- /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 00000000000..6d55e01e97a --- /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 00000000000..3bde0968eab --- /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 00000000000..d87de2b351a --- /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 00000000000..126dc47ad2f --- /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 00000000000..4e6629cd60a --- /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 00000000000..34fbdb53ca5 --- /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 00000000000..7e426cb773c --- /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 00000000000..629ff4e253b --- /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 00000000000..f932ab8696f --- /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 00000000000..1dcb057e530 --- /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 00000000000..cf7bfd352bf --- /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 00000000000..efc6a2c04db --- /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 00000000000..651085c7ac4 --- /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 00000000000..d55eb71e3c6 --- /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 00000000000..d0aa05589ff --- /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 00000000000..63e5f8d02e9 --- /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 00000000000..5377e53c31c --- /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 00000000000..d52baa79202 --- /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 00000000000..2d5c9fe07d7 --- /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 00000000000..29438bd67a9 --- /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 00000000000..6c9945677ca --- /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 00000000000..7f087156bc7 --- /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 00000000000..2c8c41abf78 --- /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 00000000000..8b93d0ab38e --- /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 00000000000..ba2c8383a2c --- /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 00000000000..21a6d39aab5 --- /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 00000000000..14651b65928 --- /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 00000000000..3a643bc861a --- /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 00000000000..fecff1f3413 --- /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 00000000000..bda00f1a85f --- /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 00000000000..7c1a1ff5bfe --- /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 00000000000..71aae3e13eb --- /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 00000000000..f6808674ed4 --- /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 00000000000..a09a0b01427 --- /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 00000000000..440fdb99bce --- /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 00000000000..5701afe569b --- /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 00000000000..7db2da6b2c2 --- /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 00000000000..055b43fa877 --- /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 00000000000..10b01f299bf --- /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 00000000000..2fd92dfb250 --- /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 00000000000..d69ab6f1a56 --- /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 00000000000..0d3109fe463 --- /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 00000000000..ef4fc51034f --- /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 00000000000..bd87357edad --- /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 00000000000..5240d59fda0 --- /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/duplicateExportAssignments.errors.txt b/tests/baselines/reference/duplicateExportAssignments.errors.txt index 1fc844fcaad..c0a93076981 100644 --- a/tests/baselines/reference/duplicateExportAssignments.errors.txt +++ b/tests/baselines/reference/duplicateExportAssignments.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/externalModules/foo1.ts(3,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. -tests/cases/conformance/externalModules/foo1.ts(3,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo1.ts(4,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo2.ts(3,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo2.ts(4,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo3.ts(7,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo3.ts(8,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo4.ts(1,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo4.ts(8,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo5.ts(4,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo5.ts(5,1): error TS2300: Duplicate identifier 'default'. -tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate identifier 'default'. +tests/cases/conformance/externalModules/foo1.ts(3,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo1.ts(4,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo2.ts(3,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo2.ts(4,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo3.ts(7,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo3.ts(8,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo4.ts(1,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo4.ts(8,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo5.ts(4,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo5.ts(5,1): error TS2300: Duplicate identifier 'export='. +tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate identifier 'export='. ==== tests/cases/conformance/externalModules/foo1.ts (3 errors) ==== @@ -19,20 +19,20 @@ tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate id ~~~~~~~~~~~ !!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = y; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. ==== tests/cases/conformance/externalModules/foo2.ts (2 errors) ==== var x = 10; class y {}; export = x; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = y; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. ==== tests/cases/conformance/externalModules/foo3.ts (2 errors) ==== module x { @@ -43,15 +43,15 @@ tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate id } export = x; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = y; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. ==== tests/cases/conformance/externalModules/foo4.ts (2 errors) ==== export = x; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. function x(){ return 42; } @@ -60,7 +60,7 @@ tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate id } export = y; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. ==== tests/cases/conformance/externalModules/foo5.ts (3 errors) ==== var x = 5; @@ -68,11 +68,11 @@ tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate id var z = {}; export = x; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = y; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = z; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. \ No newline at end of file diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js index 0a7ad4520c1..9cf50988247 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js @@ -13,7 +13,7 @@ var C = (function () { }; return C; })(); -module.exports = C; +exports.C = C; //// [es5ExportDefaultClassDeclaration.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js index 6687d8dd2d9..4d29fce3c10 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -13,7 +13,7 @@ var default_1 = (function () { }; return default_1; })(); -module.exports = default_1; +exports.default = default_1; //// [es5ExportDefaultClassDeclaration2.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultExpression.js b/tests/baselines/reference/es5ExportDefaultExpression.js index 43f82578999..1e14ae0bffd 100644 --- a/tests/baselines/reference/es5ExportDefaultExpression.js +++ b/tests/baselines/reference/es5ExportDefaultExpression.js @@ -4,7 +4,7 @@ export default (1 + 2); //// [es5ExportDefaultExpression.js] -module.exports = (1 + 2); +exports.default = (1 + 2); //// [es5ExportDefaultExpression.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js index a23eb361fd4..980a5ccab0f 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js @@ -6,7 +6,7 @@ export default function f() { } //// [es5ExportDefaultFunctionDeclaration.js] function f() { } -module.exports = f; +exports.f = f; //// [es5ExportDefaultFunctionDeclaration.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js index 696efe5fbb1..61f167619eb 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -6,7 +6,7 @@ export default function () { } //// [es5ExportDefaultFunctionDeclaration2.js] function () { } -module.exports = default_1; +exports.default = default_1; //// [es5ExportDefaultFunctionDeclaration2.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt b/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt deleted file mode 100644 index 7a4fdf52e88..00000000000 --- a/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/es5ExportDefaultIdentifier.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== tests/cases/compiler/es5ExportDefaultIdentifier.ts (1 errors) ==== - - export function f() { } - - export default f; - ~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - \ No newline at end of file diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.js b/tests/baselines/reference/es5ExportDefaultIdentifier.js index 0c3a601308b..81f2e9e0ace 100644 --- a/tests/baselines/reference/es5ExportDefaultIdentifier.js +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.js @@ -9,7 +9,7 @@ export default f; function f() { } exports.f = f; -module.exports = f; +exports.default = f; //// [es5ExportDefaultIdentifier.d.ts] diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.types b/tests/baselines/reference/es5ExportDefaultIdentifier.types new file mode 100644 index 00000000000..d57f7575070 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/es5ExportDefaultIdentifier.ts === + +export function f() { } +>f : () => void + +export default f; +>f : () => void + diff --git a/tests/baselines/reference/es5ModuleInternalNamedImports.errors.txt b/tests/baselines/reference/es5ModuleInternalNamedImports.errors.txt new file mode 100644 index 00000000000..65f29984d59 --- /dev/null +++ b/tests/baselines/reference/es5ModuleInternalNamedImports.errors.txt @@ -0,0 +1,59 @@ +tests/cases/compiler/es5ModuleInternalNamedImports.ts(23,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(24,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(25,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(26,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(27,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(28,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(29,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es5ModuleInternalNamedImports.ts(30,5): error TS1194: Export declarations are not permitted in an internal module. + + +==== tests/cases/compiler/es5ModuleInternalNamedImports.ts (8 errors) ==== + + export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; + + // Reexports + export {M_V as v}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_I as i}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_C as c}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_M as m}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_MU as mu}; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_F as f}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_E as e}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_A as a}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + } + \ No newline at end of file diff --git a/tests/baselines/reference/es5ModuleInternalNamedImports.js b/tests/baselines/reference/es5ModuleInternalNamedImports.js index 3d9966be7dd..456ad30523b 100644 --- a/tests/baselines/reference/es5ModuleInternalNamedImports.js +++ b/tests/baselines/reference/es5ModuleInternalNamedImports.js @@ -61,13 +61,5 @@ define(["require", "exports"], function (require, exports) { // alias M.M_A = M_M; // Reexports - M.v = M.M_V; - M.i = M_I; - M.c = M_C; - M.m = M_M; - M.mu = M_MU; - M.f = M_F; - M.e = M_E; - M.a = M.M_A; })(M = exports.M || (exports.M = {})); }); diff --git a/tests/baselines/reference/es6ExportAll.js b/tests/baselines/reference/es6ExportAll.js index 05c8a794e91..afa07c39d8f 100644 --- a/tests/baselines/reference/es6ExportAll.js +++ b/tests/baselines/reference/es6ExportAll.js @@ -19,11 +19,10 @@ export * from "server"; //// [server.js] export class c { } -var m; +export var m; (function (m) { m.x = 10; })(m || (m = {})); -export { m }; export var x = 10; //// [client.js] export * from "server"; diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index 073fbdaab38..1be3fa1f1b2 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -29,8 +29,10 @@ var m; })(m = exports.m || (exports.m = {})); exports.x = 10; //// [client.js] -var server_1 = require("server"); -for (var _a in server_1) if (!exports.hasOwnProperty(_a)) exports[_a] = server_1[_a]; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(require("server")); //// [server.d.ts] diff --git a/tests/baselines/reference/es6ExportAssignment.js b/tests/baselines/reference/es6ExportAssignment.js index 113e28108b1..4a4e0368bb7 100644 --- a/tests/baselines/reference/es6ExportAssignment.js +++ b/tests/baselines/reference/es6ExportAssignment.js @@ -5,4 +5,3 @@ export = a; //// [es6ExportAssignment.js] var a = 10; -export default a; diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js index 4fba47ea7d1..f0d9bbe8cff 100644 --- a/tests/baselines/reference/es6ExportClause.js +++ b/tests/baselines/reference/es6ExportClause.js @@ -26,8 +26,7 @@ var m; var x = 10; export { c }; export { c as c2 }; -export { i, m as instantiatedModule }; -export { uninstantiated }; +export { m as instantiatedModule }; export { x }; diff --git a/tests/baselines/reference/es6ExportClauseInEs5.js b/tests/baselines/reference/es6ExportClauseInEs5.js index 93c1015d207..f987b48aeca 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.js +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -31,12 +31,6 @@ var m; exports.instantiatedModule = m; var x = 10; exports.x = x; -exports.c = c; -exports.c2 = c; -exports.i = i; -exports.instantiatedModule = m; -exports.uninstantiated = uninstantiated; -exports.x = x; //// [es6ExportClauseInEs5.d.ts] diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js index 7952bdb0bcc..ccdd32d99c0 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js @@ -23,17 +23,15 @@ export { x } from "server"; //// [server.js] export class c { } -var m; +export var m; (function (m) { m.x = 10; })(m || (m = {})); -export { m }; export var x = 10; //// [client.js] export { c } from "server"; export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; +export { m as instantiatedModule } from "server"; export { x } from "server"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index 2bc573ce77f..6250e0ce326 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -38,12 +38,9 @@ exports.c = server_1.c; var server_2 = require("server"); exports.c2 = server_2.c; var server_3 = require("server"); -exports.i = server_3.i; exports.instantiatedModule = server_3.m; var server_4 = require("server"); -exports.uninstantiated = server_4.uninstantiated; -var server_5 = require("server"); -exports.x = server_5.x; +exports.x = server_4.x; //// [server.d.ts] diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js index 045de615c86..ac5d92b6c12 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/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index cc4206e2a5f..174c72341f6 100644 --- a/tests/baselines/reference/es6ExportEquals.errors.txt +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== tests/cases/compiler/es6ExportEquals.ts (1 errors) ==== +==== tests/cases/compiler/es6ExportEquals.ts (2 errors) ==== export function f() { } export = f; ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + ~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportEquals.js b/tests/baselines/reference/es6ExportEquals.js index d51f8740da0..68c5788c89b 100644 --- a/tests/baselines/reference/es6ExportEquals.js +++ b/tests/baselines/reference/es6ExportEquals.js @@ -8,7 +8,6 @@ export = f; //// [es6ExportEquals.js] export function f() { } -export default f; //// [es6ExportEquals.d.ts] diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt new file mode 100644 index 00000000000..7cc84187145 --- /dev/null +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -0,0 +1,304 @@ +tests/cases/compiler/main.ts(15,1): error TS2304: Cannot find name 'z1'. +tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. +tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. +tests/cases/compiler/main.ts(27,8): error TS1192: External module '"interface"' has no default export. +tests/cases/compiler/main.ts(28,8): error TS1192: External module '"variable"' has no default export. +tests/cases/compiler/main.ts(29,8): error TS1192: External module '"interface-variable"' has no default export. +tests/cases/compiler/main.ts(30,8): error TS1192: External module '"module"' has no default export. +tests/cases/compiler/main.ts(31,8): error TS1192: External module '"interface-module"' has no default export. +tests/cases/compiler/main.ts(32,8): error TS1192: External module '"variable-module"' has no default export. +tests/cases/compiler/main.ts(33,8): error TS1192: External module '"function"' has no default export. +tests/cases/compiler/main.ts(34,8): error TS1192: External module '"function-module"' has no default export. +tests/cases/compiler/main.ts(35,8): error TS1192: External module '"class"' has no default export. +tests/cases/compiler/main.ts(36,8): error TS1192: External module '"class-module"' has no default export. +tests/cases/compiler/main.ts(39,21): error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(45,21): error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(47,21): error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(62,25): error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(68,25): error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(70,25): error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(85,25): error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(91,25): error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(93,25): error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. +tests/cases/compiler/main.ts(97,15): error TS2498: External module '"interface"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(98,15): error TS2498: External module '"variable"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(99,15): error TS2498: External module '"interface-variable"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(100,15): error TS2498: External module '"module"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(101,15): error TS2498: External module '"interface-module"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(102,15): error TS2498: External module '"variable-module"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(103,15): error TS2498: External module '"function"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(104,15): error TS2498: External module '"function-module"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(105,15): error TS2498: External module '"class"' uses 'export =' and cannot be used with 'export *'. +tests/cases/compiler/main.ts(106,15): error TS2498: External module '"class-module"' uses 'export =' and cannot be used with 'export *'. + + +==== tests/cases/compiler/main.ts (32 errors) ==== + /// + + // import-equals + import z1 = require("interface"); + import z2 = require("variable"); + import z3 = require("interface-variable"); + import z4 = require("module"); + import z5 = require("interface-module"); + import z6 = require("variable-module"); + import z7 = require("function"); + import z8 = require("function-module"); + import z9 = require("class"); + import z0 = require("class-module"); + + z1.a; + ~~ +!!! error TS2304: Cannot find name 'z1'. + z2.a; + z3.a; + z4.a; + z5.a; + z6.a; + z7.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => any'. + z8.a; + z9.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'typeof Foo'. + z0.a; + + // default import + import x1 from "interface"; + ~~ +!!! error TS1192: External module '"interface"' has no default export. + import x2 from "variable"; + ~~ +!!! error TS1192: External module '"variable"' has no default export. + import x3 from "interface-variable"; + ~~ +!!! error TS1192: External module '"interface-variable"' has no default export. + import x4 from "module"; + ~~ +!!! error TS1192: External module '"module"' has no default export. + import x5 from "interface-module"; + ~~ +!!! error TS1192: External module '"interface-module"' has no default export. + import x6 from "variable-module"; + ~~ +!!! error TS1192: External module '"variable-module"' has no default export. + import x7 from "function"; + ~~ +!!! error TS1192: External module '"function"' has no default export. + import x8 from "function-module"; + ~~ +!!! error TS1192: External module '"function-module"' has no default export. + import x9 from "class"; + ~~ +!!! error TS1192: External module '"class"' has no default export. + import x0 from "class-module"; + ~~ +!!! error TS1192: External module '"class-module"' has no default export. + + // namespace import + import * as y1 from "interface"; + ~~~~~~~~~~~ +!!! error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. + import * as y2 from "variable"; + import * as y3 from "interface-variable"; + import * as y4 from "module"; + import * as y5 from "interface-module"; + import * as y6 from "variable-module"; + import * as y7 from "function"; + ~~~~~~~~~~ +!!! error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. + import * as y8 from "function-module"; + import * as y9 from "class"; + ~~~~~~~ +!!! error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. + import * as y0 from "class-module"; + + y1.a; + y2.a; + y3.a; + y4.a; + y5.a; + y6.a; + y7.a; + y8.a; + y9.a; + y0.a; + + // named import + import { a as a1 } from "interface"; + ~~~~~~~~~~~ +!!! error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. + import { a as a2 } from "variable"; + import { a as a3 } from "interface-variable"; + import { a as a4 } from "module"; + import { a as a5 } from "interface-module"; + import { a as a6 } from "variable-module"; + import { a as a7 } from "function"; + ~~~~~~~~~~ +!!! error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. + import { a as a8 } from "function-module"; + import { a as a9 } from "class"; + ~~~~~~~ +!!! error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. + import { a as a0 } from "class-module"; + + a1; + a2; + a3; + a4; + a5; + a6; + a7; + a8; + a9; + a0; + + // named export + export { a as a1 } from "interface"; + ~~~~~~~~~~~ +!!! error TS2497: External module '"interface"' resolves to a non-module entity and cannot be imported using this construct. + export { a as a2 } from "variable"; + export { a as a3 } from "interface-variable"; + export { a as a4 } from "module"; + export { a as a5 } from "interface-module"; + export { a as a6 } from "variable-module"; + export { a as a7 } from "function"; + ~~~~~~~~~~ +!!! error TS2497: External module '"function"' resolves to a non-module entity and cannot be imported using this construct. + export { a as a8 } from "function-module"; + export { a as a9 } from "class"; + ~~~~~~~ +!!! error TS2497: External module '"class"' resolves to a non-module entity and cannot be imported using this construct. + export { a as a0 } from "class-module"; + + // export-star + export * from "interface"; + ~~~~~~~~~~~ +!!! error TS2498: External module '"interface"' uses 'export =' and cannot be used with 'export *'. + export * from "variable"; + ~~~~~~~~~~ +!!! error TS2498: External module '"variable"' uses 'export =' and cannot be used with 'export *'. + export * from "interface-variable"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2498: External module '"interface-variable"' uses 'export =' and cannot be used with 'export *'. + export * from "module"; + ~~~~~~~~ +!!! error TS2498: External module '"module"' uses 'export =' and cannot be used with 'export *'. + export * from "interface-module"; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2498: External module '"interface-module"' uses 'export =' and cannot be used with 'export *'. + export * from "variable-module"; + ~~~~~~~~~~~~~~~~~ +!!! error TS2498: External module '"variable-module"' uses 'export =' and cannot be used with 'export *'. + export * from "function"; + ~~~~~~~~~~ +!!! error TS2498: External module '"function"' uses 'export =' and cannot be used with 'export *'. + export * from "function-module"; + ~~~~~~~~~~~~~~~~~ +!!! error TS2498: External module '"function-module"' uses 'export =' and cannot be used with 'export *'. + export * from "class"; + ~~~~~~~ +!!! error TS2498: External module '"class"' uses 'export =' and cannot be used with 'export *'. + export * from "class-module"; + ~~~~~~~~~~~~~~ +!!! error TS2498: External module '"class-module"' uses 'export =' and cannot be used with 'export *'. + +==== tests/cases/compiler/modules.d.ts (0 errors) ==== + + declare module "interface" { + interface Foo { + x: number; + y: number; + } + export = Foo; + } + + declare module "variable" { + var Foo: { + a: number; + b: number; + } + export = Foo; + } + + declare module "interface-variable" { + interface Foo { + x: number; + y: number; + } + var Foo: { + a: number; + b: number; + } + export = Foo; + } + + declare module "module" { + module Foo { + export var a: number; + export var b: number; + } + export = Foo; + } + + declare module "interface-module" { + interface Foo { + x: number; + y: number; + } + module Foo { + export var a: number; + export var b: number; + } + export = Foo; + } + + declare module "variable-module" { + module Foo { + interface Bar { + x: number; + y: number; + } + } + var Foo: { + a: number; + b: number; + } + export = Foo; + } + + declare module "function" { + function foo(); + export = foo; + } + + declare module "function-module" { + function foo(); + module foo { + export var a: number; + export var b: number; + } + export = foo; + } + + declare module "class" { + class Foo { + x: number; + y: number; + } + export = Foo; + } + + declare module "class-module" { + class Foo { + x: number; + y: number; + } + module Foo { + export var a: number; + export var b: number; + } + export = Foo; + } + \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js new file mode 100644 index 00000000000..747b0b2beb8 --- /dev/null +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -0,0 +1,301 @@ +//// [tests/cases/compiler/es6ExportEqualsInterop.ts] //// + +//// [modules.d.ts] + +declare module "interface" { + interface Foo { + x: number; + y: number; + } + export = Foo; +} + +declare module "variable" { + var Foo: { + a: number; + b: number; + } + export = Foo; +} + +declare module "interface-variable" { + interface Foo { + x: number; + y: number; + } + var Foo: { + a: number; + b: number; + } + export = Foo; +} + +declare module "module" { + module Foo { + export var a: number; + export var b: number; + } + export = Foo; +} + +declare module "interface-module" { + interface Foo { + x: number; + y: number; + } + module Foo { + export var a: number; + export var b: number; + } + export = Foo; +} + +declare module "variable-module" { + module Foo { + interface Bar { + x: number; + y: number; + } + } + var Foo: { + a: number; + b: number; + } + export = Foo; +} + +declare module "function" { + function foo(); + export = foo; +} + +declare module "function-module" { + function foo(); + module foo { + export var a: number; + export var b: number; + } + export = foo; +} + +declare module "class" { + class Foo { + x: number; + y: number; + } + export = Foo; +} + +declare module "class-module" { + class Foo { + x: number; + y: number; + } + module Foo { + export var a: number; + export var b: number; + } + export = Foo; +} + +//// [main.ts] +/// + +// import-equals +import z1 = require("interface"); +import z2 = require("variable"); +import z3 = require("interface-variable"); +import z4 = require("module"); +import z5 = require("interface-module"); +import z6 = require("variable-module"); +import z7 = require("function"); +import z8 = require("function-module"); +import z9 = require("class"); +import z0 = require("class-module"); + +z1.a; +z2.a; +z3.a; +z4.a; +z5.a; +z6.a; +z7.a; +z8.a; +z9.a; +z0.a; + +// default import +import x1 from "interface"; +import x2 from "variable"; +import x3 from "interface-variable"; +import x4 from "module"; +import x5 from "interface-module"; +import x6 from "variable-module"; +import x7 from "function"; +import x8 from "function-module"; +import x9 from "class"; +import x0 from "class-module"; + +// namespace import +import * as y1 from "interface"; +import * as y2 from "variable"; +import * as y3 from "interface-variable"; +import * as y4 from "module"; +import * as y5 from "interface-module"; +import * as y6 from "variable-module"; +import * as y7 from "function"; +import * as y8 from "function-module"; +import * as y9 from "class"; +import * as y0 from "class-module"; + +y1.a; +y2.a; +y3.a; +y4.a; +y5.a; +y6.a; +y7.a; +y8.a; +y9.a; +y0.a; + +// named import +import { a as a1 } from "interface"; +import { a as a2 } from "variable"; +import { a as a3 } from "interface-variable"; +import { a as a4 } from "module"; +import { a as a5 } from "interface-module"; +import { a as a6 } from "variable-module"; +import { a as a7 } from "function"; +import { a as a8 } from "function-module"; +import { a as a9 } from "class"; +import { a as a0 } from "class-module"; + +a1; +a2; +a3; +a4; +a5; +a6; +a7; +a8; +a9; +a0; + +// named export +export { a as a1 } from "interface"; +export { a as a2 } from "variable"; +export { a as a3 } from "interface-variable"; +export { a as a4 } from "module"; +export { a as a5 } from "interface-module"; +export { a as a6 } from "variable-module"; +export { a as a7 } from "function"; +export { a as a8 } from "function-module"; +export { a as a9 } from "class"; +export { a as a0 } from "class-module"; + +// export-star +export * from "interface"; +export * from "variable"; +export * from "interface-variable"; +export * from "module"; +export * from "interface-module"; +export * from "variable-module"; +export * from "function"; +export * from "function-module"; +export * from "class"; +export * from "class-module"; + + +//// [main.js] +/// +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +var z2 = require("variable"); +var z3 = require("interface-variable"); +var z4 = require("module"); +var z5 = require("interface-module"); +var z6 = require("variable-module"); +var z7 = require("function"); +var z8 = require("function-module"); +var z9 = require("class"); +var z0 = require("class-module"); +z1.a; +z2.a; +z3.a; +z4.a; +z5.a; +z6.a; +z7.a; +z8.a; +z9.a; +z0.a; +// namespace import +var y1 = require("interface"); +var y2 = require("variable"); +var y3 = require("interface-variable"); +var y4 = require("module"); +var y5 = require("interface-module"); +var y6 = require("variable-module"); +var y7 = require("function"); +var y8 = require("function-module"); +var y9 = require("class"); +var y0 = require("class-module"); +y1.a; +y2.a; +y3.a; +y4.a; +y5.a; +y6.a; +y7.a; +y8.a; +y9.a; +y0.a; +// named import +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_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")); +__export(require("interface-variable")); +__export(require("module")); +__export(require("interface-module")); +__export(require("variable-module")); +__export(require("function")); +__export(require("function-module")); +__export(require("class")); +__export(require("class-module")); diff --git a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt deleted file mode 100644 index 9ff3c1b3f04..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/es6ImportDefaultBinding_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - - -==== tests/cases/compiler/es6ImportDefaultBinding_0.ts (1 errors) ==== - - var a = 10; - export = a; - ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - -==== tests/cases/compiler/es6ImportDefaultBinding_1.ts (0 errors) ==== - import defaultBinding from "es6ImportDefaultBinding_0"; - var x = defaultBinding; - import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBinding.js b/tests/baselines/reference/es6ImportDefaultBinding.js index b169f9e80e4..2798d025894 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBinding.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBinding_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBinding_1.ts] import defaultBinding from "es6ImportDefaultBinding_0"; @@ -21,5 +21,5 @@ var x = defaultBinding; //// [es6ImportDefaultBinding_0.d.ts] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBinding.types b/tests/baselines/reference/es6ImportDefaultBinding.types new file mode 100644 index 00000000000..13504101a2c --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBinding.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es6ImportDefaultBinding_0.ts === + +var a = 10; +>a : number + +export default a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBinding_1.ts === +import defaultBinding from "es6ImportDefaultBinding_0"; +>defaultBinding : number + +var x = defaultBinding; +>x : number +>defaultBinding : number + +import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used +>defaultBinding2 : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index 34b39cda4b7..70e4f7e2f57 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingAmd_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingAmd_1.ts] import defaultBinding from "es6ImportDefaultBindingAmd_0"; @@ -14,15 +14,15 @@ import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import //// [es6ImportDefaultBindingAmd_0.js] define(["require", "exports"], function (require, exports) { var a = 10; - return a; + exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] -define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, defaultBinding) { - var x = defaultBinding; +define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, es6ImportDefaultBindingAmd_0_1) { + var x = es6ImportDefaultBindingAmd_0_1.default; }); //// [es6ImportDefaultBindingAmd_0.d.ts] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBindingAmd_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.types b/tests/baselines/reference/es6ImportDefaultBindingAmd.types index 9b067ef27a4..323ed557d8b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.types +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.types @@ -3,7 +3,7 @@ var a = 10; >a : number -export = a; +export default a; >a : number === tests/cases/compiler/es6ImportDefaultBindingAmd_1.ts === diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index 4e9719892db..caa46ed30ef 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -3,7 +3,7 @@ //// [server.ts] class c { } -export = c; +export default c; //// [client.ts] import defaultBinding from "server"; @@ -17,16 +17,16 @@ var c = (function () { } return c; })(); -module.exports = c; +exports.default = c; //// [client.js] -var defaultBinding = require("server"); -exports.x = new defaultBinding(); +var server_1 = require("server"); +exports.x = new server_1.default(); //// [server.d.ts] declare class c { } -export = c; +export default c; //// [client.d.ts] import defaultBinding from "server"; export declare var x: defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.types b/tests/baselines/reference/es6ImportDefaultBindingDts.types index 62f54168c36..65754d80680 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.types +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.types @@ -3,7 +3,7 @@ class c { } >c : c -export = c; +export default c; >c : c === tests/cases/compiler/client.ts === diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index 5e71478e5a1..34bb303a571 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -1,10 +1,4 @@ error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(4,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(6,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(9,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(11,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. !!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. @@ -13,30 +7,19 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(11,8): export var a = 10; export var x = a; export var m = a; + export default {}; -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (6 errors) ==== +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (0 errors) ==== import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. var x1: number = a; import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. var x1: number = b; import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. var x1: number = x; var x1: number = y; import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. var x1: number = z; import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. var x1: number = m; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 7d0d4b2582d..eef23579212 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -5,6 +5,7 @@ export var a = 10; export var x = a; export var m = a; +export default {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.ts] import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; @@ -25,6 +26,7 @@ var x1: number = m; export var a = 10; export var x = a; export var m = a; +export default {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] import { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1 = a; @@ -43,4 +45,5 @@ var x1 = m; export declare var a: number; export declare var x: number; export declare var m: number; +export default : {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt index a780f7cec30..21f488e9ca5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. @@ -7,12 +6,10 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (1 errors) ==== +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (0 errors) ==== var a = 10; - export = a; - ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + export default a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts (6 errors) ==== import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js index 3c8a4080ba7..755af6f4fdb 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingFollowedWithNamedImport1_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1_1.ts] import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; @@ -40,5 +40,5 @@ var x1 = defaultBinding6; //// [es6ImportDefaultBindingFollowedWithNamedImport1_0.d.ts] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt index 9783ad4921e..5809e0874dc 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt @@ -9,7 +9,7 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(1 ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts (0 errors) ==== var a = 10; - export = a; + export default a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts (6 errors) ==== import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 2690e7a7f51..15ca1284a1e 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts] import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; @@ -22,23 +22,23 @@ var x: number = defaultBinding6; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.js] var a = 10; -module.exports = a; +exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] -var defaultBinding1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding1; -var defaultBinding2 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding2; -var defaultBinding3 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding3; -var defaultBinding4 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding4; -var defaultBinding5 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding5; -var defaultBinding6 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -var x = defaultBinding6; +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] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt index 9b246f803a0..aa9e0cb3af3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil ==== tests/cases/compiler/server.ts (0 errors) ==== var a = 10; - export = a; + export default a; ==== tests/cases/compiler/client.ts (12 errors) ==== export import defaultBinding1, { } from "server"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 0239b68194f..b6b03176df1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -3,7 +3,7 @@ //// [server.ts] var a = 10; -export = a; +export default a; //// [client.ts] export import defaultBinding1, { } from "server"; @@ -22,25 +22,25 @@ export var x1: number = defaultBinding6; //// [server.js] var a = 10; -module.exports = a; +exports.default = a; //// [client.js] -var defaultBinding1 = require("server"); -exports.x1 = defaultBinding1; -var defaultBinding2 = require("server"); -exports.x1 = defaultBinding2; -var defaultBinding3 = require("server"); -exports.x1 = defaultBinding3; -var defaultBinding4 = require("server"); -exports.x1 = defaultBinding4; -var defaultBinding5 = require("server"); -exports.x1 = defaultBinding5; -var defaultBinding6 = require("server"); -exports.x1 = defaultBinding6; +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] declare var a: number; -export = a; +export default a; //// [client.d.ts] export declare var x1: number; export declare var x1: number; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt index bff47ba36ef..409c50d3a3f 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. -tests/cases/compiler/client.ts(2,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. -tests/cases/compiler/client.ts(4,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. -tests/cases/compiler/client.ts(6,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. -tests/cases/compiler/client.ts(9,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. -tests/cases/compiler/client.ts(11,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. +tests/cases/compiler/client.ts(2,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. +tests/cases/compiler/client.ts(4,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. +tests/cases/compiler/client.ts(6,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. +tests/cases/compiler/client.ts(9,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. +tests/cases/compiler/client.ts(11,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -18,26 +18,26 @@ tests/cases/compiler/client.ts(11,8): error TS1192: External module '"tests/case ==== tests/cases/compiler/client.ts (6 errors) ==== import defaultBinding1, { } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. import defaultBinding2, { a } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x1 = new a(); import defaultBinding3, { a11 as b } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x2 = new b(); import defaultBinding4, { x, a12 as y } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x4 = new x(); export var x5 = new y(); import defaultBinding5, { x11 as z, } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x3 = new z(); import defaultBinding6, { m, } from "server"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x6 = new m(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt index 405fab0de50..0e259f142b6 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt @@ -9,7 +9,7 @@ tests/cases/compiler/client.ts(11,27): error TS2305: Module '"tests/cases/compil ==== tests/cases/compiler/server.ts (0 errors) ==== class a { } - export = a; + export default a; ==== tests/cases/compiler/client.ts (6 errors) ==== import defaultBinding1, { } from "server"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index 21ddcbc71d6..e6211ac1ebe 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -3,7 +3,7 @@ //// [server.ts] class a { } -export = a; +export default a; //// [client.ts] import defaultBinding1, { } from "server"; @@ -25,26 +25,26 @@ var a = (function () { } return a; })(); -module.exports = a; +exports.default = a; //// [client.js] -var defaultBinding1 = require("server"); -exports.x1 = new defaultBinding1(); -var defaultBinding2 = require("server"); -exports.x2 = new defaultBinding2(); -var defaultBinding3 = require("server"); -exports.x3 = new defaultBinding3(); -var defaultBinding4 = require("server"); -exports.x4 = new defaultBinding4(); -var defaultBinding5 = require("server"); -exports.x5 = new defaultBinding5(); -var defaultBinding6 = require("server"); -exports.x6 = new defaultBinding6(); +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] declare class a { } -export = a; +export default a; //// [client.d.ts] import defaultBinding1 from "server"; export declare var x1: defaultBinding1; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt index 0377e543973..502b1940576 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(4,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(6,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(9,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(4,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(6,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(9,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.ts (0 errors) ==== @@ -15,26 +15,26 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11 ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (6 errors) ==== import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = a; import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = b; import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = x; var x1: number = y; import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = z; import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = m; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt index a9a2ed4974d..83f91787b87 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt @@ -1,15 +1,9 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(1,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(2,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(4,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(6,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(9,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(11,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -17,42 +11,31 @@ tests/cases/compiler/client.ts(11,15): error TS1192: External module '"tests/cas export var a = 10; export var x = a; export var m = a; + export default {}; -==== tests/cases/compiler/client.ts (12 errors) ==== +==== tests/cases/compiler/client.ts (6 errors) ==== export import defaultBinding1, { } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export import defaultBinding2, { a } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export var x1: number = a; export import defaultBinding3, { a as b } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export var x1: number = b; export import defaultBinding4, { x, a as y } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export var x1: number = x; export var x1: number = y; export import defaultBinding5, { x as z, } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export var x1: number = z; export import defaultBinding6, { m, } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - ~~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. export var x1: number = m; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js index af73279126f..0d5f38c0be4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -5,6 +5,7 @@ export var a = 10; export var x = a; export var m = a; +export default {}; //// [client.ts] export import defaultBinding1, { } from "server"; @@ -26,6 +27,7 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; exports.x = exports.a; exports.m = exports.a; + 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) { @@ -42,6 +44,7 @@ define(["require", "exports", "server", "server", "server", "server", "server"], export declare var a: number; export declare var x: number; export declare var m: number; +export default : {}; //// [client.d.ts] export declare var x1: number; export declare var x1: number; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt index 851a5189a54..ce7e8b1dc5d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (0 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1, ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt deleted file mode 100644 index 2a0f3ad5485..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - - -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (1 errors) ==== - - var a = 10; - export = a; - ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (0 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; - var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js index 927ed3243e7..a732cf9ec0a 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; @@ -19,5 +19,5 @@ var x = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types new file mode 100644 index 00000000000..c0c3f891c9e --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts === + +var a = 10; +>a : number + +export default a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +>defaultBinding : number +>nameSpaceBinding : typeof nameSpaceBinding + +var x: number = defaultBinding; +>x : number +>defaultBinding : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 00166b1bc41..c2bd5476a7c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; @@ -11,13 +11,13 @@ var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] var a = 10; -module.exports = a; +exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); -var x = defaultBinding; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.d.ts] declare var a: number; -export = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types index dfbc8c0be07..ad2b865bc01 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -3,7 +3,7 @@ var a = 10; >a : number -export = a; +export default a; >a : number === tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt index 5df6817e897..f738abc9bc1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot ==== tests/cases/compiler/server.ts (0 errors) ==== var a = 10; - export = a; + export default a; ==== tests/cases/compiler/client.ts (1 errors) ==== export import defaultBinding, * as nameSpaceBinding from "server"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index d1dd565c81b..ed40582e923 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -3,7 +3,7 @@ //// [server.ts] var a = 10; -export = a; +export default a; //// [client.ts] export import defaultBinding, * as nameSpaceBinding from "server"; @@ -12,16 +12,17 @@ export var x: number = defaultBinding; //// [server.js] define(["require", "exports"], function (require, exports) { var a = 10; - return a; + exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, defaultBinding) { - exports.x = defaultBinding; +define(["require", "exports", "server"], function (require, exports, server_1) { + var nameSpaceBinding = server_1; + exports.x = server_1.default; }); //// [server.d.ts] declare var a: number; -export = a; +export default a; //// [client.d.ts] export declare var x: number; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt index f8dd391fe0e..8af978d3bb6 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases ==== tests/cases/compiler/client.ts (1 errors) ==== import defaultBinding, * as nameSpaceBinding from "server"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 4bde6e25b10..31ef01c464c 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 nameSpaceBinding = require("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 69b76d79fbb..e03ded5fd5a 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -3,7 +3,7 @@ //// [server.ts] class a { } -export = a; +export default a; //// [client.ts] import defaultBinding, * as nameSpaceBinding from "server"; @@ -16,18 +16,19 @@ define(["require", "exports"], function (require, exports) { } return a; })(); - return a; + exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, defaultBinding) { - exports.x = new defaultBinding(); +define(["require", "exports", "server"], function (require, exports, server_1) { + var nameSpaceBinding = server_1; + exports.x = new server_1.default(); }); //// [server.d.ts] declare class a { } -export = a; +export default a; //// [client.d.ts] import defaultBinding from "server"; export declare var x: defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.types index e40d3893ee2..990bae10af6 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.types @@ -3,7 +3,7 @@ class a { } >a : a -export = a; +export default a; >a : a === tests/cases/compiler/client.ts === diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt index d4d51e4d5ab..48829f8e719 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export or export assignment. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts (0 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts (1 errors) ==== import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 9131fcc75db..4a49d3c2d6f 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 nameSpaceBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt index 3e06e7acae8..4730d493d8e 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. -tests/cases/compiler/client.ts(1,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(1,15): error TS1192: External module '"tests/cases/compiler/server"' has no default export. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -11,5 +11,5 @@ tests/cases/compiler/client.ts(1,15): error TS1192: External module '"tests/case ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export. export var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index b219b5e7876..df233fe18a5 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 nameSpaceBinding = require("server"); +var server_1 = require("server"), nameSpaceBinding = server_1; exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt new file mode 100644 index 00000000000..5cccfd01094 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. + + +==== tests/cases/compiler/es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== + import defaultBinding from "es6ImportDefaultBindingInEs5_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types deleted file mode 100644 index 03243fc014d..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/es6ImportDefaultBindingInEs5_0.ts === - -var a = 10; ->a : number - -export = a; ->a : number - -=== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts === -import defaultBinding from "es6ImportDefaultBindingInEs5_0"; ->defaultBinding : number - diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt index d6aacf0ba40..cd0550609c7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(8,8): error TS2300: ==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_0.ts (0 errors) ==== var a = 10; - export = a; + export default a; ==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts (3 errors) ==== import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 628faec6c27..1208ace5dde 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -3,7 +3,7 @@ //// [es6ImportDefaultBindingMergeErrors_0.ts] var a = 10; -export = a; +export default a; //// [es6ImportDefaultBindingMergeErrors_1.ts] import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; @@ -18,8 +18,8 @@ import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be //// [es6ImportDefaultBindingMergeErrors_0.js] var a = 10; -module.exports = a; +exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] -var defaultBinding = require("es6ImportDefaultBindingMergeErrors_0"); -var x = defaultBinding; +var es6ImportDefaultBindingMergeErrors_0_1 = require("es6ImportDefaultBindingMergeErrors_0"); +var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt index a6aaf9f5508..43eaa16f639 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export or export assignment. +tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. ==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0.ts (0 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error T ==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt index e0dfdc00e07..1bd24e84926 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot ==== tests/cases/compiler/server.ts (0 errors) ==== var a = 10; - export = a; + export default a; ==== tests/cases/compiler/client.ts (2 errors) ==== export import defaultBinding from "server"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index a3f8dd11c6c..e2c5fab4c94 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -3,7 +3,7 @@ //// [server.ts] var a = 10; -export = a; +export default a; //// [client.ts] export import defaultBinding from "server"; @@ -13,16 +13,16 @@ export import defaultBinding2 from "server"; // non referenced //// [server.js] define(["require", "exports"], function (require, exports) { var a = 10; - return a; + exports.default = a; }); //// [client.js] -define(["require", "exports", "server"], function (require, exports, defaultBinding) { - exports.x = defaultBinding; +define(["require", "exports", "server"], function (require, exports, server_1) { + exports.x = server_1.default; }); //// [server.d.ts] declare var a: number; -export = a; +export default a; //// [client.d.ts] export declare var x: number; diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.js b/tests/baselines/reference/es6ImportEqualsDeclaration.js index b8e9777a894..5195bdc631b 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration.js +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.js @@ -10,5 +10,4 @@ import a = require("server"); //// [server.js] var a = 10; -export default a; //// [client.js] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types index 3ba19cef9b4..e1f2e89bbd8 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -8,5 +8,5 @@ export = a; === tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error ->nameSpaceBinding : typeof nameSpaceBinding +>nameSpaceBinding : number diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js index ea9e65db34a..eab345e4e7f 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -12,7 +12,6 @@ export = a; export var a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] import { a } from "es6ImportNamedImportInExportAssignment_0"; -export default a; //// [es6ImportNamedImportInExportAssignment_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt index 22428100985..c9586d01693 100644 --- a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,10): error TS1141: tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,12): error TS1109: Expression expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS2304: Cannot find name 'from'. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,19): error TS1005: ';' expected. -tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export or export assignment. +tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,24): error TS1005: '{' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,1): error TS1128: Declaration or statement expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,8): error TS1128: Declaration or statement expected. @@ -34,7 +34,7 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: !!! error TS1005: ';' expected. import defaultBinding, from "es6ImportNamedImportParsingError_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export or export assignment. +!!! error TS1192: External module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export. ~~~~ !!! error TS1005: '{' expected. import , { a } from "es6ImportNamedImportParsingError_0"; diff --git a/tests/baselines/reference/es6ModuleClassDeclaration.js b/tests/baselines/reference/es6ModuleClassDeclaration.js index 9676720fd0f..a228739abbf 100644 --- a/tests/baselines/reference/es6ModuleClassDeclaration.js +++ b/tests/baselines/reference/es6ModuleClassDeclaration.js @@ -147,7 +147,7 @@ c2.k = 20; c2.l = 30; new c(); new c2(); -var m1; +export var m1; (function (m1) { class c3 { constructor() { @@ -187,7 +187,6 @@ var m1; new c3(); new c4(); })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { class c3 { diff --git a/tests/baselines/reference/es6ModuleConst.js b/tests/baselines/reference/es6ModuleConst.js index 2a11ec638a1..117bf0fb4d0 100644 --- a/tests/baselines/reference/es6ModuleConst.js +++ b/tests/baselines/reference/es6ModuleConst.js @@ -21,14 +21,13 @@ export const a = "hello"; export const x = a, y = x; const b = y; const c = b, d = c; -var m1; +export var m1; (function (m1) { m1.k = a; m1.l = b, m1.m = m1.k; const n = m1.k; const o = n, p = m1.k; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { m2.k = a; diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration.js b/tests/baselines/reference/es6ModuleConstEnumDeclaration.js index c8096c76c8e..1900db57b60 100644 --- a/tests/baselines/reference/es6ModuleConstEnumDeclaration.js +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration.js @@ -48,14 +48,13 @@ module m2 { //// [es6ModuleConstEnumDeclaration.js] var x = 0 /* a */; var y = 0 /* x */; -var m1; +export var m1; (function (m1) { var x1 = 0 /* a */; var y1 = 0 /* x */; var x2 = 0 /* a */; var y2 = 0 /* x */; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { var x1 = 0 /* a */; diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js index 5ec953aca88..539ec121b6b 100644 --- a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js @@ -47,13 +47,12 @@ module m2 { } //// [es6ModuleConstEnumDeclaration2.js] -var e1; +export var e1; (function (e1) { e1[e1["a"] = 0] = "a"; e1[e1["b"] = 1] = "b"; e1[e1["c"] = 2] = "c"; })(e1 || (e1 = {})); -export { e1 }; var e2; (function (e2) { e2[e2["x"] = 0] = "x"; @@ -62,7 +61,7 @@ var e2; })(e2 || (e2 = {})); var x = 0 /* a */; var y = 0 /* x */; -var m1; +export var m1; (function (m1) { (function (e3) { e3[e3["a"] = 0] = "a"; @@ -81,7 +80,6 @@ var m1; var x2 = 0 /* a */; var y2 = 0 /* x */; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { (function (e5) { diff --git a/tests/baselines/reference/es6ModuleEnumDeclaration.js b/tests/baselines/reference/es6ModuleEnumDeclaration.js index 08792149818..30c382a4508 100644 --- a/tests/baselines/reference/es6ModuleEnumDeclaration.js +++ b/tests/baselines/reference/es6ModuleEnumDeclaration.js @@ -46,13 +46,12 @@ module m2 { } //// [es6ModuleEnumDeclaration.js] -var e1; +export var e1; (function (e1) { e1[e1["a"] = 0] = "a"; e1[e1["b"] = 1] = "b"; e1[e1["c"] = 2] = "c"; })(e1 || (e1 = {})); -export { e1 }; var e2; (function (e2) { e2[e2["x"] = 0] = "x"; @@ -61,7 +60,7 @@ var e2; })(e2 || (e2 = {})); var x = e1.a; var y = e2.x; -var m1; +export var m1; (function (m1) { (function (e3) { e3[e3["a"] = 0] = "a"; @@ -80,7 +79,6 @@ var m1; var x2 = e3.a; var y2 = e4.x; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { (function (e5) { diff --git a/tests/baselines/reference/es6ModuleFunctionDeclaration.js b/tests/baselines/reference/es6ModuleFunctionDeclaration.js index 4c1fc33647c..1305d0a4e19 100644 --- a/tests/baselines/reference/es6ModuleFunctionDeclaration.js +++ b/tests/baselines/reference/es6ModuleFunctionDeclaration.js @@ -35,7 +35,7 @@ function foo2() { } foo(); foo2(); -var m1; +export var m1; (function (m1) { function foo3() { } @@ -47,7 +47,6 @@ var m1; foo3(); foo4(); })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { function foo3() { diff --git a/tests/baselines/reference/es6ModuleInternalImport.js b/tests/baselines/reference/es6ModuleInternalImport.js index 4a1659cb901..3f28ddb2b60 100644 --- a/tests/baselines/reference/es6ModuleInternalImport.js +++ b/tests/baselines/reference/es6ModuleInternalImport.js @@ -20,22 +20,20 @@ module m2 { } //// [es6ModuleInternalImport.js] -var m; +export var m; (function (m) { m.a = 10; })(m || (m = {})); -export { m }; export var a1 = m.a; var a2 = m.a; var x = a1 + a2; -var m1; +export var m1; (function (m1) { m1.a3 = m.a; var a4 = m.a; var x = a1 + a2; var x2 = m1.a3 + a4; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { m2.a3 = m.a; diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports.errors.txt b/tests/baselines/reference/es6ModuleInternalNamedImports.errors.txt new file mode 100644 index 00000000000..4e097ec1a33 --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalNamedImports.errors.txt @@ -0,0 +1,59 @@ +tests/cases/compiler/es6ModuleInternalNamedImports.ts(23,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(24,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(25,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(26,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(27,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(28,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(29,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports.ts(30,5): error TS1194: Export declarations are not permitted in an internal module. + + +==== tests/cases/compiler/es6ModuleInternalNamedImports.ts (8 errors) ==== + + export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; + + // Reexports + export {M_V as v}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_I as i}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_C as c}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_M as m}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_MU as mu}; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_F as f}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_E as e}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_A as a}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + } + \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports.js b/tests/baselines/reference/es6ModuleInternalNamedImports.js index 532025c4ee6..db7c771eaba 100644 --- a/tests/baselines/reference/es6ModuleInternalNamedImports.js +++ b/tests/baselines/reference/es6ModuleInternalNamedImports.js @@ -33,7 +33,7 @@ export module M { //// [es6ModuleInternalNamedImports.js] -var M; +export var M; (function (M) { // variable M.M_V = 0; @@ -57,13 +57,10 @@ var M; // alias M.M_A = M_M; // Reexports - M.v = M.M_V; - M.i = M_I; - M.c = M_C; - M.m = M_M; - M.mu = M_MU; - M.f = M_F; - M.e = M_E; - M.a = M.M_A; + export { M_V as v }; + export { M_C as c }; + export { M_M as m }; + export { M_F as f }; + export { M_E as e }; + export { M_A as a }; })(M || (M = {})); -export { M }; diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports.types b/tests/baselines/reference/es6ModuleInternalNamedImports.types deleted file mode 100644 index 6b614926a0a..00000000000 --- a/tests/baselines/reference/es6ModuleInternalNamedImports.types +++ /dev/null @@ -1,77 +0,0 @@ -=== tests/cases/compiler/es6ModuleInternalNamedImports.ts === - -export module M { ->M : typeof M - - // variable - export var M_V = 0; ->M_V : number - - // interface - export interface M_I { } ->M_I : M_I - - //calss - export class M_C { } ->M_C : M_C - - // instantiated module - export module M_M { var x; } ->M_M : typeof M_M ->x : any - - // uninstantiated module - export module M_MU { } ->M_MU : unknown - - // function - export function M_F() { } ->M_F : () => void - - // enum - export enum M_E { } ->M_E : M_E - - // type - export type M_T = number; ->M_T : number - - // alias - export import M_A = M_M; ->M_A : typeof M_M ->M_M : typeof M_M - - // Reexports - export {M_V as v}; ->M_V : number ->v : number - - export {M_I as i}; ->M_I : unknown ->i : unknown - - export {M_C as c}; ->M_C : typeof M_C ->c : typeof M_C - - export {M_M as m}; ->M_M : typeof M_M ->m : typeof M_M - - export {M_MU as mu}; ->M_MU : unknown ->mu : unknown - - export {M_F as f}; ->M_F : () => void ->f : () => void - - export {M_E as e}; ->M_E : typeof M_E ->e : typeof M_E - - export {M_A as a}; ->M_A : typeof M_M ->a : typeof M_M -} - diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports2.errors.txt b/tests/baselines/reference/es6ModuleInternalNamedImports2.errors.txt new file mode 100644 index 00000000000..77ee76cf9c8 --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalNamedImports2.errors.txt @@ -0,0 +1,61 @@ +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(25,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(26,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(27,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(28,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(29,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(30,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(31,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/es6ModuleInternalNamedImports2.ts(32,5): error TS1194: Export declarations are not permitted in an internal module. + + +==== tests/cases/compiler/es6ModuleInternalNamedImports2.ts (8 errors) ==== + + export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; + } + + export module M { + // Reexports + export {M_V as v}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_I as i}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_C as c}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_M as m}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_MU as mu}; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_F as f}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_E as e}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + export {M_A as a}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + } + \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports2.js b/tests/baselines/reference/es6ModuleInternalNamedImports2.js new file mode 100644 index 00000000000..b0800643060 --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalNamedImports2.js @@ -0,0 +1,71 @@ +//// [es6ModuleInternalNamedImports2.ts] + +export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; +} + +export module M { + // Reexports + export {M_V as v}; + export {M_I as i}; + export {M_C as c}; + export {M_M as m}; + export {M_MU as mu}; + export {M_F as f}; + export {M_E as e}; + export {M_A as a}; +} + + +//// [es6ModuleInternalNamedImports2.js] +export var M; +(function (M) { + // variable + M.M_V = 0; + //calss + class M_C { + } + M.M_C = M_C; + // instantiated module + var M_M; + (function (M_M) { + var x; + })(M_M = M.M_M || (M.M_M = {})); + // function + function M_F() { + } + M.M_F = M_F; + // enum + (function (M_E) { + })(M.M_E || (M.M_E = {})); + var M_E = M.M_E; + // alias + M.M_A = M_M; +})(M || (M = {})); +export var M; +(function (M) { + // Reexports + export { M_V as v }; + export { M_C as c }; + export { M_M as m }; + export { M_F as f }; + export { M_E as e }; + export { M_A as a }; +})(M || (M = {})); diff --git a/tests/baselines/reference/es6ModuleLet.js b/tests/baselines/reference/es6ModuleLet.js index 275fd39579e..29d2a73bcf1 100644 --- a/tests/baselines/reference/es6ModuleLet.js +++ b/tests/baselines/reference/es6ModuleLet.js @@ -21,14 +21,13 @@ export let a = "hello"; export let x = a, y = x; let b = y; let c = b, d = c; -var m1; +export var m1; (function (m1) { m1.k = a; m1.l = b, m1.m = m1.k; let n = m1.k; let o = n, p = m1.k; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { m2.k = a; diff --git a/tests/baselines/reference/es6ModuleModuleDeclaration.js b/tests/baselines/reference/es6ModuleModuleDeclaration.js index 1e3716ac8c2..c240545239f 100644 --- a/tests/baselines/reference/es6ModuleModuleDeclaration.js +++ b/tests/baselines/reference/es6ModuleModuleDeclaration.js @@ -25,7 +25,7 @@ module m2 { } //// [es6ModuleModuleDeclaration.js] -var m1; +export var m1; (function (m1) { m1.a = 10; var b = 10; @@ -40,7 +40,6 @@ var m1; var y = 10; })(innerNonExportedModule = m1.innerNonExportedModule || (m1.innerNonExportedModule = {})); })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { m2.a = 10; diff --git a/tests/baselines/reference/es6ModuleVariableStatement.js b/tests/baselines/reference/es6ModuleVariableStatement.js index 11b60555b0d..50c9c3fb4a8 100644 --- a/tests/baselines/reference/es6ModuleVariableStatement.js +++ b/tests/baselines/reference/es6ModuleVariableStatement.js @@ -21,14 +21,13 @@ export var a = "hello"; export var x = a, y = x; var b = y; var c = b, d = c; -var m1; +export var m1; (function (m1) { m1.k = a; m1.l = b, m1.m = m1.k; var n = m1.k; var o = n, p = m1.k; })(m1 || (m1 = {})); -export { m1 }; var m2; (function (m2) { m2.k = a; diff --git a/tests/baselines/reference/exportAssignClassAndModule.types b/tests/baselines/reference/exportAssignClassAndModule.types index 9087ac09633..05a5cbf07ae 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.types +++ b/tests/baselines/reference/exportAssignClassAndModule.types @@ -22,9 +22,9 @@ class Foo { >Foo : Foo x: Foo.Bar; ->x : default.Bar +>x : export=.Bar >Foo : unknown ->Bar : default.Bar +>Bar : export=.Bar } module Foo { >Foo : typeof Foo diff --git a/tests/baselines/reference/exportDefaultForNonInstantiatedModule.js b/tests/baselines/reference/exportDefaultForNonInstantiatedModule.js new file mode 100644 index 00000000000..f2b98e6eb44 --- /dev/null +++ b/tests/baselines/reference/exportDefaultForNonInstantiatedModule.js @@ -0,0 +1,10 @@ +//// [exportDefaultForNonInstantiatedModule.ts] + +module m { + export interface foo { + } +} +// Should not be emitted +export default m; + +//// [exportDefaultForNonInstantiatedModule.js] diff --git a/tests/baselines/reference/exportDefaultForNonInstantiatedModule.types b/tests/baselines/reference/exportDefaultForNonInstantiatedModule.types new file mode 100644 index 00000000000..940bb44658e --- /dev/null +++ b/tests/baselines/reference/exportDefaultForNonInstantiatedModule.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/exportDefaultForNonInstantiatedModule.ts === + +module m { +>m : unknown + + export interface foo { +>foo : foo + } +} +// Should not be emitted +export default m; +>m : unknown + diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation.js b/tests/baselines/reference/exportDefaultTypeAnnoation.js index 8adf31a5f18..71a829ac284 100644 --- a/tests/baselines/reference/exportDefaultTypeAnnoation.js +++ b/tests/baselines/reference/exportDefaultTypeAnnoation.js @@ -3,4 +3,4 @@ export default : number; //// [exportDefaultTypeAnnoation.js] -module.exports = ; +exports.default = ; diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation3.js b/tests/baselines/reference/exportDefaultTypeAnnoation3.js index b29e7d2d9bc..1f95e669de5 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 d = require("mod"); -var s = d; // Error +var mod_1 = require("mod"); +var s = mod_1.default; // Error //// [reference2.js] var mod_1 = require("mod"); var s = mod_1.default; // Error diff --git a/tests/baselines/reference/exportEqualNamespaces.types b/tests/baselines/reference/exportEqualNamespaces.types index b60ba5a85c0..b94770837a4 100644 --- a/tests/baselines/reference/exportEqualNamespaces.types +++ b/tests/baselines/reference/exportEqualNamespaces.types @@ -12,7 +12,7 @@ interface server { (): server.Server; >server : unknown ->Server : default.Server +>Server : export=.Server startTime: Date; >startTime : Date diff --git a/tests/baselines/reference/exportStar-amd.errors.txt b/tests/baselines/reference/exportStar-amd.errors.txt new file mode 100644 index 00000000000..87e4c4740a0 --- /dev/null +++ b/tests/baselines/reference/exportStar-amd.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export. + + +==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ==== + + export var x = 1; + export var y = 2; + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export default "hello"; + export function foo() { } + +==== tests/cases/conformance/es6/modules/t3.ts (0 errors) ==== + var x = "x"; + var y = "y"; + var z = "z"; + export { x, y, z }; + +==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ==== + export * from "./t1"; + export * from "./t2"; + export * from "./t3"; + +==== tests/cases/conformance/es6/modules/main.ts (1 errors) ==== + import hello, { x, y, z, foo } from "./t4"; + ~~~~~ +!!! error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export. + hello; + x; + y; + z; + foo; + \ No newline at end of file diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js new file mode 100644 index 00000000000..fb04aa208b2 --- /dev/null +++ b/tests/baselines/reference/exportStar-amd.js @@ -0,0 +1,69 @@ +//// [tests/cases/conformance/es6/modules/exportStar-amd.ts] //// + +//// [t1.ts] + +export var x = 1; +export var y = 2; + +//// [t2.ts] +export default "hello"; +export function foo() { } + +//// [t3.ts] +var x = "x"; +var y = "y"; +var z = "z"; +export { x, y, z }; + +//// [t4.ts] +export * from "./t1"; +export * from "./t2"; +export * from "./t3"; + +//// [main.ts] +import hello, { x, y, z, foo } from "./t4"; +hello; +x; +y; +z; +foo; + + +//// [t1.js] +define(["require", "exports"], function (require, exports) { + exports.x = 1; + exports.y = 2; +}); +//// [t2.js] +define(["require", "exports"], function (require, exports) { + exports.default = "hello"; + function foo() { + } + exports.foo = foo; +}); +//// [t3.js] +define(["require", "exports"], function (require, exports) { + var x = "x"; + exports.x = x; + var y = "y"; + exports.y = y; + var z = "z"; + exports.z = z; +}); +//// [t4.js] +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_1); + __export(t2_1); + __export(t3_1); +}); +//// [main.js] +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.errors.txt b/tests/baselines/reference/exportStar.errors.txt new file mode 100644 index 00000000000..87e4c4740a0 --- /dev/null +++ b/tests/baselines/reference/exportStar.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export. + + +==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ==== + + export var x = 1; + export var y = 2; + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export default "hello"; + export function foo() { } + +==== tests/cases/conformance/es6/modules/t3.ts (0 errors) ==== + var x = "x"; + var y = "y"; + var z = "z"; + export { x, y, z }; + +==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ==== + export * from "./t1"; + export * from "./t2"; + export * from "./t3"; + +==== tests/cases/conformance/es6/modules/main.ts (1 errors) ==== + import hello, { x, y, z, foo } from "./t4"; + ~~~~~ +!!! error TS1192: External module '"tests/cases/conformance/es6/modules/t4"' has no default export. + hello; + x; + y; + z; + foo; + \ No newline at end of file diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js new file mode 100644 index 00000000000..9fca12af8b1 --- /dev/null +++ b/tests/baselines/reference/exportStar.js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/es6/modules/exportStar.ts] //// + +//// [t1.ts] + +export var x = 1; +export var y = 2; + +//// [t2.ts] +export default "hello"; +export function foo() { } + +//// [t3.ts] +var x = "x"; +var y = "y"; +var z = "z"; +export { x, y, z }; + +//// [t4.ts] +export * from "./t1"; +export * from "./t2"; +export * from "./t3"; + +//// [main.ts] +import hello, { x, y, z, foo } from "./t4"; +hello; +x; +y; +z; +foo; + + +//// [t1.js] +exports.x = 1; +exports.y = 2; +//// [t2.js] +exports.default = "hello"; +function foo() { +} +exports.foo = foo; +//// [t3.js] +var x = "x"; +exports.x = x; +var y = "y"; +exports.y = y; +var z = "z"; +exports.z = z; +//// [t4.js] +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(require("./t1")); +__export(require("./t2")); +__export(require("./t3")); +//// [main.js] +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 new file mode 100644 index 00000000000..99c6fe8d43f --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1-amd.js @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports1-amd.ts] //// + +//// [t1.ts] + +var v = 1; +function f() { } +class C { +} +interface I { +} +enum E { + A, B, C +} +const enum D { + A, B, C +} +module M { + export var x; +} +module N { + export interface I { + } +} +type T = number; +import a = M.x; + +export { v, f, C, I, E, D, M, N, T, a }; + +//// [t2.ts] +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +//// [t3.ts] +import { v, f, C, I, E, D, M, N, T, a } from "./t1"; +export { v, f, C, I, E, D, M, N, T, a }; + + +//// [t1.js] +define(["require", "exports"], function (require, exports) { + var v = 1; + exports.v = v; + function f() { + } + exports.f = f; + var C = (function () { + function C() { + } + return C; + })(); + exports.C = C; + var E; + (function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; + E[E["C"] = 2] = "C"; + })(E || (E = {})); + exports.E = E; + var M; + (function (M) { + M.x; + })(M || (M = {})); + exports.M = M; + var a = M.x; + exports.a = a; +}); +//// [t2.js] +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_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-amd.types b/tests/baselines/reference/exportsAndImports1-amd.types new file mode 100644 index 00000000000..0b35b04e22e --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1-amd.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +var v = 1; +>v : number + +function f() { } +>f : () => void + +class C { +>C : C +} +interface I { +>I : I +} +enum E { +>E : E + + A, B, C +>A : E +>B : E +>C : E +} +const enum D { +>D : D + + A, B, C +>A : D +>B : D +>C : D +} +module M { +>M : typeof M + + export var x; +>x : any +} +module N { +>N : unknown + + export interface I { +>I : I + } +} +type T = number; +>T : number + +import a = M.x; +>a : any +>M : typeof M +>x : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +=== tests/cases/conformance/es6/modules/t2.ts === +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +=== tests/cases/conformance/es6/modules/t3.ts === +import { v, f, C, I, E, D, M, N, T, a } from "./t1"; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + diff --git a/tests/baselines/reference/exportsAndImports1.js b/tests/baselines/reference/exportsAndImports1.js new file mode 100644 index 00000000000..f381e6b7242 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1.js @@ -0,0 +1,78 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports1.ts] //// + +//// [t1.ts] + +var v = 1; +function f() { } +class C { +} +interface I { +} +enum E { + A, B, C +} +const enum D { + A, B, C +} +module M { + export var x; +} +module N { + export interface I { + } +} +type T = number; +import a = M.x; + +export { v, f, C, I, E, D, M, N, T, a }; + +//// [t2.ts] +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +//// [t3.ts] +import { v, f, C, I, E, D, M, N, T, a } from "./t1"; +export { v, f, C, I, E, D, M, N, T, a }; + + +//// [t1.js] +var v = 1; +exports.v = v; +function f() { +} +exports.f = f; +var C = (function () { + function C() { + } + return C; +})(); +exports.C = C; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; + E[E["C"] = 2] = "C"; +})(E || (E = {})); +exports.E = E; +var M; +(function (M) { + M.x; +})(M || (M = {})); +exports.M = M; +var a = M.x; +exports.a = a; +//// [t2.js] +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_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/exportsAndImports1.types b/tests/baselines/reference/exportsAndImports1.types new file mode 100644 index 00000000000..0b35b04e22e --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +var v = 1; +>v : number + +function f() { } +>f : () => void + +class C { +>C : C +} +interface I { +>I : I +} +enum E { +>E : E + + A, B, C +>A : E +>B : E +>C : E +} +const enum D { +>D : D + + A, B, C +>A : D +>B : D +>C : D +} +module M { +>M : typeof M + + export var x; +>x : any +} +module N { +>N : unknown + + export interface I { +>I : I + } +} +type T = number; +>T : number + +import a = M.x; +>a : any +>M : typeof M +>x : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +=== tests/cases/conformance/es6/modules/t2.ts === +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +=== tests/cases/conformance/es6/modules/t3.ts === +import { v, f, C, I, E, D, M, N, T, a } from "./t1"; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + diff --git a/tests/baselines/reference/exportsAndImports2-amd.js b/tests/baselines/reference/exportsAndImports2-amd.js new file mode 100644 index 00000000000..10f524de684 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports2-amd.js @@ -0,0 +1,30 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports2-amd.ts] //// + +//// [t1.ts] + +export var x = "x"; +export var y = "y"; + +//// [t2.ts] +export { x as y, y as x } from "./t1"; + +//// [t3.ts] +import { x, y } from "./t1"; +export { x as y, y as x }; + + +//// [t1.js] +define(["require", "exports"], function (require, exports) { + exports.x = "x"; + exports.y = "y"; +}); +//// [t2.js] +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_1) { + exports.y = t1_1.x; + exports.x = t1_1.y; +}); diff --git a/tests/baselines/reference/exportsAndImports2-amd.types b/tests/baselines/reference/exportsAndImports2-amd.types new file mode 100644 index 00000000000..ebfc097da5a --- /dev/null +++ b/tests/baselines/reference/exportsAndImports2-amd.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +export var x = "x"; +>x : string + +export var y = "y"; +>y : string + +=== tests/cases/conformance/es6/modules/t2.ts === +export { x as y, y as x } from "./t1"; +>x : string +>y : string +>y : string +>x : string + +=== tests/cases/conformance/es6/modules/t3.ts === +import { x, y } from "./t1"; +>x : string +>y : string + +export { x as y, y as x }; +>x : string +>y : string +>y : string +>x : string + diff --git a/tests/baselines/reference/exportsAndImports2.js b/tests/baselines/reference/exportsAndImports2.js new file mode 100644 index 00000000000..96a3b838ed1 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports2.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports2.ts] //// + +//// [t1.ts] + +export var x = "x"; +export var y = "y"; + +//// [t2.ts] +export { x as y, y as x } from "./t1"; + +//// [t3.ts] +import { x, y } from "./t1"; +export { x as y, y as x }; + + +//// [t1.js] +exports.x = "x"; +exports.y = "y"; +//// [t2.js] +var t1_1 = require("./t1"); +exports.y = t1_1.x; +exports.x = t1_1.y; +//// [t3.js] +var t1_1 = require("./t1"); +exports.y = t1_1.x; +exports.x = t1_1.y; diff --git a/tests/baselines/reference/exportsAndImports2.types b/tests/baselines/reference/exportsAndImports2.types new file mode 100644 index 00000000000..ebfc097da5a --- /dev/null +++ b/tests/baselines/reference/exportsAndImports2.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +export var x = "x"; +>x : string + +export var y = "y"; +>y : string + +=== tests/cases/conformance/es6/modules/t2.ts === +export { x as y, y as x } from "./t1"; +>x : string +>y : string +>y : string +>x : string + +=== tests/cases/conformance/es6/modules/t3.ts === +import { x, y } from "./t1"; +>x : string +>y : string + +export { x as y, y as x }; +>x : string +>y : string +>y : string +>x : string + diff --git a/tests/baselines/reference/exportsAndImports3-amd.js b/tests/baselines/reference/exportsAndImports3-amd.js new file mode 100644 index 00000000000..613598cc0ee --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3-amd.js @@ -0,0 +1,84 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports3-amd.ts] //// + +//// [t1.ts] + +export var v = 1; +export function f() { } +export class C { +} +export interface I { +} +export enum E { + A, B, C +} +export const enum D { + A, B, C +} +export module M { + export var x; +} +export module N { + export interface I { + } +} +export type T = number; +export import a = M.x; + +export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; + +//// [t2.ts] +export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + +//// [t3.ts] +import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +export { v, f, C, I, E, D, M, N, T, a }; + + +//// [t1.js] +define(["require", "exports"], function (require, exports) { + exports.v = 1; + exports.v1 = exports.v; + function f() { + } + exports.f = f; + exports.f1 = exports.f; + var C = (function () { + function C() { + } + return C; + })(); + exports.C = C; + exports.C1 = exports.C; + (function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; + E[E["C"] = 2] = "C"; + })(exports.E || (exports.E = {})); + var E = exports.E; + exports.E1 = exports.E; + var M; + (function (M) { + M.x; + })(M = exports.M || (exports.M = {})); + exports.M1 = exports.M; + exports.a = M.x; + exports.a1 = exports.a; +}); +//// [t2.js] +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_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-amd.types b/tests/baselines/reference/exportsAndImports3-amd.types new file mode 100644 index 00000000000..86e21cfd084 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3-amd.types @@ -0,0 +1,131 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +export var v = 1; +>v : number + +export function f() { } +>f : () => void + +export class C { +>C : C +} +export interface I { +>I : I +} +export enum E { +>E : E + + A, B, C +>A : E +>B : E +>C : E +} +export const enum D { +>D : D + + A, B, C +>A : D +>B : D +>C : D +} +export module M { +>M : typeof M + + export var x; +>x : any +} +export module N { +>N : unknown + + export interface I { +>I : I + } +} +export type T = number; +>T : number + +export import a = M.x; +>a : any +>M : typeof M +>x : any + +export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; +>v : number +>v1 : number +>f : () => void +>f1 : () => void +>C : typeof C +>C1 : typeof C +>I : unknown +>I1 : unknown +>E : typeof E +>E1 : typeof E +>D : typeof D +>D1 : typeof D +>M : typeof M +>M1 : typeof M +>N : unknown +>N1 : unknown +>T : unknown +>T1 : unknown +>a : any +>a1 : any + +=== tests/cases/conformance/es6/modules/t2.ts === +export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +>v1 : number +>v : number +>f1 : () => void +>f : () => void +>C1 : typeof C +>C : typeof C +>I1 : unknown +>I : unknown +>E1 : typeof E +>E : typeof E +>D1 : typeof D +>D : typeof D +>M1 : typeof M +>M : typeof M +>N1 : unknown +>N : unknown +>T1 : unknown +>T : unknown +>a1 : any +>a : any + +=== tests/cases/conformance/es6/modules/t3.ts === +import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +>v1 : number +>v : number +>f1 : () => void +>f : () => void +>C1 : typeof C +>C : typeof C +>I1 : unknown +>I : unknown +>E1 : typeof E +>E : typeof E +>D1 : typeof D +>D : typeof D +>M1 : typeof M +>M : typeof M +>N1 : unknown +>N : unknown +>T1 : unknown +>T : unknown +>a1 : any +>a : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + diff --git a/tests/baselines/reference/exportsAndImports3.js b/tests/baselines/reference/exportsAndImports3.js new file mode 100644 index 00000000000..f06a6f684d0 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3.js @@ -0,0 +1,80 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports3.ts] //// + +//// [t1.ts] + +export var v = 1; +export function f() { } +export class C { +} +export interface I { +} +export enum E { + A, B, C +} +export const enum D { + A, B, C +} +export module M { + export var x; +} +export module N { + export interface I { + } +} +export type T = number; +export import a = M.x; + +export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; + +//// [t2.ts] +export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + +//// [t3.ts] +import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +export { v, f, C, I, E, D, M, N, T, a }; + + +//// [t1.js] +exports.v = 1; +exports.v1 = exports.v; +function f() { +} +exports.f = f; +exports.f1 = exports.f; +var C = (function () { + function C() { + } + return C; +})(); +exports.C = C; +exports.C1 = exports.C; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; + E[E["C"] = 2] = "C"; +})(exports.E || (exports.E = {})); +var E = exports.E; +exports.E1 = exports.E; +var M; +(function (M) { + M.x; +})(M = exports.M || (exports.M = {})); +exports.M1 = exports.M; +exports.a = M.x; +exports.a1 = exports.a; +//// [t2.js] +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_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/exportsAndImports3.types b/tests/baselines/reference/exportsAndImports3.types new file mode 100644 index 00000000000..86e21cfd084 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3.types @@ -0,0 +1,131 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +export var v = 1; +>v : number + +export function f() { } +>f : () => void + +export class C { +>C : C +} +export interface I { +>I : I +} +export enum E { +>E : E + + A, B, C +>A : E +>B : E +>C : E +} +export const enum D { +>D : D + + A, B, C +>A : D +>B : D +>C : D +} +export module M { +>M : typeof M + + export var x; +>x : any +} +export module N { +>N : unknown + + export interface I { +>I : I + } +} +export type T = number; +>T : number + +export import a = M.x; +>a : any +>M : typeof M +>x : any + +export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; +>v : number +>v1 : number +>f : () => void +>f1 : () => void +>C : typeof C +>C1 : typeof C +>I : unknown +>I1 : unknown +>E : typeof E +>E1 : typeof E +>D : typeof D +>D1 : typeof D +>M : typeof M +>M1 : typeof M +>N : unknown +>N1 : unknown +>T : unknown +>T1 : unknown +>a : any +>a1 : any + +=== tests/cases/conformance/es6/modules/t2.ts === +export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +>v1 : number +>v : number +>f1 : () => void +>f : () => void +>C1 : typeof C +>C : typeof C +>I1 : unknown +>I : unknown +>E1 : typeof E +>E : typeof E +>D1 : typeof D +>D : typeof D +>M1 : typeof M +>M : typeof M +>N1 : unknown +>N : unknown +>T1 : unknown +>T : unknown +>a1 : any +>a : any + +=== tests/cases/conformance/es6/modules/t3.ts === +import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; +>v1 : number +>v : number +>f1 : () => void +>f : () => void +>C1 : typeof C +>C : typeof C +>I1 : unknown +>I : unknown +>E1 : typeof E +>E : typeof E +>D1 : typeof D +>D : typeof D +>M1 : typeof M +>M : typeof M +>N1 : unknown +>N : unknown +>T1 : unknown +>T : unknown +>a1 : any +>a : any + +export { v, f, C, I, E, D, M, N, T, a }; +>v : number +>f : () => void +>C : typeof C +>I : unknown +>E : typeof E +>D : typeof D +>M : typeof M +>N : unknown +>T : unknown +>a : any + diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js new file mode 100644 index 00000000000..db28ed5b350 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -0,0 +1,65 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports4-amd.ts] //// + +//// [t1.ts] + +export default "hello"; + +//// [t2.ts] +import a = require("./t1"); +a.default; +import b from "./t1"; +b; +import * as c from "./t1"; +c.default; +import { default as d } from "./t1"; +d; +import e1, * as e2 from "./t1"; +e1; +e2.default; +import f1, { default as f2 } from "./t1"; +f1; +f2; +import "./t1"; + +//// [t3.ts] +import a = require("./t1"); +a.default; +import b from "./t1"; +b; +import * as c from "./t1"; +c.default; +import { default as d } from "./t1"; +d; +import e1, * as e2 from "./t1"; +e1; +e2.default; +import f1, { default as f2 } from "./t1"; +f1; +f2; +export { a, b, c, d, e1, e2, f1, f2 }; + + +//// [t1.js] +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_1, c, t1_2, t1_3, t1_4) { + exports.a = a; + a.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.e2 = e2; + t1_3.default; + e2.default; + exports.f1 = t1_4.default; + exports.f2 = t1_4.default; + t1_4.default; + t1_4.default; +}); diff --git a/tests/baselines/reference/exportsAndImports4-amd.types b/tests/baselines/reference/exportsAndImports4-amd.types new file mode 100644 index 00000000000..4bd6f8c0e1e --- /dev/null +++ b/tests/baselines/reference/exportsAndImports4-amd.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/es6/modules/t3.ts === +import a = require("./t1"); +>a : typeof a + +a.default; +>a.default : string +>a : typeof a +>default : string + +import b from "./t1"; +>b : string + +b; +>b : string + +import * as c from "./t1"; +>c : typeof a + +c.default; +>c.default : string +>c : typeof a +>default : string + +import { default as d } from "./t1"; +>default : string +>d : string + +d; +>d : string + +import e1, * as e2 from "./t1"; +>e1 : string +>e2 : typeof a + +e1; +>e1 : string + +e2.default; +>e2.default : string +>e2 : typeof a +>default : string + +import f1, { default as f2 } from "./t1"; +>f1 : string +>default : string +>f2 : string + +f1; +>f1 : string + +f2; +>f2 : string + +export { a, b, c, d, e1, e2, f1, f2 }; +>a : typeof a +>b : string +>c : typeof a +>d : string +>e1 : string +>e2 : typeof a +>f1 : string +>f2 : string + +=== tests/cases/conformance/es6/modules/t1.ts === + +No type information for this code.export default "hello"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js new file mode 100644 index 00000000000..ea5f34b882b --- /dev/null +++ b/tests/baselines/reference/exportsAndImports4.js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImports4.ts] //// + +//// [t1.ts] + +export default "hello"; + +//// [t2.ts] +import a = require("./t1"); +a.default; +import b from "./t1"; +b; +import * as c from "./t1"; +c.default; +import { default as d } from "./t1"; +d; +import e1, * as e2 from "./t1"; +e1; +e2.default; +import f1, { default as f2 } from "./t1"; +f1; +f2; +import "./t1"; + +//// [t3.ts] +import a = require("./t1"); +a.default; +import b from "./t1"; +b; +import * as c from "./t1"; +c.default; +import { default as d } from "./t1"; +d; +import e1, * as e2 from "./t1"; +e1; +e2.default; +import f1, { default as f2 } from "./t1"; +f1; +f2; +export { a, b, c, d, e1, e2, f1, f2 }; + + +//// [t1.js] +exports.default = "hello"; +//// [t3.js] +var a = require("./t1"); +exports.a = a; +a.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; +exports.e2 = e2; +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; diff --git a/tests/baselines/reference/exportsAndImports4.types b/tests/baselines/reference/exportsAndImports4.types new file mode 100644 index 00000000000..4bd6f8c0e1e --- /dev/null +++ b/tests/baselines/reference/exportsAndImports4.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/es6/modules/t3.ts === +import a = require("./t1"); +>a : typeof a + +a.default; +>a.default : string +>a : typeof a +>default : string + +import b from "./t1"; +>b : string + +b; +>b : string + +import * as c from "./t1"; +>c : typeof a + +c.default; +>c.default : string +>c : typeof a +>default : string + +import { default as d } from "./t1"; +>default : string +>d : string + +d; +>d : string + +import e1, * as e2 from "./t1"; +>e1 : string +>e2 : typeof a + +e1; +>e1 : string + +e2.default; +>e2.default : string +>e2 : typeof a +>default : string + +import f1, { default as f2 } from "./t1"; +>f1 : string +>default : string +>f2 : string + +f1; +>f1 : string + +f2; +>f2 : string + +export { a, b, c, d, e1, e2, f1, f2 }; +>a : typeof a +>b : string +>c : typeof a +>d : string +>e1 : string +>e2 : typeof a +>f1 : string +>f2 : string + +=== tests/cases/conformance/es6/modules/t1.ts === + +No type information for this code.export default "hello"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/multipleExportAssignments.errors.txt b/tests/baselines/reference/multipleExportAssignments.errors.txt index 604236a0516..5fbabc2b4db 100644 --- a/tests/baselines/reference/multipleExportAssignments.errors.txt +++ b/tests/baselines/reference/multipleExportAssignments.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/multipleExportAssignments.ts(13,1): error TS2300: Duplicate identifier 'default'. -tests/cases/compiler/multipleExportAssignments.ts(14,1): error TS2300: Duplicate identifier 'default'. +tests/cases/compiler/multipleExportAssignments.ts(13,1): error TS2300: Duplicate identifier 'export='. +tests/cases/compiler/multipleExportAssignments.ts(14,1): error TS2300: Duplicate identifier 'export='. ==== tests/cases/compiler/multipleExportAssignments.ts (2 errors) ==== @@ -17,9 +17,9 @@ tests/cases/compiler/multipleExportAssignments.ts(14,1): error TS2300: Duplicate }; export = server; ~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = connectExport; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. \ No newline at end of file diff --git a/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.errors.txt b/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.errors.txt index ac076e7016c..c6427a5cc28 100644 --- a/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.errors.txt +++ b/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts(4,5): error TS2300: Duplicate identifier 'default'. -tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts(5,5): error TS2300: Duplicate identifier 'default'. +tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts(4,5): error TS2300: Duplicate identifier 'export='. +tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts(5,5): error TS2300: Duplicate identifier 'export='. ==== tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts (2 errors) ==== @@ -8,8 +8,8 @@ tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts(5,5): erro var b: number; export = a; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. export = b; ~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'default'. +!!! error TS2300: Duplicate identifier 'export='. } \ No newline at end of file diff --git a/tests/baselines/reference/multipleExports.errors.txt b/tests/baselines/reference/multipleExports.errors.txt new file mode 100644 index 00000000000..254717843cf --- /dev/null +++ b/tests/baselines/reference/multipleExports.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/multipleExports.ts(10,5): error TS1194: Export declarations are not permitted in an internal module. +tests/cases/compiler/multipleExports.ts(10,13): error TS2484: Export declaration conflicts with exported declaration of 'x' + + +==== tests/cases/compiler/multipleExports.ts (2 errors) ==== + + export module M { + export var v = 0; + export let x; + } + + const x = 0; + export module M { + v; + export {x}; + ~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in an internal module. + ~ +!!! error TS2484: Export declaration conflicts with exported declaration of 'x' + } + \ No newline at end of file diff --git a/tests/baselines/reference/multipleExports.js b/tests/baselines/reference/multipleExports.js new file mode 100644 index 00000000000..b8c08952b67 --- /dev/null +++ b/tests/baselines/reference/multipleExports.js @@ -0,0 +1,25 @@ +//// [multipleExports.ts] + +export module M { + export var v = 0; + export let x; +} + +const x = 0; +export module M { + v; + export {x}; +} + + +//// [multipleExports.js] +var M; +(function (M) { + M.v = 0; + M.x; +})(M = exports.M || (exports.M = {})); +var x = 0; +var M; +(function (M) { + M.v; +})(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/noDefaultLib.errors.txt b/tests/baselines/reference/noDefaultLib.errors.txt index b8f42ba7c33..c73f3e0b948 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/parser509698.errors.txt b/tests/baselines/reference/parser509698.errors.txt index 85485dd6501..3dd70275e5c 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) ==== ///