diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3535aaffb27c4..304777e040179 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 e596c84c65e9e..6fdaac79cea00 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -295,7 +295,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 @@ -304,7 +303,6 @@ module ts { } } } - // return undefined if we can't find a symbol. } @@ -346,7 +344,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; @@ -540,29 +538,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; @@ -575,9 +557,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); } @@ -585,29 +565,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; } } } @@ -626,7 +669,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); @@ -643,13 +686,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; } @@ -780,7 +827,6 @@ module ts { return symbol; } } - let sourceFile: SourceFile; while (true) { let fileName = normalizePath(combinePaths(searchPath, moduleName)); @@ -788,12 +834,10 @@ module ts { if (sourceFile || isRelative) { break; } - let parentPath = getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } - searchPath = parentPath; } if (sourceFile) { @@ -806,24 +850,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 { - return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports; + return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol: Symbol): SymbolTable { @@ -840,15 +890,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); @@ -857,7 +898,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) { @@ -868,9 +909,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)); - }); + } } } } @@ -2950,17 +2991,25 @@ module ts { return result; } - function getExportsOfExternalModule(node: ImportDeclaration): Symbol[]{ + function symbolsToArray(symbols: SymbolTable): Symbol[] { + let result: Symbol[] = []; + for (let id in symbols) { + if (!isReservedMemberName(id)) { + result.push(symbols[id]); + } + } + return result; + } + + function getExportsOfExternalModule(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 { @@ -4536,7 +4585,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; } @@ -7675,7 +7724,7 @@ module ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -9762,7 +9811,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; } @@ -9893,7 +9942,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); } @@ -10310,7 +10359,21 @@ module ts { } 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)); + } } } } @@ -10366,39 +10429,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; } @@ -10690,7 +10736,7 @@ module ts { populateSymbols(); - return mapToArray(symbols); + return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -10748,6 +10794,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 { @@ -11099,26 +11181,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); @@ -11131,7 +11221,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. @@ -11146,15 +11236,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 { @@ -11175,13 +11277,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) { @@ -11301,8 +11408,8 @@ module ts { function createResolver(): EmitResolver { return { getExpressionNameSubstitution, + isValueAliasDeclaration, hasGlobalName, - hasExportDefaultValue, isReferencedAliasDeclaration, getNodeCheckFlags, isTopLevelValueImportEqualsWithEntityName, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 23a183775e784..4b93081dc3133 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -255,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 d6feb59cc4c5b..967afd171bac8 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." }, @@ -349,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 789d467a08934..6e24afad80c4a 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 }, @@ -1388,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 200183045472e..02531593de6ff 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; @@ -109,11 +102,11 @@ module ts { 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; @@ -343,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); } } @@ -895,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); } @@ -913,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. @@ -943,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. @@ -969,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) { @@ -987,7 +980,7 @@ module ts { } write("]"); } - + function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { let tempVariable = createAndRecordTempVariable(node); write("("); @@ -995,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); @@ -1231,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: @@ -1414,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); } } @@ -1556,7 +1554,7 @@ module ts { return result; } - + function createExpressionStatement(expression: Expression): ExpressionStatement { let result = createSynthesizedNode(SyntaxKind.ExpressionStatement); result.expression = expression; @@ -1610,7 +1608,7 @@ module ts { return result; } - + function createIdentifier(name: string, startsOnNewLine?: boolean) { let result = createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine); result.text = name; @@ -1641,7 +1639,7 @@ module ts { break; } } - + let hasComputedProperty = numInitialNonComputedProperties !== properties.length; if (hasComputedProperty) { emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); @@ -2172,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); @@ -2199,7 +2197,7 @@ module ts { emitToken(SyntaxKind.CloseParenToken, node.expression.end); emitEmbeddedStatement(node.statement); } - + function emitDownLevelForOfStatement(node: ForOfStatement) { // The following ES6 code: // @@ -2250,7 +2248,7 @@ module ts { emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - + if (!rhsIsIdentifier) { // , _a = expr write(", "); @@ -2344,7 +2342,7 @@ module ts { } emitEnd(node.initializer); write(";"); - + if (node.statement.kind === SyntaxKind.Block) { emitLines((node.statement).statements); } @@ -2352,7 +2350,7 @@ module ts { writeLine(); emit(node.statement); } - + writeLine(); decreaseIndent(); write("}"); @@ -2498,7 +2496,7 @@ module ts { emitNodeWithoutSourceMap(node.name); emitEnd(node.name); } - + function createVoidZero(): Expression { let zero = createSynthesizedNode(SyntaxKind.NumericLiteral); zero.text = "0"; @@ -2507,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); @@ -2517,9 +2532,9 @@ module ts { emitNodeWithoutSourceMap(specifier.name); emitEnd(specifier.name); write(" = "); - emitNodeWithoutSourceMap(name); + emitExpressionIdentifier(name); write(";"); - }); + } } } @@ -2669,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) { @@ -2799,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; @@ -2860,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; @@ -2870,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); @@ -3019,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 "); @@ -3103,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; @@ -3588,8 +3597,7 @@ module ts { // _default = __decorate([dec], _default); // export default _default; // - - if (isES6ModuleMemberDeclaration(node) && !(node.flags & NodeFlags.Default)) { + if (isES6ExportedDeclaration(node) && !(node.flags & NodeFlags.Default)) { write("export "); } @@ -3597,15 +3605,15 @@ module ts { emitDeclarationName(node); write(" = "); } - else if (isES6ModuleMemberDeclaration(node)) { + 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. Do not emit the name if the class is decorated. if ((node.name || !(node.flags & NodeFlags.Default)) && !thisNodeIsDecorated) { write(" "); @@ -3658,9 +3666,9 @@ module ts { emitMemberAssignments(node, NodeFlags.Static); emitDecoratorsOfClass(node); - if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) { - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & NodeFlags.Export)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -3669,7 +3677,7 @@ module ts { emitEnd(node); write(";"); } - else if (isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Default) && thisNodeIsDecorated) { + 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 "); @@ -3734,15 +3742,7 @@ 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); @@ -3983,8 +3983,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); @@ -4010,10 +4013,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 "); @@ -4078,6 +4078,9 @@ module ts { } emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } write("var "); emit(node.name); write(";"); @@ -4118,7 +4121,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(" = "); } @@ -4127,23 +4130,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("); @@ -4151,11 +4142,31 @@ 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) { @@ -4165,8 +4176,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); @@ -4185,18 +4196,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); @@ -4216,72 +4216,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); } } } @@ -4298,7 +4289,7 @@ module ts { (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ModuleMemberDeclaration(node)) { + if (isES6ExportedDeclaration(node)) { write("export "); write("var "); } @@ -4310,174 +4301,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 { - // internal module + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); 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); - }); + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); } } - 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 - }; + 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; } } - 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) - }; - } + } + + 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 { - 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; } } } @@ -4495,8 +4487,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); @@ -4504,60 +4509,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); @@ -4565,42 +4574,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); } } @@ -4688,7 +4669,8 @@ var __decorate = this.__decorate || function (decorators, target, key, value) { else { externalImports = undefined; exportSpecifiers = undefined; - exportDefault = undefined; + exportEquals = undefined; + hasExportStars = false; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); @@ -4903,9 +4885,6 @@ var __decorate = this.__decorate || function (decorators, target, key, value) { 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: @@ -5087,4 +5066,3 @@ var __decorate = this.__decorate || function (decorators, target, key, value) { } } } - diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b78f61853e88e..14311ccbc52bc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4968,29 +4968,30 @@ 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); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 204212de791f7..e5697f9f37239 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -310,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, @@ -1219,8 +1220,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; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bbe156cbd3c92..9fa0674c25c07 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -925,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; diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 8fe06ca08b9c3..07d5e4337a69e 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -324,6 +324,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -948,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; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 899c08166efd9..eff47a4cb7bf1 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -987,6 +987,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -3040,15 +3043,16 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean +>node : Node +>Node : Node - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + 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 diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 268751c25c752..b57acaf0e9c1b 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -355,6 +355,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -979,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; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index da2a475311283..600bf5c6adc72 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -1133,6 +1133,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -3186,15 +3189,16 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean +>node : Node +>Node : Node - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + 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 diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 1955c175b9373..4004007508ab0 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -356,6 +356,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -980,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; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index e7ebaee5dfad9..4ea9c49d7587d 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -1083,6 +1083,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -3136,15 +3139,16 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean +>node : Node +>Node : Node - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + 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 diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index d9188afe74fa1..34503a0d81a22 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -393,6 +393,7 @@ declare module "typescript" { Let = 4096, Const = 8192, OctalLiteral = 16384, + ExportContext = 32768, Modifier = 499, AccessibilityModifier = 112, BlockScoped = 12288, @@ -1017,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; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 66caf523789da..3903e169b4e3b 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -1256,6 +1256,9 @@ declare module "typescript" { OctalLiteral = 16384, >OctalLiteral : NodeFlags + ExportContext = 32768, +>ExportContext : NodeFlags + Modifier = 499, >Modifier : NodeFlags @@ -3309,15 +3312,16 @@ declare module "typescript" { >node : Node >Node : Node - hasExportDefaultValue(node: SourceFile): boolean; ->hasExportDefaultValue : (node: SourceFile) => boolean ->node : SourceFile ->SourceFile : SourceFile + isValueAliasDeclaration(node: Node): boolean; +>isValueAliasDeclaration : (node: Node) => boolean +>node : Node +>Node : Node - isReferencedAliasDeclaration(node: Node): boolean; ->isReferencedAliasDeclaration : (node: Node) => boolean + 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 diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types index 22e4b19fb25fc..4e9043d1b75f8 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/declFileImportModuleWithExportAssignment.types b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types index 94f3e57b1a6e7..a2ae5c0768719 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/declareExternalModuleWithExportAssignedFundule.types b/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types index ff496f678f215..e861059af75f0 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 5853663634cdf..80cfbf82387b3 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 baa9fa1170c09..376a9d7ba6f4d 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.js b/tests/baselines/reference/decoratorOnArrowFunction.js index c45f43a9bbe91..1a327e7fc9a9b 100644 --- a/tests/baselines/reference/decoratorOnArrowFunction.js +++ b/tests/baselines/reference/decoratorOnArrowFunction.js @@ -1,10 +1,10 @@ -//// [decoratorOnArrowFunction.ts] +//// [decoratorOnArrowFunction.ts] declare function dec(target: T): T; var F = @dec () => { -} - -//// [decoratorOnArrowFunction.js] -var F = ; -{ -} +} + +//// [decoratorOnArrowFunction.js] +var F = ; +{ +} diff --git a/tests/baselines/reference/decoratorOnClass1.types b/tests/baselines/reference/decoratorOnClass1.types index e8b25519149dc..19e066586da2c 100644 --- a/tests/baselines/reference/decoratorOnClass1.types +++ b/tests/baselines/reference/decoratorOnClass1.types @@ -1,14 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClass2.types index e696f699068de..43102ee912299 100644 --- a/tests/baselines/reference/decoratorOnClass2.types +++ b/tests/baselines/reference/decoratorOnClass2.types @@ -1,14 +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 -} +=== 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 index 3453a58fc9d8d..dfa430dec0cd7 100644 --- a/tests/baselines/reference/decoratorOnClass3.errors.txt +++ b/tests/baselines/reference/decoratorOnClass3.errors.txt @@ -1,12 +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 { +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/decoratorOnClass4.types b/tests/baselines/reference/decoratorOnClass4.types index 8875de5d992c7..425aa63ac213d 100644 --- a/tests/baselines/reference/decoratorOnClass4.types +++ b/tests/baselines/reference/decoratorOnClass4.types @@ -1,15 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClass5.types index afd12d42d3719..1c967ffcc0011 100644 --- a/tests/baselines/reference/decoratorOnClass5.types +++ b/tests/baselines/reference/decoratorOnClass5.types @@ -1,15 +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 -} +=== 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/decoratorOnClassAccessor1.types b/tests/baselines/reference/decoratorOnClassAccessor1.types index 8bc4f661abcfe..fd592d7d29449 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.types +++ b/tests/baselines/reference/decoratorOnClassAccessor1.types @@ -1,19 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassAccessor2.types index 1278486593f43..32bb503d889ee 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.types +++ b/tests/baselines/reference/decoratorOnClassAccessor2.types @@ -1,19 +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 -} +=== 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.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index d37656cb0e740..f48a755953f3d 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -1,19 +1,19 @@ -//// [decoratorOnClassAccessor3.ts] +//// [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; -} +} + +//// [decoratorOnClassAccessor3.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +get; +accessor(); +{ + return 1; +} diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.types b/tests/baselines/reference/decoratorOnClassAccessor4.types index 127719117e217..40dd43d7e6227 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.types +++ b/tests/baselines/reference/decoratorOnClassAccessor4.types @@ -1,20 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassAccessor5.types index 63bb9159dd05d..4b167fe8df17c 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.types +++ b/tests/baselines/reference/decoratorOnClassAccessor5.types @@ -1,20 +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 -} +=== 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.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index 7335374b3c915..905e3d3b2db96 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -1,18 +1,18 @@ -//// [decoratorOnClassAccessor6.ts] +//// [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); -{ -} +} + +//// [decoratorOnClassAccessor6.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +set; +accessor(value, number); +{ +} diff --git a/tests/baselines/reference/decoratorOnClassConstructor1.js b/tests/baselines/reference/decoratorOnClassConstructor1.js index cfe9afaa3a1f5..c61d1d218a5de 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor1.js +++ b/tests/baselines/reference/decoratorOnClassConstructor1.js @@ -1,13 +1,13 @@ -//// [decoratorOnClassConstructor1.ts] +//// [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; -})(); +} + +//// [decoratorOnClassConstructor1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/decoratorOnClassMethod1.types b/tests/baselines/reference/decoratorOnClassMethod1.types index 0ca111a9b4d9e..760f758bbff17 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.types +++ b/tests/baselines/reference/decoratorOnClassMethod1.types @@ -1,19 +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 -} +=== 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/decoratorOnClassMethod2.types b/tests/baselines/reference/decoratorOnClassMethod2.types index eb46c00b8c579..98539648cd03c 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.types +++ b/tests/baselines/reference/decoratorOnClassMethod2.types @@ -1,19 +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 -} +=== 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.js b/tests/baselines/reference/decoratorOnClassMethod3.js index f2a385a30e5ce..3a01184527531 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -1,17 +1,17 @@ -//// [decoratorOnClassMethod3.ts] +//// [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(); -{ -} +} + +//// [decoratorOnClassMethod3.js] +var C = (function () { + function C() { + } + return C; +})(); +public; +method(); +{ +} diff --git a/tests/baselines/reference/decoratorOnClassMethod4.types b/tests/baselines/reference/decoratorOnClassMethod4.types index 5d89a5ac7dd9d..6d55e01e97a86 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.types +++ b/tests/baselines/reference/decoratorOnClassMethod4.types @@ -1,18 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassMethod5.types index ed57518087bc4..d87de2b351add 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.types +++ b/tests/baselines/reference/decoratorOnClassMethod5.types @@ -1,19 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassMethod6.types index ffaff625bb615..4e6629cd60aeb 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.types +++ b/tests/baselines/reference/decoratorOnClassMethod6.types @@ -1,18 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassMethod7.types index 0fd1c2086748f..7e426cb773c15 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.types +++ b/tests/baselines/reference/decoratorOnClassMethod7.types @@ -1,18 +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 -} +=== 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.types b/tests/baselines/reference/decoratorOnClassMethod8.types index de5fce22ba69b..f932ab8696fba 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.types +++ b/tests/baselines/reference/decoratorOnClassMethod8.types @@ -1,15 +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 -} +=== 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/decoratorOnClassProperty6.types b/tests/baselines/reference/decoratorOnClassProperty6.types index 77367c0893b5e..2c8c41abf78e9 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.types +++ b/tests/baselines/reference/decoratorOnClassProperty6.types @@ -1,13 +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 -} +=== 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/decoratorOnEnum.js b/tests/baselines/reference/decoratorOnEnum.js index 6a7fe81480bbf..14651b6592834 100644 --- a/tests/baselines/reference/decoratorOnEnum.js +++ b/tests/baselines/reference/decoratorOnEnum.js @@ -1,11 +1,11 @@ -//// [decoratorOnEnum.ts] +//// [decoratorOnEnum.ts] declare function dec(target: T): T; @dec enum E { -} - -//// [decoratorOnEnum.js] -var E; -(function (E) { -})(E || (E = {})); +} + +//// [decoratorOnEnum.js] +var E; +(function (E) { +})(E || (E = {})); diff --git a/tests/baselines/reference/decoratorOnEnum2.js b/tests/baselines/reference/decoratorOnEnum2.js index a99e908bddbdc..fecff1f3413be 100644 --- a/tests/baselines/reference/decoratorOnEnum2.js +++ b/tests/baselines/reference/decoratorOnEnum2.js @@ -1,12 +1,12 @@ -//// [decoratorOnEnum2.ts] +//// [decoratorOnEnum2.ts] declare function dec(target: T): T; enum E { @dec A -} - -//// [decoratorOnEnum2.js] -var E; -(function (E) { -})(E || (E = {})); -A; +} + +//// [decoratorOnEnum2.js] +var E; +(function (E) { +})(E || (E = {})); +A; diff --git a/tests/baselines/reference/decoratorOnFunctionDeclaration.js b/tests/baselines/reference/decoratorOnFunctionDeclaration.js index 59d36731548c8..7c1a1ff5bfe69 100644 --- a/tests/baselines/reference/decoratorOnFunctionDeclaration.js +++ b/tests/baselines/reference/decoratorOnFunctionDeclaration.js @@ -1,10 +1,10 @@ -//// [decoratorOnFunctionDeclaration.ts] +//// [decoratorOnFunctionDeclaration.ts] declare function dec(target: T): T; @dec function F() { -} - -//// [decoratorOnFunctionDeclaration.js] -function F() { -} +} + +//// [decoratorOnFunctionDeclaration.js] +function F() { +} diff --git a/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt b/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt index 95103a7c68735..71aae3e13eb23 100644 --- a/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt +++ b/tests/baselines/reference/decoratorOnFunctionExpression.errors.txt @@ -1,13 +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. +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 index 9a15aa699a14f..f6808674ed4e7 100644 --- a/tests/baselines/reference/decoratorOnFunctionExpression.js +++ b/tests/baselines/reference/decoratorOnFunctionExpression.js @@ -1,10 +1,10 @@ -//// [decoratorOnFunctionExpression.ts] +//// [decoratorOnFunctionExpression.ts] declare function dec(target: T): T; var F = @dec function () { -} - -//// [decoratorOnFunctionExpression.js] -var F = ; -function () { -} +} + +//// [decoratorOnFunctionExpression.js] +var F = ; +function () { +} diff --git a/tests/baselines/reference/decoratorOnImportEquals1.js b/tests/baselines/reference/decoratorOnImportEquals1.js index 08ad26af2b264..440fdb99bce3b 100644 --- a/tests/baselines/reference/decoratorOnImportEquals1.js +++ b/tests/baselines/reference/decoratorOnImportEquals1.js @@ -1,4 +1,4 @@ -//// [decoratorOnImportEquals1.ts] +//// [decoratorOnImportEquals1.ts] declare function dec(target: T): T; module M1 { @@ -8,10 +8,10 @@ module M1 { module M2 { @dec import X = M1.X; -} - -//// [decoratorOnImportEquals1.js] -var M1; -(function (M1) { - M1.X; -})(M1 || (M1 = {})); +} + +//// [decoratorOnImportEquals1.js] +var M1; +(function (M1) { + M1.X; +})(M1 || (M1 = {})); diff --git a/tests/baselines/reference/decoratorOnImportEquals2.js b/tests/baselines/reference/decoratorOnImportEquals2.js index c05d17590267c..7db2da6b2c2b9 100644 --- a/tests/baselines/reference/decoratorOnImportEquals2.js +++ b/tests/baselines/reference/decoratorOnImportEquals2.js @@ -1,14 +1,14 @@ -//// [tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2.ts] //// - -//// [decoratorOnImportEquals2_0.ts] +//// [tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2.ts] //// + +//// [decoratorOnImportEquals2_0.ts] export var X; - -//// [decoratorOnImportEquals2_1.ts] + +//// [decoratorOnImportEquals2_1.ts] @dec import lib = require('./decoratorOnImportEquals2_0'); -declare function dec(target: T): T; - -//// [decoratorOnImportEquals2_0.js] -exports.X; -//// [decoratorOnImportEquals2_1.js] +declare function dec(target: T): T; + +//// [decoratorOnImportEquals2_0.js] +exports.X; +//// [decoratorOnImportEquals2_1.js] diff --git a/tests/baselines/reference/decoratorOnInterface.js b/tests/baselines/reference/decoratorOnInterface.js index b775b4348e9fb..10b01f299bfab 100644 --- a/tests/baselines/reference/decoratorOnInterface.js +++ b/tests/baselines/reference/decoratorOnInterface.js @@ -1,8 +1,8 @@ -//// [decoratorOnInterface.ts] +//// [decoratorOnInterface.ts] declare function dec(target: T): T; @dec interface I { -} - -//// [decoratorOnInterface.js] +} + +//// [decoratorOnInterface.js] diff --git a/tests/baselines/reference/decoratorOnInternalModule.js b/tests/baselines/reference/decoratorOnInternalModule.js index 1274d9983e5d3..d69ab6f1a5622 100644 --- a/tests/baselines/reference/decoratorOnInternalModule.js +++ b/tests/baselines/reference/decoratorOnInternalModule.js @@ -1,9 +1,9 @@ -//// [decoratorOnInternalModule.ts] +//// [decoratorOnInternalModule.ts] declare function dec(target: T): T; @dec module M { -} - -//// [decoratorOnInternalModule.js] +} + +//// [decoratorOnInternalModule.js] diff --git a/tests/baselines/reference/decoratorOnTypeAlias.js b/tests/baselines/reference/decoratorOnTypeAlias.js index c43928fe80b1f..ef4fc51034f91 100644 --- a/tests/baselines/reference/decoratorOnTypeAlias.js +++ b/tests/baselines/reference/decoratorOnTypeAlias.js @@ -1,7 +1,7 @@ -//// [decoratorOnTypeAlias.ts] +//// [decoratorOnTypeAlias.ts] declare function dec(target: T): T; @dec -type T = number; - -//// [decoratorOnTypeAlias.js] +type T = number; + +//// [decoratorOnTypeAlias.js] diff --git a/tests/baselines/reference/decoratorOnVar.js b/tests/baselines/reference/decoratorOnVar.js index 92cd7f432bc5a..5240d59fda041 100644 --- a/tests/baselines/reference/decoratorOnVar.js +++ b/tests/baselines/reference/decoratorOnVar.js @@ -1,8 +1,8 @@ -//// [decoratorOnVar.ts] +//// [decoratorOnVar.ts] declare function dec(target: T): T; @dec -var x: number; - -//// [decoratorOnVar.js] -var x; +var x: number; + +//// [decoratorOnVar.js] +var x; diff --git a/tests/baselines/reference/duplicateExportAssignments.errors.txt b/tests/baselines/reference/duplicateExportAssignments.errors.txt index 1fc844fcaadae..c0a93076981fe 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 0a7ad4520c1d8..9cf5098824749 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 6687d8dd2d98c..4d29fce3c10d9 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 43f8257899913..1e14ae0bffd19 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 a23eb361fd404..980a5ccab0f83 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 696efe5fbb14f..61f167619eb9c 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 7a4fdf52e887b..0000000000000 --- 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 0c3a601308bf3..81f2e9e0ace20 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 0000000000000..d57f757507031 --- /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 0000000000000..65f29984d593a --- /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 3d9966be7ddc4..456ad30523b79 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 05c8a794e9127..afa07c39d8ff9 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 073fbdaab38ed..1be3fa1f1b2e2 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 113e28108b166..4a4e0368bb7e8 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 4fba47ea7d1d0..f0d9bbe8cfffe 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 93c1015d20785..f987b48aecadd 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 7952bdb0bcc4b..ccdd32d99c0ad 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 2bc573ce77f9e..6250e0ce3264b 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/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index cc4206e2a5f3c..174c72341f6c9 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 d51f8740da076..68c5788c89b04 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 0000000000000..7cc8418714580 --- /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 0000000000000..747b0b2beb808 --- /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 9ff3c1b3f0430..0000000000000 --- 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 b169f9e80e4c7..2798d025894ba 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 0000000000000..13504101a2c29 --- /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 34b39cda4b77b..70e4f7e2f57a1 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 9b067ef27a405..323ed557d8b3d 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 4e9719892db40..caa46ed30efe2 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 62f54168c3631..65754d806802b 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 5e71478e5a11a..34bb303a571e4 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 7d0d4b2582da5..eef2357921292 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 a780f7cec30f6..21f488e9ca581 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 3c8a4080ba77b..755af6f4fdb85 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 9783ad4921e10..5809e0874dc7e 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 2690e7a7f5166..15ca1284a1e0b 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 9b246f803a0c6..aa9e0cb3af373 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 0239b68194fba..b6b03176df115 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 bff47ba36ef82..409c50d3a3fc9 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 405fab0de509e..0e259f142b607 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 21ddcbc71d6c2..e6211ac1ebec0 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 0377e543973f9..502b1940576f1 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 a9a2ed4974d44..83f91787b87fb 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 af73279126f61..0d5f38c0be43c 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 851a5189a5447..ce7e8b1dc5dbf 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 2a0f3ad54850c..0000000000000 --- 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 927ed3243e78b..a732cf9ec0a93 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 0000000000000..c0c3f891c9e7d --- /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 00166b1bc41fc..c2bd5476a7c4e 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 dfbc8c0be07ce..ad2b865bc01e1 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 5df6817e897a9..f738abc9bc1de 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 d1dd565c81b48..ed40582e9231d 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 f8dd391fe0ebf..8af978d3bb67c 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 4bde6e25b10c1..31ef01c464c80 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -16,7 +16,7 @@ var a = (function () { })(); exports.a = a; //// [client.js] -var 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 69b76d79fbbd5..e03ded5fd5aaf 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 e40d3893ee216..990bae10af6d3 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 d4d51e4d5abf4..48829f8e719d6 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 9131fcc75db80..4a49d3c2d6fd5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -11,7 +11,7 @@ var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var 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 3e06e7acae870..4730d493d8e99 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 b219b5e7876d4..df233fe18a5b3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -11,7 +11,7 @@ export var x: number = nameSpaceBinding.a; //// [server.js] exports.a = 10; //// [client.js] -var 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 0000000000000..5cccfd01094d2 --- /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 03243fc014d86..0000000000000 --- 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 d6aacf0ba4062..cd0550609c73b 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 628faec6c27cc..1208ace5ddef4 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 a6aaf9f550866..43eaa16f639a9 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 e0dfdc00e07a0..1bd24e8492662 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 a3f8dd11c6c51..e2c5fab4c94b6 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 b8e9777a894c5..5195bdc631b30 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 3ba19cef9b443..e1f2e89bbd898 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 ea9e65db34aab..eab345e4e7f30 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 2242810098540..c9586d0169369 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 9676720fd0f1a..a228739abbfb7 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 2a11ec638a16c..117bf0fb4d0d2 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 c8096c76c8e20..1900db57b6037 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 5ec953aca88a1..539ec121b6b57 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 0879214981896..30c382a4508bc 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 4c1fc33647c71..1305d0a4e1904 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 4a1659cb90167..3f28ddb2b6095 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 0000000000000..4e097ec1a3383 --- /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 532025c4ee68d..db7c771eaba21 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 6b614926a0af6..0000000000000 --- 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 0000000000000..77ee76cf9c86a --- /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 0000000000000..b080064306067 --- /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 275fd39579e71..29d2a73bcf19d 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 1e3716ac8c20e..c240545239f85 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 11b60555b0dba..50c9c3fb4a84b 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 9087ac096337e..05a5cbf07ae39 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 0000000000000..f2b98e6eb4459 --- /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 0000000000000..940bb44658e8a --- /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 8adf31a5f186a..71a829ac2848c 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 b29e7d2d9bc06..1f95e669de5d9 100644 --- a/tests/baselines/reference/exportDefaultTypeAnnoation3.js +++ b/tests/baselines/reference/exportDefaultTypeAnnoation3.js @@ -15,8 +15,8 @@ import { default as d } from "mod"; var s: string = d; // Error //// [reference1.js] -var 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 b60ba5a85c0a4..b94770837a414 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 0000000000000..87e4c4740a094 --- /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 0000000000000..fb04aa208b22b --- /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 0000000000000..87e4c4740a094 --- /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 0000000000000..9fca12af8b153 --- /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 0000000000000..99c6fe8d43fe4 --- /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 0000000000000..0b35b04e22e85 --- /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 0000000000000..f381e6b724212 --- /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 0000000000000..0b35b04e22e85 --- /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 0000000000000..10f524de68441 --- /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 0000000000000..ebfc097da5abc --- /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 0000000000000..96a3b838ed1ec --- /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 0000000000000..ebfc097da5abc --- /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 0000000000000..613598cc0ee77 --- /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 0000000000000..86e21cfd08402 --- /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 0000000000000..f06a6f684d0e4 --- /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 0000000000000..86e21cfd08402 --- /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 0000000000000..db28ed5b35009 --- /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 0000000000000..4bd6f8c0e1eee --- /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 0000000000000..ea5f34b882be8 --- /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 0000000000000..4bd6f8c0e1eee --- /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 604236a051681..5fbabc2b4db16 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 ac076e7016cdb..c6427a5cc28e5 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 0000000000000..254717843cfb4 --- /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 0000000000000..b8c08952b67a8 --- /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/privacyCheckExportAssignmentOnExportedGenericInterface1.types b/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface1.types index b0af8ae0b6e4d..f0c8c25be291e 100644 --- a/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface1.types +++ b/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface1.types @@ -12,9 +12,9 @@ interface Foo { >T : T } var Foo: new () => Foo.A>; ->Foo : new () => default.A> +>Foo : new () => export=.A> >Foo : unknown ->A : default.A +>A : export=.A >Foo : Foo export = Foo; diff --git a/tests/cases/compiler/es6ExportEqualsInterop.ts b/tests/cases/compiler/es6ExportEqualsInterop.ts new file mode 100644 index 0000000000000..7b1f6700dd98b --- /dev/null +++ b/tests/cases/compiler/es6ExportEqualsInterop.ts @@ -0,0 +1,206 @@ +// @module: commonjs + +// @filename: 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; +} + +// @filename: 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"; diff --git a/tests/cases/compiler/es6ImportDefaultBinding.ts b/tests/cases/compiler/es6ImportDefaultBinding.ts index 3007a9e82fa09..2e68248d9ede5 100644 --- a/tests/cases/compiler/es6ImportDefaultBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBinding.ts @@ -4,7 +4,7 @@ // @filename: es6ImportDefaultBinding_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBinding_1.ts import defaultBinding from "es6ImportDefaultBinding_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingAmd.ts b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts index 85e06b8c99d8c..659f29251c524 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingAmd.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts @@ -3,7 +3,7 @@ // @filename: es6ImportDefaultBindingAmd_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingAmd_1.ts import defaultBinding from "es6ImportDefaultBindingAmd_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingDts.ts index 4700782b78e73..282a48da7de31 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingDts.ts @@ -3,7 +3,7 @@ // @filename: server.ts class c { } -export = c; +export default c; // @filename: client.ts import defaultBinding from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts index a0524dd2138d5..9a6e1a8ebf5a3 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts @@ -6,6 +6,7 @@ export var a = 10; export var x = a; export var m = a; +export default {}; // @filename: es6ImportDefaultBindingFollowedWithNamedImport_1.ts import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts index c1ac752426e00..81f8c15320b94 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts @@ -3,7 +3,7 @@ // @filename: es6ImportDefaultBindingFollowedWithNamedImport1_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport1_1.ts import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts index 80bc2a4474e0c..d5c9a6a395d1f 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts @@ -4,7 +4,7 @@ // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts index fef56560dcf81..9913fbb8fe23d 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts @@ -3,7 +3,7 @@ // @filename: server.ts var a = 10; -export = a; +export default a; // @filename: client.ts export import defaultBinding1, { } from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts index 1951a8a6b30e6..724f9ee40d083 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts @@ -3,7 +3,7 @@ // @filename: server.ts class a { } -export = a; +export default a; // @filename: client.ts import defaultBinding1, { } from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts index 6e3ac5786d1e1..5454a260c3fd2 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts @@ -5,6 +5,7 @@ export var a = 10; export var x = a; export var m = a; +export default {}; // @filename: client.ts export import defaultBinding1, { } from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts index 81113b776b4eb..dc75c522e9c27 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts @@ -3,7 +3,7 @@ // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts index db076b87c9a92..6195b279f72e1 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts @@ -4,7 +4,7 @@ // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts index ce42814a91818..ced69da29cbca 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts @@ -3,7 +3,7 @@ // @filename: server.ts var a = 10; -export = a; +export default a; // @filename: client.ts export import defaultBinding, * as nameSpaceBinding from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts index 1f026af8f34df..50ac14545547b 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts @@ -3,7 +3,7 @@ // @filename: server.ts class a { } -export = a; +export default a; // @filename: client.ts import defaultBinding, * as nameSpaceBinding from "server"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts index cd1bad8371680..b055ef5dce975 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -2,7 +2,7 @@ // @filename: es6ImportDefaultBindingMergeErrors_0.ts var a = 10; -export = a; +export default a; // @filename: es6ImportDefaultBindingMergeErrors_1.ts import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts index 87494c8a62275..0c544c9eba525 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts @@ -3,7 +3,7 @@ // @filename: server.ts var a = 10; -export = a; +export default a; // @filename: client.ts export import defaultBinding from "server"; diff --git a/tests/baselines/reference/es5ModuleInternalNamedImports.types b/tests/cases/compiler/es6ModuleInternalNamedImports2.ts similarity index 51% rename from tests/baselines/reference/es5ModuleInternalNamedImports.types rename to tests/cases/compiler/es6ModuleInternalNamedImports2.ts index fa88ab399a3fc..6f235af52bd63 100644 --- a/tests/baselines/reference/es5ModuleInternalNamedImports.types +++ b/tests/cases/compiler/es6ModuleInternalNamedImports2.ts @@ -1,77 +1,34 @@ -=== tests/cases/compiler/es5ModuleInternalNamedImports.ts === +// @target: ES6 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 +} +export module 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/cases/compiler/exportDefaultForNonInstantiatedModule.ts b/tests/cases/compiler/exportDefaultForNonInstantiatedModule.ts new file mode 100644 index 0000000000000..a1d1cab94b6aa --- /dev/null +++ b/tests/cases/compiler/exportDefaultForNonInstantiatedModule.ts @@ -0,0 +1,8 @@ +// @target: ES6 + +module m { + export interface foo { + } +} +// Should not be emitted +export default m; \ No newline at end of file diff --git a/tests/cases/compiler/multipleExports.ts b/tests/cases/compiler/multipleExports.ts new file mode 100644 index 0000000000000..b8d16ea18a80a --- /dev/null +++ b/tests/cases/compiler/multipleExports.ts @@ -0,0 +1,12 @@ +// @module: commonjs + +export module M { + export var v = 0; + export let x; +} + +const x = 0; +export module M { + v; + export {x}; +} diff --git a/tests/cases/conformance/es6/modules/exportStar-amd.ts b/tests/cases/conformance/es6/modules/exportStar-amd.ts new file mode 100644 index 0000000000000..ffa8b0a7f1070 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportStar-amd.ts @@ -0,0 +1,28 @@ +// @module: amd + +// @filename: t1.ts +export var x = 1; +export var y = 2; + +// @filename: t2.ts +export default "hello"; +export function foo() { } + +// @filename: t3.ts +var x = "x"; +var y = "y"; +var z = "z"; +export { x, y, z }; + +// @filename: t4.ts +export * from "./t1"; +export * from "./t2"; +export * from "./t3"; + +// @filename: main.ts +import hello, { x, y, z, foo } from "./t4"; +hello; +x; +y; +z; +foo; diff --git a/tests/cases/conformance/es6/modules/exportStar.ts b/tests/cases/conformance/es6/modules/exportStar.ts new file mode 100644 index 0000000000000..6d820d9c424c0 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportStar.ts @@ -0,0 +1,28 @@ +// @module: commonjs + +// @filename: t1.ts +export var x = 1; +export var y = 2; + +// @filename: t2.ts +export default "hello"; +export function foo() { } + +// @filename: t3.ts +var x = "x"; +var y = "y"; +var z = "z"; +export { x, y, z }; + +// @filename: t4.ts +export * from "./t1"; +export * from "./t2"; +export * from "./t3"; + +// @filename: main.ts +import hello, { x, y, z, foo } from "./t4"; +hello; +x; +y; +z; +foo; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports1-amd.ts b/tests/cases/conformance/es6/modules/exportsAndImports1-amd.ts new file mode 100644 index 0000000000000..0c4d1de1e6b4d --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports1-amd.ts @@ -0,0 +1,33 @@ +// @module: amd + +// @filename: 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 }; + +// @filename: t2.ts +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +// @filename: 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 }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports1.ts b/tests/cases/conformance/es6/modules/exportsAndImports1.ts new file mode 100644 index 0000000000000..5b91d1d6ccd97 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports1.ts @@ -0,0 +1,33 @@ +// @module: commonjs + +// @filename: 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 }; + +// @filename: t2.ts +export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +// @filename: 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 }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports2-amd.ts b/tests/cases/conformance/es6/modules/exportsAndImports2-amd.ts new file mode 100644 index 0000000000000..72e462f0eed05 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports2-amd.ts @@ -0,0 +1,12 @@ +// @module: amd + +// @filename: t1.ts +export var x = "x"; +export var y = "y"; + +// @filename: t2.ts +export { x as y, y as x } from "./t1"; + +// @filename: t3.ts +import { x, y } from "./t1"; +export { x as y, y as x }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports2.ts b/tests/cases/conformance/es6/modules/exportsAndImports2.ts new file mode 100644 index 0000000000000..719f74ede5554 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports2.ts @@ -0,0 +1,12 @@ +// @module: commonjs + +// @filename: t1.ts +export var x = "x"; +export var y = "y"; + +// @filename: t2.ts +export { x as y, y as x } from "./t1"; + +// @filename: t3.ts +import { x, y } from "./t1"; +export { x as y, y as x }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports3-amd.ts b/tests/cases/conformance/es6/modules/exportsAndImports3-amd.ts new file mode 100644 index 0000000000000..b634f6f7764d3 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports3-amd.ts @@ -0,0 +1,33 @@ +// @module: amd + +// @filename: 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 }; + +// @filename: 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"; + +// @filename: 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 }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports3.ts b/tests/cases/conformance/es6/modules/exportsAndImports3.ts new file mode 100644 index 0000000000000..806a5e2779e6f --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports3.ts @@ -0,0 +1,33 @@ +// @module: commonjs + +// @filename: 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 }; + +// @filename: 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"; + +// @filename: 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 }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports4-amd.ts b/tests/cases/conformance/es6/modules/exportsAndImports4-amd.ts new file mode 100644 index 0000000000000..d542a5ae71814 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports4-amd.ts @@ -0,0 +1,38 @@ +// @module: amd + +// @filename: t1.ts +export default "hello"; + +// @filename: 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"; + +// @filename: 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 }; diff --git a/tests/cases/conformance/es6/modules/exportsAndImports4.ts b/tests/cases/conformance/es6/modules/exportsAndImports4.ts new file mode 100644 index 0000000000000..f077067419626 --- /dev/null +++ b/tests/cases/conformance/es6/modules/exportsAndImports4.ts @@ -0,0 +1,38 @@ +// @module: commonjs + +// @filename: t1.ts +export default "hello"; + +// @filename: 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"; + +// @filename: 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 }; diff --git a/tests/cases/fourslash/goToDefinitionImportedNames7.ts b/tests/cases/fourslash/goToDefinitionImportedNames7.ts index 46d09012d4099..3c367600b1f8e 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames7.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames7.ts @@ -8,7 +8,7 @@ /////*classDefinition*/class Class { //// private f; ////} -////export = Class; +////export default Class; goTo.file("b.ts");