diff --git a/Jakefile b/Jakefile index 3a19812b958..dd09085800c 100644 --- a/Jakefile +++ b/Jakefile @@ -39,6 +39,7 @@ var compilerSources = [ "utilities.ts", "binder.ts", "checker.ts", + "declarationEmitter.ts", "emitter.ts", "program.ts", "commandLineParser.ts", @@ -57,6 +58,7 @@ var servicesSources = [ "utilities.ts", "binder.ts", "checker.ts", + "declarationEmitter.ts", "emitter.ts", "program.ts", "commandLineParser.ts", @@ -65,7 +67,7 @@ var servicesSources = [ return path.join(compilerDirectory, f); }).concat([ "breakpoints.ts", - "navigateTo.ts", + "navigateTo.ts", "navigationBar.ts", "outliningElementsCollector.ts", "patternMatcher.ts", @@ -539,7 +541,7 @@ function cleanTestDirs() { } jake.mkdirP(localRwcBaseline); - jake.mkdirP(localTest262Baseline); + jake.mkdirP(localTest262Baseline); jake.mkdirP(localBaseline); } @@ -718,7 +720,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() { var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; -compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], /*useBuiltCompiler*/ true); +compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true); desc("Builds an instrumented tsc.js"); task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() { diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 0d32c605fdc..b97e4a2ea54 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -65,8 +65,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ' ' + convertPropertyName(nameMap[name]) + ': { code: ' + diagnosticDetails.code + ', category: DiagnosticCategory.' + diagnosticDetails.category + - ', key: "' + name.replace('"', '\\"') + '"' + - (diagnosticDetails.isEarly ? ', isEarly: true' : '') + + ', key: "' + name.replace(/[\"]/g, '\\"') + '"' + ' },\r\n'; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4f119232476..d50e440c5e9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -512,6 +512,19 @@ module ts { node.kind === SyntaxKind.ExportAssignment; } + function getAnyImportSyntax(node: Node): AnyImportSyntax { + if (isAliasSymbolDeclaration(node)) { + if (node.kind === SyntaxKind.ImportEqualsDeclaration) { + return node; + } + + while (node.kind !== SyntaxKind.ImportDeclaration) { + node = node.parent; + } + return node; + } + } + function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration { return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); } @@ -783,7 +796,7 @@ module ts { } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { - if (compilerOptions.target < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES6) { // A default export hides all other exports in CommonJS and AMD modules let defaultSymbol = getExportAssignmentSymbol(moduleSymbol); if (defaultSymbol) { @@ -1122,7 +1135,7 @@ module ts { } function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult { - let aliasesToMakeVisible: ImportEqualsDeclaration[]; + let aliasesToMakeVisible: AnyImportSyntax[]; if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) { return undefined; } @@ -1132,17 +1145,19 @@ module ts { if (!isDeclarationVisible(declaration)) { // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file - if (declaration.kind === SyntaxKind.ImportEqualsDeclaration && - !(declaration.flags & NodeFlags.Export) && - isDeclarationVisible(declaration.parent)) { + + var anyImportSyntax = getAnyImportSyntax(declaration); + if (anyImportSyntax && + !(anyImportSyntax.flags & NodeFlags.Export) && // import clause without export + isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { - if (!contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); + if (!contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); } } else { - aliasesToMakeVisible = [declaration]; + aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -1766,8 +1781,15 @@ module ts { function determineIfDeclarationIsVisible() { switch (node.kind) { - case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: + return isDeclarationVisible(node.parent.parent); + case SyntaxKind.VariableDeclaration: + if (isBindingPattern(node.name) && + !(node.name).elements.length) { + // If the binding pattern is empty, this variable declaration is not visible + return false; + } + // Otherwise fall through case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -1779,7 +1801,7 @@ module ts { // If the node is not exported or it is not ambient module element (except import declaration) if (!(getCombinedNodeFlags(node) & NodeFlags.Export) && !(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) { - return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); + return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); @@ -1812,6 +1834,13 @@ module ts { case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); + // Default binding, import specifier and namespace import is visible + // only on demand so by default it is not visible + case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportSpecifier: + return false; + // Type parameters are always visible case SyntaxKind.TypeParameter: // Source file is always visible @@ -1832,6 +1861,40 @@ module ts { } } + function collectLinkedAliases(node: Identifier): Node[]{ + var exportSymbol: Symbol; + if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { + exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node); + } + else if (node.parent.kind === SyntaxKind.ExportSpecifier) { + exportSymbol = getTargetOfExportSpecifier(node.parent); + } + var result: Node[] = []; + if (exportSymbol) { + buildVisibleNodeList(exportSymbol.declarations); + } + return result; + + function buildVisibleNodeList(declarations: Declaration[]) { + forEach(declarations, declaration => { + getNodeLinks(declaration).isVisible = true; + var resultNode = getAnyImportSyntax(declaration) || declaration; + if (!contains(result, resultNode)) { + result.push(resultNode); + } + + if (isInternalModuleImportEqualsDeclaration(declaration)) { + // Add the referenced top container visible + var internalModuleReference = (declaration).moduleReference; + var firstIdentifier = getFirstIdentifier(internalModuleReference); + var importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, + Diagnostics.Cannot_find_name_0, firstIdentifier); + buildVisibleNodeList(importSymbol.declarations); + } + }); + } + } + function getRootDeclaration(node: Node): Node { while (node.kind === SyntaxKind.BindingElement) { node = node.parent.parent; @@ -9742,7 +9805,7 @@ module ts { } let initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + autoValue = getConstantValueForEnumMemberInitializer(initializer); if (autoValue === undefined) { if (enumIsConst) { error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); @@ -9777,7 +9840,7 @@ module ts { nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed; } - function getConstantValueForEnumMemberInitializer(initializer: Expression, enumIsConst: boolean): number { + function getConstantValueForEnumMemberInitializer(initializer: Expression): number { return evalConstant(initializer); function evalConstant(e: Node): number { @@ -9790,14 +9853,10 @@ module ts { switch ((e).operator) { case SyntaxKind.PlusToken: return value; case SyntaxKind.MinusToken: return -value; - case SyntaxKind.TildeToken: return enumIsConst ? ~value : undefined; + case SyntaxKind.TildeToken: return ~value; } return undefined; case SyntaxKind.BinaryExpression: - if (!enumIsConst) { - return undefined; - } - let left = evalConstant((e).left); if (left === undefined) { return undefined; @@ -9823,14 +9882,10 @@ module ts { case SyntaxKind.NumericLiteral: return +(e).text; case SyntaxKind.ParenthesizedExpression: - return enumIsConst ? evalConstant((e).expression) : undefined; + return evalConstant((e).expression); case SyntaxKind.Identifier: case SyntaxKind.ElementAccessExpression: case SyntaxKind.PropertyAccessExpression: - if (!enumIsConst) { - return undefined; - } - let member = initializer.parent; let currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); let enumType: Type; @@ -9843,19 +9898,37 @@ module ts { propertyName = (e).text; } else { + let expression: Expression; if (e.kind === SyntaxKind.ElementAccessExpression) { if ((e).argumentExpression === undefined || (e).argumentExpression.kind !== SyntaxKind.StringLiteral) { return undefined; } - enumType = getTypeOfNode((e).expression); + expression = (e).expression; propertyName = ((e).argumentExpression).text; } else { - enumType = getTypeOfNode((e).expression); + expression = (e).expression; propertyName = (e).name.text; } - if (enumType !== currentType) { + + // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName + var current = expression; + while (current) { + if (current.kind === SyntaxKind.Identifier) { + break; + } + else if (current.kind === SyntaxKind.PropertyAccessExpression) { + current = (current).expression; + } + else { + return undefined; + } + } + + enumType = checkExpression(expression); + // allow references to constant members of other enums + if (!(enumType.symbol && (enumType.symbol.flags & SymbolFlags.Enum))) { return undefined; } } @@ -9863,10 +9936,12 @@ module ts { if (propertyName === undefined) { return undefined; } + let property = getPropertyOfObjectType(enumType, propertyName); if (!property || !(property.flags & SymbolFlags.EnumMember)) { return undefined; } + let propertyDecl = property.valueDeclaration; // self references are illegal if (member === propertyDecl) { @@ -9877,6 +9952,7 @@ module ts { if (!isDefinedBefore(propertyDecl, member)) { return undefined; } + return getNodeLinks(propertyDecl).enumMemberValue; } } @@ -10093,6 +10169,12 @@ module ts { } } } + else { + if (languageVersion >= ScriptTarget.ES6) { + // Import equals declaration is deprecated in es6 or above + grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + } + } } } @@ -10140,6 +10222,11 @@ module ts { } checkExternalModuleExports(container); + + if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) { + // export assignment is deprecated in es6 or above + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } } function getModuleStatements(node: Declaration): ModuleElement[] { @@ -10182,7 +10269,7 @@ module ts { if (!links.exportsChecked) { let defaultSymbol = getExportAssignmentSymbol(moduleSymbol); if (defaultSymbol) { - if (hasExportedMembers(moduleSymbol)) { + 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); } @@ -11005,7 +11092,15 @@ module ts { function getExportNameSubstitution(symbol: Symbol, location: Node): string { if (isExternalModuleSymbol(symbol.parent)) { - return "exports." + unescapeIdentifier(symbol.name); + 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; + } } let node = location; let containerSymbol = getParentOfSymbol(symbol); @@ -11033,7 +11128,7 @@ module ts { return getExportNameSubstitution(exportSymbol, node.parent); } // Named imports from ES6 import declarations are rewritten - if (symbol.flags & SymbolFlags.Alias) { + if (symbol.flags & SymbolFlags.Alias && languageVersion < ScriptTarget.ES6) { return getAliasNameSubstitution(symbol); } } @@ -11069,7 +11164,6 @@ module ts { return true; } } - return forEachChild(node, isReferencedAliasDeclaration); } function isImplementationOfOverload(node: FunctionLikeDeclaration) { @@ -11109,10 +11203,9 @@ module ts { let symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { - let declaration = symbol.valueDeclaration; - let constantValue: number; - if (declaration.kind === SyntaxKind.EnumMember) { - return getEnumMemberValue(declaration); + // inline property\index accesses only for const enums + if (isConstEnumDeclaration(symbol.valueDeclaration.parent)) { + return getEnumMemberValue(symbol.valueDeclaration); } } @@ -11134,6 +11227,11 @@ module ts { getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } + function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { + var type = getTypeOfExpression(expr); + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + } + function isUnknownIdentifier(location: Node, name: string): boolean { Debug.assert(!nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location"); return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) && @@ -11177,10 +11275,12 @@ module ts { isImplementationOfOverload, writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration, + writeTypeOfExpression, isSymbolAccessible, isEntityNameVisible, getConstantValue, isUnknownIdentifier, + collectLinkedAliases, getBlockScopedVariableId, }; } @@ -12118,8 +12218,8 @@ module ts { } function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean { - // A declare modifier is required for any top level .d.ts declaration except export=, interfaces and imports: - // categories: + // A declare modifier is required for any top level .d.ts declaration except export=, export default, + // interfaces and imports categories: // // DeclarationElement: // ExportAssignment @@ -12133,7 +12233,8 @@ module ts { node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration || node.kind === SyntaxKind.ExportAssignment || - (node.flags & NodeFlags.Ambient)) { + (node.flags & NodeFlags.Ambient) || + (node.flags & (NodeFlags.Export | NodeFlags.Default))) { return false; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 27fc152f534..5433557bf84 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -122,8 +122,10 @@ module ts { } export function addRange(to: T[], from: T[]): void { - for (let v of from) { - to.push(v); + if (to && from) { + for (let v of from) { + to.push(v); + } } } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts new file mode 100644 index 00000000000..cf75467e1c5 --- /dev/null +++ b/src/compiler/declarationEmitter.ts @@ -0,0 +1,1466 @@ +/// + +module ts { + + interface ModuleElementDeclarationEmitInfo { + node: Node; + outputPos: number; + indent: number; + asynchronousOutput?: string; // If the output for alias was written asynchronously, the corresponding output + subModuleElementDeclarationEmitInfo?: ModuleElementDeclarationEmitInfo[]; + isVisible?: boolean; + } + + interface DeclarationEmit { + reportedDeclarationError: boolean; + moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]; + synchronousDeclarationOutput: string; + referencePathsOutput: string; + } + + type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; + + interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { + getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic; + } + + interface SymbolAccessibilityDiagnostic { + errorNode: Node; + diagnosticMessage: DiagnosticMessage; + typeName?: DeclarationName; + } + + export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { + let diagnostics: Diagnostic[] = []; + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + + function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit { + let newLine = host.getNewLine(); + let compilerOptions = host.getCompilerOptions(); + let languageVersion = compilerOptions.target || ScriptTarget.ES3; + + let write: (s: string) => void; + let writeLine: () => void; + let increaseIndent: () => void; + let decreaseIndent: () => void; + let writeTextOfNode: (sourceFile: SourceFile, node: Node) => void; + + let writer = createAndSetNewTextWriterWithSymbolWriter(); + + let enclosingDeclaration: Node; + let currentSourceFile: SourceFile; + let reportedDeclarationError = false; + let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; + let emit = compilerOptions.stripInternal ? stripInternal : emitNode; + + let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; + let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]; + + // Contains the reference paths that needs to go in the declaration file. + // Collecting this separately because reference paths need to be first thing in the declaration file + // and we could be collecting these paths from multiple files into single one with --out option + let referencePathsOutput = ""; + + if (root) { + // Emitting just a single file, so emit references in this file only + if (!compilerOptions.noResolve) { + let addedGlobalFileReference = false; + forEach(root.referencedFiles, fileReference => { + let referencedFile = tryResolveScriptReference(host, root, fileReference); + + // All the references that are not going to be part of same file + if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference + shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file + !addedGlobalFileReference)) { // Or the global out file corresponding to this reference was not added + + writeReferencePath(referencedFile); + if (!isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + + emitSourceFile(root); + + // create asynchronous output for the importDeclarations + if (moduleElementDeclarationEmitInfo.length) { + let oldWriter = writer; + forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => { + if (aliasEmitInfo.isVisible) { + Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration); + createAndSetNewTextWriterWithSymbolWriter(); + Debug.assert(aliasEmitInfo.indent === 0); + writeImportDeclaration(aliasEmitInfo.node); + aliasEmitInfo.asynchronousOutput = writer.getText(); + } + }); + setWriter(oldWriter); + } + } + else { + // Emit references corresponding to this file + let emittedReferencedFiles: SourceFile[] = []; + forEach(host.getSourceFiles(), sourceFile => { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + // Check what references need to be added + if (!compilerOptions.noResolve) { + forEach(sourceFile.referencedFiles, fileReference => { + let referencedFile = tryResolveScriptReference(host, sourceFile, fileReference); + + // If the reference file is a declaration file or an external module, emit that reference + if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && + !contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted + + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + + emitSourceFile(sourceFile); + } + }); + } + + return { + reportedDeclarationError, + moduleElementDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + referencePathsOutput, + } + + function hasInternalAnnotation(range: CommentRange) { + let text = currentSourceFile.text; + let comment = text.substring(range.pos, range.end); + return comment.indexOf("@internal") >= 0; + } + + function stripInternal(node: Node) { + if (node) { + let leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (forEach(leadingCommentRanges, hasInternalAnnotation)) { + return; + } + + emitNode(node); + } + } + + function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { + let writer = createTextWriter(newLine); + writer.trackSymbol = trackSymbol; + writer.writeKeyword = writer.write; + writer.writeOperator = writer.write; + writer.writePunctuation = writer.write; + writer.writeSpace = writer.write; + writer.writeStringLiteral = writer.writeLiteral; + writer.writeParameter = writer.write; + writer.writeSymbol = writer.write; + setWriter(writer); + return writer; + } + + function setWriter(newWriter: EmitTextWriterWithSymbolWriter) { + writer = newWriter; + write = newWriter.write; + writeTextOfNode = newWriter.writeTextOfNode; + writeLine = newWriter.writeLine; + increaseIndent = newWriter.increaseIndent; + decreaseIndent = newWriter.decreaseIndent; + } + + function writeAsynchronousModuleElements(nodes: Node[]) { + let oldWriter = writer; + forEach(nodes, declaration => { + let nodeToCheck: Node; + if (declaration.kind === SyntaxKind.VariableDeclaration) { + nodeToCheck = declaration.parent.parent; + } else if (declaration.kind === SyntaxKind.NamedImports || declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause) { + Debug.fail("We should be getting ImportDeclaration instead to write"); + } else { + nodeToCheck = declaration; + } + + let moduleElementEmitInfo = forEach(moduleElementDeclarationEmitInfo, declEmitInfo => declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined); + if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { + moduleElementEmitInfo = forEach(asynchronousSubModuleDeclarationEmitInfo, declEmitInfo => declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined); + } + + // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration + // then we don't need to write it at this point. We will write it when we actually see its declaration + // Eg. + // export function bar(a: foo.Foo) { } + // import foo = require("foo"); + // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, + // we would write alias foo declaration when we visit it since it would now be marked as visible + if (moduleElementEmitInfo) { + if (moduleElementEmitInfo.node.kind === SyntaxKind.ImportDeclaration) { + // we have to create asynchronous output only after we have collected complete information + // because it is possible to enable multiple bindings as asynchronously visible + moduleElementEmitInfo.isVisible = true; + } + else { + createAndSetNewTextWriterWithSymbolWriter(); + for (let declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { + increaseIndent(); + } + + if (nodeToCheck.kind === SyntaxKind.ModuleDeclaration) { + Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); + asynchronousSubModuleDeclarationEmitInfo = []; + } + writeModuleElement(nodeToCheck); + if (nodeToCheck.kind === SyntaxKind.ModuleDeclaration) { + moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; + asynchronousSubModuleDeclarationEmitInfo = undefined; + } + moduleElementEmitInfo.asynchronousOutput = writer.getText(); + } + } + }); + setWriter(oldWriter); + } + + function handleSymbolAccessibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { + if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) { + // write the aliases + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + // Report error + reportedDeclarationError = true; + let errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, + errorInfo.diagnosticMessage, + getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), + symbolAccesibilityResult.errorSymbolName, + symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, + errorInfo.diagnosticMessage, + symbolAccesibilityResult.errorSymbolName, + symbolAccesibilityResult.errorModuleName)); + } + } + } + } + + function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + } + + function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode | StringLiteralExpression, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (type) { + // Write the type + emitType(type); + } + else { + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + } + } + + function writeReturnTypeAtSignature(signature: SignatureDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + write(": "); + if (signature.type) { + // Write the type + emitType(signature.type); + } + else { + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + } + } + + function emitLines(nodes: Node[]) { + for (let node of nodes) { + emit(node); + } + } + + function emitSeparatedList(nodes: Node[], separator: string, eachNodeEmitFn: (node: Node) => void, canEmitFn?: (node: Node) => boolean) { + let currentWriterPos = writer.getTextPos(); + for (let node of nodes) { + if (!canEmitFn || canEmitFn(node)) { + if (currentWriterPos !== writer.getTextPos()) { + write(separator); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(node); + } + } + } + + function emitCommaList(nodes: Node[], eachNodeEmitFn: (node: Node) => void, canEmitFn?: (node: Node) => boolean) { + emitSeparatedList(nodes, ", ", eachNodeEmitFn, canEmitFn); + } + + function writeJsDocComments(declaration: Node) { + if (declaration) { + let jsDocComments = getJsDocComments(declaration, currentSourceFile); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space + emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange); + } + } + + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type: TypeNode | EntityName, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + emitType(type); + } + + function emitType(type: TypeNode | StringLiteralExpression | Identifier | QualifiedName) { + switch (type.kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.VoidKeyword: + case SyntaxKind.StringLiteral: + return writeTextOfNode(currentSourceFile, type); + case SyntaxKind.TypeReference: + return emitTypeReference(type); + case SyntaxKind.TypeQuery: + return emitTypeQuery(type); + case SyntaxKind.ArrayType: + return emitArrayType(type); + case SyntaxKind.TupleType: + return emitTupleType(type); + case SyntaxKind.UnionType: + return emitUnionType(type); + case SyntaxKind.ParenthesizedType: + return emitParenType(type); + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return emitSignatureDeclarationWithJsDocComments(type); + case SyntaxKind.TypeLiteral: + return emitTypeLiteral(type); + case SyntaxKind.Identifier: + return emitEntityName(type); + case SyntaxKind.QualifiedName: + return emitEntityName(type); + default: + Debug.fail("Unknown type annotation: " + type.kind); + } + + function emitEntityName(entityName: EntityName) { + let visibilityResult = resolver.isEntityNameVisible(entityName, + // Aliases can be written asynchronously so use correct enclosing declaration + entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration); + + handleSymbolAccessibilityError(visibilityResult); + writeEntityName(entityName); + + function writeEntityName(entityName: EntityName) { + if (entityName.kind === SyntaxKind.Identifier) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + let qualifiedName = entityName; + writeEntityName(qualifiedName.left); + write("."); + writeTextOfNode(currentSourceFile, qualifiedName.right); + } + } + } + + function emitTypeReference(type: TypeReferenceNode) { + emitEntityName(type.typeName); + if (type.typeArguments) { + write("<"); + emitCommaList(type.typeArguments, emitType); + write(">"); + } + } + + function emitTypeQuery(type: TypeQueryNode) { + write("typeof "); + emitEntityName(type.exprName); + } + + function emitArrayType(type: ArrayTypeNode) { + emitType(type.elementType); + write("[]"); + } + + function emitTupleType(type: TupleTypeNode) { + write("["); + emitCommaList(type.elementTypes, emitType); + write("]"); + } + + function emitUnionType(type: UnionTypeNode) { + emitSeparatedList(type.types, " | ", emitType); + } + + function emitParenType(type: ParenthesizedTypeNode) { + write("("); + emitType(type.type); + write(")"); + } + + function emitTypeLiteral(type: TypeLiteralNode) { + write("{"); + if (type.members.length) { + writeLine(); + increaseIndent(); + // write members + emitLines(type.members); + decreaseIndent(); + } + write("}"); + } + } + + function emitSourceFile(node: SourceFile) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + + function emitExportAssignment(node: ExportAssignment) { + write(node.isExportEquals ? "export = " : "export default "); + if (node.expression.kind === SyntaxKind.Identifier) { + writeTextOfNode(currentSourceFile, node.expression); + } + else { + write(": "); + if (node.type) { + emitType(node.type); + } + else { + writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + } + } + write(";"); + writeLine(); + + // Make all the declarations visible for the export name + if (node.expression.kind === SyntaxKind.Identifier) { + let nodes = resolver.collectLinkedAliases(node.expression); + + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + + function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + return { + diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }; + } + } + + function isModuleElementVisible(node: Declaration) { + return resolver.isDeclarationVisible(node); + } + + function emitModuleElement(node: Node, isModuleElementVisible: boolean) { + if (isModuleElementVisible) { + writeModuleElement(node); + } + // Import equals declaration in internal module can become visible as part of any emit so lets make sure we add these irrespective + else if (node.kind === SyntaxKind.ImportEqualsDeclaration || + (node.parent.kind === SyntaxKind.SourceFile && isExternalModule(currentSourceFile))) { + let isVisible: boolean; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== SyntaxKind.SourceFile) { + // Import declaration of another module that is visited async so lets put it in right spot + asynchronousSubModuleDeclarationEmitInfo.push({ + node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible + }); + } + else { + if (node.kind === SyntaxKind.ImportDeclaration) { + let importDeclaration = node; + if (importDeclaration.importClause) { + isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || + isVisibleNamedBinding(importDeclaration.importClause.namedBindings); + } + } + moduleElementDeclarationEmitInfo.push({ + node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + isVisible + }); + } + } + } + + function writeModuleElement(node: Node) { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + return writeFunctionDeclaration(node); + case SyntaxKind.VariableStatement: + return writeVariableStatement(node); + case SyntaxKind.InterfaceDeclaration: + return writeInterfaceDeclaration(node); + case SyntaxKind.ClassDeclaration: + return writeClassDeclaration(node); + case SyntaxKind.TypeAliasDeclaration: + return writeTypeAliasDeclaration(node); + case SyntaxKind.EnumDeclaration: + return writeEnumDeclaration(node); + case SyntaxKind.ModuleDeclaration: + return writeModuleDeclaration(node); + case SyntaxKind.ImportEqualsDeclaration: + return writeImportEqualsDeclaration(node); + case SyntaxKind.ImportDeclaration: + return writeImportDeclaration(node); + default: + Debug.fail("Unknown symbol kind"); + } + } + + function emitModuleElementDeclarationFlags(node: Node) { + // If the node is parented in the current source file we need to emit export declare or just export + if (node.parent === currentSourceFile) { + // If the node is exported + if (node.flags & NodeFlags.Export) { + write("export "); + } + + if (node.flags & NodeFlags.Default) { + write("default "); + } + else if (node.kind !== SyntaxKind.InterfaceDeclaration) { + write("declare "); + } + } + } + + function emitClassMemberDeclarationFlags(node: Declaration) { + if (node.flags & NodeFlags.Private) { + write("private "); + } + else if (node.flags & NodeFlags.Protected) { + write("protected "); + } + + if (node.flags & NodeFlags.Static) { + write("static "); + } + } + + function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { + // note usage of writer. methods instead of aliases created, just to make sure we are using + // correct writer especially to handle asynchronous alias writing + emitJsDocComments(node); + if (node.flags & NodeFlags.Export) { + write("export "); + } + write("import "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + if (isInternalModuleImportEqualsDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); + write(";"); + } + else { + write("require("); + writeTextOfNode(currentSourceFile, getExternalModuleImportEqualsDeclarationExpression(node)); + write(");"); + } + writer.writeLine(); + + function getImportEntityNameVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + return { + diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1, + errorNode: node, + typeName: node.name + }; + } + } + + function isVisibleNamedBinding(namedBindings: NamespaceImport | NamedImports): boolean { + if (namedBindings) { + if (namedBindings.kind === SyntaxKind.NamespaceImport) { + return resolver.isDeclarationVisible(namedBindings); + } + else { + return forEach((namedBindings).elements, namedImport => resolver.isDeclarationVisible(namedImport)); + } + } + } + + function writeImportDeclaration(node: ImportDeclaration) { + if (!node.importClause && !(node.flags & NodeFlags.Export)) { + // do not write non-exported import declarations that don't have import clauses + return; + } + emitJsDocComments(node); + if (node.flags & NodeFlags.Export) { + write("export "); + } + write("import "); + if (node.importClause) { + let currentWriterPos = writer.getTextPos(); + if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) { + writeTextOfNode(currentSourceFile, node.importClause.name); + } + if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) { + if (currentWriterPos !== writer.getTextPos()) { + // If the default binding was emitted, write the separated + write(", "); + } + if (node.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { + write("* as "); + writeTextOfNode(currentSourceFile, (node.importClause.namedBindings).name); + } + else { + write("{ "); + emitCommaList((node.importClause.namedBindings).elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible); + write(" }"); + } + } + write(" from "); + } + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + write(";"); + writer.writeLine(); + } + + function emitImportOrExportSpecifier(node: ImportOrExportSpecifier) { + if (node.propertyName) { + writeTextOfNode(currentSourceFile, node.propertyName); + write(" as "); + } + writeTextOfNode(currentSourceFile, node.name); + } + + function emitExportSpecifier(node: ExportSpecifier) { + emitImportOrExportSpecifier(node); + + // Make all the declarations visible for the export name + let nodes = resolver.collectLinkedAliases(node.propertyName || node.name); + + // write each of these declarations asynchronously + writeAsynchronousModuleElements(nodes); + } + + function emitExportDeclaration(node: ExportDeclaration) { + emitJsDocComments(node); + write("export "); + if (node.exportClause) { + write("{ "); + emitCommaList(node.exportClause.elements, emitExportSpecifier); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + writeTextOfNode(currentSourceFile, node.moduleSpecifier); + } + write(";"); + writer.writeLine(); + } + + function writeModuleDeclaration(node: ModuleDeclaration) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("module "); + writeTextOfNode(currentSourceFile, node.name); + while (node.body.kind !== SyntaxKind.ModuleBlock) { + node = node.body; + write("."); + writeTextOfNode(currentSourceFile, node.name); + } + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines((node.body).statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + + function writeTypeAliasDeclaration(node: TypeAliasDeclaration) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("type "); + writeTextOfNode(currentSourceFile, node.name); + write(" = "); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); + write(";"); + writeLine(); + + function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + return { + diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: node.type, + typeName: node.name + }; + } + } + + function writeEnumDeclaration(node: EnumDeclaration) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (isConst(node)) { + write("const ") + } + write("enum "); + writeTextOfNode(currentSourceFile, node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + + function emitEnumMemberDeclaration(node: EnumMember) { + emitJsDocComments(node); + writeTextOfNode(currentSourceFile, node.name); + let enumMemberValue = resolver.getConstantValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + + function isPrivateMethodTypeParameter(node: TypeParameterDeclaration) { + return node.parent.kind === SyntaxKind.MethodDeclaration && (node.parent.flags & NodeFlags.Private); + } + + function emitTypeParameters(typeParameters: TypeParameterDeclaration[]) { + function emitTypeParameter(node: TypeParameterDeclaration) { + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + writeTextOfNode(currentSourceFile, node.name); + // If there is constraint present and this is not a type parameter of the private method emit the constraint + if (node.constraint && !isPrivateMethodTypeParameter(node)) { + write(" extends "); + if (node.parent.kind === SyntaxKind.FunctionType || + node.parent.kind === SyntaxKind.ConstructorType || + (node.parent.parent && node.parent.parent.kind === SyntaxKind.TypeLiteral)) { + Debug.assert(node.parent.kind === SyntaxKind.MethodDeclaration || + node.parent.kind === SyntaxKind.MethodSignature || + node.parent.kind === SyntaxKind.FunctionType || + node.parent.kind === SyntaxKind.ConstructorType || + node.parent.kind === SyntaxKind.CallSignature || + node.parent.kind === SyntaxKind.ConstructSignature); + emitType(node.constraint); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); + } + } + + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + // Type parameter constraints are named by user so we should always be able to name it + let diagnosticMessage: DiagnosticMessage; + switch (node.parent.kind) { + case SyntaxKind.ClassDeclaration: + diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + + case SyntaxKind.InterfaceDeclaration: + diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + + case SyntaxKind.ConstructSignature: + diagnosticMessage = Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + + case SyntaxKind.CallSignature: + diagnosticMessage = Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (node.parent.flags & NodeFlags.Static) { + diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { + diagnosticMessage = Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + + case SyntaxKind.FunctionDeclaration: + diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + + default: + Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + } + + return { + diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + + function emitHeritageClause(typeReferences: TypeReferenceNode[], isImplementsList: boolean) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + + function emitTypeOfTypeReference(node: TypeReferenceNode) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); + + function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage: DiagnosticMessage; + // Heritage clause is written by user so it can always be named + if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { + // Class or Interface implemented/extended is inaccessible + diagnosticMessage = isImplementsList ? + Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + else { + // interface is inaccessible + diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + + return { + diagnosticMessage, + errorNode: node, + typeName: (node.parent.parent).name + }; + } + } + } + + function writeClassDeclaration(node: ClassDeclaration) { + function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) { + if (constructorDeclaration) { + forEach(constructorDeclaration.parameters, param => { + if (param.flags & NodeFlags.AccessibilityModifier) { + emitPropertyDeclaration(param); + } + }); + } + } + + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("class "); + writeTextOfNode(currentSourceFile, node.name); + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + let baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + } + emitHeritageClause(getClassImplementedTypeNodes(node), /*isImplementsList*/ true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + + function writeInterfaceDeclaration(node: InterfaceDeclaration) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + write("interface "); + writeTextOfNode(currentSourceFile, node.name); + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + + function emitPropertyDeclaration(node: Declaration) { + if (hasDynamicName(node)) { + return; + } + + emitJsDocComments(node); + emitClassMemberDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + + function emitVariableDeclaration(node: VariableDeclaration) { + // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted + // so there is no check needed to see if declaration is visible + if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) { + if (isBindingPattern(node.name)) { + emitBindingPattern(node.name); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentSourceFile, node.name); + // If optional property emit ? + if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && hasQuestionToken(node)) { + write("?"); + } + if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.flags & NodeFlags.Private)) { + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); + } + } + } + + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult: SymbolAccessiblityResult) { + if (node.kind === SyntaxKind.VariableDeclaration) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit + else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) { + // TODO(jfreeman): Deal with computed properties in error reporting. + if (node.flags & NodeFlags.Static) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have types that cannot be named + return symbolAccesibilityResult.errorModuleName ? + Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + + function emitBindingPattern(bindingPattern: BindingPattern) { + emitCommaList(bindingPattern.elements, emitBindingElement); + } + + function emitBindingElement(bindingElement: BindingElement) { + function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: bindingElement, + typeName: bindingElement.name + } : undefined; + } + + if (bindingElement.name) { + if (isBindingPattern(bindingElement.name)) { + emitBindingPattern(bindingElement.name); + } + else { + writeTextOfNode(currentSourceFile, bindingElement.name); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); + } + } + } + } + + function emitTypeOfVariableDeclarationFromTypeLiteral(node: VariableLikeDeclaration) { + // if this is property of type literal, + // or is parameter of method/call/construct/index signature of type literal + // emit only if type is specified + if (node.type) { + write(": "); + emitType(node.type); + } + } + + function isVariableStatementVisible(node: VariableStatement) { + return forEach(node.declarationList.declarations, varDeclaration => resolver.isDeclarationVisible(varDeclaration)); + } + + function writeVariableStatement(node: VariableStatement) { + emitJsDocComments(node); + emitModuleElementDeclarationFlags(node); + if (isLet(node.declarationList)) { + write("let "); + } + else if (isConst(node.declarationList)) { + write("const "); + } + else { + write("var "); + } + emitCommaList(node.declarationList.declarations, emitVariableDeclaration, resolver.isDeclarationVisible); + write(";"); + writeLine(); + } + + function emitAccessorDeclaration(node: AccessorDeclaration) { + if (hasDynamicName(node)) { + return; + } + + let accessors = getAllAccessorDeclarations((node.parent).members, node); + let accessorWithTypeAnnotation: AccessorDeclaration; + + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitClassMemberDeclarationFlags(node); + writeTextOfNode(currentSourceFile, node.name); + if (!(node.flags & NodeFlags.Private)) { + accessorWithTypeAnnotation = node; + let type = getTypeAnnotationFromAccessor(node); + if (!type) { + // couldn't get type for the first accessor, try the another one + let anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor; + type = getTypeAnnotationFromAccessor(anotherAccessor); + if (type) { + accessorWithTypeAnnotation = anotherAccessor; + } + } + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); + } + write(";"); + writeLine(); + } + + function getTypeAnnotationFromAccessor(accessor: AccessorDeclaration): TypeNode | StringLiteralExpression { + if (accessor) { + return accessor.kind === SyntaxKind.GetAccessor + ? accessor.type // Getter - return type + : accessor.parameters.length > 0 + ? accessor.parameters[0].type // Setter parameter type + : undefined; + } + } + + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage: DiagnosticMessage; + if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) { + // Setters have to have type named and cannot infer it so, the type should always be named + if (accessorWithTypeAnnotation.parent.flags & NodeFlags.Static) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage, + errorNode: accessorWithTypeAnnotation.parameters[0], + // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name + typeName: accessorWithTypeAnnotation.name + }; + } + else { + if (accessorWithTypeAnnotation.flags & NodeFlags.Static) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage, + errorNode: accessorWithTypeAnnotation.name, + typeName: undefined + }; + } + } + } + + function writeFunctionDeclaration(node: FunctionLikeDeclaration) { + if (hasDynamicName(node)) { + return; + } + + // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting + // so no need to verify if the declaration is visible + if (!resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + if (node.kind === SyntaxKind.FunctionDeclaration) { + emitModuleElementDeclarationFlags(node); + } + else if (node.kind === SyntaxKind.MethodDeclaration) { + emitClassMemberDeclarationFlags(node); + } + if (node.kind === SyntaxKind.FunctionDeclaration) { + write("function "); + writeTextOfNode(currentSourceFile, node.name); + } + else if (node.kind === SyntaxKind.Constructor) { + write("constructor"); + } + else { + writeTextOfNode(currentSourceFile, node.name); + if (hasQuestionToken(node)) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + + function emitSignatureDeclarationWithJsDocComments(node: SignatureDeclaration) { + emitJsDocComments(node); + emitSignatureDeclaration(node); + } + + function emitSignatureDeclaration(node: SignatureDeclaration) { + // Construct signature or constructor type write new Signature + if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { + write("new "); + } + emitTypeParameters(node.typeParameters); + if (node.kind === SyntaxKind.IndexSignature) { + write("["); + } + else { + write("("); + } + + let prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + + // Parameters + emitCommaList(node.parameters, emitParameterDeclaration); + + if (node.kind === SyntaxKind.IndexSignature) { + write("]"); + } + else { + write(")"); + } + + // If this is not a constructor and is not private, emit the return type + let isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType; + if (isFunctionTypeOrConstructorType || node.parent.kind === SyntaxKind.TypeLiteral) { + // Emit type literal signature return type only if specified + if (node.type) { + write(isFunctionTypeOrConstructorType ? " => " : ": "); + emitType(node.type); + } + } + else if (node.kind !== SyntaxKind.Constructor && !(node.flags & NodeFlags.Private)) { + writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); + } + + enclosingDeclaration = prevEnclosingDeclaration; + + if (!isFunctionTypeOrConstructorType) { + write(";"); + writeLine(); + } + + function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage: DiagnosticMessage; + switch (node.kind) { + case SyntaxKind.ConstructSignature: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + + case SyntaxKind.CallSignature: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + + case SyntaxKind.IndexSignature: + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (node.flags & NodeFlags.Static) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + + case SyntaxKind.FunctionDeclaration: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : + Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : + Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + + default: + Debug.fail("This is unknown kind for signature: " + node.kind); + } + + return { + diagnosticMessage, + errorNode: node.name || node, + }; + } + } + + function emitParameterDeclaration(node: ParameterDeclaration) { + increaseIndent(); + emitJsDocComments(node); + if (node.dotDotDotToken) { + write("..."); + } + if (isBindingPattern(node.name)) { + write("_" + indexOf((node.parent).parameters, node)); + } + else { + writeTextOfNode(currentSourceFile, node.name); + } + if (node.initializer || hasQuestionToken(node)) { + write("?"); + } + decreaseIndent(); + + if (node.parent.kind === SyntaxKind.FunctionType || + node.parent.kind === SyntaxKind.ConstructorType || + node.parent.parent.kind === SyntaxKind.TypeLiteral) { + emitTypeOfVariableDeclarationFromTypeLiteral(node); + } + else if (!(node.parent.flags & NodeFlags.Private)) { + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); + } + + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + let diagnosticMessage: DiagnosticMessage; + switch (node.parent.kind) { + case SyntaxKind.Constructor: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + break; + + case SyntaxKind.ConstructSignature: + // Interfaces cannot have parameter types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + + case SyntaxKind.CallSignature: + // Interfaces cannot have parameter types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (node.parent.flags & NodeFlags.Static) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + // Interfaces cannot have parameter types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + + case SyntaxKind.FunctionDeclaration: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + + default: + Debug.fail("This is unknown parent for parameter: " + node.parent.kind); + } + + return { + diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + + function emitNode(node: Node) { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.EnumDeclaration: + return emitModuleElement(node, isModuleElementVisible(node)); + case SyntaxKind.VariableStatement: + return emitModuleElement(node, isVariableStatementVisible(node)); + case SyntaxKind.ImportDeclaration: + // Import declaration without import clause is visible, otherwise it is not visible + return emitModuleElement(node, /*isModuleElementVisible*/!(node).importClause); + case SyntaxKind.ExportDeclaration: + return emitExportDeclaration(node); + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + return writeFunctionDeclaration(node); + case SyntaxKind.ConstructSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.IndexSignature: + return emitSignatureDeclarationWithJsDocComments(node); + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return emitAccessorDeclaration(node); + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return emitPropertyDeclaration(node); + case SyntaxKind.EnumMember: + return emitEnumMemberDeclaration(node); + case SyntaxKind.ExportAssignment: + return emitExportAssignment(node); + case SyntaxKind.SourceFile: + return emitSourceFile(node); + } + } + + function writeReferencePath(referencedFile: SourceFile) { + let declFileName = referencedFile.flags & NodeFlags.DeclarationFile + ? referencedFile.fileName // Declaration file, use declaration file name + : shouldEmitToOwnFile(referencedFile, compilerOptions) + ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file + : removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file + + declFileName = getRelativePathToDirectoryOrUrl( + getDirectoryPath(normalizeSlashes(jsFilePath)), + declFileName, + host.getCurrentDirectory(), + host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ false); + + referencePathsOutput += "/// " + newLine; + } + } + + // @internal + export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) { + let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); + // TODO(shkamat): Should we not write any declaration file if any of them can produce error, + // or should we just not write this file like we are doing now + if (!emitDeclarationResult.reportedDeclarationError) { + let declarationOutput = emitDeclarationResult.referencePathsOutput + + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); + writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM); + } + + function getDeclarationOutput(synchronousDeclarationOutput: string, moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]) { + let appliedSyncOutputPos = 0; + let declarationOutput = ""; + // apply asynchronous additions to the synchronous output + forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += getDeclarationOutput(aliasEmitInfo.asynchronousOutput, aliasEmitInfo.subModuleElementDeclarationEmitInfo); + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + return declarationOutput; + } + } +} \ No newline at end of file diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9fc4248c519..ac923d5c4df 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -159,6 +159,9 @@ module ts { Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." }, + Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, + Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, + Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -341,7 +344,8 @@ module ts { Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, 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: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, + 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." }, 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}'." }, @@ -411,6 +415,7 @@ module ts { Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, @@ -503,6 +508,5 @@ module ts { type_assertion_expressions_can_only_be_used_in_TypeScript: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in TypeScript." }, yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 379a95bc405..4f4433b11dc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -627,6 +627,18 @@ "category": "Error", "code": 1201 }, + "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": { + "category": "Error", + "code": 1202 + }, + "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": { + "category": "Error", + "code": 1203 + }, + "Cannot compile external modules into amd or commonjs when targeting es6 or higher.": { + "category": "Error", + "code": 1204 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -1358,7 +1370,11 @@ }, "Type '{0}' is not an array type or a string type.": { "category": "Error", - "code": 2461 + "code": 2495 + }, + "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": { + "category": "Error", + "code": 2496 }, "Import declaration '{0}' is using private name '{1}'.": { @@ -1637,6 +1653,10 @@ "category": "Error", "code": 4081 }, + "Default export of the module has or is using private name '{0}'.": { + "category": "Error", + "code": 4082 + }, "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher.": { "category": "Error", "code": 4091 @@ -2006,9 +2026,5 @@ "Generators are not currently supported.": { "category": "Error", "code": 9001 - }, - "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": { - "category": "Error", - "code": 9002 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e585f258ef6..b62ab704553 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1,20 +1,7 @@ /// +/// module ts { - interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(sourceFile: SourceFile, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - } interface ExternalImportInfo { rootNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration; @@ -22,1510 +9,16 @@ module ts { namedImports?: NamedImports; } - interface SymbolAccessibilityDiagnostic { - errorNode: Node; - diagnosticMessage: DiagnosticMessage; - typeName?: DeclarationName; - } - // represents one LexicalEnvironment frame to store unique generated names interface ScopeFrame { names: Map; previous: ScopeFrame; } - type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; - - interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { - getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic; - } - - interface AliasDeclarationEmitInfo { - declaration: ImportEqualsDeclaration; - outputPos: number; - indent: number; - asynchronousOutput?: string; // If the output for alias was written asynchronously, the corresponding output - } - - interface DeclarationEmit { - reportedDeclarationError: boolean; - aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[]; - synchronousDeclarationOutput: string; - referencePathsOutput: string; - } - - let indentStrings: string[] = ["", " "]; - export function getIndentString(level: number) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - - function getIndentSize() { - return indentStrings[1].length; - } - - export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { - if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.fileName, ".js")) { - return true; - } - return false; - } - return false; - } - export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } - function createTextWriter(newLine: String): EmitTextWriter { - let output = ""; - let indent = 0; - let lineStart = true; - let lineCount = 0; - let linePos = 0; - - function write(s: string) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - - function rawWrite(s: string) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - - function writeLiteral(s: string) { - if (s && s.length) { - write(s); - let lineStartsOfS = computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - - function writeTextOfNode(sourceFile: SourceFile, node: Node) { - write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - - return { - write, - rawWrite, - writeTextOfNode, - writeLiteral, - writeLine, - increaseIndent: () => indent++, - decreaseIndent: () => indent--, - getIndent: () => indent, - getTextPos: () => output.length, - getLine: () => lineCount + 1, - getColumn: () => lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1, - getText: () => output, - }; - } - - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) { - return getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - - function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) { - // If the leading comments start on different line than the start of node, write new line - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - - function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, - writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void) { - let emitLeadingSpace = !trailingSeparator; - forEach(comments, comment => { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - // Emit leading space to separate comment during next comment emit - emitLeadingSpace = true; - } - }); - } - - function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){ - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - let firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); - let lineCount = getLineStarts(currentSourceFile).length; - let firstCommentLineIndent: number; - for (let pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - let nextLineStart = (currentLine + 1) === lineCount - ? currentSourceFile.text.length + 1 - : getStartPositionOfLine(currentLine + 1, currentSourceFile); - - if (pos !== comment.pos) { - // If we are not emitting first line, we need to write the spaces to adjust the alignment - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); - } - - // These are number of spaces writer is going to write at current indent - let currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - - // Number of spaces we want to be writing - // eg: Assume writer indent - // module m { - // /* starts at character 9 this is line 1 - // * starts at character pos 4 line --1 = 8 - 8 + 3 - // More left indented comment */ --2 = 8 - 8 + 2 - // class c { } - // } - // module m { - // /* this is line 1 -- Assume current writer indent 8 - // * line --3 = 8 - 4 + 5 - // More right indented comment */ --4 = 8 - 4 + 11 - // class c { } - // } - let spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - let indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - - // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces - writer.rawWrite(indentSizeSpaceString); - - // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - // No spaces to emit write empty string - writer.rawWrite(""); - } - } - - // Write the comment line text - writeTrimmedCurrentLine(pos, nextLineStart); - - pos = nextLineStart; - } - } - else { - // Single line comment of style //.... - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - - function writeTrimmedCurrentLine(pos: number, nextLineStart: number) { - let end = Math.min(comment.end, nextLineStart - 1); - let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - // trimmed forward and ending spaces text - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - // Empty string - make sure we write empty line - writer.writeLiteral(newLine); - } - } - - function calculateIndent(pos: number, end: number) { - let currentLineIndent = 0; - for (; pos < end && isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === CharacterCodes.tab) { - // Tabs = TabSize = indent size and go to next tabStop - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - // Single space - currentLineIndent++; - } - } - - return currentLineIndent; - } - } - - function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration { - return forEach(node.members, member => { - if (member.kind === SyntaxKind.Constructor && nodeIsPresent((member).body)) { - return member; - } - }); - } - - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration) { - let firstAccessor: AccessorDeclaration; - let getAccessor: AccessorDeclaration; - let setAccessor: AccessorDeclaration; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === SyntaxKind.GetAccessor) { - getAccessor = accessor; - } - else if (accessor.kind === SyntaxKind.SetAccessor) { - setAccessor = accessor; - } - else { - Debug.fail("Accessor has wrong kind"); - } - } - else { - forEach(declarations, (member: Declaration) => { - if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) - && (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) { - let memberName = getPropertyNameForPropertyNameNode(member.name); - let accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - - if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { - getAccessor = member; - } - - if (member.kind === SyntaxKind.SetAccessor && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor, - getAccessor, - setAccessor - }; - } - - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { - let sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); - return combinePaths(newDirPath, sourceFilePath); - } - - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string){ - let compilerOptions = host.getCompilerOptions(); - let emitOutputFilePathWithoutExtension: string; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.fileName); - } - - return emitOutputFilePathWithoutExtension + extension; - } - - function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean) { - host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => { - diagnostics.push(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); - } - - function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit { - let newLine = host.getNewLine(); - let compilerOptions = host.getCompilerOptions(); - let languageVersion = compilerOptions.target || ScriptTarget.ES3; - - let write: (s: string) => void; - let writeLine: () => void; - let increaseIndent: () => void; - let decreaseIndent: () => void; - let writeTextOfNode: (sourceFile: SourceFile, node: Node) => void; - - let writer = createAndSetNewTextWriterWithSymbolWriter(); - - let enclosingDeclaration: Node; - let currentSourceFile: SourceFile; - let reportedDeclarationError = false; - let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; - let emit = compilerOptions.stripInternal ? stripInternal : emitNode; - - let aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[] = []; - - // Contains the reference paths that needs to go in the declaration file. - // Collecting this separately because reference paths need to be first thing in the declaration file - // and we could be collecting these paths from multiple files into single one with --out option - let referencePathsOutput = ""; - - if (root) { - // Emitting just a single file, so emit references in this file only - if (!compilerOptions.noResolve) { - let addedGlobalFileReference = false; - forEach(root.referencedFiles, fileReference => { - let referencedFile = tryResolveScriptReference(host, root, fileReference); - - // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference - shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file - !addedGlobalFileReference)) { // Or the global out file corresponding to this reference was not added - - writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - - emitSourceFile(root); - } - else { - // Emit references corresponding to this file - let emittedReferencedFiles: SourceFile[] = []; - forEach(host.getSourceFiles(), sourceFile => { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - // Check what references need to be added - if (!compilerOptions.noResolve) { - forEach(sourceFile.referencedFiles, fileReference => { - let referencedFile = tryResolveScriptReference(host, sourceFile, fileReference); - - // If the reference file is a declaration file or an external module, emit that reference - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && - !contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted - - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - - emitSourceFile(sourceFile); - } - }); - } - - return { - reportedDeclarationError, - aliasDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput, - } - - function hasInternalAnnotation(range: CommentRange) { - let text = currentSourceFile.text; - let comment = text.substring(range.pos, range.end); - return comment.indexOf("@internal") >= 0; - } - - function stripInternal(node: Node) { - if (node) { - let leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (forEach(leadingCommentRanges, hasInternalAnnotation)) { - return; - } - - emitNode(node); - } - } - - function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { - let writer = createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - - function setWriter(newWriter: EmitTextWriterWithSymbolWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - - function writeAsychronousImportEqualsDeclarations(importEqualsDeclarations: ImportEqualsDeclaration[]) { - let oldWriter = writer; - forEach(importEqualsDeclarations, aliasToWrite => { - let aliasEmitInfo = forEach(aliasDeclarationEmitInfo, declEmitInfo => declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined); - // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration - // then we don't need to write it at this point. We will write it when we actually see its declaration - // Eg. - // export function bar(a: foo.Foo) { } - // import foo = require("foo"); - // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, - // we would write alias foo declaration when we visit it since it would now be marked as visible - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (let declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - writeImportEqualsDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - - function handleSymbolAccessibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) { - // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportEqualsDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - // Report error - reportedDeclarationError = true; - let errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, - errorInfo.diagnosticMessage, - getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), - symbolAccesibilityResult.errorSymbolName, - symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, - errorInfo.diagnosticMessage, - symbolAccesibilityResult.errorSymbolName, - symbolAccesibilityResult.errorModuleName)); - } - } - } - } - - function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - - function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode | StringLiteralExpression, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - // Write the type - emitType(type); - } - else { - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); - } - } - - function writeReturnTypeAtSignature(signature: SignatureDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - // Write the type - emitType(signature.type); - } - else { - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); - } - } - - function emitLines(nodes: Node[]) { - for (let node of nodes) { - emit(node); - } - } - - function emitSeparatedList(nodes: Node[], separator: string, eachNodeEmitFn: (node: Node) => void) { - let currentWriterPos = writer.getTextPos(); - for (let node of nodes) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(node); - } - } - - function emitCommaList(nodes: Node[], eachNodeEmitFn: (node: Node) => void) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); - } - - function writeJsDocComments(declaration: Node) { - if (declaration) { - let jsDocComments = getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange); - } - } - - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type: TypeNode | EntityName, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - - function emitType(type: TypeNode | StringLiteralExpression | Identifier | QualifiedName) { - switch (type.kind) { - case SyntaxKind.AnyKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.VoidKeyword: - case SyntaxKind.StringLiteral: - return writeTextOfNode(currentSourceFile, type); - case SyntaxKind.TypeReference: - return emitTypeReference(type); - case SyntaxKind.TypeQuery: - return emitTypeQuery(type); - case SyntaxKind.ArrayType: - return emitArrayType(type); - case SyntaxKind.TupleType: - return emitTupleType(type); - case SyntaxKind.UnionType: - return emitUnionType(type); - case SyntaxKind.ParenthesizedType: - return emitParenType(type); - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return emitSignatureDeclarationWithJsDocComments(type); - case SyntaxKind.TypeLiteral: - return emitTypeLiteral(type); - case SyntaxKind.Identifier: - return emitEntityName(type); - case SyntaxKind.QualifiedName: - return emitEntityName(type); - default: - Debug.fail("Unknown type annotation: " + type.kind); - } - - function emitEntityName(entityName: EntityName) { - let visibilityResult = resolver.isEntityNameVisible(entityName, - // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration); - - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - - function writeEntityName(entityName: EntityName) { - if (entityName.kind === SyntaxKind.Identifier) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - let qualifiedName = entityName; - writeEntityName(qualifiedName.left); - write("."); - writeTextOfNode(currentSourceFile, qualifiedName.right); - } - } - } - - function emitTypeReference(type: TypeReferenceNode) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - - function emitTypeQuery(type: TypeQueryNode) { - write("typeof "); - emitEntityName(type.exprName); - } - - function emitArrayType(type: ArrayTypeNode) { - emitType(type.elementType); - write("[]"); - } - - function emitTupleType(type: TupleTypeNode) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - - function emitUnionType(type: UnionTypeNode) { - emitSeparatedList(type.types, " | ", emitType); - } - - function emitParenType(type: ParenthesizedTypeNode) { - write("("); - emitType(type.type); - write(")"); - } - - function emitTypeLiteral(type: TypeLiteralNode) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - // write members - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - - function emitSourceFile(node: SourceFile) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - - function emitExportAssignment(node: ExportAssignment) { - write(node.isExportEquals ? "export = " : "export default "); - writeTextOfNode(currentSourceFile, node.expression); - write(";"); - writeLine(); - } - - function emitModuleElementDeclarationFlags(node: Node) { - // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent === currentSourceFile) { - // If the node is exported - if (node.flags & NodeFlags.Export) { - write("export "); - } - - if (node.kind !== SyntaxKind.InterfaceDeclaration) { - write("declare "); - } - } - } - - function emitClassMemberDeclarationFlags(node: Declaration) { - if (node.flags & NodeFlags.Private) { - write("private "); - } - else if (node.flags & NodeFlags.Protected) { - write("protected "); - } - - if (node.flags & NodeFlags.Static) { - write("static "); - } - } - - function emitImportEqualsDeclaration(node: ImportEqualsDeclaration) { - let nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportEqualsDeclaration(node); - } - } - - function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { - // note usage of writer. methods instead of aliases created, just to make sure we are using - // correct writer especially to handle asynchronous alias writing - emitJsDocComments(node); - if (node.flags & NodeFlags.Export) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (isInternalModuleImportEqualsDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, getExternalModuleImportEqualsDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - - function getImportEntityNameVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - return { - diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - - function emitModuleDeclaration(node: ModuleDeclaration) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== SyntaxKind.ModuleBlock) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - let prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines((node.body).statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - - function emitTypeAliasDeclaration(node: TypeAliasDeclaration) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - } - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - return { - diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - - function emitEnumDeclaration(node: EnumDeclaration) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (isConst(node)) { - write("const ") - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - } - - function emitEnumMemberDeclaration(node: EnumMember) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - let enumMemberValue = resolver.getConstantValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - - function isPrivateMethodTypeParameter(node: TypeParameterDeclaration) { - return node.parent.kind === SyntaxKind.MethodDeclaration && (node.parent.flags & NodeFlags.Private); - } - - function emitTypeParameters(typeParameters: TypeParameterDeclaration[]) { - function emitTypeParameter(node: TypeParameterDeclaration) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - // If there is constraint present and this is not a type parameter of the private method emit the constraint - if (node.constraint && !isPrivateMethodTypeParameter(node)) { - write(" extends "); - if (node.parent.kind === SyntaxKind.FunctionType || - node.parent.kind === SyntaxKind.ConstructorType || - (node.parent.parent && node.parent.parent.kind === SyntaxKind.TypeLiteral)) { - Debug.assert(node.parent.kind === SyntaxKind.MethodDeclaration || - node.parent.kind === SyntaxKind.MethodSignature || - node.parent.kind === SyntaxKind.FunctionType || - node.parent.kind === SyntaxKind.ConstructorType || - node.parent.kind === SyntaxKind.CallSignature || - node.parent.kind === SyntaxKind.ConstructSignature); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - // Type parameter constraints are named by user so we should always be able to name it - let diagnosticMessage: DiagnosticMessage; - switch (node.parent.kind) { - case SyntaxKind.ClassDeclaration: - diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - - case SyntaxKind.InterfaceDeclaration: - diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - - case SyntaxKind.ConstructSignature: - diagnosticMessage = Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - - case SyntaxKind.CallSignature: - diagnosticMessage = Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (node.parent.flags & NodeFlags.Static) { - diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { - diagnosticMessage = Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - - case SyntaxKind.FunctionDeclaration: - diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - - default: - Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - - return { - diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - - function emitHeritageClause(typeReferences: TypeReferenceNode[], isImplementsList: boolean) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - - function emitTypeOfTypeReference(node: TypeReferenceNode) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - - function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage; - // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { - // Class or Interface implemented/extended is inaccessible - diagnosticMessage = isImplementsList ? - Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - // interface is inaccessible - diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - - return { - diagnosticMessage, - errorNode: node, - typeName: (node.parent.parent).name - }; - } - } - } - - function emitClassDeclaration(node: ClassDeclaration) { - function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) { - if (constructorDeclaration) { - forEach(constructorDeclaration.parameters, param => { - if (param.flags & NodeFlags.AccessibilityModifier) { - emitPropertyDeclaration(param); - } - }); - } - } - - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - let prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - let baseTypeNode = getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); - } - emitHeritageClause(getClassImplementedTypeNodes(node), /*isImplementsList*/ true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - - function emitInterfaceDeclaration(node: InterfaceDeclaration) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - let prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - - function emitPropertyDeclaration(node: Declaration) { - if (hasDynamicName(node)) { - return; - } - - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - - function emitVariableDeclaration(node: VariableDeclaration) { - // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted - // so there is no check needed to see if declaration is visible - if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentSourceFile, node.name); - // If optional property emit ? - if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && hasQuestionToken(node)) { - write("?"); - } - if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & NodeFlags.Private)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage; - if (node.kind === SyntaxKind.VariableDeclaration) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit - else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) { - // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - - return diagnosticMessage !== undefined ? { - diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - } - - function emitTypeOfVariableDeclarationFromTypeLiteral(node: VariableLikeDeclaration) { - // if this is property of type literal, - // or is parameter of method/call/construct/index signature of type literal - // emit only if type is specified - if (node.type) { - write(": "); - emitType(node.type); - } - } - - function emitVariableStatement(node: VariableStatement) { - let hasDeclarationWithEmit = forEach(node.declarationList.declarations, varDeclaration => resolver.isDeclarationVisible(varDeclaration)); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (isLet(node.declarationList)) { - write("let "); - } - else if (isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarationList.declarations, emitVariableDeclaration); - write(";"); - writeLine(); - } - } - - function emitAccessorDeclaration(node: AccessorDeclaration) { - if (hasDynamicName(node)) { - return; - } - - let accessors = getAllAccessorDeclarations((node.parent).members, node); - let accessorWithTypeAnnotation: AccessorDeclaration; - - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & NodeFlags.Private)) { - accessorWithTypeAnnotation = node; - let type = getTypeAnnotationFromAccessor(node); - if (!type) { - // couldn't get type for the first accessor, try the another one - let anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - - function getTypeAnnotationFromAccessor(accessor: AccessorDeclaration): TypeNode | StringLiteralExpression { - if (accessor) { - return accessor.kind === SyntaxKind.GetAccessor - ? accessor.type // Getter - return type - : accessor.parameters.length > 0 - ? accessor.parameters[0].type // Setter parameter type - : undefined; - } - } - - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage; - if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) { - // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - // TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - - function emitFunctionDeclaration(node: FunctionLikeDeclaration) { - if (hasDynamicName(node)) { - return; - } - - // If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting - // so no need to verify if the declaration is visible - if ((node.kind !== SyntaxKind.FunctionDeclaration || resolver.isDeclarationVisible(node)) && - !resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === SyntaxKind.FunctionDeclaration) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === SyntaxKind.MethodDeclaration) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === SyntaxKind.FunctionDeclaration) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === SyntaxKind.Constructor) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - - function emitSignatureDeclarationWithJsDocComments(node: SignatureDeclaration) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - - function emitSignatureDeclaration(node: SignatureDeclaration) { - // Construct signature or constructor type write new Signature - if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === SyntaxKind.IndexSignature) { - write("["); - } - else { - write("("); - } - - let prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - - // Parameters - emitCommaList(node.parameters, emitParameterDeclaration); - - if (node.kind === SyntaxKind.IndexSignature) { - write("]"); - } - else { - write(")"); - } - - // If this is not a constructor and is not private, emit the return type - let isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType; - if (isFunctionTypeOrConstructorType || node.parent.kind === SyntaxKind.TypeLiteral) { - // Emit type literal signature return type only if specified - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== SyntaxKind.Constructor && !(node.flags & NodeFlags.Private)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - - enclosingDeclaration = prevEnclosingDeclaration; - - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - - function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage; - switch (node.kind) { - case SyntaxKind.ConstructSignature: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - - case SyntaxKind.CallSignature: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - - case SyntaxKind.IndexSignature: - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (node.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; - } - else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - - case SyntaxKind.FunctionDeclaration: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : - Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : - Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - - default: - Debug.fail("This is unknown kind for signature: " + node.kind); - } - - return { - diagnosticMessage, - errorNode: node.name || node, - }; - } - } - - function emitParameterDeclaration(node: ParameterDeclaration) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - if (isBindingPattern(node.name)) { - write("_" + indexOf((node.parent).parameters, node)); - } - else { - writeTextOfNode(currentSourceFile, node.name); - } - if (node.initializer || hasQuestionToken(node)) { - write("?"); - } - decreaseIndent(); - - if (node.parent.kind === SyntaxKind.FunctionType || - node.parent.kind === SyntaxKind.ConstructorType || - node.parent.parent.kind === SyntaxKind.TypeLiteral) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & NodeFlags.Private)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - let diagnosticMessage: DiagnosticMessage; - switch (node.parent.kind) { - case SyntaxKind.Constructor: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - break; - - case SyntaxKind.ConstructSignature: - // Interfaces cannot have parameter types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - - case SyntaxKind.CallSignature: - // Interfaces cannot have parameter types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (node.parent.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - // Interfaces cannot have parameter types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - - case SyntaxKind.FunctionDeclaration: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? - Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : - Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - - default: - Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - - return { - diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - - function emitNode(node: Node) { - switch (node.kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - return emitFunctionDeclaration(node); - case SyntaxKind.ConstructSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.IndexSignature: - return emitSignatureDeclarationWithJsDocComments(node); - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return emitAccessorDeclaration(node); - case SyntaxKind.VariableStatement: - return emitVariableStatement(node); - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - return emitPropertyDeclaration(node); - case SyntaxKind.InterfaceDeclaration: - return emitInterfaceDeclaration(node); - case SyntaxKind.ClassDeclaration: - return emitClassDeclaration(node); - case SyntaxKind.TypeAliasDeclaration: - return emitTypeAliasDeclaration(node); - case SyntaxKind.EnumMember: - return emitEnumMemberDeclaration(node); - case SyntaxKind.EnumDeclaration: - return emitEnumDeclaration(node); - case SyntaxKind.ModuleDeclaration: - return emitModuleDeclaration(node); - case SyntaxKind.ImportEqualsDeclaration: - return emitImportEqualsDeclaration(node); - case SyntaxKind.ExportAssignment: - return emitExportAssignment(node); - case SyntaxKind.SourceFile: - return emitSourceFile(node); - } - } - - function writeReferencePath(referencedFile: SourceFile) { - let declFileName = referencedFile.flags & NodeFlags.DeclarationFile - ? referencedFile.fileName // Declaration file, use declaration file name - : shouldEmitToOwnFile(referencedFile, compilerOptions) - ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file - - declFileName = getRelativePathToDirectoryOrUrl( - getDirectoryPath(normalizeSlashes(jsFilePath)), - declFileName, - host.getCurrentDirectory(), - host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ false); - - referencePathsOutput += "/// " + newLine; - } - } - - export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { - let diagnostics: Diagnostic[] = []; - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); - emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - // @internal // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { @@ -1594,25 +87,12 @@ module ts { /** write emitted output to disk*/ let writeEmittedFiles = writeJavaScriptFile; - /** Emit leading comments of the node */ - let emitLeadingComments = compilerOptions.removeComments ? (node: Node) => { } : emitLeadingDeclarationComments; - - /** Emit Trailing comments of the node */ - let emitTrailingComments = compilerOptions.removeComments ? (node: Node) => { } : emitTrailingDeclarationComments; - - let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? (pos: number) => { } : emitLeadingCommentsOfLocalPosition; - let detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[]; - /** Emit detached comments of the node */ - let emitDetachedComments = compilerOptions.removeComments ? (node: TextRange) => { } : emitDetachedCommentsAtPosition; - let writeComment = writeCommentRange; /** Emit a node */ - let emitNodeWithoutSourceMap = compilerOptions.removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments; let emit = emitNodeWithoutSourceMap; - let emitWithoutComments = emitNodeWithoutSourceMapWithoutComments; /** Called just before starting emit of a node */ let emitStart = function (node: Node) { }; @@ -2091,17 +571,8 @@ module ts { } } - function emitNodeWithSourceMapWithoutComments(node: Node) { - if (node) { - recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMapWithoutComments(node); - recordEmitNodeEndSpan(node); - } - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; emit = emitNodeWithSourceMap; - emitWithoutComments = emitNodeWithSourceMapWithoutComments; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -3258,7 +1729,7 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - if (compilerOptions.target >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6) { emit(node.tag); write(" "); emit(node.template); @@ -3858,8 +2329,14 @@ module ts { function emitModuleMemberName(node: Declaration) { emitStart(node.name); if (getCombinedNodeFlags(node) & NodeFlags.Export) { - emitContainingModuleName(node); - write("."); + var container = getContainingModule(node); + if (container) { + write(resolver.getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < ScriptTarget.ES6) { + write("exports."); + } } emitNodeWithoutSourceMap(node.name); emitEnd(node.name); @@ -4154,7 +2631,10 @@ module ts { } function emitExportVariableAssignments(node: VariableDeclaration | BindingElement) { - let name = (node).name; + if (node.kind === SyntaxKind.OmittedExpression) { + return; + } + let name = node.name; if (name.kind === SyntaxKind.Identifier) { emitExportMemberAssignments(name); } @@ -4211,10 +2691,21 @@ module ts { generatedBlockScopeNames[variableId] = generatedName; } + function isES6ModuleMemberDeclaration(node: Node) { + return !!(node.flags & NodeFlags.Export) && + languageVersion >= ScriptTarget.ES6 && + node.parent.kind === SyntaxKind.SourceFile; + } + function emitVariableStatement(node: VariableStatement) { if (!(node.flags & NodeFlags.Export)) { emitStartOfVariableDeclarationList(node.declarationList); } + else if (languageVersion >= ScriptTarget.ES6 && node.parent.kind === SyntaxKind.SourceFile) { + // Exported ES6 module member + write("export "); + emitStartOfVariableDeclarationList(node.declarationList); + } emitCommaList(node.declarationList.declarations); write(";"); if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { @@ -4333,9 +2824,22 @@ module ts { } } + function shouldEmitFunctionName(node: Declaration): boolean { + // Emit a declaration name for the function iff: + // it is a function expression with a name provided + // it is a function declaration with a name provided + // it is a function declaration is not the default export, and is missing a name (emit a generated name for it) + if (node.kind === SyntaxKind.FunctionExpression) { + return !!node.name; + } + else if (node.kind === SyntaxKind.FunctionDeclaration) { + return !!node.name || (languageVersion >= ScriptTarget.ES6 && !(node.flags & NodeFlags.Default)); + } + } + function emitFunctionDeclaration(node: FunctionLikeDeclaration) { if (nodeIsMissing(node.body)) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { @@ -4346,12 +2850,19 @@ 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)) { + write("export "); + if (node.flags & NodeFlags.Default) { + write("default "); + } + } write("function "); } - if (node.kind === SyntaxKind.FunctionDeclaration || (node.kind === SyntaxKind.FunctionExpression && node.name)) { + if (shouldEmitFunctionName(node)) { emitDeclarationName(node); } + emitSignatureAndBody(node); if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments((node).name); @@ -4422,7 +2933,7 @@ module ts { emitExpressionFunctionBody(node, node.body); } - if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { + if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default) && !isES6ModuleMemberDeclaration(node)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -4484,10 +2995,7 @@ module ts { write(" "); emitStart(body); write("return "); - - // Don't emit comments on this body. We'll have already taken care of it above - // when we called emitDetachedComments. - emitWithoutComments(body); + emit(body); emitEnd(body); write(";"); emitTempDeclarations(/*newLine*/ false); @@ -4498,10 +3006,7 @@ module ts { writeLine(); emitLeadingComments(node.body); write("return "); - - // Don't emit comments on this body. We'll have already taken care of it above - // when we called emitDetachedComments. - emitWithoutComments(node.body); + emit(body); write(";"); emitTrailingComments(node.body); @@ -4633,7 +3138,7 @@ module ts { forEach(node.members, member => { if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { - return emitPinnedOrTripleSlashComments(member); + return emitOnlyPinnedOrTripleSlashComments(member); } writeLine(); @@ -4708,7 +3213,7 @@ module ts { function emitMemberFunctionsForES6AndHigher(node: ClassDeclaration) { for (let member of node.members) { if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { - emitPinnedOrTripleSlashComments(member); + emitOnlyPinnedOrTripleSlashComments(member); } else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { writeLine(); @@ -4749,7 +3254,7 @@ module ts { // Emit the constructor overload pinned comments forEach(node.members, member => { if (member.kind === SyntaxKind.Constructor && !(member).body) { - emitPinnedOrTripleSlashComments(member); + emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment if (member.kind === SyntaxKind.PropertyDeclaration && (member).initializer && (member.flags & NodeFlags.Static) === 0) { @@ -4857,7 +3362,7 @@ module ts { } function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { - if (node.flags & NodeFlags.Export) { + if (isES6ModuleMemberDeclaration(node)) { write("export "); if (node.flags & NodeFlags.Default) { @@ -4866,7 +3371,10 @@ module ts { } write("class "); - emitDeclarationName(node); + // check if this is an "export default class" as it may not have a name + if (node.name || !(node.flags & NodeFlags.Default)) { + emitDeclarationName(node); + } var baseTypeNode = getClassBaseTypeNode(node); if (baseTypeNode) { write(" extends "); @@ -4890,6 +3398,18 @@ module ts { // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. writeLine(); emitMemberAssignments(node, NodeFlags.Static); + + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } } function emitClassDeclarationBelowES6(node: ClassDeclaration) { @@ -4932,6 +3452,7 @@ module ts { } write(");"); emitEnd(node); + if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { writeLine(); emitStart(node); @@ -4941,13 +3462,14 @@ module ts { emitEnd(node); write(";"); } + if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } function emitInterfaceDeclaration(node: InterfaceDeclaration) { - emitPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); } function shouldEmitEnumDeclaration(node: EnumDeclaration) { @@ -4961,7 +3483,7 @@ module ts { return; } - if (!(node.flags & NodeFlags.Export)) { + if (!(node.flags & NodeFlags.Export) || isES6ModuleMemberDeclaration(node)) { emitStart(node); write("var "); emit(node.name); @@ -4988,7 +3510,10 @@ module ts { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (node.flags & NodeFlags.Export) { + if (isES6ModuleMemberDeclaration(node)) { + emitES6NamedExportForDeclaration(node); + } + else if (node.flags & NodeFlags.Export) { writeLine(); emitStart(node); write("var "); @@ -5020,15 +3545,12 @@ module ts { } function writeEnumMemberDeclarationValue(member: EnumMember) { - if (!member.initializer || isConst(member.parent)) { - let value = resolver.getConstantValue(member); - if (value !== undefined) { - write(value.toString()); - return; - } + let value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; } - - if (member.initializer) { + else if (member.initializer) { emit(member.initializer); } else { @@ -5052,7 +3574,7 @@ module ts { let shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } emitStart(node); @@ -5094,7 +3616,8 @@ module ts { scopeEmitEnd(); } write(")("); - if (node.flags & NodeFlags.Export) { + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & NodeFlags.Export) && !isES6ModuleMemberDeclaration(node)) { emit(node.name); write(" = "); } @@ -5103,11 +3626,23 @@ module ts { emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (languageVersion < ScriptTarget.ES6 && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { + if (isES6ModuleMemberDeclaration(node)) { + emitES6NamedExportForDeclaration(node); + } + else if (languageVersion < ScriptTarget.ES6 && 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("); @@ -5122,7 +3657,95 @@ module ts { } } - function emitImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) { + function emitImportDeclaration(node: ImportDeclaration) { + if (languageVersion < ScriptTarget.ES6) { + return emitExternalImportDeclaration(node); + } + + // ES6 import + if (node.importClause) { + let shouldEmitDefaultBindings = hasReferencedDefaultName(node.importClause); + let shouldEmitNamedBindings = hasReferencedNamedBindings(node.importClause); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { + write("* as "); + emit((node.importClause.namedBindings).name); + } + 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]); + } + } + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + + 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; @@ -5164,7 +3787,7 @@ module ts { function emitImportEqualsDeclaration(node: ImportEqualsDeclaration) { if (isExternalModuleImportEqualsDeclaration(node)) { - emitImportDeclaration(node); + emitExternalImportDeclaration(node); return; } // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when @@ -5174,7 +3797,13 @@ module ts { (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (!(node.flags & NodeFlags.Export)) write("var "); + if (isES6ModuleMemberDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & NodeFlags.Export)) { + write("var "); + } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); @@ -5185,77 +3814,121 @@ module ts { } function emitExportDeclaration(node: ExportDeclaration) { - if (node.moduleSpecifier) { - emitStart(node); - let generatedName = resolver.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(" = "); + if (languageVersion < ScriptTarget.ES6 || node.parent.kind !== SyntaxKind.SourceFile) { + if (node.moduleSpecifier) { + emitStart(node); + let generatedName = resolver.getGeneratedNameForNode(node); + if (compilerOptions.module !== ModuleKind.AMD) { + write("var "); write(generatedName); - write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); - write(";"); - emitEnd(specifier); - }); + 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(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + }); + } + else { + // export * + let tempName = createTempVariable(node).text; + writeLine(); + write("for (var " + tempName + " in " + generatedName + ") if (!"); + emitContainingModuleName(node); + write(".hasOwnProperty(" + tempName + ")) "); + emitContainingModuleName(node); + write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); + } + emitEnd(node); } else { - // export * - let tempName = createTempVariable(node).text; - writeLine(); - write("for (var " + tempName + " in " + generatedName + ") if (!"); - emitContainingModuleName(node); - write(".hasOwnProperty(" + tempName + ")) "); - emitContainingModuleName(node); - write("[" + tempName + "] = " + generatedName + "[" + tempName + "];"); + // internal module + if (node.exportClause) { + // export { x, y, ... } + forEach(node.exportClause.elements, specifier => { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + }); + } } - 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) { - return { - rootNode: node, - declarationNode: node - }; + if (resolver.isReferencedAliasDeclaration(node)) { + return { + rootNode: node, + declarationNode: node + }; + } } } else if (node.kind === SyntaxKind.ImportDeclaration) { let importClause = (node).importClause; if (importClause) { - if (importClause.name) { + if (importClause.name && resolver.isReferencedAliasDeclaration(importClause)) { return { rootNode: node, declarationNode: importClause }; } - if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { - return { - rootNode: node, - declarationNode: importClause.namedBindings - }; + if (hasReferencedNamedBindings(importClause)) { + if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { + return { + rootNode: node, + declarationNode: importClause.namedBindings + }; + } + else { + return { + rootNode: node, + namedImports: importClause.namedBindings, + localName: resolver.getGeneratedNameForNode(node) + }; + } } - return { - rootNode: node, - namedImports: importClause.namedBindings, - localName: resolver.getGeneratedNameForNode(node) - }; } - return { - rootNode: node + else { + return { + rootNode: node + }; } } else if (node.kind === SyntaxKind.ExportDeclaration) { @@ -5292,9 +3965,7 @@ module ts { else { let info = createExternalImportInfo(node); if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); - } + externalImports.push(info); } } }); @@ -5324,6 +3995,7 @@ module ts { } function emitAMDModule(node: SourceFile, startIndex: number) { + createExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -5374,28 +4046,60 @@ module ts { } function emitCommonJSModule(node: SourceFile, startIndex: number) { + createExternalModuleInfo(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); emitExportDefault(node, /*emitAsReturn*/ false); } - function emitExportDefault(sourceFile: SourceFile, emitAsReturn: boolean) { - if (exportDefault && resolver.hasExportDefaultValue(sourceFile)) { + function emitES6Module(node: SourceFile, startIndex: number) { + externalImports = undefined; + exportSpecifiers = undefined; + exportDefault = undefined; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + // Emit exportDefault if it exists will happen as part + // 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) { writeLine(); - emitStart(exportDefault); - write(emitAsReturn ? "return " : "module.exports = "); - if (exportDefault.kind === SyntaxKind.ExportAssignment) { - emit((exportDefault).expression); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== SyntaxKind.FunctionDeclaration && + expression.kind !== SyntaxKind.ClassDeclaration) { + write(";"); } - else if (exportDefault.kind === SyntaxKind.ExportSpecifier) { - emit((exportDefault).propertyName); + 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); } - else { - emitDeclarationName(exportDefault); - } - write(";"); - emitEnd(exportDefault); } } @@ -5442,8 +4146,10 @@ module ts { extendsEmitted = true; } if (isExternalModule(node)) { - createExternalModuleInfo(node); - if (compilerOptions.module === ModuleKind.AMD) { + if (languageVersion >= ScriptTarget.ES6) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === ModuleKind.AMD) { emitAMDModule(node, startIndex); } else { @@ -5462,13 +4168,13 @@ module ts { emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node: Node, allowGeneratedIdentifiers?: boolean): void { + function emitNodeWithoutSourceMap(node: Node, allowGeneratedIdentifiers?: boolean): void { if (!node) { return; } if (node.flags & NodeFlags.Ambient) { - return emitPinnedOrTripleSlashComments(node); + return emitOnlyPinnedOrTripleSlashComments(node); } let emitComments = shouldEmitLeadingAndTrailingComments(node); @@ -5483,22 +4189,10 @@ module ts { } } - function emitNodeWithoutSourceMapWithoutComments(node: Node, allowGeneratedIdentifiers?: boolean): void { - if (!node) { - return; - } - - if (node.flags & NodeFlags.Ambient) { - return emitPinnedOrTripleSlashComments(node); - } - - emitJavaScriptWorker(node, allowGeneratedIdentifiers); - } - function shouldEmitLeadingAndTrailingComments(node: Node) { switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow - // the specilized methods for each to handle the comments on the nodes. + // the specialized methods for each to handle the comments on the nodes. case SyntaxKind.InterfaceDeclaration: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ImportDeclaration: @@ -5518,6 +4212,19 @@ module ts { return shouldEmitEnumDeclaration(node); } + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== SyntaxKind.Block && + node.parent && + node.parent.kind === SyntaxKind.ArrowFunction && + (node.parent).body === node && + compilerOptions.target <= ScriptTarget.ES5) { + + return false; + } + // Emit comments for everything else. return true; } @@ -5667,10 +4374,15 @@ module ts { return emitModuleDeclaration(node); case SyntaxKind.ImportDeclaration: return emitImportDeclaration(node); + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ExportSpecifier: + return emitImportOrExportSpecifier(node); case SyntaxKind.ImportEqualsDeclaration: return emitImportEqualsDeclaration(node); case SyntaxKind.ExportDeclaration: return emitExportDeclaration(node); + case SyntaxKind.ExportAssignment: + return emitExportAssignment(node); case SyntaxKind.SourceFile: return emitSourceFileNode(node); } @@ -5682,7 +4394,8 @@ module ts { function getLeadingCommentsWithoutDetachedComments() { // get the leading comments from detachedPos - let leadingComments = getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + let leadingComments = getLeadingCommentRanges(currentSourceFile.text, + detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -5693,43 +4406,72 @@ module ts { return leadingComments; } + function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] { + // If we're removing comments, then we want to strip out all but the pinned or + // triple slash comments. + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + + return ranges; + } + function getLeadingCommentsToEmit(node: Node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) { - let leadingComments: CommentRange[]; if (hasDetachedComments(node.pos)) { // get comments without detached comments - leadingComments = getLeadingCommentsWithoutDetachedComments(); + return getLeadingCommentsWithoutDetachedComments(); } else { // get the leading comments from the node - leadingComments = getLeadingCommentRangesOfNode(node, currentSourceFile); + return getLeadingCommentRangesOfNode(node, currentSourceFile); } - return leadingComments; } } } - function emitLeadingDeclarationComments(node: Node) { - let leadingComments = getLeadingCommentsToEmit(node); + function getTrailingCommentsToEmit(node: Node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) { + return getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + + function emitOnlyPinnedOrTripleSlashComments(node: Node) { + emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); + } + + function emitLeadingComments(node: Node) { + return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + } + + function emitLeadingCommentsWorker(node: Node, onlyPinnedOrTripleSlashComments: boolean) { + // If the caller only wants pinned or triple slash comments, then always filter + // down to that set. Otherwise, filter based on the current compiler options. + let leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitTrailingDeclarationComments(node: Node) { + function emitTrailingComments(node: Node) { // Emit the trailing comments only if the parent's end doesn't match - if (node.parent) { - if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) { - let trailingComments = getTrailingCommentRanges(currentSourceFile.text, node.end); - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); - } - } + var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); } - function emitLeadingCommentsOfLocalPosition(pos: number) { + function emitLeadingCommentsOfPosition(pos: number) { let leadingComments: CommentRange[]; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -5739,12 +4481,15 @@ module ts { // get the leading comments from the node leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos); } + + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedCommentsAtPosition(node: TextRange) { + function emitDetachedComments(node: TextRange) { let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { let detachedComments: CommentRange[] = []; @@ -5789,47 +4534,18 @@ module ts { } } - /** Emits /// or pinned which is comment starting with /*! comments */ - function emitPinnedOrTripleSlashComments(node: Node) { - let pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - - function isPinnedOrTripleSlashComment(comment: CommentRange) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && - currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) { - return true; - } + function isPinnedOrTripleSlashComment(comment: CommentRange) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; + } + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && + currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) { + return true; } - - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentSourceFile, writer, pinnedComments, /*trailingSeparator*/ true, newLine, writeComment); - } - } - - function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile) { - let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); - // TODO(shkamat): Should we not write any declaration file if any of them can produce error, - // or should we just not write this file like we are doing now - if (!emitDeclarationResult.reportedDeclarationError) { - let declarationOutput = emitDeclarationResult.referencePathsOutput; - // apply additions - let appliedSyncOutputPos = 0; - forEach(emitDeclarationResult.aliasDeclarationEmitInfo, aliasEmitInfo => { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } @@ -5837,8 +4553,9 @@ module ts { emitJavaScript(jsFilePath, sourceFile); if (compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); + writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); } } } } + diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 0851ad1690f..a4c3a65f29c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -10,7 +10,7 @@ module ts { /** The version of the TypeScript compiler release */ export let version = "1.5.0.0"; - export function createCompilerHost(options: CompilerOptions): CompilerHost { + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { let currentDirectory: string; let existingDirectories: Map = {}; @@ -38,7 +38,7 @@ module ts { } text = ""; } - return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined; + return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath: string): boolean { @@ -87,6 +87,11 @@ module ts { export function getPreEmitDiagnostics(program: Program): Diagnostic[] { let diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics()); + + if (program.getCompilerOptions().declaration) { + diagnostics.concat(program.getDeclarationDiagnostics()); + } + return sortAndDeduplicateDiagnostics(diagnostics); } @@ -178,11 +183,6 @@ module ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[] { - let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile); - return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile); - } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. @@ -232,6 +232,10 @@ module ts { return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); } + function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + } + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return sourceFile.parseDiagnostics; } @@ -247,6 +251,15 @@ module ts { return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); } + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + if (!isDeclarationFile(sourceFile)) { + let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); + // Don't actually write any files since we're just getting diagnostics. + var writeFile: WriteFileCallback = () => { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + } + function getGlobalDiagnostics(): Diagnostic[] { let typeChecker = getDiagnosticsProducingTypeChecker(); @@ -436,11 +449,20 @@ module ts { return; } + let languageVersion = options.target || ScriptTarget.ES3; + let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (firstExternalModuleSourceFile && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet - let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + if (!options.module && languageVersion < ScriptTarget.ES6) { + // We cannot use createDiagnosticFromNode because nodes do not have parents yet + let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); + diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); + } + } + + // Cannot specify module gen target when in es6 or above + if (options.module && languageVersion >= ScriptTarget.ES6) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourcRoot diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fbcadab8c1d..9e5e65db935 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -318,13 +318,38 @@ module ts { let hasOwnProperty = Object.prototype.hasOwnProperty; export function isWhiteSpace(ch: number): boolean { - return ch === CharacterCodes.space || ch === CharacterCodes.tab || ch === CharacterCodes.verticalTab || ch === CharacterCodes.formFeed || - ch === CharacterCodes.nonBreakingSpace || ch === CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || - ch === CharacterCodes.narrowNoBreakSpace || ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark; + // Note: nextLine is in the Zs space, and should be considered to be a whitespace. + // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. + return ch === CharacterCodes.space || + ch === CharacterCodes.tab || + ch === CharacterCodes.verticalTab || + ch === CharacterCodes.formFeed || + ch === CharacterCodes.nonBreakingSpace || + ch === CharacterCodes.nextLine || + ch === CharacterCodes.ogham || + ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || + ch === CharacterCodes.narrowNoBreakSpace || + ch === CharacterCodes.mathematicalSpace || + ch === CharacterCodes.ideographicSpace || + ch === CharacterCodes.byteOrderMark; } export function isLineBreak(ch: number): boolean { - return ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn || ch === CharacterCodes.lineSeparator || ch === CharacterCodes.paragraphSeparator || ch === CharacterCodes.nextLine; + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3 — Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. + + return ch === CharacterCodes.lineFeed || + ch === CharacterCodes.carriageReturn || + ch === CharacterCodes.lineSeparator || + ch === CharacterCodes.paragraphSeparator; } function isDigit(ch: number): boolean { @@ -455,11 +480,13 @@ module ts { return pos; } - // Extract comments from the given source text starting at the given position. If trailing is false, whitespace is skipped until - // the first line break and comments between that location and the next token are returned. If trailing is true, comments occurring - // between the given position and the next line break are returned. The return value is an array containing a TextRange for each - // comment. Single-line comment ranges include the beginning '//' characters but not the ending line break. Multi-line comment - // ranges include the beginning '/* and ending '*/' characters. The return value is undefined if no comments were found. + // Extract comments from the given source text starting at the given position. If trailing is + // false, whitespace is skipped until the first line break and comments between that location + // and the next token are returned.If trailing is true, comments occurring between the given + // position and the next line break are returned.The return value is an array containing a + // TextRange for each comment. Single-line comment ranges include the beginning '//' characters + // but not the ending line break. Multi - line comment ranges include the beginning '/* and + // ending '*/' characters.The return value is undefined if no comments were found. function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; let collecting = trailing || pos === 0; @@ -467,7 +494,9 @@ module ts { let ch = text.charCodeAt(pos); switch (ch) { case CharacterCodes.carriageReturn: - if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) pos++; + if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { + pos++; + } case CharacterCodes.lineFeed: pos++; if (trailing) { @@ -509,7 +538,10 @@ module ts { } } if (collecting) { - if (!result) result = []; + if (!result) { + result = []; + } + result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); } continue; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a60c0666419..6d0b1309a72 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1189,9 +1189,11 @@ module ts { CannotBeNamed } + export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; + export interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; // aliases that need to have this symbol visible + aliasesToMakeVisible?: AnyImportSyntax[]; // aliases that need to have this symbol visible errorSymbolName?: string; // Optional symbol name that results in error errorNode?: Node; // optional node that results in error } @@ -1208,9 +1210,11 @@ module ts { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4fce9c928f7..bdd23f82746 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -361,16 +361,16 @@ module ts { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; } - export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - + export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { // If parameter/type parameter, the prev token trailing comments are part of this node too if (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) { // e.g. (/** blah */ a, /** blah */ b); - return concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), - // e.g.: ( - // /** blah */ a, - // /** blah */ b); + + // e.g.: ( + // /** blah */ a, + // /** blah */ b); + return concatenate( + getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -1364,4 +1364,317 @@ module ts { s.replace(nonAsciiCharacters, c => get16BitUnicodeEscapeSequence(c.charCodeAt(0))) : s; } + + export interface EmitTextWriter { + write(s: string): void; + writeTextOfNode(sourceFile: SourceFile, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + getText(): string; + rawWrite(s: string): void; + writeLiteral(s: string): void; + getTextPos(): number; + getLine(): number; + getColumn(): number; + getIndent(): number; + } + + let indentStrings: string[] = ["", " "]; + export function getIndentString(level: number) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + + export function getIndentSize() { + return indentStrings[1].length; + } + + export function createTextWriter(newLine: String): EmitTextWriter { + let output = ""; + let indent = 0; + let lineStart = true; + let lineCount = 0; + let linePos = 0; + + function write(s: string) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + + function rawWrite(s: string) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + + function writeLiteral(s: string) { + if (s && s.length) { + write(s); + let lineStartsOfS = computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + + function writeTextOfNode(sourceFile: SourceFile, node: Node) { + write(getSourceTextOfNodeFromSourceFile(sourceFile, node)); + } + + return { + write, + rawWrite, + writeTextOfNode, + writeLiteral, + writeLine, + increaseIndent: () => indent++, + decreaseIndent: () => indent--, + getIndent: () => indent, + getTextPos: () => output.length, + getLine: () => lineCount + 1, + getColumn: () => lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1, + getText: () => output, + }; + } + + export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { + let compilerOptions = host.getCompilerOptions(); + let emitOutputFilePathWithoutExtension: string; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.fileName); + } + + return emitOutputFilePathWithoutExtension + extension; + } + + export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { + let sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); + return combinePaths(newDirPath, sourceFilePath); + } + + export function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean) { + host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => { + diagnostics.push(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }); + } + + export function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) { + return getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + + export function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration { + return forEach(node.members, member => { + if (member.kind === SyntaxKind.Constructor && nodeIsPresent((member).body)) { + return member; + } + }); + } + + export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { + if (!isDeclarationFile(sourceFile)) { + if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.fileName, ".js")) { + return true; + } + return false; + } + return false; + } + + export function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration) { + let firstAccessor: AccessorDeclaration; + let getAccessor: AccessorDeclaration; + let setAccessor: AccessorDeclaration; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === SyntaxKind.GetAccessor) { + getAccessor = accessor; + } + else if (accessor.kind === SyntaxKind.SetAccessor) { + setAccessor = accessor; + } + else { + Debug.fail("Accessor has wrong kind"); + } + } + else { + forEach(declarations, (member: Declaration) => { + if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) + && (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) { + let memberName = getPropertyNameForPropertyNameNode(member.name); + let accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + + if (member.kind === SyntaxKind.GetAccessor && !getAccessor) { + getAccessor = member; + } + + if (member.kind === SyntaxKind.SetAccessor && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor, + getAccessor, + setAccessor + }; + } + + export function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) { + // If the leading comments start on different line than the start of node, write new line + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && + getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + + export function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, + writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void) { + let emitLeadingSpace = !trailingSeparator; + forEach(comments, comment => { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + // Emit leading space to separate comment during next comment emit + emitLeadingSpace = true; + } + }); + } + + export function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { + let firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); + let lineCount = getLineStarts(currentSourceFile).length; + let firstCommentLineIndent: number; + for (let pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + let nextLineStart = (currentLine + 1) === lineCount + ? currentSourceFile.text.length + 1 + : getStartPositionOfLine(currentLine + 1, currentSourceFile); + + if (pos !== comment.pos) { + // If we are not emitting first line, we need to write the spaces to adjust the alignment + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos); + } + + // These are number of spaces writer is going to write at current indent + let currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + + // Number of spaces we want to be writing + // eg: Assume writer indent + // module m { + // /* starts at character 9 this is line 1 + // * starts at character pos 4 line --1 = 8 - 8 + 3 + // More left indented comment */ --2 = 8 - 8 + 2 + // class c { } + // } + // module m { + // /* this is line 1 -- Assume current writer indent 8 + // * line --3 = 8 - 4 + 5 + // More right indented comment */ --4 = 8 - 4 + 11 + // class c { } + // } + let spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + let indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + + // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces + writer.rawWrite(indentSizeSpaceString); + + // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + // No spaces to emit write empty string + writer.rawWrite(""); + } + } + + // Write the comment line text + writeTrimmedCurrentLine(pos, nextLineStart); + + pos = nextLineStart; + } + } + else { + // Single line comment of style //.... + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + + function writeTrimmedCurrentLine(pos: number, nextLineStart: number) { + let end = Math.min(comment.end, nextLineStart - 1); + let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + // trimmed forward and ending spaces text + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + // Empty string - make sure we write empty line + writer.writeLiteral(newLine); + } + } + + function calculateIndent(pos: number, end: number) { + let currentLineIndent = 0; + for (; pos < end && isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === CharacterCodes.tab) { + // Tabs = TabSize = indent size and go to next tabStop + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + // Single space + currentLineIndent++; + } + } + + return currentLineIndent; + } + } + } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 9d55fcc58b9..1f233a4bfb8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -625,7 +625,7 @@ module FourSlash { this.scenarioActions.push(''); var members = this.getMemberListAtCaret(); - if (members.entries.filter(e => e.name === symbol).length !== 0) { + if (members && members.entries.filter(e => e.name === symbol).length !== 0) { this.raiseError('Member list did contain ' + symbol); } } @@ -696,7 +696,12 @@ module FourSlash { public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { var completions = this.getCompletionListAtCaret(); - this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); + if (completions) { + this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); + } + else { + this.raiseError(`No completions at position '${ this.currentCaretPosition }' when looking for '${ symbol }'.`); + } } public verifyCompletionListDoesNotContain(symbol: string) { @@ -704,7 +709,7 @@ module FourSlash { this.scenarioActions.push(''); var completions = this.getCompletionListAtCaret(); - if (completions && completions.entries && completions.entries.filter(e => e.name === symbol).length !== 0) { + if (completions && completions.entries.filter(e => e.name === symbol).length !== 0) { this.raiseError('Completion list did contain ' + symbol); } } diff --git a/src/server/client.ts b/src/server/client.ts index c8e7f2fdcb1..07c742db4f8 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -46,21 +46,21 @@ module ts.server { return lineMap; } - private lineColToPosition(fileName: string, lineCol: protocol.Location): number { - return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1); + private lineOffsetToPosition(fileName: string, lineOffset: protocol.Location): number { + return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineOffset.line - 1, lineOffset.offset - 1); } - private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location { - var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position); + private positionToOneBasedLineOffset(fileName: string, position: number): protocol.Location { + var lineOffset = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position); return { - line: lineCol.line + 1, - col: lineCol.character + 1 + line: lineOffset.line + 1, + offset: lineOffset.character + 1 }; } private convertCodeEditsToTextChange(fileName: string, codeEdit: protocol.CodeEdit): ts.TextChange { - var start = this.lineColToPosition(fileName, codeEdit.start); - var end = this.lineColToPosition(fileName, codeEdit.end); + var start = this.lineOffsetToPosition(fileName, codeEdit.start); + var end = this.lineOffsetToPosition(fileName, codeEdit.end); return { span: ts.createTextSpanFromBounds(start, end), @@ -134,15 +134,15 @@ module ts.server { // clear the line map after an edit this.lineMaps[fileName] = undefined; - var lineCol = this.positionToOneBasedLineCol(fileName, start); - var endLineCol = this.positionToOneBasedLineCol(fileName, end); + var lineOffset = this.positionToOneBasedLineOffset(fileName, start); + var endLineOffset = this.positionToOneBasedLineOffset(fileName, end); var args: protocol.ChangeRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, - endLine: endLineCol.line, - endCol: endLineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, + endLine: endLineOffset.line, + endOffset: endLineOffset.offset, insertString: newText }; @@ -150,18 +150,18 @@ module ts.server { } getQuickInfoAtPosition(fileName: string, position: number): QuickInfo { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col + line: lineOffset.line, + offset: lineOffset.offset }; var request = this.processRequest(CommandNames.Quickinfo, args); var response = this.processResponse(request); - var start = this.lineColToPosition(fileName, response.body.start); - var end = this.lineColToPosition(fileName, response.body.end); + var start = this.lineOffsetToPosition(fileName, response.body.start); + var end = this.lineOffsetToPosition(fileName, response.body.end); return { kind: response.body.kind, @@ -173,11 +173,11 @@ module ts.server { } getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.CompletionsRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, prefix: undefined }; @@ -194,11 +194,11 @@ module ts.server { } getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.CompletionDetailsRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, entryNames: [entryName] }; @@ -219,8 +219,8 @@ module ts.server { return response.body.map(entry => { var fileName = entry.file; - var start = this.lineColToPosition(fileName, entry.start); - var end = this.lineColToPosition(fileName, entry.end); + var start = this.lineOffsetToPosition(fileName, entry.start); + var end = this.lineOffsetToPosition(fileName, entry.end); return { name: entry.name, @@ -237,14 +237,14 @@ module ts.server { } getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] { - var startLineCol = this.positionToOneBasedLineCol(fileName, start); - var endLineCol = this.positionToOneBasedLineCol(fileName, end); + var startLineOffset = this.positionToOneBasedLineOffset(fileName, start); + var endLineOffset = this.positionToOneBasedLineOffset(fileName, end); var args: protocol.FormatRequestArgs = { file: fileName, - line: startLineCol.line, - col: startLineCol.col, - endLine: endLineCol.line, - endCol: endLineCol.col, + line: startLineOffset.line, + offset: startLineOffset.offset, + endLine: endLineOffset.line, + endOffset: endLineOffset.offset, }; // TODO: handle FormatCodeOptions @@ -259,11 +259,11 @@ module ts.server { } getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FormatOnKeyRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, key: key }; @@ -275,11 +275,11 @@ module ts.server { } getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, }; var request = this.processRequest(CommandNames.Definition, args); @@ -287,8 +287,8 @@ module ts.server { return response.body.map(entry => { var fileName = entry.file; - var start = this.lineColToPosition(fileName, entry.start); - var end = this.lineColToPosition(fileName, entry.end); + var start = this.lineOffsetToPosition(fileName, entry.start); + var end = this.lineOffsetToPosition(fileName, entry.end); return { containerKind: "", containerName: "", @@ -301,11 +301,11 @@ module ts.server { } getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, }; var request = this.processRequest(CommandNames.References, args); @@ -313,8 +313,8 @@ module ts.server { return response.body.refs.map(entry => { var fileName = entry.file; - var start = this.lineColToPosition(fileName, entry.start); - var end = this.lineColToPosition(fileName, entry.end); + var start = this.lineOffsetToPosition(fileName, entry.start); + var end = this.lineOffsetToPosition(fileName, entry.end); return { fileName: fileName, textSpan: ts.createTextSpanFromBounds(start, end), @@ -340,11 +340,11 @@ module ts.server { } getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.RenameRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, findInStrings, findInComments }; @@ -355,8 +355,8 @@ module ts.server { response.body.locs.map((entry: protocol.SpanGroup) => { var fileName = entry.file; entry.locs.map((loc: protocol.TextSpan) => { - var start = this.lineColToPosition(fileName, loc.start); - var end = this.lineColToPosition(fileName, loc.end); + var start = this.lineOffsetToPosition(fileName, loc.start); + var end = this.lineOffsetToPosition(fileName, loc.end); locations.push({ textSpan: ts.createTextSpanFromBounds(start, end), fileName: fileName @@ -400,7 +400,7 @@ module ts.server { text: item.text, kind: item.kind, kindModifiers: item.kindModifiers || "", - spans: item.spans.map(span=> createTextSpanFromBounds(this.lineColToPosition(fileName, span.start), this.lineColToPosition(fileName, span.end))), + spans: item.spans.map(span=> createTextSpanFromBounds(this.lineOffsetToPosition(fileName, span.start), this.lineOffsetToPosition(fileName, span.end))), childItems: this.decodeNavigationBarItems(item.childItems, fileName), indent: 0, bolded: false, @@ -444,19 +444,19 @@ module ts.server { } getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { - var lineCol = this.positionToOneBasedLineCol(fileName, position); + var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { file: fileName, - line: lineCol.line, - col: lineCol.col, + line: lineOffset.line, + offset: lineOffset.offset, }; var request = this.processRequest(CommandNames.Brace, args); var response = this.processResponse(request); return response.body.map(entry => { - var start = this.lineColToPosition(fileName, entry.start); - var end = this.lineColToPosition(fileName, entry.end); + var start = this.lineOffsetToPosition(fileName, entry.start); + var end = this.lineOffsetToPosition(fileName, entry.end); return { start: start, length: end - start, diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 7c9ccfa7854..1f9df9b46f0 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -19,15 +19,23 @@ module ts.server { class ScriptInfo { svc: ScriptVersionCache; children: ScriptInfo[] = []; // files referenced by this file - defaultProject: Project; // project to use by default for file - fileWatcher: FileWatcher; + formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { this.svc = ScriptVersionCache.fromString(content); } + setFormatOptions(tabSize?: number, indentSize?: number) { + if (tabSize) { + this.formatCodeOptions.TabSize = tabSize; + } + if (indentSize) { + this.formatCodeOptions.IndentSize = indentSize; + } + } + close() { this.isOpen = false; } @@ -200,33 +208,33 @@ module ts.server { } else { var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.col - lineInfo.col; + len = nextLineInfo.offset - lineInfo.offset; } - return ts.createTextSpan(lineInfo.col, len); + return ts.createTextSpan(lineInfo.offset, len); } /** * @param line 1 based index - * @param col 1 based index + * @param offset 1 based index */ - lineColToPosition(filename: string, line: number, col: number): number { + lineOffsetToPosition(filename: string, line: number, offset: number): number { var script: ScriptInfo = this.filenameToScript[filename]; var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); - // TODO: assert this column is actually on the line - return (lineInfo.col + col - 1); + // TODO: assert this offset is actually on the line + return (lineInfo.offset + offset - 1); } /** * @param line 1-based index - * @param col 1-based index + * @param offset 1-based index */ - positionToLineCol(filename: string, position: number): ILineInfo { + positionToLineOffset(filename: string, position: number): ILineInfo { var script: ScriptInfo = this.filenameToScript[filename]; var index = script.snap().index; - var lineCol = index.charOffsetToLineNumberAndPos(position); - return { line: lineCol.line, col: lineCol.col + 1 }; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; } } @@ -259,7 +267,6 @@ module ts.server { interface ProjectOptions { // these fields can be present in the project file files?: string[]; - formatCodeOptions?: ts.FormatCodeOptions; compilerOptions?: ts.CompilerOptions; } @@ -338,7 +345,6 @@ module ts.server { if (projectOptions.compilerOptions) { this.compilerService.setCompilerOptions(projectOptions.compilerOptions); } - // TODO: format code options } } @@ -362,6 +368,11 @@ module ts.server { (eventName: string, project: Project, fileName: string): void; } + interface HostConfiguration { + formatCodeOptions: ts.FormatCodeOptions; + hostInfo: string; + } + export class ProjectService { filenameToScriptInfo: ts.Map = {}; // open, non-configured files in two lists @@ -369,9 +380,28 @@ module ts.server { openFilesReferenced: ScriptInfo[] = []; // projects covering open files inferredProjects: Project[] = []; + hostConfiguration: HostConfiguration; constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) { // ts.disableIncrementalParsing = true; + this.addDefaultHostConfiguration(); + } + + addDefaultHostConfiguration() { + this.hostConfiguration = { + formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions), + hostInfo: "Unknown host" + } + } + + getFormatCodeOptions(file?: string) { + if (file) { + var info = this.filenameToScriptInfo[file]; + if (info) { + return info.formatCodeOptions; + } + } + return this.hostConfiguration.formatCodeOptions; } watchedFileChanged(fileName: string) { @@ -395,6 +425,22 @@ module ts.server { this.psLogger.msg(msg, type); } + setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments) { + if (args.file) { + var info = this.filenameToScriptInfo[args.file]; + if (info) { + info.setFormatOptions(args.tabSize, args.indentSize); + this.log("Host configuration update for file " + args.file + " tab size " + args.tabSize); + } + } + else { + this.hostConfiguration.formatCodeOptions.TabSize = args.tabSize; + this.hostConfiguration.formatCodeOptions.IndentSize = args.indentSize; + this.hostConfiguration.hostInfo = args.hostInfo; + this.log("Host information " + args.hostInfo, "Info"); + } + } + closeLog() { this.psLogger.close(); } @@ -595,7 +641,7 @@ module ts.server { /** * @param filename is absolute pathname */ - openFile(fileName: string, openedByClient = false) { + openFile(fileName: string, openedByClient: boolean) { fileName = ts.normalizePath(fileName); var info = ts.lookUp(this.filenameToScriptInfo, fileName); if (!info) { @@ -609,6 +655,7 @@ module ts.server { } } if (content !== undefined) { + var indentSize: number; info = new ScriptInfo(this.host, fileName, content, openedByClient); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { @@ -731,7 +778,8 @@ module ts.server { var normRootFilename = ts.normalizePath(rootFilename); normRootFilename = getAbsolutePath(normRootFilename, dirPath); if (this.host.fileExists(normRootFilename)) { - var info = this.openFile(normRootFilename); + // TODO: pass true for file exiplicitly opened + var info = this.openFile(normRootFilename, false); proj.addRoot(info); } else { @@ -742,9 +790,6 @@ module ts.server { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; - if (rawConfig.formatCodeOptions) { - projectOptions.formatCodeOptions = rawConfig.formatCodeOptions; - } proj.setProjectOptions(projectOptions); return { success: true, project: proj }; } @@ -768,7 +813,6 @@ module ts.server { classifier: ts.Classifier; settings = ts.getDefaultCompilerOptions(); documentRegistry = ts.createDocumentRegistry(); - formatCodeOptions: ts.FormatCodeOptions = CompilerService.defaultFormatCodeOptions; constructor(public project: Project) { this.host = new LSHost(project.projectService.host, project); @@ -815,7 +859,7 @@ module ts.server { export interface ILineInfo { line: number; - col: number; + offset: number; text?: string; leaf?: LineLeaf; } @@ -1208,7 +1252,7 @@ module ts.server { getLineMapper() { return ((line: number) => { - return this.index.lineNumberToInfo(line).col; + return this.index.lineNumberToInfo(line).offset; }); } @@ -1245,7 +1289,7 @@ module ts.server { else { return { line: lineNumber, - col: this.root.charCount() + offset: this.root.charCount() } } } @@ -1331,7 +1375,7 @@ module ts.server { // check whether last characters deleted are line break var e = pos + deleteLength; var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.col == 0))) { + if ((lineInfo && (lineInfo.offset == 0))) { // move range end just past line that will merge with previous line deleteLength += lineInfo.text.length; // store text by appending to end of insertedText @@ -1507,14 +1551,14 @@ module ts.server { if (!childInfo.child) { return { line: lineNumber, - col: charOffset, + offset: charOffset, } } else if (childInfo.childIndex < this.children.length) { if (childInfo.child.isLeaf()) { return { line: childInfo.lineNumber, - col: childInfo.charOffset, + offset: childInfo.charOffset, text: ((childInfo.child)).text, leaf: ((childInfo.child)) }; @@ -1526,7 +1570,7 @@ module ts.server { } else { var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), col: lineInfo.leaf.charCount() }; + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; } } @@ -1535,13 +1579,13 @@ module ts.server { if (!childInfo.child) { return { line: lineNumber, - col: charOffset + offset: charOffset } - } + } else if (childInfo.child.isLeaf()) { return { line: lineNumber, - col: childInfo.charOffset, + offset: childInfo.charOffset, text: ((childInfo.child)).text, leaf: ((childInfo.child)) } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 23ef00d6b44..d63aa53ba12 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -96,7 +96,7 @@ declare module ts.server.protocol { /** * Instances of this interface specify a location in a source file: - * (file, line, col), where line and column are 1-based. + * (file, line, character offset), where line and character offset are 1-based. */ export interface FileLocationRequestArgs extends FileRequestArgs { /** @@ -105,9 +105,9 @@ declare module ts.server.protocol { line: number; /** - * The column for the request (1-based). + * The character offset (on the line) for the request (1-based). */ - col: number; + offset: number; } /** @@ -126,11 +126,11 @@ declare module ts.server.protocol { } /** - * Location in source code expressed as (one-based) line and column. + * Location in source code expressed as (one-based) line and character offset. */ export interface Location { line: number; - col: number; + offset: number; } /** @@ -202,9 +202,9 @@ declare module ts.server.protocol { symbolName: string; /** - * The start column of the symbol (on the line provided by the references request). + * The start character offset of the symbol (on the line provided by the references request). */ - symbolStartCol: number; + symbolStartOffset: number; /** * The full display name of the symbol. @@ -299,6 +299,50 @@ declare module ts.server.protocol { body?: RenameResponseBody; } + /** + * Information found in a configure request. + */ + export interface ConfigureRequestArguments { + /** Number of spaces for each tab */ + tabSize: number; + /** Number of spaces to indent during formatting */ + indentSize: number; + /** + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ + hostInfo: string; + /** + * If present, tab settings apply only to this file. + */ + file?: string; + } + + /** + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ + export interface ConfigureRequest extends Request { + arguments: ConfigureRequestArguments; + } + + /** + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ + export interface ConfigureResponse extends Response { + } + + /** + * Information found in an "open" request. + */ + export interface OpenRequestArgs extends FileRequestArgs { + /** Initial tab size of file. */ + tabSize?: number; + /** Number of spaces to indent during formatting */ + indentSize?: number; + } + /** * Open request; value of command field is "open". Notify the * server that the client has file open. The server will not @@ -307,7 +351,8 @@ declare module ts.server.protocol { * reload messages) when the file changes. Server does not currently * send a response to an open request. */ - export interface OpenRequest extends FileRequest { + export interface OpenRequest extends Request { + arguments: OpenRequestArgs; } /** @@ -381,9 +426,9 @@ declare module ts.server.protocol { endLine: number; /** - * Last column of range for which to format text in file. + * Character offset on last line of range for which to format text in file. */ - endCol: number; + endOffset: number; } /** @@ -762,7 +807,7 @@ declare module ts.server.protocol { */ export interface ChangeRequestArgs extends FormatRequestArgs { /** - * Optional string to insert at location (file, line, col). + * Optional string to insert at location (file, line, offset). */ insertString?: string; } @@ -786,7 +831,7 @@ declare module ts.server.protocol { /** * Brace matching request; value of command field is "brace". * Return response giving the file locations of matching braces - * found in file at location line, col. + * found in file at location line, offset. */ export interface BraceRequest extends FileLocationRequest { } diff --git a/src/server/session.ts b/src/server/session.ts index cc705d64d5e..79eefb879da 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -5,13 +5,13 @@ /// module ts.server { - var spaceCache = [" ", " ", " ", " "]; + var spaceCache:string[] = []; interface StackTraceError extends Error { stack?: string; } - function generateSpaces(n: number): string { + export function generateSpaces(n: number): string { if (!spaceCache[n]) { var strBuilder = ""; for (var i = 0; i < n; i++) { @@ -44,7 +44,7 @@ module ts.server { else if (a.file == b.file) { var n = compareNumber(a.start.line, b.start.line); if (n == 0) { - return compareNumber(a.start.col, b.start.col); + return compareNumber(a.start.offset, b.start.offset); } else return n; } @@ -55,8 +55,8 @@ module ts.server { function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) { return { - start: project.compilerService.host.positionToLineCol(fileName, diag.start), - end: project.compilerService.host.positionToLineCol(fileName, diag.start + diag.length), + start: project.compilerService.host.positionToLineOffset(fileName, diag.start), + end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") }; } @@ -80,6 +80,7 @@ module ts.server { export var Close = "close"; export var Completions = "completions"; export var CompletionDetails = "completionEntryDetails"; + export var Configure = "configure"; export var Definition = "definition"; export var Format = "format"; export var Formatonkey = "formatonkey"; @@ -259,7 +260,7 @@ module ts.server { } } - getDefinition(line: number, col: number, fileName: string): protocol.FileSpan[] { + getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -267,7 +268,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); if (!definitions) { @@ -276,12 +277,12 @@ module ts.server { return definitions.map(def => ({ file: def.fileName, - start: compilerService.host.positionToLineCol(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan)) + start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), + end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) })); } - getRenameLocations(line: number, col: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { + getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -289,7 +290,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var renameInfo = compilerService.languageService.getRenameInfo(file, position); if (!renameInfo) { return undefined; @@ -309,8 +310,8 @@ module ts.server { var bakedRenameLocs = renameLocations.map(location => ({ file: location.fileName, - start: compilerService.host.positionToLineCol(location.fileName, location.textSpan.start), - end: compilerService.host.positionToLineCol(location.fileName, ts.textSpanEnd(location.textSpan)), + start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), + end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)), })).sort((a, b) => { if (a.file < b.file) { return -1; @@ -327,7 +328,7 @@ module ts.server { return -1; } else { - return b.start.col - a.start.col; + return b.start.offset - a.start.offset; } } }).reduce((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => { @@ -349,7 +350,7 @@ module ts.server { return { info: renameInfo, locs: bakedRenameLocs }; } - getReferences(line: number, col: number, fileName: string): protocol.ReferencesResponseBody { + getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody { // TODO: get all projects for this file; report refs for all projects deleting duplicates // can avoid duplicates by eliminating same ref file from subsequent projects var file = ts.normalizePath(fileName); @@ -359,7 +360,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var references = compilerService.languageService.getReferencesAtPosition(file, position); if (!references) { @@ -373,10 +374,10 @@ module ts.server { var displayString = ts.displayPartsToString(nameInfo.displayParts); var nameSpan = nameInfo.textSpan; - var nameColStart = compilerService.host.positionToLineCol(file, nameSpan.start).col; + var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset; var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => { - var start = compilerService.host.positionToLineCol(ref.fileName, ref.textSpan.start); + var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); var snap = compilerService.host.getScriptSnapshot(ref.fileName); var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); @@ -384,24 +385,27 @@ module ts.server { file: ref.fileName, start: start, lineText: lineText, - end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)), + end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), isWriteAccess: ref.isWriteAccess }; }).sort(compareFileStart); return { refs: bakedRefs, symbolName: nameText, - symbolStartCol: nameColStart, + symbolStartOffset: nameColStart, symbolDisplayString: displayString }; } - openClientFile(fileName: string) { + openClientFile(fileName: string, tabSize?: number, indentSize?: number) { var file = ts.normalizePath(fileName); - this.projectService.openClientFile(file); + var info = this.projectService.openClientFile(file); + if (info) { + info.setFormatOptions(tabSize, indentSize); + } } - getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody { + getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -409,7 +413,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); if (!quickInfo) { return undefined; @@ -420,14 +424,14 @@ module ts.server { return { kind: quickInfo.kind, kindModifiers: quickInfo.kindModifiers, - start: compilerService.host.positionToLineCol(file, quickInfo.textSpan.start), - end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(quickInfo.textSpan)), + start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, }; } - getFormattingEditsForRange(line: number, col: number, endLine: number, endCol: number, fileName: string): protocol.CodeEdit[] { + getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -435,25 +439,26 @@ module ts.server { } var compilerService = project.compilerService; - var startPosition = compilerService.host.lineColToPosition(file, line, col); - var endPosition = compilerService.host.lineColToPosition(file, endLine, endCol); + var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); + var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); // TODO: avoid duplicate code (with formatonkey) - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, compilerService.formatCodeOptions); + var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, + this.projectService.getFormatCodeOptions(file)); if (!edits) { return undefined; } return edits.map((edit) => { return { - start: compilerService.host.positionToLineCol(file, edit.span.start), - end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(edit.span)), + start: compilerService.host.positionToLineOffset(file, edit.span.start), + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), newText: edit.newText ? edit.newText : "" }; }); } - getFormattingEditsAfterKeystroke(line: number, col: number, key: string, fileName: string): protocol.CodeEdit[] { + getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -462,9 +467,10 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, - compilerService.formatCodeOptions); + formatOptions); // Check whether we should auto-indent. This will be when // the position is on a line containing only whitespace. // This should leave the edits returned from @@ -480,8 +486,8 @@ module ts.server { if (lineText.search("\\S") < 0) { // TODO: get these options from host var editorOptions: ts.EditorOptions = { - IndentSize: 4, - TabSize: 4, + IndentSize: formatOptions.IndentSize, + TabSize: formatOptions.TabSize, NewLineCharacter: "\n", ConvertTabsToSpaces: true, }; @@ -516,16 +522,16 @@ module ts.server { return edits.map((edit) => { return { - start: compilerService.host.positionToLineCol(file, + start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineCol(file, + end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), newText: edit.newText ? edit.newText : "" }; }); } - getCompletions(line: number, col: number, prefix: string, fileName: string): protocol.CompletionEntry[] { + getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] { if (!prefix) { prefix = ""; } @@ -536,7 +542,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var completions = compilerService.languageService.getCompletionsAtPosition(file, position); if (!completions) { @@ -551,7 +557,7 @@ module ts.server { }, []); } - getCompletionEntryDetails(line: number, col: number, + getCompletionEntryDetails(line: number, offset: number, entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -560,7 +566,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => { var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); @@ -586,13 +592,13 @@ module ts.server { } } - change(line: number, col: number, endLine: number, endCol: number, insertString: string, fileName: string) { + change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (project) { var compilerService = project.compilerService; - var start = compilerService.host.lineColToPosition(file, line, col); - var end = compilerService.host.lineColToPosition(file, endLine, endCol); + var start = compilerService.host.lineOffsetToPosition(file, line, offset); + var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); if (start >= 0) { compilerService.host.editScript(file, start, end, insertString); this.changeSeq++; @@ -608,7 +614,7 @@ module ts.server { if (project) { this.changeSeq++; // make sure no changes happen before this one is finished - project.compilerService.host.reloadScript(file, tmpfile,() => { + project.compilerService.host.reloadScript(file, tmpfile, () => { this.output(undefined, CommandNames.Reload, reqSeq); }); } @@ -641,8 +647,8 @@ module ts.server { kind: item.kind, kindModifiers: item.kindModifiers, spans: item.spans.map(span => ({ - start: compilerService.host.positionToLineCol(fileName, span.start), - end: compilerService.host.positionToLineCol(fileName, ts.textSpanEnd(span)) + start: compilerService.host.positionToLineOffset(fileName, span.start), + end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span)) })), childItems: this.decorateNavigationBarItem(project, fileName, item.childItems) })); @@ -678,8 +684,8 @@ module ts.server { } return navItems.map((navItem) => { - var start = compilerService.host.positionToLineCol(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineCol(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); + var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); + var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); var bakedItem: protocol.NavtoItem = { name: navItem.name, kind: navItem.kind, @@ -703,7 +709,7 @@ module ts.server { }); } - getBraceMatching(line: number, col: number, fileName: string): protocol.TextSpan[] { + getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -712,7 +718,7 @@ module ts.server { } var compilerService = project.compilerService; - var position = compilerService.host.lineColToPosition(file, line, col); + var position = compilerService.host.lineOffsetToPosition(file, line, offset); var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); if (!spans) { @@ -720,8 +726,8 @@ module ts.server { } return spans.map(span => ({ - start: compilerService.host.positionToLineCol(file, span.start), - end: compilerService.host.positionToLineCol(file, span.start + span.length) + start: compilerService.host.positionToLineOffset(file, span.start), + end: compilerService.host.positionToLineOffset(file, span.start + span.length) })); } @@ -738,49 +744,50 @@ module ts.server { switch (request.command) { case CommandNames.Definition: { var defArgs = request.arguments; - response = this.getDefinition(defArgs.line, defArgs.col, defArgs.file); + response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); break; } case CommandNames.References: { var refArgs = request.arguments; - response = this.getReferences(refArgs.line, refArgs.col, refArgs.file); + response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); break; } case CommandNames.Rename: { var renameArgs = request.arguments; - response = this.getRenameLocations(renameArgs.line, renameArgs.col, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); + response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); break; } case CommandNames.Open: { - var openArgs = request.arguments; - this.openClientFile(openArgs.file); + var openArgs = request.arguments; + this.openClientFile(openArgs.file,openArgs.tabSize, openArgs.indentSize); responseRequired = false; break; } case CommandNames.Quickinfo: { var quickinfoArgs = request.arguments; - response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.col, quickinfoArgs.file); + response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file); break; } case CommandNames.Format: { var formatArgs = request.arguments; - response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.col, formatArgs.endLine, formatArgs.endCol, formatArgs.file); + response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file); break; } case CommandNames.Formatonkey: { var formatOnKeyArgs = request.arguments; - response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.col, formatOnKeyArgs.key, formatOnKeyArgs.file); + response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file); break; } case CommandNames.Completions: { var completionsArgs = request.arguments; - response = this.getCompletions(request.arguments.line, request.arguments.col, completionsArgs.prefix, request.arguments.file); + response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file); break; } case CommandNames.CompletionDetails: { var completionDetailsArgs = request.arguments; - response = this.getCompletionEntryDetails(request.arguments.line, request.arguments.col, completionDetailsArgs.entryNames, - request.arguments.file); + response = + this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset, + completionDetailsArgs.entryNames,completionDetailsArgs.file); break; } case CommandNames.Geterr: { @@ -791,14 +798,22 @@ module ts.server { } case CommandNames.Change: { var changeArgs = request.arguments; - this.change(changeArgs.line, changeArgs.col, changeArgs.endLine, changeArgs.endCol, + this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); responseRequired = false; break; } + case CommandNames.Configure: { + var configureArgs = request.arguments; + this.projectService.setHostConfiguration(configureArgs); + this.output(undefined, CommandNames.Configure, request.seq); + responseRequired = false; + break; + } case CommandNames.Reload: { var reloadArgs = request.arguments; this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); + responseRequired = false; break; } case CommandNames.Saveto: { @@ -820,7 +835,7 @@ module ts.server { } case CommandNames.Brace: { var braceArguments = request.arguments; - response = this.getBraceMatching(braceArguments.line, braceArguments.col, braceArguments.file); + response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file); break; } case CommandNames.NavBar: { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 24ddabc2b2b..23a392d7718 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1008,10 +1008,20 @@ module ts.formatting { return SyntaxKind.Unknown; } - let internedTabsIndentation: string[]; - let internedSpacesIndentation: string[]; + var internedSizes: { tabSize: number; indentSize: number }; + var internedTabsIndentation: string[]; + var internedSpacesIndentation: string[]; export function getIndentationString(indentation: number, options: FormatCodeOptions): string { + // reset interned strings if FormatCodeOptions were changed + let resetInternedStrings = + !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } + if (!options.ConvertTabsToSpaces) { let tabs = Math.floor(indentation / options.TabSize); let spaces = indentation - tabs * options.TabSize; diff --git a/src/services/formatting/indentation.ts b/src/services/formatting/indentation.ts deleted file mode 100644 index f6f8fc0319f..00000000000 --- a/src/services/formatting/indentation.ts +++ /dev/null @@ -1,54 +0,0 @@ -module ts.formatting { - - var internedTabsIndentation: string[]; - var internedSpacesIndentation: string[]; - - export function getIndentationString(indentation: number, options: FormatCodeOptions): string { - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - - var tabString: string; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString: string; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; - } - - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - - - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - - function repeat(value: string, count: number): string { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - - return s; - } - } -} \ No newline at end of file diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 1a52c72c9d8..8508e3b932d 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -215,11 +215,7 @@ module ts.formatting { function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - + export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean { if (parent.kind === SyntaxKind.IfStatement && (parent).elseStatement === child) { let elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile); @@ -403,128 +399,5 @@ module ts.formatting { return false; } } - - /* - * Checks if node ends with 'expectedLastToken'. - * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. - */ - function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean { - let children = n.getChildren(sourceFile); - if (children.length) { - let last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === SyntaxKind.SemicolonToken && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - - /* - * This function is always called when position of the cursor is located after the node - */ - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean { - if (n.getFullWidth() === 0) { - return false; - } - - switch (n.kind) { - case SyntaxKind.ClassDeclaration: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.ObjectBindingPattern: - case SyntaxKind.TypeLiteral: - case SyntaxKind.Block: - case SyntaxKind.ModuleBlock: - case SyntaxKind.CaseBlock: - return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile); - case SyntaxKind.CatchClause: - return isCompletedNode((n).block, sourceFile); - case SyntaxKind.NewExpression: - if (!(n).arguments) { - return true; - } - // fall through - case SyntaxKind.CallExpression: - case SyntaxKind.ParenthesizedExpression: - case SyntaxKind.ParenthesizedType: - return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); - - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return isCompletedNode((n).type, sourceFile); - - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ArrowFunction: - if ((n).body) { - return isCompletedNode((n).body, sourceFile); - } - - if ((n).type) { - return isCompletedNode((n).type, sourceFile); - } - - // Even though type parameters can be unclosed, we can get away with - // having at least a closing paren. - return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile); - - case SyntaxKind.ModuleDeclaration: - return (n).body && isCompletedNode((n).body, sourceFile); - - case SyntaxKind.IfStatement: - if ((n).elseStatement) { - return isCompletedNode((n).elseStatement, sourceFile); - } - return isCompletedNode((n).thenStatement, sourceFile); - - case SyntaxKind.ExpressionStatement: - return isCompletedNode((n).expression, sourceFile); - - case SyntaxKind.ArrayLiteralExpression: - case SyntaxKind.ArrayBindingPattern: - case SyntaxKind.ComputedPropertyName: - case SyntaxKind.TupleType: - return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile); - - case SyntaxKind.IndexSignature: - if ((n).type) { - return isCompletedNode((n).type, sourceFile); - } - - return hasChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); - - case SyntaxKind.CaseClause: - case SyntaxKind.DefaultClause: - // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed - return false; - - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.WhileStatement: - return isCompletedNode((n).statement, sourceFile); - case SyntaxKind.DoStatement: - // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - let hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); - } - return isCompletedNode((n).statement, sourceFile); - - default: - return true; - } - } } } \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index 188a1bfcb03..152f50bf86a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2400,7 +2400,7 @@ module ts { // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); - return semanticDiagnostics.concat(declarationDiagnostics); + return concatenate(semanticDiagnostics, declarationDiagnostics); } function getJavaScriptSemanticDiagnostics(sourceFile: SourceFile): Diagnostic[] { @@ -2836,8 +2836,9 @@ module ts { isNewIdentifierLocation = isNewIdentifierDefinitionLocation(previousToken); /// TODO filter meaning based on the current context + let scopeNode = getScopeNode(previousToken, position, sourceFile); let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - let symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); + let symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings); getCompletionEntriesFromSymbols(symbols); } @@ -2845,6 +2846,25 @@ module ts { return true; } + return { + isMemberCompletion, + isNewIdentifierLocation, + isBuilder: isNewIdentifierDefinitionLocation, // temporary property used to match VS implementation + entries: activeCompletionSession.entries + }; + + /** + * Finds the first node that "embraces" the position, so that one may + * accurately aggregate locals from the closest containing scope. + */ + function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) { + var scope = initialToken; + while (scope && !positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; + } + return scope; + } + function getCompletionEntriesFromSymbols(symbols: Symbol[]): void { let session = activeCompletionSession; let start = new Date().getTime(); @@ -3708,7 +3728,6 @@ module ts { } } - let result: DefinitionInfo[] = []; // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than @@ -3717,16 +3736,19 @@ module ts { // assignment. This case and others are handled by the following code. if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { let shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; + } + let shorthandDeclarations = shorthandSymbol.getDeclarations(); let shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node); let shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol); let shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node); - forEach(shorthandDeclarations, declaration => { - result.push(getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); - }); - return result + return map(shorthandDeclarations, + declaration => getDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); } + let result: DefinitionInfo[] = []; let declarations = symbol.getDeclarations(); let symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol let symbolKind = getSymbolKind(symbol, typeInfoResolver, node); @@ -4240,18 +4262,18 @@ module ts { let container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. - if (declaration.flags & NodeFlags.AccessibilityModifier) { + if (isAccessibilityModifier(modifier)) { if (!(container.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { return undefined; } } - else if (declaration.flags & NodeFlags.Static) { + else if (modifier === SyntaxKind.StaticKeyword) { if (container.kind !== SyntaxKind.ClassDeclaration) { return undefined; } } - else if (declaration.flags & (NodeFlags.Export | NodeFlags.Ambient)) { + else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { return undefined; } @@ -4292,7 +4314,7 @@ module ts { default: Debug.fail("Invalid container kind.") } - + forEach(nodes, node => { if (node.modifiers && node.flags & modifierFlag) { forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); @@ -6077,17 +6099,6 @@ module ts { // a string literal, and a template end consisting of '} } `'. let templateStack: SyntaxKind[] = []; - function isAccessibilityModifier(kind: SyntaxKind) { - switch (kind) { - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - return true; - } - - return false; - } - /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1: SyntaxKind, keyword2: SyntaxKind) { if (isAccessibilityModifier(keyword1)) { diff --git a/src/services/shims.ts b/src/services/shims.ts index f2082ee39cb..506aa37f478 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -838,3 +838,5 @@ module ts { module TypeScript.Services { export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory; } + +let toolsVersion = "1.4"; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7671ee3f88d..2a9af04409e 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -59,6 +59,157 @@ module ts { return start < end; } + export function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + + export function isCompletedNode(n: Node, sourceFile: SourceFile): boolean { + if (nodeIsMissing(n)) { + return false; + } + + switch (n.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ObjectBindingPattern: + case SyntaxKind.TypeLiteral: + case SyntaxKind.Block: + case SyntaxKind.ModuleBlock: + case SyntaxKind.CaseBlock: + return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile); + case SyntaxKind.CatchClause: + return isCompletedNode((n).block, sourceFile); + case SyntaxKind.NewExpression: + if (!(n).arguments) { + return true; + } + // fall through + case SyntaxKind.CallExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.ParenthesizedType: + return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); + + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return isCompletedNode((n).type, sourceFile); + + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ArrowFunction: + if ((n).body) { + return isCompletedNode((n).body, sourceFile); + } + + if ((n).type) { + return isCompletedNode((n).type, sourceFile); + } + + // Even though type parameters can be unclosed, we can get away with + // having at least a closing paren. + return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile); + + case SyntaxKind.ModuleDeclaration: + return (n).body && isCompletedNode((n).body, sourceFile); + + case SyntaxKind.IfStatement: + if ((n).elseStatement) { + return isCompletedNode((n).elseStatement, sourceFile); + } + return isCompletedNode((n).thenStatement, sourceFile); + + case SyntaxKind.ExpressionStatement: + return isCompletedNode((n).expression, sourceFile); + + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ArrayBindingPattern: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.ComputedPropertyName: + case SyntaxKind.TupleType: + return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile); + + case SyntaxKind.IndexSignature: + if ((n).type) { + return isCompletedNode((n).type, sourceFile); + } + + return hasChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); + + case SyntaxKind.CaseClause: + case SyntaxKind.DefaultClause: + // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed + return false; + + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.WhileStatement: + return isCompletedNode((n).statement, sourceFile); + case SyntaxKind.DoStatement: + // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; + let hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); + } + return isCompletedNode((n).statement, sourceFile); + + case SyntaxKind.TypeQuery: + return isCompletedNode((n).exprName, sourceFile); + + case SyntaxKind.TypeOfExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.VoidExpression: + case SyntaxKind.YieldExpression: + case SyntaxKind.SpreadElementExpression: + let unaryWordExpression = (n); + return isCompletedNode(unaryWordExpression.expression, sourceFile); + + case SyntaxKind.TaggedTemplateExpression: + return isCompletedNode((n).template, sourceFile); + case SyntaxKind.TemplateExpression: + let lastSpan = lastOrUndefined((n).templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case SyntaxKind.TemplateSpan: + return nodeIsPresent((n).literal); + + case SyntaxKind.PrefixUnaryExpression: + return isCompletedNode((n).operand, sourceFile); + case SyntaxKind.BinaryExpression: + return isCompletedNode((n).right, sourceFile); + case SyntaxKind.ConditionalExpression: + return isCompletedNode((n).whenFalse, sourceFile); + + default: + return true; + } + } + + /* + * Checks if node ends with 'expectedLastToken'. + * If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'. + */ + function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean { + let children = n.getChildren(sourceFile); + if (children.length) { + let last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === SyntaxKind.SemicolonToken && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + export function findListItemInfo(node: Node): ListItemInfo { let list = findContainingList(node); @@ -320,6 +471,17 @@ module ts { && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } + export function isAccessibilityModifier(kind: SyntaxKind) { + switch (kind) { + case SyntaxKind.PublicKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + return true; + } + + return false; + } + export function compareDataObjects(dst: any, src: any): boolean { for (let e in dst) { if (typeof dst[e] === "object") { diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 4ea2a7a7bed..b8f4c7cdd13 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -927,9 +927,10 @@ declare module "typescript" { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -944,9 +945,11 @@ declare module "typescript" { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; @@ -1472,7 +1475,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index d0ba1e8457b..e1d9aa58961 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2970,6 +2970,11 @@ declare module "typescript" { CannotBeNamed = 2, >CannotBeNamed : SymbolAccessibility } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration +>ImportDeclaration : ImportDeclaration +>ImportEqualsDeclaration : ImportEqualsDeclaration + interface SymbolVisibilityResult { >SymbolVisibilityResult : SymbolVisibilityResult @@ -2977,9 +2982,9 @@ declare module "typescript" { >accessibility : SymbolAccessibility >SymbolAccessibility : SymbolAccessibility - aliasesToMakeVisible?: ImportEqualsDeclaration[]; ->aliasesToMakeVisible : ImportEqualsDeclaration[] ->ImportEqualsDeclaration : ImportEqualsDeclaration + aliasesToMakeVisible?: AnyImportSyntax[]; +>aliasesToMakeVisible : (ImportEqualsDeclaration | ImportDeclaration)[] +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration errorSymbolName?: string; >errorSymbolName : string @@ -3034,6 +3039,12 @@ declare module "typescript" { >node : Declaration >Declaration : Declaration + collectLinkedAliases(node: Identifier): Node[]; +>collectLinkedAliases : (node: Identifier) => Node[] +>node : Identifier +>Identifier : Identifier +>Node : Node + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; >isImplementationOfOverload : (node: FunctionLikeDeclaration) => boolean >node : FunctionLikeDeclaration @@ -3060,6 +3071,17 @@ declare module "typescript" { >flags : TypeFormatFlags >TypeFormatFlags : TypeFormatFlags >writer : SymbolWriter +>SymbolWriter : SymbolWriter + + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfExpression : (expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>expr : Expression +>Expression : Expression +>enclosingDeclaration : Node +>Node : Node +>flags : TypeFormatFlags +>TypeFormatFlags : TypeFormatFlags +>writer : SymbolWriter >SymbolWriter : SymbolWriter isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; @@ -4714,10 +4736,11 @@ declare module "typescript" { let version: string; >version : string - function createCompilerHost(options: CompilerOptions): CompilerHost; ->createCompilerHost : (options: CompilerOptions) => CompilerHost + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; +>createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions >CompilerOptions : CompilerOptions +>setParentNodes : boolean >CompilerHost : CompilerHost function getPreEmitDiagnostics(program: Program): Diagnostic[]; diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 6e6665e3d40..4e3af8d1be0 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -958,9 +958,10 @@ declare module "typescript" { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -975,9 +976,11 @@ declare module "typescript" { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; @@ -1503,7 +1506,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 839e41a62f4..7cf542f0b40 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3116,6 +3116,11 @@ declare module "typescript" { CannotBeNamed = 2, >CannotBeNamed : SymbolAccessibility } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration +>ImportDeclaration : ImportDeclaration +>ImportEqualsDeclaration : ImportEqualsDeclaration + interface SymbolVisibilityResult { >SymbolVisibilityResult : SymbolVisibilityResult @@ -3123,9 +3128,9 @@ declare module "typescript" { >accessibility : SymbolAccessibility >SymbolAccessibility : SymbolAccessibility - aliasesToMakeVisible?: ImportEqualsDeclaration[]; ->aliasesToMakeVisible : ImportEqualsDeclaration[] ->ImportEqualsDeclaration : ImportEqualsDeclaration + aliasesToMakeVisible?: AnyImportSyntax[]; +>aliasesToMakeVisible : (ImportEqualsDeclaration | ImportDeclaration)[] +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration errorSymbolName?: string; >errorSymbolName : string @@ -3180,6 +3185,12 @@ declare module "typescript" { >node : Declaration >Declaration : Declaration + collectLinkedAliases(node: Identifier): Node[]; +>collectLinkedAliases : (node: Identifier) => Node[] +>node : Identifier +>Identifier : Identifier +>Node : Node + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; >isImplementationOfOverload : (node: FunctionLikeDeclaration) => boolean >node : FunctionLikeDeclaration @@ -3206,6 +3217,17 @@ declare module "typescript" { >flags : TypeFormatFlags >TypeFormatFlags : TypeFormatFlags >writer : SymbolWriter +>SymbolWriter : SymbolWriter + + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfExpression : (expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>expr : Expression +>Expression : Expression +>enclosingDeclaration : Node +>Node : Node +>flags : TypeFormatFlags +>TypeFormatFlags : TypeFormatFlags +>writer : SymbolWriter >SymbolWriter : SymbolWriter isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; @@ -4860,10 +4882,11 @@ declare module "typescript" { let version: string; >version : string - function createCompilerHost(options: CompilerOptions): CompilerHost; ->createCompilerHost : (options: CompilerOptions) => CompilerHost + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; +>createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions >CompilerOptions : CompilerOptions +>setParentNodes : boolean >CompilerHost : CompilerHost function getPreEmitDiagnostics(program: Program): Diagnostic[]; diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index ed852980b0c..261ad5b25f6 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -959,9 +959,10 @@ declare module "typescript" { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -976,9 +977,11 @@ declare module "typescript" { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; @@ -1504,7 +1507,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 589af2369f7..eb4c7ab122f 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3066,6 +3066,11 @@ declare module "typescript" { CannotBeNamed = 2, >CannotBeNamed : SymbolAccessibility } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration +>ImportDeclaration : ImportDeclaration +>ImportEqualsDeclaration : ImportEqualsDeclaration + interface SymbolVisibilityResult { >SymbolVisibilityResult : SymbolVisibilityResult @@ -3073,9 +3078,9 @@ declare module "typescript" { >accessibility : SymbolAccessibility >SymbolAccessibility : SymbolAccessibility - aliasesToMakeVisible?: ImportEqualsDeclaration[]; ->aliasesToMakeVisible : ImportEqualsDeclaration[] ->ImportEqualsDeclaration : ImportEqualsDeclaration + aliasesToMakeVisible?: AnyImportSyntax[]; +>aliasesToMakeVisible : (ImportEqualsDeclaration | ImportDeclaration)[] +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration errorSymbolName?: string; >errorSymbolName : string @@ -3130,6 +3135,12 @@ declare module "typescript" { >node : Declaration >Declaration : Declaration + collectLinkedAliases(node: Identifier): Node[]; +>collectLinkedAliases : (node: Identifier) => Node[] +>node : Identifier +>Identifier : Identifier +>Node : Node + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; >isImplementationOfOverload : (node: FunctionLikeDeclaration) => boolean >node : FunctionLikeDeclaration @@ -3156,6 +3167,17 @@ declare module "typescript" { >flags : TypeFormatFlags >TypeFormatFlags : TypeFormatFlags >writer : SymbolWriter +>SymbolWriter : SymbolWriter + + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfExpression : (expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>expr : Expression +>Expression : Expression +>enclosingDeclaration : Node +>Node : Node +>flags : TypeFormatFlags +>TypeFormatFlags : TypeFormatFlags +>writer : SymbolWriter >SymbolWriter : SymbolWriter isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; @@ -4810,10 +4832,11 @@ declare module "typescript" { let version: string; >version : string - function createCompilerHost(options: CompilerOptions): CompilerHost; ->createCompilerHost : (options: CompilerOptions) => CompilerHost + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; +>createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions >CompilerOptions : CompilerOptions +>setParentNodes : boolean >CompilerHost : CompilerHost function getPreEmitDiagnostics(program: Program): Diagnostic[]; diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index c0f6f52e774..a821bc5011d 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -996,9 +996,10 @@ declare module "typescript" { NotAccessible = 1, CannotBeNamed = 2, } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - aliasesToMakeVisible?: ImportEqualsDeclaration[]; + aliasesToMakeVisible?: AnyImportSyntax[]; errorSymbolName?: string; errorNode?: Node; } @@ -1013,9 +1014,11 @@ declare module "typescript" { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; @@ -1541,7 +1544,7 @@ declare module "typescript" { declare module "typescript" { /** The version of the TypeScript compiler release */ let version: string; - function createCompilerHost(options: CompilerOptions): CompilerHost; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 78261fffa91..47e5a0147fd 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -3239,6 +3239,11 @@ declare module "typescript" { CannotBeNamed = 2, >CannotBeNamed : SymbolAccessibility } + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration +>ImportDeclaration : ImportDeclaration +>ImportEqualsDeclaration : ImportEqualsDeclaration + interface SymbolVisibilityResult { >SymbolVisibilityResult : SymbolVisibilityResult @@ -3246,9 +3251,9 @@ declare module "typescript" { >accessibility : SymbolAccessibility >SymbolAccessibility : SymbolAccessibility - aliasesToMakeVisible?: ImportEqualsDeclaration[]; ->aliasesToMakeVisible : ImportEqualsDeclaration[] ->ImportEqualsDeclaration : ImportEqualsDeclaration + aliasesToMakeVisible?: AnyImportSyntax[]; +>aliasesToMakeVisible : (ImportEqualsDeclaration | ImportDeclaration)[] +>AnyImportSyntax : ImportEqualsDeclaration | ImportDeclaration errorSymbolName?: string; >errorSymbolName : string @@ -3303,6 +3308,12 @@ declare module "typescript" { >node : Declaration >Declaration : Declaration + collectLinkedAliases(node: Identifier): Node[]; +>collectLinkedAliases : (node: Identifier) => Node[] +>node : Identifier +>Identifier : Identifier +>Node : Node + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; >isImplementationOfOverload : (node: FunctionLikeDeclaration) => boolean >node : FunctionLikeDeclaration @@ -3329,6 +3340,17 @@ declare module "typescript" { >flags : TypeFormatFlags >TypeFormatFlags : TypeFormatFlags >writer : SymbolWriter +>SymbolWriter : SymbolWriter + + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; +>writeTypeOfExpression : (expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) => void +>expr : Expression +>Expression : Expression +>enclosingDeclaration : Node +>Node : Node +>flags : TypeFormatFlags +>TypeFormatFlags : TypeFormatFlags +>writer : SymbolWriter >SymbolWriter : SymbolWriter isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; @@ -4983,10 +5005,11 @@ declare module "typescript" { let version: string; >version : string - function createCompilerHost(options: CompilerOptions): CompilerHost; ->createCompilerHost : (options: CompilerOptions) => CompilerHost + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; +>createCompilerHost : (options: CompilerOptions, setParentNodes?: boolean) => CompilerHost >options : CompilerOptions >CompilerOptions : CompilerOptions +>setParentNodes : boolean >CompilerHost : CompilerHost function getPreEmitDiagnostics(program: Program): Diagnostic[]; diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt index 9551d0467e9..b762db8a04b 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2461: Type 'StringIterator' is not an array type or a string type. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2495: Type 'StringIterator' is not an array type or a string type. tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ==== for (var v of new StringIterator) { } ~~~~~~~~~~~~~~~~~~ -!!! error TS2461: Type 'StringIterator' is not an array type or a string type. +!!! error TS2495: Type 'StringIterator' is not an array type or a string type. // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { diff --git a/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt index b726aaad6c7..67af1f4f401 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2461: Type 'number' is not an array type or a string type. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2495: Type 'number' is not an array type or a string type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts (1 errors) ==== for (const v of 0) { } ~ -!!! error TS2461: Type 'number' is not an array type or a string type. \ No newline at end of file +!!! error TS2495: Type 'number' is not an array type or a string type. \ No newline at end of file diff --git a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js index d9fdb511fa2..4ca0b4cd5f7 100644 --- a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js @@ -34,6 +34,6 @@ var enumdule; enumdule.Point = Point; })(enumdule || (enumdule = {})); var x; -var x = 0 /* Red */; +var x = enumdule.Red; var y; var y = new enumdule.Point(0, 0); diff --git a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js index 533843d2947..96df9812bc6 100644 --- a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js @@ -34,6 +34,6 @@ var enumdule; enumdule[enumdule["Blue"] = 1] = "Blue"; })(enumdule || (enumdule = {})); var x; -var x = 0 /* Red */; +var x = enumdule.Red; var y; var y = new enumdule.Point(0, 0); diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js index afcef6bbb5c..3cd522d3c2c 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js @@ -26,6 +26,6 @@ var A; })(Day || (Day = {})); })(A || (A = {})); // not an error since exported -var a = 0 /* Red */; +var a = A.Color.Red; // error not exported var b = A.Day.Monday; diff --git a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js index ca3e8435e05..d68af6c23c3 100644 --- a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js +++ b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js @@ -81,7 +81,7 @@ var r11 = a + foo(); var r12 = a + C; var r13 = a + new C(); var r14 = a + E; -var r15 = a + 0 /* a */; +var r15 = a + E.a; var r16 = a + M; var r17 = a + ''; var r18 = a + 123; diff --git a/tests/baselines/reference/additionOperatorWithInvalidOperands.js b/tests/baselines/reference/additionOperatorWithInvalidOperands.js index baf4fadedb3..f2403bc1670 100644 --- a/tests/baselines/reference/additionOperatorWithInvalidOperands.js +++ b/tests/baselines/reference/additionOperatorWithInvalidOperands.js @@ -85,6 +85,6 @@ var r14 = b + d; var r15 = b + foo; var r16 = b + foo(); var r17 = b + C; -var r18 = 0 /* a */ + new C(); -var r19 = 0 /* a */ + C.foo(); -var r20 = 0 /* a */ + M; +var r18 = E.a + new C(); +var r19 = E.a + C.foo(); +var r20 = E.a + M; diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js index 1ba54d47f1c..1b5cb877d21 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js @@ -49,13 +49,13 @@ var r2 = a + null; var r3 = null + b; var r4 = null + 1; var r5 = null + c; -var r6 = null + 0 /* a */; -var r7 = null + 0 /* 'a' */; +var r6 = null + E.a; +var r7 = null + E['a']; var r8 = b + null; var r9 = 1 + null; var r10 = c + null; -var r11 = 0 /* a */ + null; -var r12 = 0 /* 'a' */ + null; +var r11 = E.a + null; +var r12 = E['a'] + null; // null + string var r13 = null + d; var r14 = null + ''; diff --git a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js index 231831518e6..d559e98dc3e 100644 --- a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js +++ b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js @@ -43,10 +43,10 @@ var r2 = a + b; var r3 = b + a; var r4 = b + b; var r5 = 0 + a; -var r6 = 0 /* a */ + 0; -var r7 = 0 /* a */ + 1 /* b */; -var r8 = 0 /* 'a' */ + 1 /* 'b' */; -var r9 = 0 /* 'a' */ + 0 /* 'c' */; +var r6 = E.a + 0; +var r7 = E.a + E.b; +var r8 = E['a'] + E['b']; +var r9 = E['a'] + F['c']; var r10 = a + c; var r11 = c + a; var r12 = b + c; diff --git a/tests/baselines/reference/additionOperatorWithStringAndEveryType.js b/tests/baselines/reference/additionOperatorWithStringAndEveryType.js index 35c6056574e..56949533e09 100644 --- a/tests/baselines/reference/additionOperatorWithStringAndEveryType.js +++ b/tests/baselines/reference/additionOperatorWithStringAndEveryType.js @@ -72,7 +72,7 @@ var r13 = f + x; var r14 = g + x; // other cases var r15 = x + E; -var r16 = x + 0 /* a */; +var r16 = x + E.a; var r17 = x + ''; var r18 = x + 0; var r19 = x + { diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js index cb89d242a18..68804694449 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js @@ -49,13 +49,13 @@ var r2 = a + undefined; var r3 = undefined + b; var r4 = undefined + 1; var r5 = undefined + c; -var r6 = undefined + 0 /* a */; -var r7 = undefined + 0 /* 'a' */; +var r6 = undefined + E.a; +var r7 = undefined + E['a']; var r8 = b + undefined; var r9 = 1 + undefined; var r10 = c + undefined; -var r11 = 0 /* a */ + undefined; -var r12 = 0 /* 'a' */ + undefined; +var r11 = E.a + undefined; +var r12 = E['a'] + undefined; // undefined + string var r13 = undefined + d; var r14 = undefined + ''; diff --git a/tests/baselines/reference/amdImportAsPrimaryExpression.js b/tests/baselines/reference/amdImportAsPrimaryExpression.js index 4704b32d989..fc8d0420842 100644 --- a/tests/baselines/reference/amdImportAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportAsPrimaryExpression.js @@ -23,6 +23,6 @@ define(["require", "exports"], function (require, exports) { }); //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { - if (0 /* A */ === 0) { + if (foo.E1.A === 0) { } }); diff --git a/tests/baselines/reference/arithmeticOperatorWithEnum.js b/tests/baselines/reference/arithmeticOperatorWithEnum.js index 9ef2790b4ce..3572f3ecc41 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnum.js +++ b/tests/baselines/reference/arithmeticOperatorWithEnum.js @@ -166,127 +166,127 @@ var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; -var ra6 = 0 /* a */ * a; -var ra7 = 0 /* a */ * b; -var ra8 = 0 /* a */ * 1 /* b */; -var ra9 = 0 /* a */ * 1; -var ra10 = a * 1 /* b */; -var ra11 = b * 1 /* b */; -var ra12 = 1 * 1 /* b */; +var ra6 = E.a * a; +var ra7 = E.a * b; +var ra8 = E.a * E.b; +var ra9 = E.a * 1; +var ra10 = a * E.b; +var ra11 = b * E.b; +var ra12 = 1 * E.b; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; -var rb6 = 0 /* a */ / a; -var rb7 = 0 /* a */ / b; -var rb8 = 0 /* a */ / 1 /* b */; -var rb9 = 0 /* a */ / 1; -var rb10 = a / 1 /* b */; -var rb11 = b / 1 /* b */; -var rb12 = 1 / 1 /* b */; +var rb6 = E.a / a; +var rb7 = E.a / b; +var rb8 = E.a / E.b; +var rb9 = E.a / 1; +var rb10 = a / E.b; +var rb11 = b / E.b; +var rb12 = 1 / E.b; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; -var rc6 = 0 /* a */ % a; -var rc7 = 0 /* a */ % b; -var rc8 = 0 /* a */ % 1 /* b */; -var rc9 = 0 /* a */ % 1; -var rc10 = a % 1 /* b */; -var rc11 = b % 1 /* b */; -var rc12 = 1 % 1 /* b */; +var rc6 = E.a % a; +var rc7 = E.a % b; +var rc8 = E.a % E.b; +var rc9 = E.a % 1; +var rc10 = a % E.b; +var rc11 = b % E.b; +var rc12 = 1 % E.b; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; -var rd6 = 0 /* a */ - a; -var rd7 = 0 /* a */ - b; -var rd8 = 0 /* a */ - 1 /* b */; -var rd9 = 0 /* a */ - 1; -var rd10 = a - 1 /* b */; -var rd11 = b - 1 /* b */; -var rd12 = 1 - 1 /* b */; +var rd6 = E.a - a; +var rd7 = E.a - b; +var rd8 = E.a - E.b; +var rd9 = E.a - 1; +var rd10 = a - E.b; +var rd11 = b - E.b; +var rd12 = 1 - E.b; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; -var re6 = 0 /* a */ << a; -var re7 = 0 /* a */ << b; -var re8 = 0 /* a */ << 1 /* b */; -var re9 = 0 /* a */ << 1; -var re10 = a << 1 /* b */; -var re11 = b << 1 /* b */; -var re12 = 1 << 1 /* b */; +var re6 = E.a << a; +var re7 = E.a << b; +var re8 = E.a << E.b; +var re9 = E.a << 1; +var re10 = a << E.b; +var re11 = b << E.b; +var re12 = 1 << E.b; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; -var rf6 = 0 /* a */ >> a; -var rf7 = 0 /* a */ >> b; -var rf8 = 0 /* a */ >> 1 /* b */; -var rf9 = 0 /* a */ >> 1; -var rf10 = a >> 1 /* b */; -var rf11 = b >> 1 /* b */; -var rf12 = 1 >> 1 /* b */; +var rf6 = E.a >> a; +var rf7 = E.a >> b; +var rf8 = E.a >> E.b; +var rf9 = E.a >> 1; +var rf10 = a >> E.b; +var rf11 = b >> E.b; +var rf12 = 1 >> E.b; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; -var rg6 = 0 /* a */ >>> a; -var rg7 = 0 /* a */ >>> b; -var rg8 = 0 /* a */ >>> 1 /* b */; -var rg9 = 0 /* a */ >>> 1; -var rg10 = a >>> 1 /* b */; -var rg11 = b >>> 1 /* b */; -var rg12 = 1 >>> 1 /* b */; +var rg6 = E.a >>> a; +var rg7 = E.a >>> b; +var rg8 = E.a >>> E.b; +var rg9 = E.a >>> 1; +var rg10 = a >>> E.b; +var rg11 = b >>> E.b; +var rg12 = 1 >>> E.b; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; -var rh6 = 0 /* a */ & a; -var rh7 = 0 /* a */ & b; -var rh8 = 0 /* a */ & 1 /* b */; -var rh9 = 0 /* a */ & 1; -var rh10 = a & 1 /* b */; -var rh11 = b & 1 /* b */; -var rh12 = 1 & 1 /* b */; +var rh6 = E.a & a; +var rh7 = E.a & b; +var rh8 = E.a & E.b; +var rh9 = E.a & 1; +var rh10 = a & E.b; +var rh11 = b & E.b; +var rh12 = 1 & E.b; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; -var ri6 = 0 /* a */ ^ a; -var ri7 = 0 /* a */ ^ b; -var ri8 = 0 /* a */ ^ 1 /* b */; -var ri9 = 0 /* a */ ^ 1; -var ri10 = a ^ 1 /* b */; -var ri11 = b ^ 1 /* b */; -var ri12 = 1 ^ 1 /* b */; +var ri6 = E.a ^ a; +var ri7 = E.a ^ b; +var ri8 = E.a ^ E.b; +var ri9 = E.a ^ 1; +var ri10 = a ^ E.b; +var ri11 = b ^ E.b; +var ri12 = 1 ^ E.b; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; -var rj6 = 0 /* a */ | a; -var rj7 = 0 /* a */ | b; -var rj8 = 0 /* a */ | 1 /* b */; -var rj9 = 0 /* a */ | 1; -var rj10 = a | 1 /* b */; -var rj11 = b | 1 /* b */; -var rj12 = 1 | 1 /* b */; +var rj6 = E.a | a; +var rj7 = E.a | b; +var rj8 = E.a | E.b; +var rj9 = E.a | 1; +var rj10 = a | E.b; +var rj11 = b | E.b; +var rj12 = 1 | E.b; diff --git a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js index 315f7dd237b..95bc0b866c9 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js +++ b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js @@ -175,127 +175,127 @@ var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; -var ra6 = 0 /* a */ * a; -var ra7 = 0 /* a */ * b; -var ra8 = 0 /* a */ * 1 /* b */; -var ra9 = 0 /* a */ * 1; -var ra10 = a * 1 /* b */; -var ra11 = b * 1 /* b */; -var ra12 = 1 * 1 /* b */; +var ra6 = E.a * a; +var ra7 = E.a * b; +var ra8 = E.a * E.b; +var ra9 = E.a * 1; +var ra10 = a * E.b; +var ra11 = b * E.b; +var ra12 = 1 * E.b; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; -var rb6 = 0 /* a */ / a; -var rb7 = 0 /* a */ / b; -var rb8 = 0 /* a */ / 1 /* b */; -var rb9 = 0 /* a */ / 1; -var rb10 = a / 1 /* b */; -var rb11 = b / 1 /* b */; -var rb12 = 1 / 1 /* b */; +var rb6 = E.a / a; +var rb7 = E.a / b; +var rb8 = E.a / E.b; +var rb9 = E.a / 1; +var rb10 = a / E.b; +var rb11 = b / E.b; +var rb12 = 1 / E.b; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; -var rc6 = 0 /* a */ % a; -var rc7 = 0 /* a */ % b; -var rc8 = 0 /* a */ % 1 /* b */; -var rc9 = 0 /* a */ % 1; -var rc10 = a % 1 /* b */; -var rc11 = b % 1 /* b */; -var rc12 = 1 % 1 /* b */; +var rc6 = E.a % a; +var rc7 = E.a % b; +var rc8 = E.a % E.b; +var rc9 = E.a % 1; +var rc10 = a % E.b; +var rc11 = b % E.b; +var rc12 = 1 % E.b; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; -var rd6 = 0 /* a */ - a; -var rd7 = 0 /* a */ - b; -var rd8 = 0 /* a */ - 1 /* b */; -var rd9 = 0 /* a */ - 1; -var rd10 = a - 1 /* b */; -var rd11 = b - 1 /* b */; -var rd12 = 1 - 1 /* b */; +var rd6 = E.a - a; +var rd7 = E.a - b; +var rd8 = E.a - E.b; +var rd9 = E.a - 1; +var rd10 = a - E.b; +var rd11 = b - E.b; +var rd12 = 1 - E.b; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; -var re6 = 0 /* a */ << a; -var re7 = 0 /* a */ << b; -var re8 = 0 /* a */ << 1 /* b */; -var re9 = 0 /* a */ << 1; -var re10 = a << 1 /* b */; -var re11 = b << 1 /* b */; -var re12 = 1 << 1 /* b */; +var re6 = E.a << a; +var re7 = E.a << b; +var re8 = E.a << E.b; +var re9 = E.a << 1; +var re10 = a << E.b; +var re11 = b << E.b; +var re12 = 1 << E.b; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; -var rf6 = 0 /* a */ >> a; -var rf7 = 0 /* a */ >> b; -var rf8 = 0 /* a */ >> 1 /* b */; -var rf9 = 0 /* a */ >> 1; -var rf10 = a >> 1 /* b */; -var rf11 = b >> 1 /* b */; -var rf12 = 1 >> 1 /* b */; +var rf6 = E.a >> a; +var rf7 = E.a >> b; +var rf8 = E.a >> E.b; +var rf9 = E.a >> 1; +var rf10 = a >> E.b; +var rf11 = b >> E.b; +var rf12 = 1 >> E.b; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; -var rg6 = 0 /* a */ >>> a; -var rg7 = 0 /* a */ >>> b; -var rg8 = 0 /* a */ >>> 1 /* b */; -var rg9 = 0 /* a */ >>> 1; -var rg10 = a >>> 1 /* b */; -var rg11 = b >>> 1 /* b */; -var rg12 = 1 >>> 1 /* b */; +var rg6 = E.a >>> a; +var rg7 = E.a >>> b; +var rg8 = E.a >>> E.b; +var rg9 = E.a >>> 1; +var rg10 = a >>> E.b; +var rg11 = b >>> E.b; +var rg12 = 1 >>> E.b; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; -var rh6 = 0 /* a */ & a; -var rh7 = 0 /* a */ & b; -var rh8 = 0 /* a */ & 1 /* b */; -var rh9 = 0 /* a */ & 1; -var rh10 = a & 1 /* b */; -var rh11 = b & 1 /* b */; -var rh12 = 1 & 1 /* b */; +var rh6 = E.a & a; +var rh7 = E.a & b; +var rh8 = E.a & E.b; +var rh9 = E.a & 1; +var rh10 = a & E.b; +var rh11 = b & E.b; +var rh12 = 1 & E.b; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; -var ri6 = 0 /* a */ ^ a; -var ri7 = 0 /* a */ ^ b; -var ri8 = 0 /* a */ ^ 1 /* b */; -var ri9 = 0 /* a */ ^ 1; -var ri10 = a ^ 1 /* b */; -var ri11 = b ^ 1 /* b */; -var ri12 = 1 ^ 1 /* b */; +var ri6 = E.a ^ a; +var ri7 = E.a ^ b; +var ri8 = E.a ^ E.b; +var ri9 = E.a ^ 1; +var ri10 = a ^ E.b; +var ri11 = b ^ E.b; +var ri12 = 1 ^ E.b; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; -var rj6 = 0 /* a */ | a; -var rj7 = 0 /* a */ | b; -var rj8 = 0 /* a */ | 1 /* b */; -var rj9 = 0 /* a */ | 1; -var rj10 = a | 1 /* b */; -var rj11 = b | 1 /* b */; -var rj12 = 1 | 1 /* b */; +var rj6 = E.a | a; +var rj7 = E.a | b; +var rj8 = E.a | E.b; +var rj9 = E.a | 1; +var rj10 = a | E.b; +var rj11 = b | E.b; +var rj12 = 1 | E.b; diff --git a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js index 8a9e6549144..974e9930103 100644 --- a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js @@ -634,18 +634,18 @@ var r1f3 = f * c; var r1f4 = f * d; var r1f5 = f * e; var r1f6 = f * f; -var r1g1 = 0 /* a */ * a; //ok -var r1g2 = 0 /* a */ * b; -var r1g3 = 0 /* a */ * c; //ok -var r1g4 = 0 /* a */ * d; -var r1g5 = 0 /* a */ * e; -var r1g6 = 0 /* a */ * f; -var r1h1 = a * 1 /* b */; //ok -var r1h2 = b * 1 /* b */; -var r1h3 = c * 1 /* b */; //ok -var r1h4 = d * 1 /* b */; -var r1h5 = e * 1 /* b */; -var r1h6 = f * 1 /* b */; +var r1g1 = E.a * a; //ok +var r1g2 = E.a * b; +var r1g3 = E.a * c; //ok +var r1g4 = E.a * d; +var r1g5 = E.a * e; +var r1g6 = E.a * f; +var r1h1 = a * E.b; //ok +var r1h2 = b * E.b; +var r1h3 = c * E.b; //ok +var r1h4 = d * E.b; +var r1h5 = e * E.b; +var r1h6 = f * E.b; // operator / var r2a1 = a / a; //ok var r2a2 = a / b; @@ -683,18 +683,18 @@ var r2f3 = f / c; var r2f4 = f / d; var r2f5 = f / e; var r2f6 = f / f; -var r2g1 = 0 /* a */ / a; //ok -var r2g2 = 0 /* a */ / b; -var r2g3 = 0 /* a */ / c; //ok -var r2g4 = 0 /* a */ / d; -var r2g5 = 0 /* a */ / e; -var r2g6 = 0 /* a */ / f; -var r2h1 = a / 1 /* b */; //ok -var r2h2 = b / 1 /* b */; -var r2h3 = c / 1 /* b */; //ok -var r2h4 = d / 1 /* b */; -var r2h5 = e / 1 /* b */; -var r2h6 = f / 1 /* b */; +var r2g1 = E.a / a; //ok +var r2g2 = E.a / b; +var r2g3 = E.a / c; //ok +var r2g4 = E.a / d; +var r2g5 = E.a / e; +var r2g6 = E.a / f; +var r2h1 = a / E.b; //ok +var r2h2 = b / E.b; +var r2h3 = c / E.b; //ok +var r2h4 = d / E.b; +var r2h5 = e / E.b; +var r2h6 = f / E.b; // operator % var r3a1 = a % a; //ok var r3a2 = a % b; @@ -732,18 +732,18 @@ var r3f3 = f % c; var r3f4 = f % d; var r3f5 = f % e; var r3f6 = f % f; -var r3g1 = 0 /* a */ % a; //ok -var r3g2 = 0 /* a */ % b; -var r3g3 = 0 /* a */ % c; //ok -var r3g4 = 0 /* a */ % d; -var r3g5 = 0 /* a */ % e; -var r3g6 = 0 /* a */ % f; -var r3h1 = a % 1 /* b */; //ok -var r3h2 = b % 1 /* b */; -var r3h3 = c % 1 /* b */; //ok -var r3h4 = d % 1 /* b */; -var r3h5 = e % 1 /* b */; -var r3h6 = f % 1 /* b */; +var r3g1 = E.a % a; //ok +var r3g2 = E.a % b; +var r3g3 = E.a % c; //ok +var r3g4 = E.a % d; +var r3g5 = E.a % e; +var r3g6 = E.a % f; +var r3h1 = a % E.b; //ok +var r3h2 = b % E.b; +var r3h3 = c % E.b; //ok +var r3h4 = d % E.b; +var r3h5 = e % E.b; +var r3h6 = f % E.b; // operator - var r4a1 = a - a; //ok var r4a2 = a - b; @@ -781,18 +781,18 @@ var r4f3 = f - c; var r4f4 = f - d; var r4f5 = f - e; var r4f6 = f - f; -var r4g1 = 0 /* a */ - a; //ok -var r4g2 = 0 /* a */ - b; -var r4g3 = 0 /* a */ - c; //ok -var r4g4 = 0 /* a */ - d; -var r4g5 = 0 /* a */ - e; -var r4g6 = 0 /* a */ - f; -var r4h1 = a - 1 /* b */; //ok -var r4h2 = b - 1 /* b */; -var r4h3 = c - 1 /* b */; //ok -var r4h4 = d - 1 /* b */; -var r4h5 = e - 1 /* b */; -var r4h6 = f - 1 /* b */; +var r4g1 = E.a - a; //ok +var r4g2 = E.a - b; +var r4g3 = E.a - c; //ok +var r4g4 = E.a - d; +var r4g5 = E.a - e; +var r4g6 = E.a - f; +var r4h1 = a - E.b; //ok +var r4h2 = b - E.b; +var r4h3 = c - E.b; //ok +var r4h4 = d - E.b; +var r4h5 = e - E.b; +var r4h6 = f - E.b; // operator << var r5a1 = a << a; //ok var r5a2 = a << b; @@ -830,18 +830,18 @@ var r5f3 = f << c; var r5f4 = f << d; var r5f5 = f << e; var r5f6 = f << f; -var r5g1 = 0 /* a */ << a; //ok -var r5g2 = 0 /* a */ << b; -var r5g3 = 0 /* a */ << c; //ok -var r5g4 = 0 /* a */ << d; -var r5g5 = 0 /* a */ << e; -var r5g6 = 0 /* a */ << f; -var r5h1 = a << 1 /* b */; //ok -var r5h2 = b << 1 /* b */; -var r5h3 = c << 1 /* b */; //ok -var r5h4 = d << 1 /* b */; -var r5h5 = e << 1 /* b */; -var r5h6 = f << 1 /* b */; +var r5g1 = E.a << a; //ok +var r5g2 = E.a << b; +var r5g3 = E.a << c; //ok +var r5g4 = E.a << d; +var r5g5 = E.a << e; +var r5g6 = E.a << f; +var r5h1 = a << E.b; //ok +var r5h2 = b << E.b; +var r5h3 = c << E.b; //ok +var r5h4 = d << E.b; +var r5h5 = e << E.b; +var r5h6 = f << E.b; // operator >> var r6a1 = a >> a; //ok var r6a2 = a >> b; @@ -879,18 +879,18 @@ var r6f3 = f >> c; var r6f4 = f >> d; var r6f5 = f >> e; var r6f6 = f >> f; -var r6g1 = 0 /* a */ >> a; //ok -var r6g2 = 0 /* a */ >> b; -var r6g3 = 0 /* a */ >> c; //ok -var r6g4 = 0 /* a */ >> d; -var r6g5 = 0 /* a */ >> e; -var r6g6 = 0 /* a */ >> f; -var r6h1 = a >> 1 /* b */; //ok -var r6h2 = b >> 1 /* b */; -var r6h3 = c >> 1 /* b */; //ok -var r6h4 = d >> 1 /* b */; -var r6h5 = e >> 1 /* b */; -var r6h6 = f >> 1 /* b */; +var r6g1 = E.a >> a; //ok +var r6g2 = E.a >> b; +var r6g3 = E.a >> c; //ok +var r6g4 = E.a >> d; +var r6g5 = E.a >> e; +var r6g6 = E.a >> f; +var r6h1 = a >> E.b; //ok +var r6h2 = b >> E.b; +var r6h3 = c >> E.b; //ok +var r6h4 = d >> E.b; +var r6h5 = e >> E.b; +var r6h6 = f >> E.b; // operator >>> var r7a1 = a >>> a; //ok var r7a2 = a >>> b; @@ -928,18 +928,18 @@ var r7f3 = f >>> c; var r7f4 = f >>> d; var r7f5 = f >>> e; var r7f6 = f >>> f; -var r7g1 = 0 /* a */ >>> a; //ok -var r7g2 = 0 /* a */ >>> b; -var r7g3 = 0 /* a */ >>> c; //ok -var r7g4 = 0 /* a */ >>> d; -var r7g5 = 0 /* a */ >>> e; -var r7g6 = 0 /* a */ >>> f; -var r7h1 = a >>> 1 /* b */; //ok -var r7h2 = b >>> 1 /* b */; -var r7h3 = c >>> 1 /* b */; //ok -var r7h4 = d >>> 1 /* b */; -var r7h5 = e >>> 1 /* b */; -var r7h6 = f >>> 1 /* b */; +var r7g1 = E.a >>> a; //ok +var r7g2 = E.a >>> b; +var r7g3 = E.a >>> c; //ok +var r7g4 = E.a >>> d; +var r7g5 = E.a >>> e; +var r7g6 = E.a >>> f; +var r7h1 = a >>> E.b; //ok +var r7h2 = b >>> E.b; +var r7h3 = c >>> E.b; //ok +var r7h4 = d >>> E.b; +var r7h5 = e >>> E.b; +var r7h6 = f >>> E.b; // operator & var r8a1 = a & a; //ok var r8a2 = a & b; @@ -977,18 +977,18 @@ var r8f3 = f & c; var r8f4 = f & d; var r8f5 = f & e; var r8f6 = f & f; -var r8g1 = 0 /* a */ & a; //ok -var r8g2 = 0 /* a */ & b; -var r8g3 = 0 /* a */ & c; //ok -var r8g4 = 0 /* a */ & d; -var r8g5 = 0 /* a */ & e; -var r8g6 = 0 /* a */ & f; -var r8h1 = a & 1 /* b */; //ok -var r8h2 = b & 1 /* b */; -var r8h3 = c & 1 /* b */; //ok -var r8h4 = d & 1 /* b */; -var r8h5 = e & 1 /* b */; -var r8h6 = f & 1 /* b */; +var r8g1 = E.a & a; //ok +var r8g2 = E.a & b; +var r8g3 = E.a & c; //ok +var r8g4 = E.a & d; +var r8g5 = E.a & e; +var r8g6 = E.a & f; +var r8h1 = a & E.b; //ok +var r8h2 = b & E.b; +var r8h3 = c & E.b; //ok +var r8h4 = d & E.b; +var r8h5 = e & E.b; +var r8h6 = f & E.b; // operator ^ var r9a1 = a ^ a; //ok var r9a2 = a ^ b; @@ -1026,18 +1026,18 @@ var r9f3 = f ^ c; var r9f4 = f ^ d; var r9f5 = f ^ e; var r9f6 = f ^ f; -var r9g1 = 0 /* a */ ^ a; //ok -var r9g2 = 0 /* a */ ^ b; -var r9g3 = 0 /* a */ ^ c; //ok -var r9g4 = 0 /* a */ ^ d; -var r9g5 = 0 /* a */ ^ e; -var r9g6 = 0 /* a */ ^ f; -var r9h1 = a ^ 1 /* b */; //ok -var r9h2 = b ^ 1 /* b */; -var r9h3 = c ^ 1 /* b */; //ok -var r9h4 = d ^ 1 /* b */; -var r9h5 = e ^ 1 /* b */; -var r9h6 = f ^ 1 /* b */; +var r9g1 = E.a ^ a; //ok +var r9g2 = E.a ^ b; +var r9g3 = E.a ^ c; //ok +var r9g4 = E.a ^ d; +var r9g5 = E.a ^ e; +var r9g6 = E.a ^ f; +var r9h1 = a ^ E.b; //ok +var r9h2 = b ^ E.b; +var r9h3 = c ^ E.b; //ok +var r9h4 = d ^ E.b; +var r9h5 = e ^ E.b; +var r9h6 = f ^ E.b; // operator | var r10a1 = a | a; //ok var r10a2 = a | b; @@ -1075,15 +1075,15 @@ var r10f3 = f | c; var r10f4 = f | d; var r10f5 = f | e; var r10f6 = f | f; -var r10g1 = 0 /* a */ | a; //ok -var r10g2 = 0 /* a */ | b; -var r10g3 = 0 /* a */ | c; //ok -var r10g4 = 0 /* a */ | d; -var r10g5 = 0 /* a */ | e; -var r10g6 = 0 /* a */ | f; -var r10h1 = a | 1 /* b */; //ok -var r10h2 = b | 1 /* b */; -var r10h3 = c | 1 /* b */; //ok -var r10h4 = d | 1 /* b */; -var r10h5 = e | 1 /* b */; -var r10h6 = f | 1 /* b */; +var r10g1 = E.a | a; //ok +var r10g2 = E.a | b; +var r10g3 = E.a | c; //ok +var r10g4 = E.a | d; +var r10g5 = E.a | e; +var r10g6 = E.a | f; +var r10h1 = a | E.b; //ok +var r10h2 = b | E.b; +var r10h3 = c | E.b; //ok +var r10h4 = d | E.b; +var r10h5 = e | E.b; +var r10h6 = f | E.b; diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js index 40676ef4495..0c30e8d0484 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js @@ -124,89 +124,89 @@ var b; var ra1 = null * a; var ra2 = null * b; var ra3 = null * 1; -var ra4 = null * 0 /* a */; +var ra4 = null * E.a; var ra5 = a * null; var ra6 = b * null; var ra7 = 0 * null; -var ra8 = 1 /* b */ * null; +var ra8 = E.b * null; // operator / var rb1 = null / a; var rb2 = null / b; var rb3 = null / 1; -var rb4 = null / 0 /* a */; +var rb4 = null / E.a; var rb5 = a / null; var rb6 = b / null; var rb7 = 0 / null; -var rb8 = 1 /* b */ / null; +var rb8 = E.b / null; // operator % var rc1 = null % a; var rc2 = null % b; var rc3 = null % 1; -var rc4 = null % 0 /* a */; +var rc4 = null % E.a; var rc5 = a % null; var rc6 = b % null; var rc7 = 0 % null; -var rc8 = 1 /* b */ % null; +var rc8 = E.b % null; // operator - var rd1 = null - a; var rd2 = null - b; var rd3 = null - 1; -var rd4 = null - 0 /* a */; +var rd4 = null - E.a; var rd5 = a - null; var rd6 = b - null; var rd7 = 0 - null; -var rd8 = 1 /* b */ - null; +var rd8 = E.b - null; // operator << var re1 = null << a; var re2 = null << b; var re3 = null << 1; -var re4 = null << 0 /* a */; +var re4 = null << E.a; var re5 = a << null; var re6 = b << null; var re7 = 0 << null; -var re8 = 1 /* b */ << null; +var re8 = E.b << null; // operator >> var rf1 = null >> a; var rf2 = null >> b; var rf3 = null >> 1; -var rf4 = null >> 0 /* a */; +var rf4 = null >> E.a; var rf5 = a >> null; var rf6 = b >> null; var rf7 = 0 >> null; -var rf8 = 1 /* b */ >> null; +var rf8 = E.b >> null; // operator >>> var rg1 = null >>> a; var rg2 = null >>> b; var rg3 = null >>> 1; -var rg4 = null >>> 0 /* a */; +var rg4 = null >>> E.a; var rg5 = a >>> null; var rg6 = b >>> null; var rg7 = 0 >>> null; -var rg8 = 1 /* b */ >>> null; +var rg8 = E.b >>> null; // operator & var rh1 = null & a; var rh2 = null & b; var rh3 = null & 1; -var rh4 = null & 0 /* a */; +var rh4 = null & E.a; var rh5 = a & null; var rh6 = b & null; var rh7 = 0 & null; -var rh8 = 1 /* b */ & null; +var rh8 = E.b & null; // operator ^ var ri1 = null ^ a; var ri2 = null ^ b; var ri3 = null ^ 1; -var ri4 = null ^ 0 /* a */; +var ri4 = null ^ E.a; var ri5 = a ^ null; var ri6 = b ^ null; var ri7 = 0 ^ null; -var ri8 = 1 /* b */ ^ null; +var ri8 = E.b ^ null; // operator | var rj1 = null | a; var rj2 = null | b; var rj3 = null | 1; -var rj4 = null | 0 /* a */; +var rj4 = null | E.a; var rj5 = a | null; var rj6 = b | null; var rj7 = 0 | null; -var rj8 = 1 /* b */ | null; +var rj8 = E.b | null; diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js index ddc2c87dd7a..60ea9af32c2 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js @@ -124,89 +124,89 @@ var b; var ra1 = undefined * a; var ra2 = undefined * b; var ra3 = undefined * 1; -var ra4 = undefined * 0 /* a */; +var ra4 = undefined * E.a; var ra5 = a * undefined; var ra6 = b * undefined; var ra7 = 0 * undefined; -var ra8 = 1 /* b */ * undefined; +var ra8 = E.b * undefined; // operator / var rb1 = undefined / a; var rb2 = undefined / b; var rb3 = undefined / 1; -var rb4 = undefined / 0 /* a */; +var rb4 = undefined / E.a; var rb5 = a / undefined; var rb6 = b / undefined; var rb7 = 0 / undefined; -var rb8 = 1 /* b */ / undefined; +var rb8 = E.b / undefined; // operator % var rc1 = undefined % a; var rc2 = undefined % b; var rc3 = undefined % 1; -var rc4 = undefined % 0 /* a */; +var rc4 = undefined % E.a; var rc5 = a % undefined; var rc6 = b % undefined; var rc7 = 0 % undefined; -var rc8 = 1 /* b */ % undefined; +var rc8 = E.b % undefined; // operator - var rd1 = undefined - a; var rd2 = undefined - b; var rd3 = undefined - 1; -var rd4 = undefined - 0 /* a */; +var rd4 = undefined - E.a; var rd5 = a - undefined; var rd6 = b - undefined; var rd7 = 0 - undefined; -var rd8 = 1 /* b */ - undefined; +var rd8 = E.b - undefined; // operator << var re1 = undefined << a; var re2 = undefined << b; var re3 = undefined << 1; -var re4 = undefined << 0 /* a */; +var re4 = undefined << E.a; var re5 = a << undefined; var re6 = b << undefined; var re7 = 0 << undefined; -var re8 = 1 /* b */ << undefined; +var re8 = E.b << undefined; // operator >> var rf1 = undefined >> a; var rf2 = undefined >> b; var rf3 = undefined >> 1; -var rf4 = undefined >> 0 /* a */; +var rf4 = undefined >> E.a; var rf5 = a >> undefined; var rf6 = b >> undefined; var rf7 = 0 >> undefined; -var rf8 = 1 /* b */ >> undefined; +var rf8 = E.b >> undefined; // operator >>> var rg1 = undefined >>> a; var rg2 = undefined >>> b; var rg3 = undefined >>> 1; -var rg4 = undefined >>> 0 /* a */; +var rg4 = undefined >>> E.a; var rg5 = a >>> undefined; var rg6 = b >>> undefined; var rg7 = 0 >>> undefined; -var rg8 = 1 /* b */ >>> undefined; +var rg8 = E.b >>> undefined; // operator & var rh1 = undefined & a; var rh2 = undefined & b; var rh3 = undefined & 1; -var rh4 = undefined & 0 /* a */; +var rh4 = undefined & E.a; var rh5 = a & undefined; var rh6 = b & undefined; var rh7 = 0 & undefined; -var rh8 = 1 /* b */ & undefined; +var rh8 = E.b & undefined; // operator ^ var ri1 = undefined ^ a; var ri2 = undefined ^ b; var ri3 = undefined ^ 1; -var ri4 = undefined ^ 0 /* a */; +var ri4 = undefined ^ E.a; var ri5 = a ^ undefined; var ri6 = b ^ undefined; var ri7 = 0 ^ undefined; -var ri8 = 1 /* b */ ^ undefined; +var ri8 = E.b ^ undefined; // operator | var rj1 = undefined | a; var rj2 = undefined | b; var rj3 = undefined | 1; -var rj4 = undefined | 0 /* a */; +var rj4 = undefined | E.a; var rj5 = a | undefined; var rj6 = b | undefined; var rj7 = 0 | undefined; -var rj8 = 1 /* b */ | undefined; +var rj8 = E.b | undefined; diff --git a/tests/baselines/reference/assignAnyToEveryType.js b/tests/baselines/reference/assignAnyToEveryType.js index 47093cd0852..94b8067ddd7 100644 --- a/tests/baselines/reference/assignAnyToEveryType.js +++ b/tests/baselines/reference/assignAnyToEveryType.js @@ -61,7 +61,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var g = x; -var g2 = 0 /* A */; +var g2 = E.A; g2 = x; var C = (function () { function C() { diff --git a/tests/baselines/reference/assignEveryTypeToAny.js b/tests/baselines/reference/assignEveryTypeToAny.js index afe0d17cea1..ed1911ef995 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.js +++ b/tests/baselines/reference/assignEveryTypeToAny.js @@ -77,8 +77,8 @@ var E; (function (E) { E[E["A"] = 0] = "A"; })(E || (E = {})); -x = 0 /* A */; -var f = 0 /* A */; +x = E.A; +var f = E.A; x = f; var g; x = g; diff --git a/tests/baselines/reference/assignToEnum.js b/tests/baselines/reference/assignToEnum.js index 153068738d1..5f7048894fa 100644 --- a/tests/baselines/reference/assignToEnum.js +++ b/tests/baselines/reference/assignToEnum.js @@ -14,6 +14,6 @@ var A; A[A["bar"] = 1] = "bar"; })(A || (A = {})); A = undefined; // invalid LHS -A = 1 /* bar */; // invalid LHS -0 /* foo */ = 1; // invalid LHS -0 /* foo */ = 1 /* bar */; // invalid LHS +A = A.bar; // invalid LHS +A.foo = 1; // invalid LHS +A.foo = A.bar; // invalid LHS diff --git a/tests/baselines/reference/assignments.js b/tests/baselines/reference/assignments.js index f9bb008ccac..f6ca508384b 100644 --- a/tests/baselines/reference/assignments.js +++ b/tests/baselines/reference/assignments.js @@ -52,7 +52,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); E = null; // Error -0 /* A */ = null; // OK per spec, Error per implementation (509581) +E.A = null; // OK per spec, Error per implementation (509581) function fn() { } fn = null; // Should be error diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.js b/tests/baselines/reference/bestCommonTypeOfTuple.js index 704cae200a4..d5cbe7e67c8 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple.js @@ -53,16 +53,16 @@ t1 = [ f2 ]; t2 = [ - 0 /* one */, - 0 /* two */ + E1.one, + E2.two ]; t3 = [ 5, undefined ]; t4 = [ - 0 /* one */, - 0 /* two */, + E1.one, + E2.two, 20 ]; var e1 = t1[2]; // {} diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js index 710af4edfa7..0bcf2fa3956 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js @@ -30,11 +30,11 @@ var ENUM1; // enum type var var ResultIsNumber1 = ~ENUM1; // enum type expressions -var ResultIsNumber2 = ~0 /* "A" */; -var ResultIsNumber3 = ~(0 /* A */ + 1 /* "B" */); +var ResultIsNumber2 = ~ENUM1["A"]; +var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]); // multiple ~ operators -var ResultIsNumber4 = ~~~(0 /* "A" */ + 1 /* B */); +var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); // miss assignment operators ~ENUM1; -~0 /* "A" */; -~0 /* A */, ~1 /* "B" */; +~ENUM1["A"]; +~ENUM1.A, ~ENUM1["B"]; diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index bea141968a6..e615590ea7d 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -97,8 +97,8 @@ var classCDATuple = classCDTuple; var eleFromCDA1 = classCDATuple[2]; // A var eleFromCDA2 = classCDATuple[5]; // C | D | A var t10 = [ - 0 /* one */, - 0 /* one */ + E1.one, + E2.one ]; var t11 = t10; var array1 = emptyObjTuple; diff --git a/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.js b/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.js index 454fddf6fa8..1e56eb8bd9f 100644 --- a/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.js +++ b/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.js @@ -8,5 +8,5 @@ enum Color { var Color; (function (Color) { Color[Color["Color"] = 0] = "Color"; - Color[Color["Thing"] = Color.Color] = "Thing"; + Color[Color["Thing"] = 0] = "Thing"; })(Color || (Color = {})); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.js b/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.js index 0dc8e508d45..3662f5d6ddd 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.js +++ b/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.js @@ -12,6 +12,6 @@ var m1; var e; (function (e) { e[e["m1"] = 0] = "m1"; - e[e["m2"] = e.m1] = "m2"; + e[e["m2"] = 0] = "m2"; })(e || (e = {})); })(m1 || (m1 = {})); diff --git a/tests/baselines/reference/commentsEnums.js b/tests/baselines/reference/commentsEnums.js index c8bba8a4f77..7be17f085b0 100644 --- a/tests/baselines/reference/commentsEnums.js +++ b/tests/baselines/reference/commentsEnums.js @@ -21,8 +21,8 @@ var Colors; /** Fancy name for 'pink'*/ Colors[Colors["FancyPink"] = 1] = "FancyPink"; })(Colors || (Colors = {})); // trailing comment -var x = 0 /* Cornflower */; -x = 1 /* FancyPink */; +var x = Colors.Cornflower; +x = Colors.FancyPink; //// [commentsEnums.d.ts] diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.js b/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.js index e0c1f33cb4a..fc0323a89aa 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.js @@ -80,56 +80,56 @@ var b; // operator < var ra1 = a < b; var ra2 = b < a; -var ra3 = 0 /* a */ < b; -var ra4 = b < 0 /* a */; -var ra5 = 0 /* a */ < 0; -var ra6 = 0 < 0 /* a */; +var ra3 = E.a < b; +var ra4 = b < E.a; +var ra5 = E.a < 0; +var ra6 = 0 < E.a; // operator > var rb1 = a > b; var rb2 = b > a; -var rb3 = 0 /* a */ > b; -var rb4 = b > 0 /* a */; -var rb5 = 0 /* a */ > 0; -var rb6 = 0 > 0 /* a */; +var rb3 = E.a > b; +var rb4 = b > E.a; +var rb5 = E.a > 0; +var rb6 = 0 > E.a; // operator <= var rc1 = a <= b; var rc2 = b <= a; -var rc3 = 0 /* a */ <= b; -var rc4 = b <= 0 /* a */; -var rc5 = 0 /* a */ <= 0; -var rc6 = 0 <= 0 /* a */; +var rc3 = E.a <= b; +var rc4 = b <= E.a; +var rc5 = E.a <= 0; +var rc6 = 0 <= E.a; // operator >= var rd1 = a >= b; var rd2 = b >= a; -var rd3 = 0 /* a */ >= b; -var rd4 = b >= 0 /* a */; -var rd5 = 0 /* a */ >= 0; -var rd6 = 0 >= 0 /* a */; +var rd3 = E.a >= b; +var rd4 = b >= E.a; +var rd5 = E.a >= 0; +var rd6 = 0 >= E.a; // operator == var re1 = a == b; var re2 = b == a; -var re3 = 0 /* a */ == b; -var re4 = b == 0 /* a */; -var re5 = 0 /* a */ == 0; -var re6 = 0 == 0 /* a */; +var re3 = E.a == b; +var re4 = b == E.a; +var re5 = E.a == 0; +var re6 = 0 == E.a; // operator != var rf1 = a != b; var rf2 = b != a; -var rf3 = 0 /* a */ != b; -var rf4 = b != 0 /* a */; -var rf5 = 0 /* a */ != 0; -var rf6 = 0 != 0 /* a */; +var rf3 = E.a != b; +var rf4 = b != E.a; +var rf5 = E.a != 0; +var rf6 = 0 != E.a; // operator === var rg1 = a === b; var rg2 = b === a; -var rg3 = 0 /* a */ === b; -var rg4 = b === 0 /* a */; -var rg5 = 0 /* a */ === 0; -var rg6 = 0 === 0 /* a */; +var rg3 = E.a === b; +var rg4 = b === E.a; +var rg5 = E.a === 0; +var rg6 = 0 === E.a; // operator !== var rh1 = a !== b; var rh2 = b !== a; -var rh3 = 0 /* a */ !== b; -var rh4 = b !== 0 /* a */; -var rh5 = 0 /* a */ !== 0; -var rh6 = 0 !== 0 /* a */; +var rh3 = E.a !== b; +var rh4 = b !== E.a; +var rh5 = E.a !== 0; +var rh6 = 0 !== E.a; diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.js b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.js index aebacb88827..ae53d064178 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.js +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.js @@ -64,7 +64,7 @@ x1 += b; x1 += true; x1 += 0; x1 += ''; -x1 += 0 /* a */; +x1 += E.a; x1 += {}; x1 += null; x1 += undefined; @@ -74,20 +74,20 @@ x2 += b; x2 += true; x2 += 0; x2 += ''; -x2 += 0 /* a */; +x2 += E.a; x2 += {}; x2 += null; x2 += undefined; var x3; x3 += a; x3 += 0; -x3 += 0 /* a */; +x3 += E.a; x3 += null; x3 += undefined; var x4; x4 += a; x4 += 0; -x4 += 0 /* a */; +x4 += E.a; x4 += null; x4 += undefined; var x5; diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.js b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.js index af4f1bc1521..cef1d3e424e 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.js +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.js @@ -51,7 +51,7 @@ var x1; x1 += a; x1 += true; x1 += 0; -x1 += 0 /* a */; +x1 += E.a; x1 += {}; x1 += null; x1 += undefined; @@ -59,7 +59,7 @@ var x2; x2 += a; x2 += true; x2 += 0; -x2 += 0 /* a */; +x2 += E.a; x2 += {}; x2 += null; x2 += undefined; @@ -67,7 +67,7 @@ var x3; x3 += a; x3 += true; x3 += 0; -x3 += 0 /* a */; +x3 += E.a; x3 += {}; x3 += null; x3 += undefined; diff --git a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.js b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.js index 61722df0fb0..5c71f717bb2 100644 --- a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.js +++ b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.js @@ -74,7 +74,7 @@ x1 *= b; x1 *= true; x1 *= 0; x1 *= ''; -x1 *= 0 /* a */; +x1 *= E.a; x1 *= {}; x1 *= null; x1 *= undefined; @@ -84,7 +84,7 @@ x2 *= b; x2 *= true; x2 *= 0; x2 *= ''; -x2 *= 0 /* a */; +x2 *= E.a; x2 *= {}; x2 *= null; x2 *= undefined; @@ -94,7 +94,7 @@ x3 *= b; x3 *= true; x3 *= 0; x3 *= ''; -x3 *= 0 /* a */; +x3 *= E.a; x3 *= {}; x3 *= null; x3 *= undefined; @@ -104,7 +104,7 @@ x4 *= b; x4 *= true; x4 *= 0; x4 *= ''; -x4 *= 0 /* a */; +x4 *= E.a; x4 *= {}; x4 *= null; x4 *= undefined; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.js b/tests/baselines/reference/computedPropertyNames47_ES5.js index 7d839e16ffb..a2fff2110b4 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.js +++ b/tests/baselines/reference/computedPropertyNames47_ES5.js @@ -15,6 +15,6 @@ var E2; E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); var o = (_a = {}, - _a[0 /* x */ || 0 /* x */] = 0, + _a[E1.x || E2.x] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.js b/tests/baselines/reference/computedPropertyNames47_ES6.js index e104d33e7d3..0b6cb352999 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.js +++ b/tests/baselines/reference/computedPropertyNames47_ES6.js @@ -15,5 +15,5 @@ var E2; E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); var o = { - [0 /* x */ || 0 /* x */]: 0 + [E1.x || E2.x]: 0 }; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index c5ca0d5b241..55b08ef8301 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -27,7 +27,7 @@ extractIndexer((_a = {}, _a[a] = "", _a)); // Should return string extractIndexer((_b = {}, - _b[0 /* x */] = "", + _b[E.x] = "", _b)); // Should return string extractIndexer((_c = {}, _c["" || 0] = "", diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.js b/tests/baselines/reference/computedPropertyNames48_ES6.js index 27821647565..8e54d67238c 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.js +++ b/tests/baselines/reference/computedPropertyNames48_ES6.js @@ -27,7 +27,7 @@ extractIndexer({ [a]: "" }); // Should return string extractIndexer({ - [0 /* x */]: "" + [E.x]: "" }); // Should return string extractIndexer({ ["" || 0]: "" diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.js b/tests/baselines/reference/computedPropertyNames7_ES5.js index 9c23dcab20d..01cf2efc030 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.js +++ b/tests/baselines/reference/computedPropertyNames7_ES5.js @@ -12,6 +12,6 @@ var E; E[E["member"] = 0] = "member"; })(E || (E = {})); var v = (_a = {}, - _a[0 /* member */] = 0, + _a[E.member] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.js b/tests/baselines/reference/computedPropertyNames7_ES6.js index 5714fb747a6..ee1e1c85c06 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.js +++ b/tests/baselines/reference/computedPropertyNames7_ES6.js @@ -12,5 +12,5 @@ var E; E[E["member"] = 0] = "member"; })(E || (E = {})); var v = { - [0 /* member */]: 0 + [E.member]: 0 }; diff --git a/tests/baselines/reference/constDeclarations-access5.errors.txt b/tests/baselines/reference/constDeclarations-access5.errors.txt index 23200e50ee4..a098b0e72c6 100644 --- a/tests/baselines/reference/constDeclarations-access5.errors.txt +++ b/tests/baselines/reference/constDeclarations-access5.errors.txt @@ -1,3 +1,5 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant. @@ -18,9 +20,12 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant. -==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ==== +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ==== /// import m = require('constDeclarations_access_1'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. // Errors m.x = 1; ~~~ diff --git a/tests/baselines/reference/constDeclarations-access5.js b/tests/baselines/reference/constDeclarations-access5.js index 7acc95ad055..313ce3db21a 100644 --- a/tests/baselines/reference/constDeclarations-access5.js +++ b/tests/baselines/reference/constDeclarations-access5.js @@ -49,41 +49,37 @@ m.x.toString(); //// [constDeclarations_access_1.js] -define(["require", "exports"], function (require, exports) { - exports.x = 0; -}); +export const x = 0; //// [constDeclarations_access_2.js] -define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) { - // Errors - m.x = 1; - m.x += 2; - m.x -= 3; - m.x *= 4; - m.x /= 5; - m.x %= 6; - m.x <<= 7; - m.x >>= 8; - m.x >>>= 9; - m.x &= 10; - m.x |= 11; - m.x ^= 12; - m; - m.x++; - m.x--; - ++m.x; - --m.x; - ++((m.x)); - m["x"] = 0; - // OK - var a = m.x + 1; - function f(v) { - } - f(m.x); - if (m.x) { - } - m.x; - (m.x); - -m.x; - +m.x; - m.x.toString(); -}); +// Errors +m.x = 1; +m.x += 2; +m.x -= 3; +m.x *= 4; +m.x /= 5; +m.x %= 6; +m.x <<= 7; +m.x >>= 8; +m.x >>>= 9; +m.x &= 10; +m.x |= 11; +m.x ^= 12; +m; +m.x++; +m.x--; +++m.x; +--m.x; +++((m.x)); +m["x"] = 0; +// OK +var a = m.x + 1; +function f(v) { +} +f(m.x); +if (m.x) { +} +m.x; +(m.x); +-m.x; ++m.x; +m.x.toString(); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 566213887f4..0bc51e90c5c 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -369,7 +369,7 @@ var BasicFeatures = (function () { return 'objLit{42}'; } }; - var weekday = 0 /* Monday */; + var weekday = Weekdays.Monday; var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday; // var any = 0 ^= ; diff --git a/tests/baselines/reference/declFileEnums.js b/tests/baselines/reference/declFileEnums.js index 97559f05574..34f1e386a96 100644 --- a/tests/baselines/reference/declFileEnums.js +++ b/tests/baselines/reference/declFileEnums.js @@ -46,14 +46,14 @@ var e1; var e2; (function (e2) { e2[e2["a"] = 10] = "a"; - e2[e2["b"] = e2.a + 2] = "b"; + e2[e2["b"] = 12] = "b"; e2[e2["c"] = 10] = "c"; })(e2 || (e2 = {})); var e3; (function (e3) { e3[e3["a"] = 10] = "a"; e3[e3["b"] = Math.PI] = "b"; - e3[e3["c"] = e3.a + 3] = "c"; + e3[e3["c"] = 13] = "c"; })(e3 || (e3 = {})); var e4; (function (e4) { @@ -80,13 +80,13 @@ declare enum e1 { } declare enum e2 { a = 10, - b, + b = 12, c = 10, } declare enum e3 { a = 10, b, - c, + c = 13, } declare enum e4 { a = 0, diff --git a/tests/baselines/reference/declFileTypeofEnum.js b/tests/baselines/reference/declFileTypeofEnum.js index 8ced6f9e595..5b1c6977472 100644 --- a/tests/baselines/reference/declFileTypeofEnum.js +++ b/tests/baselines/reference/declFileTypeofEnum.js @@ -25,7 +25,7 @@ var days; days[days["saturday"] = 5] = "saturday"; days[days["sunday"] = 6] = "sunday"; })(days || (days = {})); -var weekendDay = 5 /* saturday */; +var weekendDay = days.saturday; var daysOfMonth = days; var daysOfYear; diff --git a/tests/baselines/reference/declFileTypeofInAnonymousType.js b/tests/baselines/reference/declFileTypeofInAnonymousType.js index ab812720d9a..1a5071fd219 100644 --- a/tests/baselines/reference/declFileTypeofInAnonymousType.js +++ b/tests/baselines/reference/declFileTypeofInAnonymousType.js @@ -56,7 +56,7 @@ var d = { me: { en: m1.e }, - mh: 2 /* holiday */ + mh: m1.e.holiday }; diff --git a/tests/baselines/reference/declarationEmitDefaultExport1.js b/tests/baselines/reference/declarationEmitDefaultExport1.js new file mode 100644 index 00000000000..197e4fc9cc8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport1.js @@ -0,0 +1,12 @@ +//// [declarationEmitDefaultExport1.ts] +export default class C { +} + +//// [declarationEmitDefaultExport1.js] +export default class C { +} + + +//// [declarationEmitDefaultExport1.d.ts] +export default class C { +} diff --git a/tests/baselines/reference/declarationEmitDefaultExport1.types b/tests/baselines/reference/declarationEmitDefaultExport1.types new file mode 100644 index 00000000000..41dd3547b6d --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport1.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/declarationEmitDefaultExport1.ts === +export default class C { +>C : C +} diff --git a/tests/baselines/reference/declarationEmitDefaultExport2.js b/tests/baselines/reference/declarationEmitDefaultExport2.js new file mode 100644 index 00000000000..388bd41e4f8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport2.js @@ -0,0 +1,12 @@ +//// [declarationEmitDefaultExport2.ts] +export default class { +} + +//// [declarationEmitDefaultExport2.js] +export default class { +} + + +//// [declarationEmitDefaultExport2.d.ts] +export default class { +} diff --git a/tests/baselines/reference/declarationEmitDefaultExport2.types b/tests/baselines/reference/declarationEmitDefaultExport2.types new file mode 100644 index 00000000000..b82e6cfb923 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport2.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/declarationEmitDefaultExport2.ts === +export default class { +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport3.js b/tests/baselines/reference/declarationEmitDefaultExport3.js new file mode 100644 index 00000000000..ba412a1b4b7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport3.js @@ -0,0 +1,13 @@ +//// [declarationEmitDefaultExport3.ts] +export default function foo() { + return "" +} + +//// [declarationEmitDefaultExport3.js] +export default function foo() { + return ""; +} + + +//// [declarationEmitDefaultExport3.d.ts] +export default function foo(): string; diff --git a/tests/baselines/reference/declarationEmitDefaultExport3.types b/tests/baselines/reference/declarationEmitDefaultExport3.types new file mode 100644 index 00000000000..0bde6eff915 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport3.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/declarationEmitDefaultExport3.ts === +export default function foo() { +>foo : () => string + + return "" +} diff --git a/tests/baselines/reference/declarationEmitDefaultExport4.js b/tests/baselines/reference/declarationEmitDefaultExport4.js new file mode 100644 index 00000000000..92f8ef8bb81 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport4.js @@ -0,0 +1,13 @@ +//// [declarationEmitDefaultExport4.ts] +export default function () { + return 1; +} + +//// [declarationEmitDefaultExport4.js] +export default function () { + return 1; +} + + +//// [declarationEmitDefaultExport4.d.ts] +export default function (): number; diff --git a/tests/baselines/reference/declarationEmitDefaultExport4.types b/tests/baselines/reference/declarationEmitDefaultExport4.types new file mode 100644 index 00000000000..8043af36b76 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport4.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declarationEmitDefaultExport4.ts === +export default function () { +No type information for this code. return 1; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport5.js b/tests/baselines/reference/declarationEmitDefaultExport5.js new file mode 100644 index 00000000000..a8794d92c63 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport5.js @@ -0,0 +1,10 @@ +//// [declarationEmitDefaultExport5.ts] +export default 1 + 2; + + +//// [declarationEmitDefaultExport5.js] +export default 1 + 2; + + +//// [declarationEmitDefaultExport5.d.ts] +export default : number; diff --git a/tests/baselines/reference/declarationEmitDefaultExport5.types b/tests/baselines/reference/declarationEmitDefaultExport5.types new file mode 100644 index 00000000000..702cc51f71e --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport5.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/declarationEmitDefaultExport5.ts === +export default 1 + 2; +>1 + 2 : number + diff --git a/tests/baselines/reference/declarationEmitDefaultExport6.js b/tests/baselines/reference/declarationEmitDefaultExport6.js new file mode 100644 index 00000000000..d328458366e --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport6.js @@ -0,0 +1,15 @@ +//// [declarationEmitDefaultExport6.ts] +export class A {} +export default new A(); + + +//// [declarationEmitDefaultExport6.js] +export class A { +} +export default new A(); + + +//// [declarationEmitDefaultExport6.d.ts] +export declare class A { +} +export default : A; diff --git a/tests/baselines/reference/declarationEmitDefaultExport6.types b/tests/baselines/reference/declarationEmitDefaultExport6.types new file mode 100644 index 00000000000..9c839edb1a9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport6.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/declarationEmitDefaultExport6.ts === +export class A {} +>A : A + +export default new A(); +>new A() : A +>A : typeof A + diff --git a/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt new file mode 100644 index 00000000000..f19766cbb00 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/declarationEmitDefaultExport7.ts(2,1): error TS4082: Default export of the module has or is using private name 'A'. + + +==== tests/cases/compiler/declarationEmitDefaultExport7.ts (1 errors) ==== + class A {} + export default new A(); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4082: Default export of the module has or is using private name 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport7.js b/tests/baselines/reference/declarationEmitDefaultExport7.js new file mode 100644 index 00000000000..99751113dd6 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExport7.js @@ -0,0 +1,9 @@ +//// [declarationEmitDefaultExport7.ts] +class A {} +export default new A(); + + +//// [declarationEmitDefaultExport7.js] +class A { +} +export default new A(); diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js new file mode 100644 index 00000000000..7ee32cab16c --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js @@ -0,0 +1,44 @@ +//// [declarationEmitDestructuringArrayPattern1.ts] + +var [] = [1, "hello"]; // Dont emit anything +var [x] = [1, "hello"]; // emit x: number +var [x1, y1] = [1, "hello"]; // emit x1: number, y1: string +var [, , z1] = [0, 1, 2]; // emit z1: number + +var a = [1, "hello"]; +var [x2] = a; // emit x2: number | string +var [x3, y3, z3] = a; // emit x3, y3, z3 + +//// [declarationEmitDestructuringArrayPattern1.js] +var _a = [ + 1, + "hello" +]; // Dont emit anything +var x = ([ + 1, + "hello" +])[0]; // emit x: number +var _b = [ + 1, + "hello" +], x1 = _b[0], y1 = _b[1]; // emit x1: number, y1: string +var _c = [ + 0, + 1, + 2 +], z1 = _c[2]; // emit z1: number +var a = [ + 1, + "hello" +]; +var x2 = a[0]; // emit x2: number | string +var x3 = a[0], y3 = a[1], z3 = a[2]; // emit x3, y3, z3 + + +//// [declarationEmitDestructuringArrayPattern1.d.ts] +declare var x: number; +declare var x1: number, y1: string; +declare var z1: number; +declare var a: (string | number)[]; +declare var x2: string | number; +declare var x3: string | number, y3: string | number, z3: string | number; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types new file mode 100644 index 00000000000..9f6f4c9857d --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts === + +var [] = [1, "hello"]; // Dont emit anything +>[1, "hello"] : (string | number)[] + +var [x] = [1, "hello"]; // emit x: number +>x : number +>[1, "hello"] : [number, string] + +var [x1, y1] = [1, "hello"]; // emit x1: number, y1: string +>x1 : number +>y1 : string +>[1, "hello"] : [number, string] + +var [, , z1] = [0, 1, 2]; // emit z1: number +>z1 : number +>[0, 1, 2] : [number, number, number] + +var a = [1, "hello"]; +>a : (string | number)[] +>[1, "hello"] : (string | number)[] + +var [x2] = a; // emit x2: number | string +>x2 : string | number +>a : (string | number)[] + +var [x3, y3, z3] = a; // emit x3, y3, z3 +>x3 : string | number +>y3 : string | number +>z3 : string | number +>a : (string | number)[] + diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js new file mode 100644 index 00000000000..5734b9bc6f9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js @@ -0,0 +1,69 @@ +//// [declarationEmitDestructuringArrayPattern2.ts] +var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; + +var [x11 = 0, y11 = ""] = [1, "hello"]; +var [a11, b11, c11] = []; + +var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; + +var [x13, y13] = [1, "hello"]; +var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; + + +//// [declarationEmitDestructuringArrayPattern2.js] +var _a = [ + 1, + [ + "hello", + [ + true + ] + ] +], x10 = _a[0], _b = _a[1], y10 = _b[0], z10 = _b[1][0]; +var _c = [ + 1, + "hello" +], _d = _c[0], x11 = _d === void 0 ? 0 : _d, _e = _c[1], y11 = _e === void 0 ? "" : _e; +var _f = [], a11 = _f[0], b11 = _f[1], c11 = _f[2]; +var _g = [ + 1, + [ + "hello", + { + x12: 5, + y12: true + } + ] +], a2 = _g[0], _h = _g[1], _j = _h === void 0 ? [ + "abc", + { + x12: 10, + y12: false + } +] : _h, b2 = _j[0], _k = _j[1], x12 = _k.x12, c2 = _k.y12; +var _l = [ + 1, + "hello" +], x13 = _l[0], y13 = _l[1]; +var _m = [ + [ + x13, + y13 + ], + { + x: x13, + y: y13 + } +], a3 = _m[0], b3 = _m[1]; + + +//// [declarationEmitDestructuringArrayPattern2.d.ts] +declare var x10: number, y10: string, z10: boolean; +declare var x11: number, y11: string; +declare var a11: any, b11: any, c11: any; +declare var a2: number, b2: string, x12: number, c2: boolean; +declare var x13: number, y13: string; +declare var a3: (string | number)[], b3: { + x: number; + y: string; +}; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types new file mode 100644 index 00000000000..2b40a388e3b --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts === +var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; +>x10 : number +>y10 : string +>z10 : boolean +>[1, ["hello", [true]]] : [number, [string, [boolean]]] +>["hello", [true]] : [string, [boolean]] +>[true] : [boolean] + +var [x11 = 0, y11 = ""] = [1, "hello"]; +>x11 : number +>y11 : string +>[1, "hello"] : [number, string] + +var [a11, b11, c11] = []; +>a11 : any +>b11 : any +>c11 : any +>[] : undefined[] + +var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; +>a2 : number +>b2 : string +>x12 : number +>y12 : unknown +>c2 : boolean +>["abc", { x12: 10, y12: false }] : [string, { x12: number; y12: boolean; }] +>{ x12: 10, y12: false } : { x12: number; y12: boolean; } +>x12 : number +>y12 : boolean +>[1, ["hello", { x12: 5, y12: true }]] : [number, [string, { x12: number; y12: boolean; }]] +>["hello", { x12: 5, y12: true }] : [string, { x12: number; y12: boolean; }] +>{ x12: 5, y12: true } : { x12: number; y12: boolean; } +>x12 : number +>y12 : boolean + +var [x13, y13] = [1, "hello"]; +>x13 : number +>y13 : string +>[1, "hello"] : [number, string] + +var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; +>a3 : (string | number)[] +>b3 : { x: number; y: string; } +>[[x13, y13], { x: x13, y: y13 }] : [(string | number)[], { x: number; y: string; }] +>[x13, y13] : (string | number)[] +>x13 : number +>y13 : string +>{ x: x13, y: y13 } : { x: number; y: string; } +>x : number +>x13 : number +>y : string +>y13 : string + diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js new file mode 100644 index 00000000000..258fa17d7ff --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js @@ -0,0 +1,20 @@ +//// [declarationEmitDestructuringArrayPattern3.ts] +module M { + export var [a, b] = [1, 2]; +} + +//// [declarationEmitDestructuringArrayPattern3.js] +var M; +(function (M) { + _a = [ + 1, + 2 + ], M.a = _a[0], M.b = _a[1]; + var _a; +})(M || (M = {})); + + +//// [declarationEmitDestructuringArrayPattern3.d.ts] +declare module M { + var a: number, b: number; +} diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types new file mode 100644 index 00000000000..4852a7e37fb --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/declarationEmitDestructuringArrayPattern3.ts === +module M { +>M : typeof M + + export var [a, b] = [1, 2]; +>a : number +>b : number +>[1, 2] : [number, number] +} diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js new file mode 100644 index 00000000000..97a8c20b73b --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js @@ -0,0 +1,63 @@ +//// [declarationEmitDestructuringArrayPattern4.ts] +var [...a5] = [1, 2, 3]; +var [x14, ...a6] = [1, 2, 3]; +var [x15, y15, ...a7] = [1, 2, 3]; +var [x16, y16, z16, ...a8] = [1, 2, 3]; + +var [...a9] = [1, "hello", true]; +var [x17, ...a10] = [1, "hello", true]; +var [x18, y18, ...a12] = [1, "hello", true]; +var [x19, y19, z19, ...a13] = [1, "hello", true]; + +//// [declarationEmitDestructuringArrayPattern4.js] +var _a = [ + 1, + 2, + 3 +], a5 = _a.slice(0); +var _b = [ + 1, + 2, + 3 +], x14 = _b[0], a6 = _b.slice(1); +var _c = [ + 1, + 2, + 3 +], x15 = _c[0], y15 = _c[1], a7 = _c.slice(2); +var _d = [ + 1, + 2, + 3 +], x16 = _d[0], y16 = _d[1], z16 = _d[2], a8 = _d.slice(3); +var _e = [ + 1, + "hello", + true +], a9 = _e.slice(0); +var _f = [ + 1, + "hello", + true +], x17 = _f[0], a10 = _f.slice(1); +var _g = [ + 1, + "hello", + true +], x18 = _g[0], y18 = _g[1], a12 = _g.slice(2); +var _h = [ + 1, + "hello", + true +], x19 = _h[0], y19 = _h[1], z19 = _h[2], a13 = _h.slice(3); + + +//// [declarationEmitDestructuringArrayPattern4.d.ts] +declare var a5: number[]; +declare var x14: number, a6: number[]; +declare var x15: number, y15: number, a7: number[]; +declare var x16: number, y16: number, z16: number, a8: number[]; +declare var a9: (string | number | boolean)[]; +declare var x17: string | number | boolean, a10: (string | number | boolean)[]; +declare var x18: string | number | boolean, y18: string | number | boolean, a12: (string | number | boolean)[]; +declare var x19: string | number | boolean, y19: string | number | boolean, z19: string | number | boolean, a13: (string | number | boolean)[]; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types new file mode 100644 index 00000000000..d6d0fa758d7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/declarationEmitDestructuringArrayPattern4.ts === +var [...a5] = [1, 2, 3]; +>a5 : number[] +>[1, 2, 3] : number[] + +var [x14, ...a6] = [1, 2, 3]; +>x14 : number +>a6 : number[] +>[1, 2, 3] : number[] + +var [x15, y15, ...a7] = [1, 2, 3]; +>x15 : number +>y15 : number +>a7 : number[] +>[1, 2, 3] : number[] + +var [x16, y16, z16, ...a8] = [1, 2, 3]; +>x16 : number +>y16 : number +>z16 : number +>a8 : number[] +>[1, 2, 3] : number[] + +var [...a9] = [1, "hello", true]; +>a9 : (string | number | boolean)[] +>[1, "hello", true] : (string | number | boolean)[] + +var [x17, ...a10] = [1, "hello", true]; +>x17 : string | number | boolean +>a10 : (string | number | boolean)[] +>[1, "hello", true] : (string | number | boolean)[] + +var [x18, y18, ...a12] = [1, "hello", true]; +>x18 : string | number | boolean +>y18 : string | number | boolean +>a12 : (string | number | boolean)[] +>[1, "hello", true] : (string | number | boolean)[] + +var [x19, y19, z19, ...a13] = [1, "hello", true]; +>x19 : string | number | boolean +>y19 : string | number | boolean +>z19 : string | number | boolean +>a13 : (string | number | boolean)[] +>[1, "hello", true] : (string | number | boolean)[] + diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js new file mode 100644 index 00000000000..de3045be1cc --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js @@ -0,0 +1,97 @@ +//// [declarationEmitDestructuringObjectLiteralPattern.ts] + +var { } = { x: 5, y: "hello" }; +var { x4 } = { x4: 5, y4: "hello" }; +var { y5 } = { x5: 5, y5: "hello" }; +var { x6, y6 } = { x6: 5, y6: "hello" }; +var { x7: a1 } = { x7: 5, y7: "hello" }; +var { y8: b1 } = { x8: 5, y8: "hello" }; +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; +} +var { a4, b4, c4 } = f15(); + +module m { + export var { a4, b4, c4 } = f15(); +} + +//// [declarationEmitDestructuringObjectLiteralPattern.js] +var _a = { + x: 5, + y: "hello" +}; +var x4 = ({ + x4: 5, + y4: "hello" +}).x4; +var y5 = ({ + x5: 5, + y5: "hello" +}).y5; +var _b = { + x6: 5, + y6: "hello" +}, x6 = _b.x6, y6 = _b.y6; +var a1 = ({ + x7: 5, + y7: "hello" +}).x7; +var b1 = ({ + x8: 5, + y8: "hello" +}).y8; +var _c = { + x9: 5, + y9: "hello" +}, a2 = _c.x9, b2 = _c.y9; +var _d = { + a: 1, + b: { + a: "hello", + b: { + a: true + } + } +}, x11 = _d.a, _e = _d.b, y11 = _e.a, z11 = _e.b.a; +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { + a4: a4, + b4: b4, + c4: c4 + }; +} +var _f = f15(), a4 = _f.a4, b4 = _f.b4, c4 = _f.c4; +var m; +(function (m) { + _g = f15(), m.a4 = _g.a4, m.b4 = _g.b4, m.c4 = _g.c4; + var _g; +})(m || (m = {})); + + +//// [declarationEmitDestructuringObjectLiteralPattern.d.ts] +declare var x4: number; +declare var y5: string; +declare var x6: number, y6: string; +declare var a1: number; +declare var b1: string; +declare var a2: number, b2: string; +declare var x11: number, y11: string, z11: boolean; +declare function f15(): { + a4: string; + b4: number; + c4: boolean; +}; +declare var a4: string, b4: number, c4: boolean; +declare module m { + var a4: string, b4: number, c4: boolean; +} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types new file mode 100644 index 00000000000..b3c422e4958 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types @@ -0,0 +1,102 @@ +=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts === + +var { } = { x: 5, y: "hello" }; +>{ x: 5, y: "hello" } : { x: number; y: string; } +>x : number +>y : string + +var { x4 } = { x4: 5, y4: "hello" }; +>x4 : number +>{ x4: 5, y4: "hello" } : { x4: number; y4: string; } +>x4 : number +>y4 : string + +var { y5 } = { x5: 5, y5: "hello" }; +>y5 : string +>{ x5: 5, y5: "hello" } : { x5: number; y5: string; } +>x5 : number +>y5 : string + +var { x6, y6 } = { x6: 5, y6: "hello" }; +>x6 : number +>y6 : string +>{ x6: 5, y6: "hello" } : { x6: number; y6: string; } +>x6 : number +>y6 : string + +var { x7: a1 } = { x7: 5, y7: "hello" }; +>x7 : unknown +>a1 : number +>{ x7: 5, y7: "hello" } : { x7: number; y7: string; } +>x7 : number +>y7 : string + +var { y8: b1 } = { x8: 5, y8: "hello" }; +>y8 : unknown +>b1 : string +>{ x8: 5, y8: "hello" } : { x8: number; y8: string; } +>x8 : number +>y8 : string + +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; +>x9 : unknown +>a2 : number +>y9 : unknown +>b2 : string +>{ x9: 5, y9: "hello" } : { x9: number; y9: string; } +>x9 : number +>y9 : string + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; +>a : unknown +>x11 : number +>b : unknown +>a : unknown +>y11 : string +>b : unknown +>a : unknown +>z11 : boolean +>{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; } +>a : number +>b : { a: string; b: { a: boolean; }; } +>{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; } +>a : string +>b : { a: boolean; } +>{ a: true } : { a: boolean; } +>a : boolean + +function f15() { +>f15 : () => { a4: string; b4: number; c4: boolean; } + + var a4 = "hello"; +>a4 : string + + var b4 = 1; +>b4 : number + + var c4 = true; +>c4 : boolean + + return { a4, b4, c4 }; +>{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } +>a4 : string +>b4 : number +>c4 : boolean +} +var { a4, b4, c4 } = f15(); +>a4 : string +>b4 : number +>c4 : boolean +>f15() : { a4: string; b4: number; c4: boolean; } +>f15 : () => { a4: string; b4: number; c4: boolean; } + +module m { +>m : typeof m + + export var { a4, b4, c4 } = f15(); +>a4 : string +>b4 : number +>c4 : boolean +>f15() : { a4: string; b4: number; c4: boolean; } +>f15 : () => { a4: string; b4: number; c4: boolean; } +} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js new file mode 100644 index 00000000000..889047185e7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js @@ -0,0 +1,48 @@ +//// [declarationEmitDestructuringObjectLiteralPattern1.ts] + +var { } = { x: 5, y: "hello" }; +var { x4 } = { x4: 5, y4: "hello" }; +var { y5 } = { x5: 5, y5: "hello" }; +var { x6, y6 } = { x6: 5, y6: "hello" }; +var { x7: a1 } = { x7: 5, y7: "hello" }; +var { y8: b1 } = { x8: 5, y8: "hello" }; +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; + +//// [declarationEmitDestructuringObjectLiteralPattern1.js] +var _a = { + x: 5, + y: "hello" +}; +var x4 = ({ + x4: 5, + y4: "hello" +}).x4; +var y5 = ({ + x5: 5, + y5: "hello" +}).y5; +var _b = { + x6: 5, + y6: "hello" +}, x6 = _b.x6, y6 = _b.y6; +var a1 = ({ + x7: 5, + y7: "hello" +}).x7; +var b1 = ({ + x8: 5, + y8: "hello" +}).y8; +var _c = { + x9: 5, + y9: "hello" +}, a2 = _c.x9, b2 = _c.y9; + + +//// [declarationEmitDestructuringObjectLiteralPattern1.d.ts] +declare var x4: number; +declare var y5: string; +declare var x6: number, y6: string; +declare var a1: number; +declare var b1: string; +declare var a2: number, b2: string; diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types new file mode 100644 index 00000000000..cc2094c68f4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types @@ -0,0 +1,49 @@ +=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts === + +var { } = { x: 5, y: "hello" }; +>{ x: 5, y: "hello" } : { x: number; y: string; } +>x : number +>y : string + +var { x4 } = { x4: 5, y4: "hello" }; +>x4 : number +>{ x4: 5, y4: "hello" } : { x4: number; y4: string; } +>x4 : number +>y4 : string + +var { y5 } = { x5: 5, y5: "hello" }; +>y5 : string +>{ x5: 5, y5: "hello" } : { x5: number; y5: string; } +>x5 : number +>y5 : string + +var { x6, y6 } = { x6: 5, y6: "hello" }; +>x6 : number +>y6 : string +>{ x6: 5, y6: "hello" } : { x6: number; y6: string; } +>x6 : number +>y6 : string + +var { x7: a1 } = { x7: 5, y7: "hello" }; +>x7 : unknown +>a1 : number +>{ x7: 5, y7: "hello" } : { x7: number; y7: string; } +>x7 : number +>y7 : string + +var { y8: b1 } = { x8: 5, y8: "hello" }; +>y8 : unknown +>b1 : string +>{ x8: 5, y8: "hello" } : { x8: number; y8: string; } +>x8 : number +>y8 : string + +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; +>x9 : unknown +>a2 : number +>y9 : unknown +>b2 : string +>{ x9: 5, y9: "hello" } : { x9: number; y9: string; } +>x9 : number +>y9 : string + diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js new file mode 100644 index 00000000000..509edfa6c87 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js @@ -0,0 +1,55 @@ +//// [declarationEmitDestructuringObjectLiteralPattern2.ts] + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; +} +var { a4, b4, c4 } = f15(); + +module m { + export var { a4, b4, c4 } = f15(); +} + +//// [declarationEmitDestructuringObjectLiteralPattern2.js] +var _a = { + a: 1, + b: { + a: "hello", + b: { + a: true + } + } +}, x11 = _a.a, _b = _a.b, y11 = _b.a, z11 = _b.b.a; +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { + a4: a4, + b4: b4, + c4: c4 + }; +} +var _c = f15(), a4 = _c.a4, b4 = _c.b4, c4 = _c.c4; +var m; +(function (m) { + _d = f15(), m.a4 = _d.a4, m.b4 = _d.b4, m.c4 = _d.c4; + var _d; +})(m || (m = {})); + + +//// [declarationEmitDestructuringObjectLiteralPattern2.d.ts] +declare var x11: number, y11: string, z11: boolean; +declare function f15(): { + a4: string; + b4: number; + c4: boolean; +}; +declare var a4: string, b4: number, c4: boolean; +declare module m { + var a4: string, b4: number, c4: boolean; +} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types new file mode 100644 index 00000000000..68394686e31 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts === + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; +>a : unknown +>x11 : number +>b : unknown +>a : unknown +>y11 : string +>b : unknown +>a : unknown +>z11 : boolean +>{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; } +>a : number +>b : { a: string; b: { a: boolean; }; } +>{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; } +>a : string +>b : { a: boolean; } +>{ a: true } : { a: boolean; } +>a : boolean + +function f15() { +>f15 : () => { a4: string; b4: number; c4: boolean; } + + var a4 = "hello"; +>a4 : string + + var b4 = 1; +>b4 : number + + var c4 = true; +>c4 : boolean + + return { a4, b4, c4 }; +>{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } +>a4 : string +>b4 : number +>c4 : boolean +} +var { a4, b4, c4 } = f15(); +>a4 : string +>b4 : number +>c4 : boolean +>f15() : { a4: string; b4: number; c4: boolean; } +>f15 : () => { a4: string; b4: number; c4: boolean; } + +module m { +>m : typeof m + + export var { a4, b4, c4 } = f15(); +>a4 : string +>b4 : number +>c4 : boolean +>f15() : { a4: string; b4: number; c4: boolean; } +>f15 : () => { a4: string; b4: number; c4: boolean; } +} diff --git a/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.js b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.js new file mode 100644 index 00000000000..c907add11f7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.js @@ -0,0 +1,33 @@ +//// [declarationEmitDestructuringOptionalBindingParametersInOverloads.ts] + +function foo([x, y, z] ?: [string, number, boolean]); +function foo(...rest: any[]) { +} + +function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); +function foo2(...rest: any[]) { + +} + +//// [declarationEmitDestructuringOptionalBindingParametersInOverloads.js] +function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +function foo2() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} + + +//// [declarationEmitDestructuringOptionalBindingParametersInOverloads.d.ts] +declare function foo(_0?: [string, number, boolean]): any; +declare function foo2(_0?: { + x: string; + y: number; + z: boolean; +}): any; diff --git a/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types new file mode 100644 index 00000000000..1c75466f0c3 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts === + +function foo([x, y, z] ?: [string, number, boolean]); +>foo : ([x, y, z]?: [string, number, boolean]) => any +>x : string +>y : number +>z : boolean + +function foo(...rest: any[]) { +>foo : ([x, y, z]?: [string, number, boolean]) => any +>rest : any[] +} + +function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); +>foo2 : ({ x, y, z }?: { x: string; y: number; z: boolean; }) => any +>x : string +>y : number +>z : boolean +>x : string +>y : number +>z : boolean + +function foo2(...rest: any[]) { +>foo2 : ({ x, y, z }?: { x: string; y: number; z: boolean; }) => any +>rest : any[] + +} diff --git a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.errors.txt b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.errors.txt new file mode 100644 index 00000000000..83785e86f65 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(2,17): error TS1187: A parameter property may not be a binding pattern. +tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(8,17): error TS1187: A parameter property may not be a binding pattern. +tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(14,17): error TS1187: A parameter property may not be a binding pattern. + + +==== tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts (3 errors) ==== + class C1 { + constructor(public [x, y, z]: string[]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. + } + } + + type TupleType1 =[string, number, boolean]; + class C2 { + constructor(public [x, y, z]: TupleType1) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. + } + } + + type ObjType1 = { x: number; y: string; z: boolean } + class C3 { + constructor(public { x, y, z }: ObjType1) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.js b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.js new file mode 100644 index 00000000000..cfe4acc1733 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.js @@ -0,0 +1,61 @@ +//// [declarationEmitDestructuringParameterProperties.ts] +class C1 { + constructor(public [x, y, z]: string[]) { + } +} + +type TupleType1 =[string, number, boolean]; +class C2 { + constructor(public [x, y, z]: TupleType1) { + } +} + +type ObjType1 = { x: number; y: string; z: boolean } +class C3 { + constructor(public { x, y, z }: ObjType1) { + } +} + +//// [declarationEmitDestructuringParameterProperties.js] +var C1 = (function () { + function C1(_a) { + var x = _a[0], y = _a[1], z = _a[2]; + this.[x, y, z] = [x, y, z]; + } + return C1; +})(); +var C2 = (function () { + function C2(_a) { + var x = _a[0], y = _a[1], z = _a[2]; + this.[x, y, z] = [x, y, z]; + } + return C2; +})(); +var C3 = (function () { + function C3(_a) { + var x = _a.x, y = _a.y, z = _a.z; + this.{ x, y, z } = { x, y, z }; + } + return C3; +})(); + + +//// [declarationEmitDestructuringParameterProperties.d.ts] +declare class C1 { + x: string, y: string, z: string; + constructor(_0: string[]); +} +declare type TupleType1 = [string, number, boolean]; +declare class C2 { + x: string, y: number, z: boolean; + constructor(_0: TupleType1); +} +declare type ObjType1 = { + x: number; + y: string; + z: boolean; +}; +declare class C3 { + x: number, y: string, z: boolean; + constructor(_0: ObjType1); +} diff --git a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt new file mode 100644 index 00000000000..e464b96a8bf --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts(4,20): error TS4025: Exported variable 'y' has or is using private name 'c'. + + +==== tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts (1 errors) ==== + module m { + class c { + } + export var [x, y, z] = [10, new c(), 30]; + ~ +!!! error TS4025: Exported variable 'y' has or is using private name 'c'. + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js new file mode 100644 index 00000000000..c076dca665a --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js @@ -0,0 +1,22 @@ +//// [declarationEmitDestructuringPrivacyError.ts] +module m { + class c { + } + export var [x, y, z] = [10, new c(), 30]; +} + +//// [declarationEmitDestructuringPrivacyError.js] +var m; +(function (m) { + var c = (function () { + function c() { + } + return c; + })(); + _a = [ + 10, + new c(), + 30 + ], m.x = _a[0], m.y = _a[1], m.z = _a[2]; + var _a; +})(m || (m = {})); diff --git a/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.errors.txt b/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.errors.txt new file mode 100644 index 00000000000..7b8a70ae8f1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. +tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts(3,16): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + + +==== tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts (2 errors) ==== + function foo([x,y,z]?: [string, number, boolean]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + } + function foo1( { x, y, z }?: { x: string; y: number; z: boolean }) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.js b/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.js new file mode 100644 index 00000000000..284cf107782 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringWithOptionalBindingParameters.js @@ -0,0 +1,22 @@ +//// [declarationEmitDestructuringWithOptionalBindingParameters.ts] +function foo([x,y,z]?: [string, number, boolean]) { +} +function foo1( { x, y, z }?: { x: string; y: number; z: boolean }) { +} + +//// [declarationEmitDestructuringWithOptionalBindingParameters.js] +function foo(_a) { + var x = _a[0], y = _a[1], z = _a[2]; +} +function foo1(_a) { + var x = _a.x, y = _a.y, z = _a.z; +} + + +//// [declarationEmitDestructuringWithOptionalBindingParameters.d.ts] +declare function foo(_0?: [string, number, boolean]): void; +declare function foo1(_0?: { + x: string; + y: number; + z: boolean; +}): void; diff --git a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js new file mode 100644 index 00000000000..b41ca177b05 --- /dev/null +++ b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js @@ -0,0 +1,39 @@ +//// [declarationEmitImportInExportAssignmentModule.ts] + +module m { + export module c { + export class c { + } + } + import x = c; + export var a: typeof x; +} +export = m; + +//// [declarationEmitImportInExportAssignmentModule.js] +var m; +(function (m) { + var c; + (function (_c) { + var c = (function () { + function c() { + } + return c; + })(); + _c.c = c; + })(c = m.c || (m.c = {})); + m.a; +})(m || (m = {})); +module.exports = m; + + +//// [declarationEmitImportInExportAssignmentModule.d.ts] +declare module m { + module c { + class c { + } + } + import x = c; + var a: typeof x; +} +export = m; diff --git a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.types b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.types new file mode 100644 index 00000000000..23176a0abe2 --- /dev/null +++ b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/declarationEmitImportInExportAssignmentModule.ts === + +module m { +>m : typeof m + + export module c { +>c : typeof x + + export class c { +>c : c + } + } + import x = c; +>x : typeof x +>c : typeof x + + export var a: typeof x; +>a : typeof x +>x : typeof x +} +export = m; +>m : typeof m + diff --git a/tests/baselines/reference/decrementOperatorWithEnumType.js b/tests/baselines/reference/decrementOperatorWithEnumType.js index 15247ea4225..27cb376cc05 100644 --- a/tests/baselines/reference/decrementOperatorWithEnumType.js +++ b/tests/baselines/reference/decrementOperatorWithEnumType.js @@ -22,8 +22,8 @@ var ENUM1; })(ENUM1 || (ENUM1 = {})); ; // expression -var ResultIsNumber1 = --0 /* "A" */; -var ResultIsNumber2 = 0 /* A */--; +var ResultIsNumber1 = --ENUM1["A"]; +var ResultIsNumber2 = ENUM1.A--; // miss assignment operator ---0 /* "A" */; +--ENUM1["A"]; ENUM1[A]--; diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.js b/tests/baselines/reference/deleteOperatorWithEnumType.js index b87ab8298a7..0a17b300d3d 100644 --- a/tests/baselines/reference/deleteOperatorWithEnumType.js +++ b/tests/baselines/reference/deleteOperatorWithEnumType.js @@ -39,13 +39,13 @@ var ENUM1; var ResultIsBoolean1 = delete ENUM; var ResultIsBoolean2 = delete ENUM1; // enum type expressions -var ResultIsBoolean3 = delete 0 /* "A" */; -var ResultIsBoolean4 = delete (ENUM[0] + 1 /* "B" */); +var ResultIsBoolean3 = delete ENUM1["A"]; +var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); // multiple delete operators var ResultIsBoolean5 = delete delete ENUM; -var ResultIsBoolean6 = delete delete delete (ENUM[0] + 1 /* "B" */); +var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); // miss assignment operators delete ENUM; delete ENUM1; -delete 1 /* B */; +delete ENUM1.B; delete ENUM, ENUM1; diff --git a/tests/baselines/reference/duplicateLocalVariable4.js b/tests/baselines/reference/duplicateLocalVariable4.js index d7d67f28d50..34fe30a1f1c 100644 --- a/tests/baselines/reference/duplicateLocalVariable4.js +++ b/tests/baselines/reference/duplicateLocalVariable4.js @@ -12,4 +12,4 @@ var E; E[E["a"] = 0] = "a"; })(E || (E = {})); var x = E; -var x = 0 /* a */; +var x = E.a; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt index 3a0ab0e597c..2f5ca2a387c 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt @@ -1,21 +1,21 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(2,15): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(7,19): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(13,13): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(19,15): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(2,15): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(7,19): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(13,13): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(19,15): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts (4 errors) ==== var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } var b = function () { var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } } @@ -23,7 +23,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts () => { var arg = arguments[0]; ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } } @@ -31,7 +31,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts foo(() => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. }); function bar() { diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt b/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt index f879f11799b..26f204d3ee6 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt @@ -1,21 +1,21 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(2,15): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(7,19): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(13,13): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(19,15): error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(2,15): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(7,19): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(13,13): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(19,15): error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts (4 errors) ==== var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } var b = function () { var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } } @@ -23,7 +23,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6 () => { var arg = arguments[0]; ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. } } @@ -31,7 +31,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6 foo(() => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. +!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression. }); function bar() { diff --git a/tests/baselines/reference/enumAssignability.js b/tests/baselines/reference/enumAssignability.js index 874c177c4e6..5bf639d9cf1 100644 --- a/tests/baselines/reference/enumAssignability.js +++ b/tests/baselines/reference/enumAssignability.js @@ -64,8 +64,8 @@ var F; (function (F) { F[F["B"] = 0] = "B"; })(F || (F = {})); -var e = 0 /* A */; -var f = 0 /* B */; +var e = E.A; +var f = F.B; e = f; f = e; e = 1; // ok diff --git a/tests/baselines/reference/enumAssignabilityInInheritance.js b/tests/baselines/reference/enumAssignabilityInInheritance.js index bec59a3d0de..065c561d9eb 100644 --- a/tests/baselines/reference/enumAssignabilityInInheritance.js +++ b/tests/baselines/reference/enumAssignabilityInInheritance.js @@ -115,42 +115,42 @@ var E; (function (E) { E[E["A"] = 0] = "A"; })(E || (E = {})); -var r = foo(0 /* A */); // E +var r = foo(E.A); // E var r2 = foo(1); // number var r3 = foo(null); // any -var r4 = foo2(0 /* A */); -var r4 = foo3(0 /* A */); -var r4 = foo4(0 /* A */); -var r4 = foo5(0 /* A */); -var r4 = foo6(0 /* A */); -var r4 = foo7(0 /* A */); -var r4 = foo8(0 /* A */); +var r4 = foo2(E.A); +var r4 = foo3(E.A); +var r4 = foo4(E.A); +var r4 = foo5(E.A); +var r4 = foo6(E.A); +var r4 = foo7(E.A); +var r4 = foo8(E.A); var A = (function () { function A() { } return A; })(); -var r4 = foo9(0 /* A */); +var r4 = foo9(E.A); var A2 = (function () { function A2() { } return A2; })(); -var r4 = foo10(0 /* A */); -var r4 = foo11(0 /* A */); -var r4 = foo12(0 /* A */); +var r4 = foo10(E.A); +var r4 = foo11(E.A); +var r4 = foo12(E.A); var E2; (function (E2) { E2[E2["A"] = 0] = "A"; })(E2 || (E2 = {})); -var r4 = foo13(0 /* A */); +var r4 = foo13(E.A); function f() { } var f; (function (f) { f.bar = 1; })(f || (f = {})); -var r4 = foo14(0 /* A */); +var r4 = foo14(E.A); var CC = (function () { function CC() { } @@ -160,6 +160,6 @@ var CC; (function (CC) { CC.bar = 1; })(CC || (CC = {})); -var r4 = foo15(0 /* A */); -var r4 = foo16(0 /* A */); -var r4 = foo16(0 /* A */); +var r4 = foo15(E.A); +var r4 = foo16(E.A); +var r4 = foo16(E.A); diff --git a/tests/baselines/reference/enumAssignmentCompat.js b/tests/baselines/reference/enumAssignmentCompat.js index 24f65bc96a9..f56b1f300ed 100644 --- a/tests/baselines/reference/enumAssignmentCompat.js +++ b/tests/baselines/reference/enumAssignmentCompat.js @@ -57,15 +57,15 @@ var W; var x = W; var y = W; var z = W; // error -var a = 0 /* a */; -var b = 0 /* a */; // error -var c = 0 /* a */; +var a = W.a; +var b = W.a; // error +var c = W.a; var d = 3; // error var e = 4; -var f = 0 /* a */; // error +var f = W.a; // error var g = 5; // error var h = 3; -var i = 0 /* a */; -i = 0 /* a */; +var i = W.a; +i = W.a; W.D; var p; diff --git a/tests/baselines/reference/enumAssignmentCompat2.js b/tests/baselines/reference/enumAssignmentCompat2.js index 7ded9416c11..1fb7eb65e36 100644 --- a/tests/baselines/reference/enumAssignmentCompat2.js +++ b/tests/baselines/reference/enumAssignmentCompat2.js @@ -56,15 +56,15 @@ var W; var x = W; var y = W; var z = W; // error -var a = 0 /* a */; -var b = 0 /* a */; // error -var c = 0 /* a */; +var a = W.a; +var b = W.a; // error +var c = W.a; var d = 3; // error var e = 4; -var f = 0 /* a */; // error +var f = W.a; // error var g = 5; // error var h = 3; -var i = 0 /* a */; -i = 0 /* a */; +var i = W.a; +i = W.a; W.D; var p; diff --git a/tests/baselines/reference/enumBasics.js b/tests/baselines/reference/enumBasics.js index 6f1a039ca6e..f6548f99b95 100644 --- a/tests/baselines/reference/enumBasics.js +++ b/tests/baselines/reference/enumBasics.js @@ -89,13 +89,13 @@ var E1; E1[E1["C"] = 2] = "C"; })(E1 || (E1 = {})); // Enum type is a subtype of Number -var x = 0 /* A */; +var x = E1.A; // Enum object type is anonymous with properties of the enum type and numeric indexer var e = E1; var e; var e; // Reverse mapping of enum returns string name of property -var s = E1[0 /* A */]; +var s = E1[e.A]; var s; // Enum with only constant members var E2; @@ -108,7 +108,7 @@ var E2; var E3; (function (E3) { E3[E3["X"] = 'foo'.length] = "X"; - E3[E3["Y"] = 4 + 3] = "Y"; + E3[E3["Y"] = 7] = "Y"; E3[E3["Z"] = +'foo'] = "Z"; })(E3 || (E3 = {})); // Enum with constant members followed by computed members @@ -145,7 +145,7 @@ var E8; var E9; (function (E9) { E9[E9["A"] = 0] = "A"; - E9[E9["B"] = E9.A] = "B"; + E9[E9["B"] = 0] = "B"; })(E9 || (E9 = {})); // (refer to .js to validate) // Enum constant members are propagated @@ -159,12 +159,12 @@ var doNotPropagate = [ ]; // Enum computed members are not propagated var doPropagate = [ - 0 /* A */, + E9.A, E9.B, - 0 /* B */, - 1 /* C */, - 0 /* A */, - 0 /* A */, - 3 /* B */, - 4 /* C */ + E6.B, + E6.C, + E6.A, + E5.A, + E5.B, + E5.C ]; diff --git a/tests/baselines/reference/enumBasics1.js b/tests/baselines/reference/enumBasics1.js index 13b6da353b9..e5c9c6d29d4 100644 --- a/tests/baselines/reference/enumBasics1.js +++ b/tests/baselines/reference/enumBasics1.js @@ -63,7 +63,7 @@ class C { var e = E; // shouldn't error */ -1 /* A */.A; // should error +E.A.A; // should error var E2; (function (E2) { E2[E2["A"] = 0] = "A"; diff --git a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.js b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.js index 67d9a020bb6..d463073bb81 100644 --- a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.js +++ b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.js @@ -12,4 +12,4 @@ var Position; Position[Position["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; })(Position || (Position = {})); var x = IgnoreRulesSpecific.; -var y = 0 /* IgnoreRulesSpecific */; +var y = Position.IgnoreRulesSpecific; diff --git a/tests/baselines/reference/enumErrors.errors.txt b/tests/baselines/reference/enumErrors.errors.txt index ca13ceba4ae..14cad3cb53b 100644 --- a/tests/baselines/reference/enumErrors.errors.txt +++ b/tests/baselines/reference/enumErrors.errors.txt @@ -3,15 +3,13 @@ tests/cases/conformance/enums/enumErrors.ts(3,6): error TS2431: Enum name cannot tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string' tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean' tests/cases/conformance/enums/enumErrors.ts(9,9): error TS2322: Type 'Number' is not assignable to type 'E5'. -tests/cases/conformance/enums/enumErrors.ts(20,9): error TS2322: Type 'E9' is not assignable to type 'E10'. -tests/cases/conformance/enums/enumErrors.ts(21,9): error TS2322: Type 'E9' is not assignable to type 'E10'. tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type 'string' is not assignable to type 'E11'. tests/cases/conformance/enums/enumErrors.ts(27,9): error TS2322: Type 'Date' is not assignable to type 'E11'. tests/cases/conformance/enums/enumErrors.ts(28,9): error TS2304: Cannot find name 'window'. tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is not assignable to type 'E11'. -==== tests/cases/conformance/enums/enumErrors.ts (11 errors) ==== +==== tests/cases/conformance/enums/enumErrors.ts (9 errors) ==== // Enum named with PredefinedTypes enum any { } ~~~ @@ -42,11 +40,7 @@ tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is no // Bug 707850: This should be allowed enum E10 { A = E9.A, - ~~~~ -!!! error TS2322: Type 'E9' is not assignable to type 'E10'. B = E9.B - ~~~~ -!!! error TS2322: Type 'E9' is not assignable to type 'E10'. } // Enum with computed member intializer of other types diff --git a/tests/baselines/reference/enumErrors.js b/tests/baselines/reference/enumErrors.js index 44aa2f90162..a8ecdf2470a 100644 --- a/tests/baselines/reference/enumErrors.js +++ b/tests/baselines/reference/enumErrors.js @@ -53,14 +53,14 @@ var E5; var E9; (function (E9) { E9[E9["A"] = 0] = "A"; - E9[E9["B"] = E9.A] = "B"; + E9[E9["B"] = 0] = "B"; })(E9 || (E9 = {})); //Enum with computed member intializer of different enum type // Bug 707850: This should be allowed var E10; (function (E10) { - E10[E10["A"] = 0 /* A */] = "A"; - E10[E10["B"] = E9.B] = "B"; + E10[E10["A"] = 0] = "A"; + E10[E10["B"] = 0] = "B"; })(E10 || (E10 = {})); // Enum with computed member intializer of other types var E11; diff --git a/tests/baselines/reference/enumFromExternalModule.js b/tests/baselines/reference/enumFromExternalModule.js index 8e92cbbbda7..ed2a1f3926a 100644 --- a/tests/baselines/reference/enumFromExternalModule.js +++ b/tests/baselines/reference/enumFromExternalModule.js @@ -18,4 +18,4 @@ var Mode = exports.Mode; //// [enumFromExternalModule_1.js] /// var f = require('enumFromExternalModule_0'); -var x = 0 /* Open */; +var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumIndexer.js b/tests/baselines/reference/enumIndexer.js index 77c2708dab3..9862d787d23 100644 --- a/tests/baselines/reference/enumIndexer.js +++ b/tests/baselines/reference/enumIndexer.js @@ -21,7 +21,7 @@ var _arr = [ key: 'bar' } ]; -var enumValue = 0 /* foo */; +var enumValue = MyEnumType.foo; var x = _arr.map(function (o) { return MyEnumType[o.key] === enumValue; }); // these are not same type diff --git a/tests/baselines/reference/enumMapBackIntoItself.js b/tests/baselines/reference/enumMapBackIntoItself.js index 2d177731b95..80a4b88479f 100644 --- a/tests/baselines/reference/enumMapBackIntoItself.js +++ b/tests/baselines/reference/enumMapBackIntoItself.js @@ -16,7 +16,7 @@ var TShirtSize; TShirtSize[TShirtSize["Medium"] = 1] = "Medium"; TShirtSize[TShirtSize["Large"] = 2] = "Large"; })(TShirtSize || (TShirtSize = {})); -var mySize = 2 /* Large */; +var mySize = TShirtSize.Large; var test = TShirtSize[mySize]; // specifically checking output here, bug was that test used to be undefined at runtime test + ''; diff --git a/tests/baselines/reference/enumMemberResolution.js b/tests/baselines/reference/enumMemberResolution.js index e1d79ebeb92..c021eb8d47a 100644 --- a/tests/baselines/reference/enumMemberResolution.js +++ b/tests/baselines/reference/enumMemberResolution.js @@ -14,4 +14,4 @@ var Position2; })(Position2 || (Position2 = {})); var x = IgnoreRulesSpecific.; // error var y = 1; -var z = 0 /* IgnoreRulesSpecific */; // no error +var z = Position2.IgnoreRulesSpecific; // no error diff --git a/tests/baselines/reference/enumMerging.js b/tests/baselines/reference/enumMerging.js index b76f789da1d..d8d9373d3ff 100644 --- a/tests/baselines/reference/enumMerging.js +++ b/tests/baselines/reference/enumMerging.js @@ -96,12 +96,12 @@ var M1; })(M1.EConst1 || (M1.EConst1 = {})); var EConst1 = M1.EConst1; var x = [ - 3 /* A */, - 2 /* B */, - 1 /* C */, - 7 /* D */, - 9 /* E */, - 8 /* F */ + EConst1.A, + EConst1.B, + EConst1.C, + EConst1.D, + EConst1.E, + EConst1.F ]; })(M1 || (M1 = {})); // Enum with only computed members across 2 declarations with the same root module @@ -183,6 +183,6 @@ var M6; })(A.Color || (A.Color = {})); var Color = A.Color; })(A = M6.A || (M6.A = {})); - var t = 1 /* Yellow */; - t = 0 /* Red */; + var t = A.Color.Yellow; + t = A.Color.Red; })(M6 || (M6 = {})); diff --git a/tests/baselines/reference/enumOperations.js b/tests/baselines/reference/enumOperations.js index 902079c04c0..96d9ace576c 100644 --- a/tests/baselines/reference/enumOperations.js +++ b/tests/baselines/reference/enumOperations.js @@ -21,7 +21,7 @@ var Enum; (function (Enum) { Enum[Enum["None"] = 0] = "None"; })(Enum || (Enum = {})); -var enumType = 0 /* None */; +var enumType = Enum.None; var numberType = 0; var anyType = 0; enumType ^ numberType; diff --git a/tests/baselines/reference/enumPropertyAccess.js b/tests/baselines/reference/enumPropertyAccess.js index 4c2a7df3c94..1ac82b0a3de 100644 --- a/tests/baselines/reference/enumPropertyAccess.js +++ b/tests/baselines/reference/enumPropertyAccess.js @@ -20,7 +20,7 @@ var Colors; Colors[Colors["Red"] = 0] = "Red"; Colors[Colors["Green"] = 1] = "Green"; })(Colors || (Colors = {})); -var x = 0 /* Red */; // type of 'x' should be 'Colors' +var x = Colors.Red; // type of 'x' should be 'Colors' var p = x.Green; // error x.toFixed(); // ok // Now with generics diff --git a/tests/baselines/reference/enumWithParenthesizedInitializer1.js b/tests/baselines/reference/enumWithParenthesizedInitializer1.js index 0c125b3d8b2..f81af2c4dda 100644 --- a/tests/baselines/reference/enumWithParenthesizedInitializer1.js +++ b/tests/baselines/reference/enumWithParenthesizedInitializer1.js @@ -6,5 +6,5 @@ enum E { //// [enumWithParenthesizedInitializer1.js] var E; (function (E) { - E[E["e"] = -(3)] = "e"; + E[E["e"] = -3] = "e"; })(E || (E = {})); diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js index ef9192c1c90..8d203e9fd71 100644 --- a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js +++ b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js @@ -9,6 +9,6 @@ enum E { var E; (function (E) { E[E["a"] = 0] = "a"; - E[E["b"] = E.a] = "b"; - E[E["c"] = undefined] = "c"; + E[E["b"] = 0] = "b"; + E[E["c"] = 1] = "c"; })(E || (E = {})); diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js new file mode 100644 index 00000000000..0a7ad4520c1 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js @@ -0,0 +1,22 @@ +//// [es5ExportDefaultClassDeclaration.ts] + +export default class C { + method() { } +} + + +//// [es5ExportDefaultClassDeclaration.js] +var C = (function () { + function C() { + } + C.prototype.method = function () { + }; + return C; +})(); +module.exports = C; + + +//// [es5ExportDefaultClassDeclaration.d.ts] +export default class C { + method(): void; +} diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.types b/tests/baselines/reference/es5ExportDefaultClassDeclaration.types new file mode 100644 index 00000000000..34fb87fcbb2 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/es5ExportDefaultClassDeclaration.ts === + +export default class C { +>C : C + + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js new file mode 100644 index 00000000000..3e4e4d9eed6 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -0,0 +1,22 @@ +//// [es5ExportDefaultClassDeclaration2.ts] + +export default class { + method() { } +} + + +//// [es5ExportDefaultClassDeclaration2.js] +var _default = (function () { + function _default() { + } + _default.prototype.method = function () { + }; + return _default; +})(); +module.exports = _default; + + +//// [es5ExportDefaultClassDeclaration2.d.ts] +export default class { + method(): void; +} diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.types b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.types new file mode 100644 index 00000000000..e4c7a59e0e7 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts === + +export default class { + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/es5ExportDefaultExpression.js b/tests/baselines/reference/es5ExportDefaultExpression.js new file mode 100644 index 00000000000..43f82578999 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultExpression.js @@ -0,0 +1,11 @@ +//// [es5ExportDefaultExpression.ts] + +export default (1 + 2); + + +//// [es5ExportDefaultExpression.js] +module.exports = (1 + 2); + + +//// [es5ExportDefaultExpression.d.ts] +export default : number; diff --git a/tests/baselines/reference/es5ExportDefaultExpression.types b/tests/baselines/reference/es5ExportDefaultExpression.types new file mode 100644 index 00000000000..2f4e2b57284 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultExpression.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es5ExportDefaultExpression.ts === + +export default (1 + 2); +>(1 + 2) : number +>1 + 2 : number + diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js new file mode 100644 index 00000000000..a23eb361fd4 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js @@ -0,0 +1,13 @@ +//// [es5ExportDefaultFunctionDeclaration.ts] + +export default function f() { } + + +//// [es5ExportDefaultFunctionDeclaration.js] +function f() { +} +module.exports = f; + + +//// [es5ExportDefaultFunctionDeclaration.d.ts] +export default function f(): void; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.types b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.types new file mode 100644 index 00000000000..446bd8e2a31 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts === + +export default function f() { } +>f : () => void + diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js new file mode 100644 index 00000000000..dedb36b7e64 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -0,0 +1,13 @@ +//// [es5ExportDefaultFunctionDeclaration2.ts] + +export default function () { } + + +//// [es5ExportDefaultFunctionDeclaration2.js] +function () { +} +module.exports = _default; + + +//// [es5ExportDefaultFunctionDeclaration2.d.ts] +export default function (): void; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.types b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.types new file mode 100644 index 00000000000..1b9f9d26151 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts === + +No type information for this code.export default function () { } +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt b/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt new file mode 100644 index 00000000000..7a4fdf52e88 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.errors.txt @@ -0,0 +1,11 @@ +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 new file mode 100644 index 00000000000..0c3a601308b --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.js @@ -0,0 +1,17 @@ +//// [es5ExportDefaultIdentifier.ts] + +export function f() { } + +export default f; + + +//// [es5ExportDefaultIdentifier.js] +function f() { +} +exports.f = f; +module.exports = f; + + +//// [es5ExportDefaultIdentifier.d.ts] +export declare function f(): void; +export default f; diff --git a/tests/baselines/reference/es5ExportEquals.errors.txt b/tests/baselines/reference/es5ExportEquals.errors.txt new file mode 100644 index 00000000000..89197aca632 --- /dev/null +++ b/tests/baselines/reference/es5ExportEquals.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/es5ExportEquals.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== tests/cases/compiler/es5ExportEquals.ts (1 errors) ==== + + export function f() { } + + export = 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/es5ExportEquals.js b/tests/baselines/reference/es5ExportEquals.js new file mode 100644 index 00000000000..04a34b1e23b --- /dev/null +++ b/tests/baselines/reference/es5ExportEquals.js @@ -0,0 +1,17 @@ +//// [es5ExportEquals.ts] + +export function f() { } + +export = f; + + +//// [es5ExportEquals.js] +function f() { +} +exports.f = f; +module.exports = f; + + +//// [es5ExportEquals.d.ts] +export declare function f(): void; +export = f; diff --git a/tests/baselines/reference/es5ModuleInternalNamedImports.js b/tests/baselines/reference/es5ModuleInternalNamedImports.js new file mode 100644 index 00000000000..3d9966be7dd --- /dev/null +++ b/tests/baselines/reference/es5ModuleInternalNamedImports.js @@ -0,0 +1,73 @@ +//// [es5ModuleInternalNamedImports.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; + + // 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}; +} + + +//// [es5ModuleInternalNamedImports.js] +define(["require", "exports"], function (require, exports) { + var M; + (function (M) { + // variable + M.M_V = 0; + //calss + var M_C = (function () { + function M_C() { + } + return 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; + // 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/es5ModuleInternalNamedImports.types b/tests/baselines/reference/es5ModuleInternalNamedImports.types new file mode 100644 index 00000000000..fa88ab399a3 --- /dev/null +++ b/tests/baselines/reference/es5ModuleInternalNamedImports.types @@ -0,0 +1,77 @@ +=== tests/cases/compiler/es5ModuleInternalNamedImports.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/es5ModuleWithModuleGenAmd.js b/tests/baselines/reference/es5ModuleWithModuleGenAmd.js new file mode 100644 index 00000000000..f4757b539eb --- /dev/null +++ b/tests/baselines/reference/es5ModuleWithModuleGenAmd.js @@ -0,0 +1,25 @@ +//// [es5ModuleWithModuleGenAmd.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es5ModuleWithModuleGenAmd.js] +define(["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; + })(); + exports.A = A; +}); diff --git a/tests/baselines/reference/es6-declaration-amd.types b/tests/baselines/reference/es5ModuleWithModuleGenAmd.types similarity index 55% rename from tests/baselines/reference/es6-declaration-amd.types rename to tests/baselines/reference/es5ModuleWithModuleGenAmd.types index e275fc52439..e3453587a12 100644 --- a/tests/baselines/reference/es6-declaration-amd.types +++ b/tests/baselines/reference/es5ModuleWithModuleGenAmd.types @@ -1,11 +1,9 @@ -=== tests/cases/compiler/es6-declaration-amd.ts === - -class A +=== tests/cases/compiler/es5ModuleWithModuleGenAmd.ts === +export class A >A : A { constructor () { - } public B() diff --git a/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js new file mode 100644 index 00000000000..b4ca020f566 --- /dev/null +++ b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js @@ -0,0 +1,23 @@ +//// [es5ModuleWithModuleGenCommonjs.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es5ModuleWithModuleGenCommonjs.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +exports.A = A; diff --git a/tests/baselines/reference/es6-sourcemap-amd.types b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types similarity index 53% rename from tests/baselines/reference/es6-sourcemap-amd.types rename to tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types index 661ab2e7cdd..721df9afe58 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.types +++ b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types @@ -1,11 +1,9 @@ -=== tests/cases/compiler/es6-sourcemap-amd.ts === - -class A +=== tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts === +export class A >A : A { constructor () { - } public B() diff --git a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt new file mode 100644 index 00000000000..25e64fc72d0 --- /dev/null +++ b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts(1,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided. + + +==== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts (1 errors) ==== + export class A + ~ +!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. + { + constructor () + { + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js new file mode 100644 index 00000000000..4f663875ade --- /dev/null +++ b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js @@ -0,0 +1,23 @@ +//// [es5ModuleWithoutModuleGenTarget.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es5ModuleWithoutModuleGenTarget.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +exports.A = A; diff --git a/tests/baselines/reference/es6-amd.errors.txt b/tests/baselines/reference/es6-amd.errors.txt new file mode 100644 index 00000000000..cb1ef4b1287 --- /dev/null +++ b/tests/baselines/reference/es6-amd.errors.txt @@ -0,0 +1,18 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6-amd.ts (0 errors) ==== + + class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.errors.txt b/tests/baselines/reference/es6-declaration-amd.errors.txt new file mode 100644 index 00000000000..18319504dc9 --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.errors.txt @@ -0,0 +1,18 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ==== + + class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.errors.txt b/tests/baselines/reference/es6-sourcemap-amd.errors.txt new file mode 100644 index 00000000000..24a83f8ee12 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.errors.txt @@ -0,0 +1,18 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ==== + + class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAll.js b/tests/baselines/reference/es6ExportAll.js new file mode 100644 index 00000000000..05c8a794e91 --- /dev/null +++ b/tests/baselines/reference/es6ExportAll.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/es6ExportAll.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export * from "server"; + +//// [server.js] +export class c { +} +var m; +(function (m) { + m.x = 10; +})(m || (m = {})); +export { m }; +export var x = 10; +//// [client.js] +export * from "server"; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] +export * from "server"; diff --git a/tests/baselines/reference/es6ExportAll.types b/tests/baselines/reference/es6ExportAll.types new file mode 100644 index 00000000000..99e8fde9d40 --- /dev/null +++ b/tests/baselines/reference/es6ExportAll.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export * from "server"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js new file mode 100644 index 00000000000..dd83c31b72a --- /dev/null +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/es6ExportAllInEs5.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export * from "server"; + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +exports.c = c; +var m; +(function (m) { + m.x = 10; +})(m = exports.m || (exports.m = {})); +exports.x = 10; +//// [client.js] +var _server = require("server"); +for (var _a in _server) if (!exports.hasOwnProperty(_a)) exports[_a] = _server[_a]; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] +export * from "server"; diff --git a/tests/baselines/reference/es6ExportAllInEs5.types b/tests/baselines/reference/es6ExportAllInEs5.types new file mode 100644 index 00000000000..99e8fde9d40 --- /dev/null +++ b/tests/baselines/reference/es6ExportAllInEs5.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export * from "server"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt new file mode 100644 index 00000000000..1db7d04e05e --- /dev/null +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/es6ExportAssignment.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. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment.js b/tests/baselines/reference/es6ExportAssignment.js new file mode 100644 index 00000000000..113e28108b1 --- /dev/null +++ b/tests/baselines/reference/es6ExportAssignment.js @@ -0,0 +1,8 @@ +//// [es6ExportAssignment.ts] + +var a = 10; +export = a; + +//// [es6ExportAssignment.js] +var a = 10; +export default a; diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js new file mode 100644 index 00000000000..4fba47ea7d1 --- /dev/null +++ b/tests/baselines/reference/es6ExportClause.js @@ -0,0 +1,49 @@ +//// [es6ExportClause.ts] + +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; + +//// [es6ExportClause.js] +class c { +} +var m; +(function (m) { + m.x = 10; +})(m || (m = {})); +var x = 10; +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; + + +//// [es6ExportClause.d.ts] +declare class c { +} +interface i { +} +declare module m { + var x: number; +} +declare var x: number; +declare module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; diff --git a/tests/baselines/reference/es6ExportClause.types b/tests/baselines/reference/es6ExportClause.types new file mode 100644 index 00000000000..24b9859e0e8 --- /dev/null +++ b/tests/baselines/reference/es6ExportClause.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/es6ExportClause.ts === + +class c { +>c : c +} +interface i { +>i : i +} +module m { +>m : typeof m + + export var x = 10; +>x : number +} +var x = 10; +>x : number + +module uninstantiated { +>uninstantiated : unknown +} +export { c }; +>c : typeof c + +export { c as c2 }; +>c : typeof c +>c2 : typeof c + +export { i, m as instantiatedModule }; +>i : unknown +>m : typeof m +>instantiatedModule : typeof m + +export { uninstantiated }; +>uninstantiated : unknown + +export { x }; +>x : number + diff --git a/tests/baselines/reference/es6ExportClauseInEs5.js b/tests/baselines/reference/es6ExportClauseInEs5.js new file mode 100644 index 00000000000..93c1015d207 --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -0,0 +1,57 @@ +//// [es6ExportClauseInEs5.ts] + +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; + +//// [es6ExportClauseInEs5.js] +var c = (function () { + function c() { + } + return c; +})(); +exports.c = c; +exports.c2 = c; +var m; +(function (m) { + m.x = 10; +})(m || (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] +declare class c { +} +interface i { +} +declare module m { + var x: number; +} +declare var x: number; +declare module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; diff --git a/tests/baselines/reference/es6ExportClauseInEs5.types b/tests/baselines/reference/es6ExportClauseInEs5.types new file mode 100644 index 00000000000..8caedfa5ceb --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseInEs5.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/es6ExportClauseInEs5.ts === + +class c { +>c : c +} +interface i { +>i : i +} +module m { +>m : typeof m + + export var x = 10; +>x : number +} +var x = 10; +>x : number + +module uninstantiated { +>uninstantiated : unknown +} +export { c }; +>c : typeof c + +export { c as c2 }; +>c : typeof c +>c2 : typeof c + +export { i, m as instantiatedModule }; +>i : unknown +>m : typeof m +>instantiatedModule : typeof m + +export { uninstantiated }; +>uninstantiated : unknown + +export { x }; +>x : number + diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js new file mode 100644 index 00000000000..7952bdb0bcc --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; + +//// [server.js] +export class c { +} +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 { x } from "server"; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types new file mode 100644 index 00000000000..c0087dccd94 --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export { c } from "server"; +>c : typeof c + +export { c as c2 } from "server"; +>c : typeof c +>c2 : typeof c + +export { i, m as instantiatedModule } from "server"; +>i : unknown +>m : typeof instantiatedModule +>instantiatedModule : typeof instantiatedModule + +export { uninstantiated } from "server"; +>uninstantiated : unknown + +export { x } from "server"; +>x : number + diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js new file mode 100644 index 00000000000..3e412c13a32 --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +exports.c = c; +var m; +(function (m) { + m.x = 10; +})(m = exports.m || (exports.m = {})); +exports.x = 10; +//// [client.js] +var _server = require("server"); +exports.c = _server.c; +var _server_1 = require("server"); +exports.c2 = _server_1.c; +var _server_2 = require("server"); +exports.i = _server_2.i; +exports.instantiatedModule = _server_2.m; +var _server_3 = require("server"); +exports.uninstantiated = _server_3.uninstantiated; +var _server_4 = require("server"); +exports.x = _server_4.x; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types new file mode 100644 index 00000000000..c0087dccd94 --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export { c } from "server"; +>c : typeof c + +export { c as c2 } from "server"; +>c : typeof c +>c2 : typeof c + +export { i, m as instantiatedModule } from "server"; +>i : unknown +>m : typeof instantiatedModule +>instantiatedModule : typeof instantiatedModule + +export { uninstantiated } from "server"; +>uninstantiated : unknown + +export { x } from "server"; +>x : number + diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration.js b/tests/baselines/reference/es6ExportDefaultClassDeclaration.js new file mode 100644 index 00000000000..2a25b5ac349 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration.js @@ -0,0 +1,18 @@ +//// [es6ExportDefaultClassDeclaration.ts] + +export default class C { + method() { } +} + + +//// [es6ExportDefaultClassDeclaration.js] +export default class C { + method() { + } +} + + +//// [es6ExportDefaultClassDeclaration.d.ts] +export default class C { + method(): void; +} diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration.types b/tests/baselines/reference/es6ExportDefaultClassDeclaration.types new file mode 100644 index 00000000000..59e74fc1257 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/es6ExportDefaultClassDeclaration.ts === + +export default class C { +>C : C + + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js new file mode 100644 index 00000000000..045de615c86 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js @@ -0,0 +1,18 @@ +//// [es6ExportDefaultClassDeclaration2.ts] + +export default class { + method() { } +} + + +//// [es6ExportDefaultClassDeclaration2.js] +export default class { + method() { + } +} + + +//// [es6ExportDefaultClassDeclaration2.d.ts] +export default class { + method(): void; +} diff --git a/tests/baselines/reference/es6ExportDefaultClassDeclaration2.types b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.types new file mode 100644 index 00000000000..513cacf05e4 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts === + +export default class { + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/es6ExportDefaultExpression.js b/tests/baselines/reference/es6ExportDefaultExpression.js new file mode 100644 index 00000000000..322e09bc46f --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultExpression.js @@ -0,0 +1,11 @@ +//// [es6ExportDefaultExpression.ts] + +export default (1 + 2); + + +//// [es6ExportDefaultExpression.js] +export default (1 + 2); + + +//// [es6ExportDefaultExpression.d.ts] +export default : number; diff --git a/tests/baselines/reference/es6ExportDefaultExpression.types b/tests/baselines/reference/es6ExportDefaultExpression.types new file mode 100644 index 00000000000..3b056b8d9f9 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultExpression.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es6ExportDefaultExpression.ts === + +export default (1 + 2); +>(1 + 2) : number +>1 + 2 : number + diff --git a/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.js b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.js new file mode 100644 index 00000000000..ec5789203d0 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.js @@ -0,0 +1,12 @@ +//// [es6ExportDefaultFunctionDeclaration.ts] + +export default function f() { } + + +//// [es6ExportDefaultFunctionDeclaration.js] +export default function f() { +} + + +//// [es6ExportDefaultFunctionDeclaration.d.ts] +export default function f(): void; diff --git a/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.types b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.types new file mode 100644 index 00000000000..6179bde9613 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts === + +export default function f() { } +>f : () => void + diff --git a/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.js new file mode 100644 index 00000000000..80e37f18d21 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.js @@ -0,0 +1,12 @@ +//// [es6ExportDefaultFunctionDeclaration2.ts] + +export default function () { } + + +//// [es6ExportDefaultFunctionDeclaration2.js] +export default function () { +} + + +//// [es6ExportDefaultFunctionDeclaration2.d.ts] +export default function (): void; diff --git a/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types new file mode 100644 index 00000000000..3cb2fc9b1cd --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts === + +No type information for this code.export default function () { } +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportDefaultIdentifier.js b/tests/baselines/reference/es6ExportDefaultIdentifier.js new file mode 100644 index 00000000000..5785220dfee --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultIdentifier.js @@ -0,0 +1,16 @@ +//// [es6ExportDefaultIdentifier.ts] + +export function f() { } + +export default f; + + +//// [es6ExportDefaultIdentifier.js] +export function f() { +} +export default f; + + +//// [es6ExportDefaultIdentifier.d.ts] +export declare function f(): void; +export default f; diff --git a/tests/baselines/reference/es6ExportDefaultIdentifier.types b/tests/baselines/reference/es6ExportDefaultIdentifier.types new file mode 100644 index 00000000000..81dc168efd0 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultIdentifier.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/es6ExportDefaultIdentifier.ts === + +export function f() { } +>f : () => void + +export default f; +>f : () => void + diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt new file mode 100644 index 00000000000..cc4206e2a5f --- /dev/null +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -0,0 +1,11 @@ +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 (1 errors) ==== + + export function f() { } + + export = f; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportEquals.js b/tests/baselines/reference/es6ExportEquals.js new file mode 100644 index 00000000000..d51f8740da0 --- /dev/null +++ b/tests/baselines/reference/es6ExportEquals.js @@ -0,0 +1,16 @@ +//// [es6ExportEquals.ts] + +export function f() { } + +export = f; + + +//// [es6ExportEquals.js] +export function f() { +} +export default f; + + +//// [es6ExportEquals.d.ts] +export declare function f(): void; +export = f; diff --git a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt index 85390ecce4b..9ff3c1b3f04 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt @@ -1,11 +1,15 @@ -tests/cases/compiler/es6ImportDefaultBinding_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment. +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 (0 errors) ==== +==== tests/cases/compiler/es6ImportDefaultBinding_0.ts (1 errors) ==== - export var a = 10; + 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 (1 errors) ==== +==== tests/cases/compiler/es6ImportDefaultBinding_1.ts (0 errors) ==== import defaultBinding from "es6ImportDefaultBinding_0"; - ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment. \ No newline at end of file + 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 d8d1fa8111d..b169f9e80e4 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBinding.js @@ -2,11 +2,24 @@ //// [es6ImportDefaultBinding_0.ts] -export var a = 10; +var a = 10; +export = a; //// [es6ImportDefaultBinding_1.ts] -import defaultBinding from "es6ImportDefaultBinding_0"; +import defaultBinding from "es6ImportDefaultBinding_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used + //// [es6ImportDefaultBinding_0.js] -exports.a = 10; +var a = 10; +export default a; //// [es6ImportDefaultBinding_1.js] +import defaultBinding from "es6ImportDefaultBinding_0"; +var x = defaultBinding; + + +//// [es6ImportDefaultBinding_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js new file mode 100644 index 00000000000..34b39cda4b7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingAmd.ts] //// + +//// [es6ImportDefaultBindingAmd_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingAmd_1.ts] +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used + + +//// [es6ImportDefaultBindingAmd_0.js] +define(["require", "exports"], function (require, exports) { + var a = 10; + return a; +}); +//// [es6ImportDefaultBindingAmd_1.js] +define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, defaultBinding) { + var x = defaultBinding; +}); + + +//// [es6ImportDefaultBindingAmd_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingAmd_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.types b/tests/baselines/reference/es6ImportDefaultBindingAmd.types new file mode 100644 index 00000000000..9b067ef27a4 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es6ImportDefaultBindingAmd_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBindingAmd_1.ts === +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +>defaultBinding : number + +var x = defaultBinding; +>x : number +>defaultBinding : number + +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used +>defaultBinding2 : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js new file mode 100644 index 00000000000..4e9719892db --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingDts.ts] //// + +//// [server.ts] + +class c { } +export = c; + +//// [client.ts] +import defaultBinding from "server"; +export var x = new defaultBinding(); +import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used + + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +module.exports = c; +//// [client.js] +var defaultBinding = require("server"); +exports.x = new defaultBinding(); + + +//// [server.d.ts] +declare class c { +} +export = 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 new file mode 100644 index 00000000000..62f54168c36 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/server.ts === + +class c { } +>c : c + +export = c; +>c : c + +=== tests/cases/compiler/client.ts === +import defaultBinding from "server"; +>defaultBinding : typeof defaultBinding + +export var x = new defaultBinding(); +>x : defaultBinding +>new defaultBinding() : defaultBinding +>defaultBinding : typeof defaultBinding + +import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +>defaultBinding2 : typeof defaultBinding + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index bd8714cb86f..5e71478e5a1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -1,51 +1,42 @@ +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(1,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(2,8): error TS2300: Duplicate identifier 'defaultBinding'. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(3,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(3,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(4,8): error TS2300: Duplicate identifier 'defaultBinding'. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(5,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(5,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(6,8): error TS2300: Duplicate identifier 'defaultBinding'. +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. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ==== export var a = 10; export var x = a; export var m = a; -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (12 errors) ==== - import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (6 errors) ==== + import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + ~~~~~~~~~~~~~~~ !!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ + import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + ~~~~~~~~~~~~~~~ !!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ + 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. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ + 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. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ + 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. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - ~~~~~~~~~~~~~~ + 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. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. \ No newline at end of file + 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 a7402bfeb6a..7d0d4b2582d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -7,15 +7,40 @@ export var x = a; export var m = a; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.ts] -import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = a; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = b; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = x; +var x1: number = y; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = z; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = m; + //// [es6ImportDefaultBindingFollowedWithNamedImport_0.js] -exports.a = 10; -exports.x = exports.a; -exports.m = exports.a; +export var a = 10; +export var x = a; +export var m = a; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] +import { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1 = a; +import { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1 = b; +import { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1 = x; +var x1 = y; +import { x as z } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1 = z; +import { m } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1 = m; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +//// [es6ImportDefaultBindingFollowedWithNamedImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt new file mode 100644 index 00000000000..a780f7cec30 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt @@ -0,0 +1,42 @@ +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'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,30): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. +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) ==== + + 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/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts (6 errors) ==== + import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + var x1: number = defaultBinding1; + import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding2; + import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding3; + import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding4; + import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. + var x1: number = defaultBinding5; + import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. + var x1: number = defaultBinding6; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js new file mode 100644 index 00000000000..3c8a4080ba7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.ts] +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding6; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.js] +var a = 10; +export default a; +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.js] +import defaultBinding1 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding1; +import defaultBinding2 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding2; +import defaultBinding3 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding3; +import defaultBinding4 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding4; +import defaultBinding5 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding5; +import defaultBinding6 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding6; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt new file mode 100644 index 00000000000..9783ad4921e --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt @@ -0,0 +1,39 @@ +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(3,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(5,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(7,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(7,30): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(9,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(11,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'm'. + + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts (6 errors) ==== + import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + var x: number = defaultBinding1; + import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. + var x: number = defaultBinding2; + import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. + var x: number = defaultBinding3; + import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. + var x: number = defaultBinding4; + import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. + var x: number = defaultBinding5; + import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'm'. + var x: number = defaultBinding6; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js new file mode 100644 index 00000000000..2690e7a7f51 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts] +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding6; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.js] +var a = 10; +module.exports = 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; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt new file mode 100644 index 00000000000..9b246f803a0 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt @@ -0,0 +1,57 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(5,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(5,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(7,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(7,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. +tests/cases/compiler/client.ts(7,37): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(9,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. +tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/client.ts (12 errors) ==== + export import defaultBinding1, { } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = defaultBinding1; + export import defaultBinding2, { a } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x1: number = defaultBinding2; + export import defaultBinding3, { a as b } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x1: number = defaultBinding3; + export import defaultBinding4, { x, a as y } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x1: number = defaultBinding4; + export import defaultBinding5, { x as z, } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. + export var x1: number = defaultBinding5; + export import defaultBinding6, { m, } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. + export var x1: number = defaultBinding6; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js new file mode 100644 index 00000000000..0239b68194f --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts] //// + +//// [server.ts] + +var a = 10; +export = a; + +//// [client.ts] +export import defaultBinding1, { } from "server"; +export var x1: number = defaultBinding1; +export import defaultBinding2, { a } from "server"; +export var x1: number = defaultBinding2; +export import defaultBinding3, { a as b } from "server"; +export var x1: number = defaultBinding3; +export import defaultBinding4, { x, a as y } from "server"; +export var x1: number = defaultBinding4; +export import defaultBinding5, { x as z, } from "server"; +export var x1: number = defaultBinding5; +export import defaultBinding6, { m, } from "server"; +export var x1: number = defaultBinding6; + + +//// [server.js] +var a = 10; +module.exports = 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; + + +//// [server.d.ts] +declare var a: number; +export = a; +//// [client.d.ts] +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +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 new file mode 100644 index 00000000000..bff47ba36ef --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -0,0 +1,43 @@ +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/server.ts (0 errors) ==== + + export class a { } + export class x { } + export class m { } + export class a11 { } + export class a12 { } + export class x11 { } + +==== 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. + import defaultBinding2, { a } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + 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. + 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. + 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. + 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. + export var x6 = new m(); + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js new file mode 100644 index 00000000000..6c85e281150 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts] //// + +//// [server.ts] + +export class a { } +export class x { } +export class m { } +export class a11 { } +export class a12 { } +export class x11 { } + +//// [client.ts] +import defaultBinding1, { } from "server"; +import defaultBinding2, { a } from "server"; +export var x1 = new a(); +import defaultBinding3, { a11 as b } from "server"; +export var x2 = new b(); +import defaultBinding4, { x, a12 as y } from "server"; +export var x4 = new x(); +export var x5 = new y(); +import defaultBinding5, { x11 as z, } from "server"; +export var x3 = new z(); +import defaultBinding6, { m, } from "server"; +export var x6 = new m(); + + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +exports.a = a; +var x = (function () { + function x() { + } + return x; +})(); +exports.x = x; +var m = (function () { + function m() { + } + return m; +})(); +exports.m = m; +var a11 = (function () { + function a11() { + } + return a11; +})(); +exports.a11 = a11; +var a12 = (function () { + function a12() { + } + return a12; +})(); +exports.a12 = a12; +var x11 = (function () { + function x11() { + } + return x11; +})(); +exports.x11 = x11; +//// [client.js] +var _server_1 = require("server"); +exports.x1 = new _server_1.a(); +var _server_2 = require("server"); +exports.x2 = new _server_2.a11(); +var _server_3 = require("server"); +exports.x4 = new _server_3.x(); +exports.x5 = new _server_3.a12(); +var _server_4 = require("server"); +exports.x3 = new _server_4.x11(); +var _server_5 = require("server"); +exports.x6 = new _server_5.m(); + + +//// [server.d.ts] +export declare class a { +} +export declare class x { +} +export declare class m { +} +export declare class a11 { +} +export declare class a12 { +} +export declare class x11 { +} +//// [client.d.ts] +import { a } from "server"; +export declare var x1: a; +import { a11 as b } from "server"; +export declare var x2: b; +import { x, a12 as y } from "server"; +export declare var x4: x; +export declare var x5: y; +import { x11 as z } from "server"; +export declare var x3: z; +import { m } from "server"; +export declare var x6: m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt new file mode 100644 index 00000000000..405fab0de50 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt @@ -0,0 +1,38 @@ +tests/cases/compiler/client.ts(3,27): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(5,27): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(7,27): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. +tests/cases/compiler/client.ts(7,30): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(9,27): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. +tests/cases/compiler/client.ts(11,27): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + class a { } + export = a; + +==== tests/cases/compiler/client.ts (6 errors) ==== + import defaultBinding1, { } from "server"; + export var x1 = new defaultBinding1(); + import defaultBinding2, { a } from "server"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x2 = new defaultBinding2(); + import defaultBinding3, { a as b } from "server"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x3 = new defaultBinding3(); + import defaultBinding4, { x, a as y } from "server"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. + export var x4 = new defaultBinding4(); + import defaultBinding5, { x as z, } from "server"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. + export var x5 = new defaultBinding5(); + import defaultBinding6, { m, } from "server"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. + export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js new file mode 100644 index 00000000000..21ddcbc71d6 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts] //// + +//// [server.ts] + +class a { } +export = a; + +//// [client.ts] +import defaultBinding1, { } from "server"; +export var x1 = new defaultBinding1(); +import defaultBinding2, { a } from "server"; +export var x2 = new defaultBinding2(); +import defaultBinding3, { a as b } from "server"; +export var x3 = new defaultBinding3(); +import defaultBinding4, { x, a as y } from "server"; +export var x4 = new defaultBinding4(); +import defaultBinding5, { x as z, } from "server"; +export var x5 = new defaultBinding5(); +import defaultBinding6, { m, } from "server"; +export var x6 = new defaultBinding6(); + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +module.exports = 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(); + + +//// [server.d.ts] +declare class a { +} +export = a; +//// [client.d.ts] +import defaultBinding1 from "server"; +export declare var x1: defaultBinding1; +export declare var x2: defaultBinding1; +export declare var x3: defaultBinding1; +export declare var x4: defaultBinding1; +export declare var x5: defaultBinding1; +export declare var x6: defaultBinding1; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt index 157360f5238..0377e543973 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt @@ -1,15 +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(1,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(2,8): error TS2300: Duplicate identifier 'defaultBinding'. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(3,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(3,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(4,8): error TS2300: Duplicate identifier 'defaultBinding'. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(5,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. -tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(5,8): error TS2300: Duplicate identifier 'defaultBinding'. 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(6,8): error TS2300: Duplicate identifier 'defaultBinding'. +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_0.ts (0 errors) ==== @@ -18,34 +12,29 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(6, export var x = a; export var m = a; -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (12 errors) ==== - import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ +==== 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 TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ + import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ !!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export or export assignment. - ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ + 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 TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ + 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 TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ + 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 TS2300: Duplicate identifier 'defaultBinding'. - import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; - ~~~~~~~~~~~~~~ + 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 TS2300: Duplicate identifier 'defaultBinding'. \ No newline at end of file + var x1: number = m; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index 4cf3046532a..1c63005bb06 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -7,15 +7,40 @@ export var x = a; export var m = a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts] -import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = a; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = b; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = x; +var x1: number = y; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = z; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = m; + //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.js] exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; + + +//// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +//// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt new file mode 100644 index 00000000000..a9a2ed4974d --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt @@ -0,0 +1,58 @@ +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) ==== + + export var a = 10; + export var x = a; + export var m = a; + +==== tests/cases/compiler/client.ts (12 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 new file mode 100644 index 00000000000..5497a82b041 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts] //// + +//// [server.ts] + +export var a = 10; +export var x = a; +export var m = a; + +//// [client.ts] +export import defaultBinding1, { } from "server"; +export import defaultBinding2, { a } from "server"; +export var x1: number = a; +export import defaultBinding3, { a as b } from "server"; +export var x1: number = b; +export import defaultBinding4, { x, a as y } from "server"; +export var x1: number = x; +export var x1: number = y; +export import defaultBinding5, { x as z, } from "server"; +export var x1: number = z; +export import defaultBinding6, { m, } from "server"; +export var x1: number = m; + + +//// [server.js] +define(["require", "exports"], function (require, exports) { + exports.a = 10; + exports.x = exports.a; + exports.m = exports.a; +}); +//// [client.js] +define(["require", "exports", "server", "server", "server", "server", "server"], function (require, exports, _server_1, _server_2, _server_3, _server_4, _server_5) { + exports.x1 = _server_1.a; + exports.x1 = _server_2.a; + exports.x1 = _server_3.x; + exports.x1 = _server_3.a; + exports.x1 = _server_4.x; + exports.x1 = _server_5.m; +}); + + +//// [server.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +//// [client.d.ts] +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +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 98371eb9198..851a5189a54 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt @@ -8,4 +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. \ No newline at end of file +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment. + var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js index 5ec91279306..2b24fda0755 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js @@ -5,8 +5,16 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] +import * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x = nameSpaceBinding.a; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts] +export declare var a: number; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt new file mode 100644 index 00000000000..2a0f3ad5485 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt @@ -0,0 +1,13 @@ +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 new file mode 100644 index 00000000000..927ed3243e7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = defaultBinding; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] +var a = 10; +export default a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] +import defaultBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x = defaultBinding; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js new file mode 100644 index 00000000000..00166b1bc41 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = defaultBinding; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] +var a = 10; +module.exports = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] +var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var x = defaultBinding; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types new file mode 100644 index 00000000000..dfbc8c0be07 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +>defaultBinding : number +>nameSpaceBinding : typeof nameSpaceBinding + +var x: number = defaultBinding; +>x : number +>defaultBinding : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt new file mode 100644 index 00000000000..5df6817e897 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/client.ts (1 errors) ==== + export import defaultBinding, * as nameSpaceBinding from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js new file mode 100644 index 00000000000..d1dd565c81b --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts] //// + +//// [server.ts] + +var a = 10; +export = a; + +//// [client.ts] +export import defaultBinding, * as nameSpaceBinding from "server"; +export var x: number = defaultBinding; + +//// [server.js] +define(["require", "exports"], function (require, exports) { + var a = 10; + return a; +}); +//// [client.js] +define(["require", "exports", "server"], function (require, exports, defaultBinding) { + exports.x = defaultBinding; +}); + + +//// [server.d.ts] +declare var a: number; +export = 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 new file mode 100644 index 00000000000..f8dd391fe0e --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -0,0 +1,12 @@ +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/server.ts (0 errors) ==== + + export class a { } + +==== 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. + 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 new file mode 100644 index 00000000000..4bde6e25b10 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts] //// + +//// [server.ts] + +export class a { } + +//// [client.ts] +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.a(); + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +exports.a = a; +//// [client.js] +var nameSpaceBinding = require("server"); +exports.x = new nameSpaceBinding.a(); + + +//// [server.d.ts] +export declare class a { +} +//// [client.d.ts] +import * as nameSpaceBinding from "server"; +export declare var x: nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js new file mode 100644 index 00000000000..69b76d79fbb --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts] //// + +//// [server.ts] + +class a { } +export = a; + +//// [client.ts] +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new defaultBinding(); + +//// [server.js] +define(["require", "exports"], function (require, exports) { + var a = (function () { + function a() { + } + return a; + })(); + return a; +}); +//// [client.js] +define(["require", "exports", "server"], function (require, exports, defaultBinding) { + exports.x = new defaultBinding(); +}); + + +//// [server.d.ts] +declare class a { +} +export = 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 new file mode 100644 index 00000000000..e40d3893ee2 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/server.ts === + +class a { } +>a : a + +export = a; +>a : a + +=== tests/cases/compiler/client.ts === +import defaultBinding, * as nameSpaceBinding from "server"; +>defaultBinding : typeof defaultBinding +>nameSpaceBinding : typeof nameSpaceBinding + +export var x = new defaultBinding(); +>x : defaultBinding +>new defaultBinding() : defaultBinding +>defaultBinding : typeof defaultBinding + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt index f1d20dccc59..d4d51e4d5ab 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt @@ -8,4 +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. \ No newline at end of file +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export or export assignment. + 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 abd4736fca7..9131fcc75db 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -5,8 +5,16 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] +var nameSpaceBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var x = nameSpaceBinding.a; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.d.ts] +export declare var a: number; +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt new file mode 100644 index 00000000000..3e06e7acae8 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt @@ -0,0 +1,15 @@ +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/server.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/client.ts (2 errors) ==== + export import defaultBinding, * as nameSpaceBinding 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 x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js new file mode 100644 index 00000000000..b219b5e7876 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts] //// + +//// [server.ts] + +export var a = 10; + +//// [client.ts] +export import defaultBinding, * as nameSpaceBinding from "server"; +export var x: number = nameSpaceBinding.a; + +//// [server.js] +exports.a = 10; +//// [client.js] +var nameSpaceBinding = require("server"); +exports.x = nameSpaceBinding.a; + + +//// [server.d.ts] +export declare var a: number; +//// [client.d.ts] +export declare var x: number; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt deleted file mode 100644 index 5d656094a8c..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export or export assignment. - - -==== tests/cases/compiler/es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== - - export var a = 10; - -==== 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 or export assignment. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js index b6d293225fd..0b703f829ca 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js @@ -2,11 +2,19 @@ //// [es6ImportDefaultBindingInEs5_0.ts] -export var a = 10; +var a = 10; +export = a; //// [es6ImportDefaultBindingInEs5_1.ts] import defaultBinding from "es6ImportDefaultBindingInEs5_0"; //// [es6ImportDefaultBindingInEs5_0.js] -exports.a = 10; +var a = 10; +module.exports = a; //// [es6ImportDefaultBindingInEs5_1.js] + + +//// [es6ImportDefaultBindingInEs5_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types new file mode 100644 index 00000000000..03243fc014d --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types @@ -0,0 +1,12 @@ +=== 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 new file mode 100644 index 00000000000..d6aacf0ba40 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(5,8): error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(7,8): error TS2300: Duplicate identifier 'defaultBinding3'. +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(8,8): error TS2300: Duplicate identifier 'defaultBinding3'. + + +==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts (3 errors) ==== + import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; + interface defaultBinding { // This is ok + } + var x = defaultBinding; + import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + ~~~~~~~~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' + var defaultBinding2 = "hello world"; + import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + ~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'defaultBinding3'. + import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + ~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'defaultBinding3'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js new file mode 100644 index 00000000000..628faec6c27 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts] //// + +//// [es6ImportDefaultBindingMergeErrors_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingMergeErrors_1.ts] +import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +interface defaultBinding { // This is ok +} +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +var defaultBinding2 = "hello world"; +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + + +//// [es6ImportDefaultBindingMergeErrors_0.js] +var a = 10; +module.exports = a; +//// [es6ImportDefaultBindingMergeErrors_1.js] +var defaultBinding = require("es6ImportDefaultBindingMergeErrors_0"); +var x = defaultBinding; +var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt new file mode 100644 index 00000000000..a6aaf9f5508 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -0,0 +1,12 @@ +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_0.ts (0 errors) ==== + + export var a = 10; + +==== 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. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js new file mode 100644 index 00000000000..f824dbf71d5 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts] //// + +//// [es6ImportDefaultBindingNoDefaultProperty_0.ts] + +export var a = 10; + +//// [es6ImportDefaultBindingNoDefaultProperty_1.ts] +import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; + + +//// [es6ImportDefaultBindingNoDefaultProperty_0.js] +exports.a = 10; +//// [es6ImportDefaultBindingNoDefaultProperty_1.js] diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt new file mode 100644 index 00000000000..e0dfdc00e07 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot have modifiers. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/client.ts (2 errors) ==== + export import defaultBinding from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x = defaultBinding; + export import defaultBinding2 from "server"; // non referenced + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js new file mode 100644 index 00000000000..a3f8dd11c6c --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingWithExport.ts] //// + +//// [server.ts] + +var a = 10; +export = a; + +//// [client.ts] +export import defaultBinding from "server"; +export var x = defaultBinding; +export import defaultBinding2 from "server"; // non referenced + +//// [server.js] +define(["require", "exports"], function (require, exports) { + var a = 10; + return a; +}); +//// [client.js] +define(["require", "exports", "server"], function (require, exports, defaultBinding) { + exports.x = defaultBinding; +}); + + +//// [server.d.ts] +declare var a: number; +export = a; +//// [client.d.ts] +export declare var x: number; diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt new file mode 100644 index 00000000000..d3351ee97b2 --- /dev/null +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. +tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/client.ts (1 errors) ==== + import a = require("server"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. +==== tests/cases/compiler/server.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. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.js b/tests/baselines/reference/es6ImportEqualsDeclaration.js new file mode 100644 index 00000000000..b8e9777a894 --- /dev/null +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/es6ImportEqualsDeclaration.ts] //// + +//// [server.ts] + +var a = 10; +export = a; + +//// [client.ts] +import a = require("server"); + +//// [server.js] +var a = 10; +export default a; +//// [client.js] diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt new file mode 100644 index 00000000000..635bb955c00 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt @@ -0,0 +1,13 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/es6ImportNameSpaceImport_1.ts (0 errors) ==== + import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; + var x = nameSpaceBinding.a; + import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index c6daa3b1222..653feeb22b7 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -5,8 +5,18 @@ export var a = 10; //// [es6ImportNameSpaceImport_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this + //// [es6ImportNameSpaceImport_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportNameSpaceImport_1.js] +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +var x = nameSpaceBinding.a; + + +//// [es6ImportNameSpaceImport_0.d.ts] +export declare var a: number; +//// [es6ImportNameSpaceImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.types b/tests/baselines/reference/es6ImportNameSpaceImport.types deleted file mode 100644 index 1e09de42ec6..00000000000 --- a/tests/baselines/reference/es6ImportNameSpaceImport.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts === - -export var a = 10; ->a : number - -=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; ->nameSpaceBinding : typeof nameSpaceBinding - diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js new file mode 100644 index 00000000000..e7d0eae9ca9 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportAmd.ts] //// + +//// [es6ImportNameSpaceImportAmd_0.ts] + +export var a = 10; + +//// [es6ImportNameSpaceImportAmd_1.ts] +import * as nameSpaceBinding from "es6ImportNameSpaceImportAmd_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportAmd_0"; // elide this + + +//// [es6ImportNameSpaceImportAmd_0.js] +define(["require", "exports"], function (require, exports) { + exports.a = 10; +}); +//// [es6ImportNameSpaceImportAmd_1.js] +define(["require", "exports", "es6ImportNameSpaceImportAmd_0"], function (require, exports, nameSpaceBinding) { + var x = nameSpaceBinding.a; +}); + + +//// [es6ImportNameSpaceImportAmd_0.d.ts] +export declare var a: number; +//// [es6ImportNameSpaceImportAmd_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.types b/tests/baselines/reference/es6ImportNameSpaceImportAmd.types new file mode 100644 index 00000000000..623a7e8e160 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es6ImportNameSpaceImportAmd_0.ts === + +export var a = 10; +>a : number + +=== tests/cases/compiler/es6ImportNameSpaceImportAmd_1.ts === +import * as nameSpaceBinding from "es6ImportNameSpaceImportAmd_0"; +>nameSpaceBinding : typeof nameSpaceBinding + +var x = nameSpaceBinding.a; +>x : number +>nameSpaceBinding.a : number +>nameSpaceBinding : typeof nameSpaceBinding +>a : number + +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportAmd_0"; // elide this +>nameSpaceBinding2 : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js new file mode 100644 index 00000000000..91e927428a1 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportDts.ts] //// + +//// [server.ts] + +export class c { }; + +//// [client.ts] +import * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.c(); +import * as nameSpaceBinding2 from "server"; // unreferenced + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +exports.c = c; +; +//// [client.js] +var nameSpaceBinding = require("server"); +exports.x = new nameSpaceBinding.c(); + + +//// [server.d.ts] +export declare class c { +} +//// [client.d.ts] +import * as nameSpaceBinding from "server"; +export declare var x: nameSpaceBinding.c; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.types b/tests/baselines/reference/es6ImportNameSpaceImportDts.types new file mode 100644 index 00000000000..345d593b143 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/server.ts === + +export class c { }; +>c : c + +=== tests/cases/compiler/client.ts === +import * as nameSpaceBinding from "server"; +>nameSpaceBinding : typeof nameSpaceBinding + +export var x = new nameSpaceBinding.c(); +>x : nameSpaceBinding.c +>new nameSpaceBinding.c() : nameSpaceBinding.c +>nameSpaceBinding.c : typeof nameSpaceBinding.c +>nameSpaceBinding : typeof nameSpaceBinding +>c : typeof nameSpaceBinding.c + +import * as nameSpaceBinding2 from "server"; // unreferenced +>nameSpaceBinding2 : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 2c7785dec6e..50a03972cc2 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -5,8 +5,18 @@ export var a = 10; //// [es6ImportNameSpaceImportInEs5_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this + //// [es6ImportNameSpaceImportInEs5_0.js] exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] +var nameSpaceBinding = require("es6ImportNameSpaceImportInEs5_0"); +var x = nameSpaceBinding.a; + + +//// [es6ImportNameSpaceImportInEs5_0.d.ts] +export declare var a: number; +//// [es6ImportNameSpaceImportInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types index cb7b669eea1..6ba725f2494 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types @@ -7,3 +7,12 @@ export var a = 10; import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; >nameSpaceBinding : typeof nameSpaceBinding +var x = nameSpaceBinding.a; +>x : number +>nameSpaceBinding.a : number +>nameSpaceBinding : typeof nameSpaceBinding +>a : number + +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +>nameSpaceBinding2 : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt new file mode 100644 index 00000000000..98a68870833 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(4,13): error TS2300: Duplicate identifier 'nameSpaceBinding1'. +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(5,13): error TS2300: Duplicate identifier 'nameSpaceBinding1'. +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(7,8): error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' + + +==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_0.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts (3 errors) ==== + import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; + interface nameSpaceBinding { } // this should be ok + + import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. + import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. + + import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' + var nameSpaceBinding3 = 10; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js new file mode 100644 index 00000000000..3c8461fba2b --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts] //// + +//// [es6ImportNameSpaceImportMergeErrors_0.ts] + +export var a = 10; + +//// [es6ImportNameSpaceImportMergeErrors_1.ts] +import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +interface nameSpaceBinding { } // this should be ok + +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + +import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +var nameSpaceBinding3 = 10; + + +//// [es6ImportNameSpaceImportMergeErrors_0.js] +exports.a = 10; +//// [es6ImportNameSpaceImportMergeErrors_1.js] +var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js new file mode 100644 index 00000000000..3d6dab17785 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts] //// + +//// [es6ImportNameSpaceImportNoNamedExports_0.ts] + +var a = 10; +export = a; + +//// [es6ImportNameSpaceImportNoNamedExports_1.ts] +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error + +//// [es6ImportNameSpaceImportNoNamedExports_0.js] +var a = 10; +module.exports = a; +//// [es6ImportNameSpaceImportNoNamedExports_1.js] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types new file mode 100644 index 00000000000..3ba19cef9b4 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +>nameSpaceBinding : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.errors.txt new file mode 100644 index 00000000000..901556e73bd --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot have modifiers. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/client.ts (2 errors) ==== + export import * as nameSpaceBinding from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x = nameSpaceBinding.a; + export import * as nameSpaceBinding2 from "server"; // Not referenced imports + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js new file mode 100644 index 00000000000..84f6936d4b0 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportWithExport.ts] //// + +//// [server.ts] + +export var a = 10; + +//// [client.ts] +export import * as nameSpaceBinding from "server"; +export var x = nameSpaceBinding.a; +export import * as nameSpaceBinding2 from "server"; // Not referenced imports + + +//// [server.js] +define(["require", "exports"], function (require, exports) { + exports.a = 10; +}); +//// [client.js] +define(["require", "exports", "server"], function (require, exports, nameSpaceBinding) { + exports.x = nameSpaceBinding.a; +}); + + +//// [server.d.ts] +export declare var a: number; +//// [client.d.ts] +export declare var x: number; diff --git a/tests/baselines/reference/es6ImportNamedImport.errors.txt b/tests/baselines/reference/es6ImportNamedImport.errors.txt new file mode 100644 index 00000000000..5723b5c20d4 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImport.errors.txt @@ -0,0 +1,44 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ==== + + export var a = 10; + export var x = a; + export var m = a; + export var a1 = 10; + export var x1 = 10; + export var z1 = 10; + export var z2 = 10; + export var aaaa = 10; + +==== tests/cases/compiler/es6ImportNamedImport_1.ts (0 errors) ==== + import { } from "es6ImportNamedImport_0"; + import { a } from "es6ImportNamedImport_0"; + var xxxx = a; + import { a as b } from "es6ImportNamedImport_0"; + var xxxx = b; + import { x, a as y } from "es6ImportNamedImport_0"; + var xxxx = x; + var xxxx = y; + import { x as z, } from "es6ImportNamedImport_0"; + var xxxx = z; + import { m, } from "es6ImportNamedImport_0"; + var xxxx = m; + import { a1, x1 } from "es6ImportNamedImport_0"; + var xxxx = a1; + var xxxx = x1; + import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; + var xxxx = a11; + var xxxx = x11; + import { z1 } from "es6ImportNamedImport_0"; + var z111 = z1; + import { z2 as z3 } from "es6ImportNamedImport_0"; + var z2 = z3; // z2 shouldn't give redeclare error + + // These are elided + import { aaaa } from "es6ImportNamedImport_0"; + // These are elided + import { aaaa as bbbb } from "es6ImportNamedImport_0"; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index c52499ef994..9606c59351b 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -7,21 +7,80 @@ export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; //// [es6ImportNamedImport_1.ts] import { } from "es6ImportNamedImport_0"; import { a } from "es6ImportNamedImport_0"; +var xxxx = a; import { a as b } from "es6ImportNamedImport_0"; +var xxxx = b; import { x, a as y } from "es6ImportNamedImport_0"; +var xxxx = x; +var xxxx = y; import { x as z, } from "es6ImportNamedImport_0"; +var xxxx = z; import { m, } from "es6ImportNamedImport_0"; +var xxxx = m; import { a1, x1 } from "es6ImportNamedImport_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImport_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImport_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImport_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImport_0"; + //// [es6ImportNamedImport_0.js] -exports.a = 10; -exports.x = exports.a; -exports.m = exports.a; -exports.a1 = 10; -exports.x1 = 10; +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; //// [es6ImportNamedImport_1.js] +import { a } from "es6ImportNamedImport_0"; +var xxxx = a; +import { a as b } from "es6ImportNamedImport_0"; +var xxxx = b; +import { x, a as y } from "es6ImportNamedImport_0"; +var xxxx = x; +var xxxx = y; +import { x as z } from "es6ImportNamedImport_0"; +var xxxx = z; +import { m } from "es6ImportNamedImport_0"; +var xxxx = m; +import { a1, x1 } from "es6ImportNamedImport_0"; +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImport_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImport_0"; +var z2 = z3; // z2 shouldn't give redeclare error + + +//// [es6ImportNamedImport_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +export declare var a1: number; +export declare var x1: number; +export declare var z1: number; +export declare var z2: number; +export declare var aaaa: number; +//// [es6ImportNamedImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImport.types b/tests/baselines/reference/es6ImportNamedImport.types deleted file mode 100644 index cb06c9918ea..00000000000 --- a/tests/baselines/reference/es6ImportNamedImport.types +++ /dev/null @@ -1,50 +0,0 @@ -=== tests/cases/compiler/es6ImportNamedImport_0.ts === - -export var a = 10; ->a : number - -export var x = a; ->x : number ->a : number - -export var m = a; ->m : number ->a : number - -export var a1 = 10; ->a1 : number - -export var x1 = 10; ->x1 : number - -=== tests/cases/compiler/es6ImportNamedImport_1.ts === -import { } from "es6ImportNamedImport_0"; -import { a } from "es6ImportNamedImport_0"; ->a : number - -import { a as b } from "es6ImportNamedImport_0"; ->a : number ->b : number - -import { x, a as y } from "es6ImportNamedImport_0"; ->x : number ->a : number ->y : number - -import { x as z, } from "es6ImportNamedImport_0"; ->x : number ->z : number - -import { m, } from "es6ImportNamedImport_0"; ->m : number - -import { a1, x1 } from "es6ImportNamedImport_0"; ->a1 : number ->x1 : number - -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; ->a1 : number ->a11 : number ->x1 : number ->x11 : number - diff --git a/tests/baselines/reference/es6ImportNamedImportAmd.js b/tests/baselines/reference/es6ImportNamedImportAmd.js new file mode 100644 index 00000000000..5e3ddc43308 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportAmd.js @@ -0,0 +1,81 @@ +//// [tests/cases/compiler/es6ImportNamedImportAmd.ts] //// + +//// [es6ImportNamedImportAmd_0.ts] + +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; + +//// [es6ImportNamedImportAmd_1.ts] +import { } from "es6ImportNamedImportAmd_0"; +import { a } from "es6ImportNamedImportAmd_0"; +var xxxx = a; +import { a as b } from "es6ImportNamedImportAmd_0"; +var xxxx = b; +import { x, a as y } from "es6ImportNamedImportAmd_0"; +var xxxx = x; +var xxxx = y; +import { x as z, } from "es6ImportNamedImportAmd_0"; +var xxxx = z; +import { m, } from "es6ImportNamedImportAmd_0"; +var xxxx = m; +import { a1, x1 } from "es6ImportNamedImportAmd_0"; +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImportAmd_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImportAmd_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImportAmd_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImportAmd_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportAmd_0"; + + +//// [es6ImportNamedImportAmd_0.js] +define(["require", "exports"], function (require, exports) { + exports.a = 10; + exports.x = exports.a; + exports.m = exports.a; + exports.a1 = 10; + exports.x1 = 10; + exports.z1 = 10; + exports.z2 = 10; + exports.aaaa = 10; +}); +//// [es6ImportNamedImportAmd_1.js] +define(["require", "exports", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0"], function (require, exports, _es6ImportNamedImportAmd_0_1, _es6ImportNamedImportAmd_0_2, _es6ImportNamedImportAmd_0_3, _es6ImportNamedImportAmd_0_4, _es6ImportNamedImportAmd_0_5, _es6ImportNamedImportAmd_0_6, _es6ImportNamedImportAmd_0_7, _es6ImportNamedImportAmd_0_8, _es6ImportNamedImportAmd_0_9) { + var xxxx = _es6ImportNamedImportAmd_0_1.a; + var xxxx = _es6ImportNamedImportAmd_0_2.a; + var xxxx = _es6ImportNamedImportAmd_0_3.x; + var xxxx = _es6ImportNamedImportAmd_0_3.a; + var xxxx = _es6ImportNamedImportAmd_0_4.x; + var xxxx = _es6ImportNamedImportAmd_0_5.m; + var xxxx = _es6ImportNamedImportAmd_0_6.a1; + var xxxx = _es6ImportNamedImportAmd_0_6.x1; + var xxxx = _es6ImportNamedImportAmd_0_7.a1; + var xxxx = _es6ImportNamedImportAmd_0_7.x1; + var z111 = _es6ImportNamedImportAmd_0_8.z1; + var z2 = _es6ImportNamedImportAmd_0_9.z2; // z2 shouldn't give redeclare error +}); + + +//// [es6ImportNamedImportAmd_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +export declare var a1: number; +export declare var x1: number; +export declare var z1: number; +export declare var z2: number; +export declare var aaaa: number; +//// [es6ImportNamedImportAmd_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportAmd.types b/tests/baselines/reference/es6ImportNamedImportAmd.types new file mode 100644 index 00000000000..4a0abe853e0 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportAmd.types @@ -0,0 +1,123 @@ +=== tests/cases/compiler/es6ImportNamedImportAmd_0.ts === + +export var a = 10; +>a : number + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export var a1 = 10; +>a1 : number + +export var x1 = 10; +>x1 : number + +export var z1 = 10; +>z1 : number + +export var z2 = 10; +>z2 : number + +export var aaaa = 10; +>aaaa : number + +=== tests/cases/compiler/es6ImportNamedImportAmd_1.ts === +import { } from "es6ImportNamedImportAmd_0"; +import { a } from "es6ImportNamedImportAmd_0"; +>a : number + +var xxxx = a; +>xxxx : number +>a : number + +import { a as b } from "es6ImportNamedImportAmd_0"; +>a : number +>b : number + +var xxxx = b; +>xxxx : number +>b : number + +import { x, a as y } from "es6ImportNamedImportAmd_0"; +>x : number +>a : number +>y : number + +var xxxx = x; +>xxxx : number +>x : number + +var xxxx = y; +>xxxx : number +>y : number + +import { x as z, } from "es6ImportNamedImportAmd_0"; +>x : number +>z : number + +var xxxx = z; +>xxxx : number +>z : number + +import { m, } from "es6ImportNamedImportAmd_0"; +>m : number + +var xxxx = m; +>xxxx : number +>m : number + +import { a1, x1 } from "es6ImportNamedImportAmd_0"; +>a1 : number +>x1 : number + +var xxxx = a1; +>xxxx : number +>a1 : number + +var xxxx = x1; +>xxxx : number +>x1 : number + +import { a1 as a11, x1 as x11 } from "es6ImportNamedImportAmd_0"; +>a1 : number +>a11 : number +>x1 : number +>x11 : number + +var xxxx = a11; +>xxxx : number +>a11 : number + +var xxxx = x11; +>xxxx : number +>x11 : number + +import { z1 } from "es6ImportNamedImportAmd_0"; +>z1 : number + +var z111 = z1; +>z111 : number +>z1 : number + +import { z2 as z3 } from "es6ImportNamedImportAmd_0"; +>z2 : number +>z3 : number + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : number +>z3 : number + +// These are elided +import { aaaa } from "es6ImportNamedImportAmd_0"; +>aaaa : number + +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportAmd_0"; +>aaaa : number +>bbbb : number + diff --git a/tests/baselines/reference/es6ImportNamedImportDts.js b/tests/baselines/reference/es6ImportNamedImportDts.js new file mode 100644 index 00000000000..877ae6fab74 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportDts.js @@ -0,0 +1,208 @@ +//// [tests/cases/compiler/es6ImportNamedImportDts.ts] //// + +//// [server.ts] + +export class a { } +export class a11 { } +export class a12 { } +export class x { } +export class x11 { } +export class m { } +export class a1 { } +export class x1 { } +export class a111 { } +export class x111 { } +export class z1 { } +export class z2 { } +export class aaaa { } +export class aaaa1 { } + +//// [client.ts] +import { } from "server"; +import { a } from "server"; +export var xxxx = new a(); +import { a11 as b } from "server"; +export var xxxx1 = new b(); +import { x, a12 as y } from "server"; +export var xxxx2 = new x(); +export var xxxx3 = new y(); +import { x11 as z, } from "server"; +export var xxxx4 = new z(); +import { m, } from "server"; +export var xxxx5 = new m(); +import { a1, x1 } from "server"; +export var xxxx6 = new a1(); +export var xxxx7 = new x1(); +import { a111 as a11, x111 as x11 } from "server"; +export var xxxx8 = new a11(); +export var xxxx9 = new x11(); +import { z1 } from "server"; +export var z111 = new z1(); +import { z2 as z3 } from "server"; +export var z2 = new z3(); // z2 shouldn't give redeclare error + +// not referenced +import { aaaa } from "server"; +import { aaaa1 as bbbb } from "server"; + + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +exports.a = a; +var a11 = (function () { + function a11() { + } + return a11; +})(); +exports.a11 = a11; +var a12 = (function () { + function a12() { + } + return a12; +})(); +exports.a12 = a12; +var x = (function () { + function x() { + } + return x; +})(); +exports.x = x; +var x11 = (function () { + function x11() { + } + return x11; +})(); +exports.x11 = x11; +var m = (function () { + function m() { + } + return m; +})(); +exports.m = m; +var a1 = (function () { + function a1() { + } + return a1; +})(); +exports.a1 = a1; +var x1 = (function () { + function x1() { + } + return x1; +})(); +exports.x1 = x1; +var a111 = (function () { + function a111() { + } + return a111; +})(); +exports.a111 = a111; +var x111 = (function () { + function x111() { + } + return x111; +})(); +exports.x111 = x111; +var z1 = (function () { + function z1() { + } + return z1; +})(); +exports.z1 = z1; +var z2 = (function () { + function z2() { + } + return z2; +})(); +exports.z2 = z2; +var aaaa = (function () { + function aaaa() { + } + return aaaa; +})(); +exports.aaaa = aaaa; +var aaaa1 = (function () { + function aaaa1() { + } + return aaaa1; +})(); +exports.aaaa1 = aaaa1; +//// [client.js] +var _server_1 = require("server"); +exports.xxxx = new _server_1.a(); +var _server_2 = require("server"); +exports.xxxx1 = new _server_2.a11(); +var _server_3 = require("server"); +exports.xxxx2 = new _server_3.x(); +exports.xxxx3 = new _server_3.a12(); +var _server_4 = require("server"); +exports.xxxx4 = new _server_4.x11(); +var _server_5 = require("server"); +exports.xxxx5 = new _server_5.m(); +var _server_6 = require("server"); +exports.xxxx6 = new _server_6.a1(); +exports.xxxx7 = new _server_6.x1(); +var _server_7 = require("server"); +exports.xxxx8 = new _server_7.a111(); +exports.xxxx9 = new _server_7.x111(); +var _server_8 = require("server"); +exports.z111 = new _server_8.z1(); +var _server_9 = require("server"); +exports.z2 = new _server_9.z2(); // z2 shouldn't give redeclare error + + +//// [server.d.ts] +export declare class a { +} +export declare class a11 { +} +export declare class a12 { +} +export declare class x { +} +export declare class x11 { +} +export declare class m { +} +export declare class a1 { +} +export declare class x1 { +} +export declare class a111 { +} +export declare class x111 { +} +export declare class z1 { +} +export declare class z2 { +} +export declare class aaaa { +} +export declare class aaaa1 { +} +//// [client.d.ts] +import { a } from "server"; +export declare var xxxx: a; +import { a11 as b } from "server"; +export declare var xxxx1: b; +import { x, a12 as y } from "server"; +export declare var xxxx2: x; +export declare var xxxx3: y; +import { x11 as z } from "server"; +export declare var xxxx4: z; +import { m } from "server"; +export declare var xxxx5: m; +import { a1, x1 } from "server"; +export declare var xxxx6: a1; +export declare var xxxx7: x1; +import { a111 as a11, x111 as x11 } from "server"; +export declare var xxxx8: a11; +export declare var xxxx9: x11; +import { z1 } from "server"; +export declare var z111: z1; +import { z2 as z3 } from "server"; +export declare var z2: z3; diff --git a/tests/baselines/reference/es6ImportNamedImportDts.types b/tests/baselines/reference/es6ImportNamedImportDts.types new file mode 100644 index 00000000000..93bd55716a5 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportDts.types @@ -0,0 +1,150 @@ +=== tests/cases/compiler/server.ts === + +export class a { } +>a : a + +export class a11 { } +>a11 : a11 + +export class a12 { } +>a12 : a12 + +export class x { } +>x : x + +export class x11 { } +>x11 : x11 + +export class m { } +>m : m + +export class a1 { } +>a1 : a1 + +export class x1 { } +>x1 : x1 + +export class a111 { } +>a111 : a111 + +export class x111 { } +>x111 : x111 + +export class z1 { } +>z1 : z1 + +export class z2 { } +>z2 : z2 + +export class aaaa { } +>aaaa : aaaa + +export class aaaa1 { } +>aaaa1 : aaaa1 + +=== tests/cases/compiler/client.ts === +import { } from "server"; +import { a } from "server"; +>a : typeof a + +export var xxxx = new a(); +>xxxx : a +>new a() : a +>a : typeof a + +import { a11 as b } from "server"; +>a11 : typeof b +>b : typeof b + +export var xxxx1 = new b(); +>xxxx1 : b +>new b() : b +>b : typeof b + +import { x, a12 as y } from "server"; +>x : typeof x +>a12 : typeof y +>y : typeof y + +export var xxxx2 = new x(); +>xxxx2 : x +>new x() : x +>x : typeof x + +export var xxxx3 = new y(); +>xxxx3 : y +>new y() : y +>y : typeof y + +import { x11 as z, } from "server"; +>x11 : typeof z +>z : typeof z + +export var xxxx4 = new z(); +>xxxx4 : z +>new z() : z +>z : typeof z + +import { m, } from "server"; +>m : typeof m + +export var xxxx5 = new m(); +>xxxx5 : m +>new m() : m +>m : typeof m + +import { a1, x1 } from "server"; +>a1 : typeof a1 +>x1 : typeof x1 + +export var xxxx6 = new a1(); +>xxxx6 : a1 +>new a1() : a1 +>a1 : typeof a1 + +export var xxxx7 = new x1(); +>xxxx7 : x1 +>new x1() : x1 +>x1 : typeof x1 + +import { a111 as a11, x111 as x11 } from "server"; +>a111 : typeof a11 +>a11 : typeof a11 +>x111 : typeof x11 +>x11 : typeof x11 + +export var xxxx8 = new a11(); +>xxxx8 : a11 +>new a11() : a11 +>a11 : typeof a11 + +export var xxxx9 = new x11(); +>xxxx9 : x11 +>new x11() : x11 +>x11 : typeof x11 + +import { z1 } from "server"; +>z1 : typeof z1 + +export var z111 = new z1(); +>z111 : z1 +>new z1() : z1 +>z1 : typeof z1 + +import { z2 as z3 } from "server"; +>z2 : typeof z3 +>z3 : typeof z3 + +export var z2 = new z3(); // z2 shouldn't give redeclare error +>z2 : z3 +>new z3() : z3 +>z3 : typeof z3 + +// not referenced +import { aaaa } from "server"; +>aaaa : typeof aaaa + +import { aaaa1 as bbbb } from "server"; +>aaaa1 : typeof bbbb +>bbbb : typeof bbbb + diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.js b/tests/baselines/reference/es6ImportNamedImportInEs5.js index 66f8ce0ef92..fcb88d55b33 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.js @@ -7,16 +7,39 @@ export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; //// [es6ImportNamedImportInEs5_1.ts] import { } from "es6ImportNamedImportInEs5_0"; import { a } from "es6ImportNamedImportInEs5_0"; +var xxxx = a; import { a as b } from "es6ImportNamedImportInEs5_0"; +var xxxx = b; import { x, a as y } from "es6ImportNamedImportInEs5_0"; +var xxxx = x; +var xxxx = y; import { x as z, } from "es6ImportNamedImportInEs5_0"; +var xxxx = z; import { m, } from "es6ImportNamedImportInEs5_0"; +var xxxx = m; import { a1, x1 } from "es6ImportNamedImportInEs5_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImportInEs5_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImportInEs5_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; + //// [es6ImportNamedImportInEs5_0.js] exports.a = 10; @@ -24,4 +47,40 @@ exports.x = exports.a; exports.m = exports.a; exports.a1 = 10; exports.x1 = 10; +exports.z1 = 10; +exports.z2 = 10; +exports.aaaa = 10; //// [es6ImportNamedImportInEs5_1.js] +var _es6ImportNamedImportInEs5_0_1 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_1.a; +var _es6ImportNamedImportInEs5_0_2 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_2.a; +var _es6ImportNamedImportInEs5_0_3 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_3.x; +var xxxx = _es6ImportNamedImportInEs5_0_3.a; +var _es6ImportNamedImportInEs5_0_4 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_4.x; +var _es6ImportNamedImportInEs5_0_5 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_5.m; +var _es6ImportNamedImportInEs5_0_6 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_6.a1; +var xxxx = _es6ImportNamedImportInEs5_0_6.x1; +var _es6ImportNamedImportInEs5_0_7 = require("es6ImportNamedImportInEs5_0"); +var xxxx = _es6ImportNamedImportInEs5_0_7.a1; +var xxxx = _es6ImportNamedImportInEs5_0_7.x1; +var _es6ImportNamedImportInEs5_0_8 = require("es6ImportNamedImportInEs5_0"); +var z111 = _es6ImportNamedImportInEs5_0_8.z1; +var _es6ImportNamedImportInEs5_0_9 = require("es6ImportNamedImportInEs5_0"); +var z2 = _es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error + + +//// [es6ImportNamedImportInEs5_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +export declare var a1: number; +export declare var x1: number; +export declare var z1: number; +export declare var z2: number; +export declare var aaaa: number; +//// [es6ImportNamedImportInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.types b/tests/baselines/reference/es6ImportNamedImportInEs5.types index 334ae905e95..f60644b2621 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.types +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.types @@ -17,34 +17,107 @@ export var a1 = 10; export var x1 = 10; >x1 : number +export var z1 = 10; +>z1 : number + +export var z2 = 10; +>z2 : number + +export var aaaa = 10; +>aaaa : number + === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === import { } from "es6ImportNamedImportInEs5_0"; import { a } from "es6ImportNamedImportInEs5_0"; >a : number +var xxxx = a; +>xxxx : number +>a : number + import { a as b } from "es6ImportNamedImportInEs5_0"; >a : number >b : number +var xxxx = b; +>xxxx : number +>b : number + import { x, a as y } from "es6ImportNamedImportInEs5_0"; >x : number >a : number >y : number +var xxxx = x; +>xxxx : number +>x : number + +var xxxx = y; +>xxxx : number +>y : number + import { x as z, } from "es6ImportNamedImportInEs5_0"; >x : number >z : number +var xxxx = z; +>xxxx : number +>z : number + import { m, } from "es6ImportNamedImportInEs5_0"; >m : number +var xxxx = m; +>xxxx : number +>m : number + import { a1, x1 } from "es6ImportNamedImportInEs5_0"; >a1 : number >x1 : number +var xxxx = a1; +>xxxx : number +>a1 : number + +var xxxx = x1; +>xxxx : number +>x1 : number + import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; >a1 : number >a11 : number >x1 : number >x11 : number +var xxxx = a11; +>xxxx : number +>a11 : number + +var xxxx = x11; +>xxxx : number +>x11 : number + +import { z1 } from "es6ImportNamedImportInEs5_0"; +>z1 : number + +var z111 = z1; +>z111 : number +>z1 : number + +import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +>z2 : number +>z3 : number + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : number +>z3 : number + +// These are elided +import { aaaa } from "es6ImportNamedImportInEs5_0"; +>aaaa : number + +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +>aaaa : number +>bbbb : number + diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt new file mode 100644 index 00000000000..41d3f160938 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt @@ -0,0 +1,14 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts (1 errors) ==== + import { a } from "es6ImportNamedImportInExportAssignment_0"; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js new file mode 100644 index 00000000000..ea9e65db34a --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts] //// + +//// [es6ImportNamedImportInExportAssignment_0.ts] + +export var a = 10; + +//// [es6ImportNamedImportInExportAssignment_1.ts] +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export = a; + +//// [es6ImportNamedImportInExportAssignment_0.js] +export var a = 10; +//// [es6ImportNamedImportInExportAssignment_1.js] +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export default a; + + +//// [es6ImportNamedImportInExportAssignment_0.d.ts] +export declare var a: number; +//// [es6ImportNamedImportInExportAssignment_1.d.ts] +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export = a; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js new file mode 100644 index 00000000000..9c383ab3e3b --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts] //// + +//// [es6ImportNamedImportInIndirectExportAssignment_0.ts] + +export module a { + export class c { + } +} + +//// [es6ImportNamedImportInIndirectExportAssignment_1.ts] +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import x = a; +export = x; + +//// [es6ImportNamedImportInIndirectExportAssignment_0.js] +var a; +(function (a) { + var c = (function () { + function c() { + } + return c; + })(); + a.c = c; +})(a = exports.a || (exports.a = {})); +//// [es6ImportNamedImportInIndirectExportAssignment_1.js] +var _es6ImportNamedImportInIndirectExportAssignment_0 = require("es6ImportNamedImportInIndirectExportAssignment_0"); +var x = _es6ImportNamedImportInIndirectExportAssignment_0.a; +module.exports = x; + + +//// [es6ImportNamedImportInIndirectExportAssignment_0.d.ts] +export declare module a { + class c { + } +} +//// [es6ImportNamedImportInIndirectExportAssignment_1.d.ts] +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import x = a; +export = x; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types new file mode 100644 index 00000000000..36792ece82e --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_0.ts === + +export module a { +>a : typeof a + + export class c { +>c : c + } +} + +=== tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts === +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +>a : typeof a + +import x = a; +>x : typeof a +>a : typeof a + +export = x; +>x : typeof a + diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt new file mode 100644 index 00000000000..b9461b6caca --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'x' +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(7,10): error TS2440: Import declaration conflicts with local declaration of 'x44' +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(9,10): error TS2300: Duplicate identifier 'z'. +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(10,16): error TS2300: Duplicate identifier 'z'. + + +==== tests/cases/compiler/es6ImportNamedImportMergeErrors_0.ts (0 errors) ==== + + export var a = 10; + export var x = a; + export var z = a; + export var z1 = a; + +==== tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts (4 errors) ==== + import { a } from "es6ImportNamedImportMergeErrors_0"; + interface a { } // shouldnt be error + import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; + interface x1 { } // shouldnt be error + import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2440: Import declaration conflicts with local declaration of 'x' + var x = 10; + import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'x44' + var x44 = 10; + import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2300: Duplicate identifier 'z'. + import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2300: Duplicate identifier 'z'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js new file mode 100644 index 00000000000..fad411f557d --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es6ImportNamedImportMergeErrors.ts] //// + +//// [es6ImportNamedImportMergeErrors_0.ts] + +export var a = 10; +export var x = a; +export var z = a; +export var z1 = a; + +//// [es6ImportNamedImportMergeErrors_1.ts] +import { a } from "es6ImportNamedImportMergeErrors_0"; +interface a { } // shouldnt be error +import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +interface x1 { } // shouldnt be error +import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x = 10; +import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x44 = 10; +import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + + +//// [es6ImportNamedImportMergeErrors_0.js] +exports.a = 10; +exports.x = exports.a; +exports.z = exports.a; +exports.z1 = exports.a; +//// [es6ImportNamedImportMergeErrors_1.js] +var x = 10; +var x44 = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt new file mode 100644 index 00000000000..57a77410cb2 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/es6ImportNamedImport_1.ts(1,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. +tests/cases/compiler/es6ImportNamedImport_1.ts(2,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. + + +==== tests/cases/compiler/es6ImportNamedImportNoExportMember_0.ts (0 errors) ==== + + export var a = 10; + export var x = a; + +==== tests/cases/compiler/es6ImportNamedImport_1.ts (2 errors) ==== + import { a1 } from "es6ImportNamedImportNoExportMember_0"; + ~~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. + import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + ~~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js new file mode 100644 index 00000000000..da473fa42a3 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/es6ImportNamedImportNoExportMember.ts] //// + +//// [es6ImportNamedImportNoExportMember_0.ts] + +export var a = 10; +export var x = a; + +//// [es6ImportNamedImport_1.ts] +import { a1 } from "es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + +//// [es6ImportNamedImportNoExportMember_0.js] +exports.a = 10; +exports.x = exports.a; +//// [es6ImportNamedImport_1.js] diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt new file mode 100644 index 00000000000..a5abd986ee8 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(1,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. + + +==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts (2 errors) ==== + import { a } from "es6ImportNamedImportNoNamedExports_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. + import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js new file mode 100644 index 00000000000..524860827e6 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts] //// + +//// [es6ImportNamedImportNoNamedExports_0.ts] + +var a = 10; +export = a; + +//// [es6ImportNamedImportNoNamedExports_1.ts] +import { a } from "es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + +//// [es6ImportNamedImportNoNamedExports_0.js] +var a = 10; +module.exports = a; +//// [es6ImportNamedImportNoNamedExports_1.js] diff --git a/tests/baselines/reference/es6ImportNamedImportParsingError.js b/tests/baselines/reference/es6ImportNamedImportParsingError.js index f9d8e90f707..81f141b3dd8 100644 --- a/tests/baselines/reference/es6ImportNamedImportParsingError.js +++ b/tests/baselines/reference/es6ImportNamedImportParsingError.js @@ -13,16 +13,16 @@ import , { a } from "es6ImportNamedImportParsingError_0"; import { a }, from "es6ImportNamedImportParsingError_0"; //// [es6ImportNamedImportParsingError_0.js] -exports.a = 10; -exports.x = exports.a; -exports.m = exports.a; +export var a = 10; +export var x = a; +export var m = a; //// [es6ImportNamedImportParsingError_1.js] from; "es6ImportNamedImportParsingError_0"; { - _module_1.a; + a; } from; "es6ImportNamedImportParsingError_0"; -var _module_1 = require(); +import { a } from , from; "es6ImportNamedImportParsingError_0"; diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt new file mode 100644 index 00000000000..ff8fe604622 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt @@ -0,0 +1,77 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(13,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(16,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(19,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(21,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(25,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot have modifiers. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + export var a = 10; + export var x = a; + export var m = a; + export var a1 = 10; + export var x1 = 10; + export var z1 = 10; + export var z2 = 10; + export var aaaa = 10; + +==== tests/cases/compiler/client.ts (12 errors) ==== + export import { } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export import { a } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = a; + export import { a as b } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = b; + export import { x, a as y } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = x; + export var xxxx = y; + export import { x as z, } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = z; + export import { m, } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = m; + export import { a1, x1 } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = a1; + export var xxxx = x1; + export import { a1 as a11, x1 as x11 } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var xxxx = a11; + export var xxxx = x11; + export import { z1 } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var z111 = z1; + export import { z2 as z3 } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var z2 = z3; // z2 shouldn't give redeclare error + + // Non referenced imports + export import { aaaa } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export import { aaaa as bbbb } from "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.js b/tests/baselines/reference/es6ImportNamedImportWithExport.js new file mode 100644 index 00000000000..71f4af72178 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.js @@ -0,0 +1,97 @@ +//// [tests/cases/compiler/es6ImportNamedImportWithExport.ts] //// + +//// [server.ts] + +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; + +//// [client.ts] +export import { } from "server"; +export import { a } from "server"; +export var xxxx = a; +export import { a as b } from "server"; +export var xxxx = b; +export import { x, a as y } from "server"; +export var xxxx = x; +export var xxxx = y; +export import { x as z, } from "server"; +export var xxxx = z; +export import { m, } from "server"; +export var xxxx = m; +export import { a1, x1 } from "server"; +export var xxxx = a1; +export var xxxx = x1; +export import { a1 as a11, x1 as x11 } from "server"; +export var xxxx = a11; +export var xxxx = x11; +export import { z1 } from "server"; +export var z111 = z1; +export import { z2 as z3 } from "server"; +export var z2 = z3; // z2 shouldn't give redeclare error + +// Non referenced imports +export import { aaaa } from "server"; +export import { aaaa as bbbb } from "server"; + + +//// [server.js] +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.a1 = 10; +exports.x1 = 10; +exports.z1 = 10; +exports.z2 = 10; +exports.aaaa = 10; +//// [client.js] +var _server_1 = require("server"); +exports.xxxx = _server_1.a; +var _server_2 = require("server"); +exports.xxxx = _server_2.a; +var _server_3 = require("server"); +exports.xxxx = _server_3.x; +exports.xxxx = _server_3.a; +var _server_4 = require("server"); +exports.xxxx = _server_4.x; +var _server_5 = require("server"); +exports.xxxx = _server_5.m; +var _server_6 = require("server"); +exports.xxxx = _server_6.a1; +exports.xxxx = _server_6.x1; +var _server_7 = require("server"); +exports.xxxx = _server_7.a1; +exports.xxxx = _server_7.x1; +var _server_8 = require("server"); +exports.z111 = _server_8.z1; +var _server_9 = require("server"); +exports.z2 = _server_9.z2; // z2 shouldn't give redeclare error + + +//// [server.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +export declare var a1: number; +export declare var x1: number; +export declare var z1: number; +export declare var z2: number; +export declare var aaaa: number; +//// [client.d.ts] +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var xxxx: number; +export declare var z111: number; +export declare var z2: number; diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js new file mode 100644 index 00000000000..7852d2991bc --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts] //// + +//// [server.ts] + +export interface I { + prop: string; +} +export interface I2 { + prop2: string; +} +export class C implements I { + prop = "hello"; +} +export class C2 implements I2 { + prop2 = "world"; +} + +//// [client.ts] +import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +export type cValInterface = I; +export var cVal = new C(); + +//// [server.js] +var C = (function () { + function C() { + this.prop = "hello"; + } + return C; +})(); +exports.C = C; +var C2 = (function () { + function C2() { + this.prop2 = "world"; + } + return C2; +})(); +exports.C2 = C2; +//// [client.js] +var _server = require("server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +exports.cVal = new _server.C(); + + +//// [server.d.ts] +export interface I { + prop: string; +} +export interface I2 { + prop2: string; +} +export declare class C implements I { + prop: string; +} +export declare class C2 implements I2 { + prop2: string; +} +//// [client.d.ts] +import { C, I } from "server"; +export declare type cValInterface = I; +export declare var cVal: C; diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types new file mode 100644 index 00000000000..62917e5ff36 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/server.ts === + +export interface I { +>I : I + + prop: string; +>prop : string +} +export interface I2 { +>I2 : I2 + + prop2: string; +>prop2 : string +} +export class C implements I { +>C : C +>I : I + + prop = "hello"; +>prop : string +} +export class C2 implements I2 { +>C2 : C2 +>I2 : I2 + + prop2 = "world"; +>prop2 : string +} + +=== tests/cases/compiler/client.ts === +import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +>C : typeof C +>I : unknown +>C2 : typeof C2 + +export type cValInterface = I; +>cValInterface : I +>I : I + +export var cVal = new C(); +>cVal : C +>new C() : C +>C : typeof C + diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.js b/tests/baselines/reference/es6ImportWithoutFromClause.js index 43d21885c27..9666409b924 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.js +++ b/tests/baselines/reference/es6ImportWithoutFromClause.js @@ -5,9 +5,15 @@ export var a = 10; //// [es6ImportWithoutFromClause_1.ts] -import "es6ImportWithoutFromClause_0"; +import "es6ImportWithoutFromClause_0"; + //// [es6ImportWithoutFromClause_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportWithoutFromClause_1.js] -require("es6ImportWithoutFromClause_0"); +import "es6ImportWithoutFromClause_0"; + + +//// [es6ImportWithoutFromClause_0.d.ts] +export declare var a: number; +//// [es6ImportWithoutFromClause_1.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.types b/tests/baselines/reference/es6ImportWithoutFromClause.types index 1cd7df9962e..3cc5067891a 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.types +++ b/tests/baselines/reference/es6ImportWithoutFromClause.types @@ -5,4 +5,5 @@ export var a = 10; === tests/cases/compiler/es6ImportWithoutFromClause_1.ts === import "es6ImportWithoutFromClause_0"; +No type information for this code. No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js new file mode 100644 index 00000000000..7b10da7cc9f --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts] //// + +//// [es6ImportWithoutFromClauseAmd_0.ts] + +export var a = 10; + +//// [es6ImportWithoutFromClauseAmd_1.ts] +export var b = 10; + +//// [es6ImportWithoutFromClauseAmd_2.ts] +import "es6ImportWithoutFromClauseAmd_0"; +import "es6ImportWithoutFromClauseAmd_2"; +var _a = 10; +var _b = 10; + +//// [es6ImportWithoutFromClauseAmd_0.js] +define(["require", "exports"], function (require, exports) { + exports.a = 10; +}); +//// [es6ImportWithoutFromClauseAmd_1.js] +define(["require", "exports"], function (require, exports) { + exports.b = 10; +}); +//// [es6ImportWithoutFromClauseAmd_2.js] +define(["require", "exports", "es6ImportWithoutFromClauseAmd_0", "es6ImportWithoutFromClauseAmd_2"], function (require, exports, , ) { + var _a = 10; + var _b = 10; +}); + + +//// [es6ImportWithoutFromClauseAmd_0.d.ts] +export declare var a: number; +//// [es6ImportWithoutFromClauseAmd_1.d.ts] +export declare var b: number; +//// [es6ImportWithoutFromClauseAmd_2.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types new file mode 100644 index 00000000000..c3d09388916 --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_0.ts === + +export var a = 10; +>a : number + +=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_1.ts === +export var b = 10; +>b : number + +=== tests/cases/compiler/es6ImportWithoutFromClauseAmd_2.ts === +import "es6ImportWithoutFromClauseAmd_0"; +import "es6ImportWithoutFromClauseAmd_2"; +var _a = 10; +>_a : number + +var _b = 10; +>_b : number + diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js index f6610ac5ad2..aacb936ab36 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js @@ -11,3 +11,8 @@ import "es6ImportWithoutFromClauseInEs5_0"; exports.a = 10; //// [es6ImportWithoutFromClauseInEs5_1.js] require("es6ImportWithoutFromClauseInEs5_0"); + + +//// [es6ImportWithoutFromClauseInEs5_0.d.ts] +export declare var a: number; +//// [es6ImportWithoutFromClauseInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js new file mode 100644 index 00000000000..e63dd4bb53a --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts] //// + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.ts] + +export interface i { +} + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.ts] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.js] +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.js] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; + + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.d.ts] +export interface i { +} +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types new file mode 100644 index 00000000000..2be3f67f1e9 --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_0.ts === + +export interface i { +>i : i +} + +=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_1.ts === +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.errors.txt b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.errors.txt new file mode 100644 index 00000000000..da865698e56 --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/client.ts (1 errors) ==== + export import "server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js new file mode 100644 index 00000000000..208f71bcbfe --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts] //// + +//// [server.ts] + +export var a = 10; + +//// [client.ts] +export import "server"; + +//// [server.js] +exports.a = 10; +//// [client.js] +require("server"); + + +//// [server.d.ts] +export declare var a: number; +//// [client.d.ts] +export import "server"; diff --git a/tests/baselines/reference/es6Module.js b/tests/baselines/reference/es6Module.js new file mode 100644 index 00000000000..d3141572c92 --- /dev/null +++ b/tests/baselines/reference/es6Module.js @@ -0,0 +1,21 @@ +//// [es6Module.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es6Module.js] +export class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/es6-amd.types b/tests/baselines/reference/es6Module.types similarity index 60% rename from tests/baselines/reference/es6-amd.types rename to tests/baselines/reference/es6Module.types index 62815911f7f..93910200215 100644 --- a/tests/baselines/reference/es6-amd.types +++ b/tests/baselines/reference/es6Module.types @@ -1,11 +1,9 @@ -=== tests/cases/compiler/es6-amd.ts === - -class A +=== tests/cases/compiler/es6Module.ts === +export class A >A : A { constructor () { - } public B() diff --git a/tests/baselines/reference/es6ModuleClassDeclaration.js b/tests/baselines/reference/es6ModuleClassDeclaration.js new file mode 100644 index 00000000000..9676720fd0f --- /dev/null +++ b/tests/baselines/reference/es6ModuleClassDeclaration.js @@ -0,0 +1,231 @@ +//// [es6ModuleClassDeclaration.ts] +export class c { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } +} +class c2 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } +} +new c(); +new c2(); + +export module m1 { + export class c3 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + class c4 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + new c(); + new c2(); + new c3(); + new c4(); +} +module m2 { + export class c3 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + class c4 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + new c(); + new c2(); + new c3(); + new c4(); + new m1.c3(); +} + +//// [es6ModuleClassDeclaration.js] +export class c { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } +} +c.k = 20; +c.l = 30; +class c2 { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } +} +c2.k = 20; +c2.l = 30; +new c(); +new c2(); +var m1; +(function (m1) { + class c3 { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } + } + c3.k = 20; + c3.l = 30; + m1.c3 = c3; + class c4 { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } + } + c4.k = 20; + c4.l = 30; + new c(); + new c2(); + new c3(); + new c4(); +})(m1 || (m1 = {})); +export { m1 }; +var m2; +(function (m2) { + class c3 { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } + } + c3.k = 20; + c3.l = 30; + m2.c3 = c3; + class c4 { + constructor() { + this.x = 10; + this.y = 30; + } + method1() { + } + method2() { + } + static method3() { + } + static method4() { + } + } + c4.k = 20; + c4.l = 30; + new c(); + new c2(); + new c3(); + new c4(); + new m1.c3(); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleClassDeclaration.types b/tests/baselines/reference/es6ModuleClassDeclaration.types new file mode 100644 index 00000000000..09d50c4e542 --- /dev/null +++ b/tests/baselines/reference/es6ModuleClassDeclaration.types @@ -0,0 +1,233 @@ +=== tests/cases/compiler/es6ModuleClassDeclaration.ts === +export class c { +>c : c + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } +} +class c2 { +>c2 : c2 + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } +} +new c(); +>new c() : c +>c : typeof c + +new c2(); +>new c2() : c2 +>c2 : typeof c2 + +export module m1 { +>m1 : typeof m1 + + export class c3 { +>c3 : c3 + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } + } + class c4 { +>c4 : c4 + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } + } + new c(); +>new c() : c +>c : typeof c + + new c2(); +>new c2() : c2 +>c2 : typeof c2 + + new c3(); +>new c3() : c3 +>c3 : typeof c3 + + new c4(); +>new c4() : c4 +>c4 : typeof c4 +} +module m2 { +>m2 : typeof m2 + + export class c3 { +>c3 : c3 + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } + } + class c4 { +>c4 : c4 + + constructor() { + } + private x = 10; +>x : number + + public y = 30; +>y : number + + static k = 20; +>k : number + + private static l = 30; +>l : number + + private method1() { +>method1 : () => void + } + public method2() { +>method2 : () => void + } + static method3() { +>method3 : () => void + } + private static method4() { +>method4 : () => void + } + } + new c(); +>new c() : c +>c : typeof c + + new c2(); +>new c2() : c2 +>c2 : typeof c2 + + new c3(); +>new c3() : c3 +>c3 : typeof c3 + + new c4(); +>new c4() : c4 +>c4 : typeof c4 + + new m1.c3(); +>new m1.c3() : m1.c3 +>m1.c3 : typeof m1.c3 +>m1 : typeof m1 +>c3 : typeof m1.c3 +} diff --git a/tests/baselines/reference/es6ModuleConst.js b/tests/baselines/reference/es6ModuleConst.js new file mode 100644 index 00000000000..2a11ec638a1 --- /dev/null +++ b/tests/baselines/reference/es6ModuleConst.js @@ -0,0 +1,38 @@ +//// [es6ModuleConst.ts] +export const a = "hello"; +export const x: string = a, y = x; +const b = y; +const c: string = b, d = c; +export module m1 { + export const k = a; + export const l: string = b, m = k; + const n = m1.k; + const o: string = n, p = k; +} +module m2 { + export const k = a; + export const l: string = b, m = k; + const n = m1.k; + const o: string = n, p = k; +} + +//// [es6ModuleConst.js] +export const a = "hello"; +export const x = a, y = x; +const b = y; +const c = b, d = c; +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; + m2.l = b, m2.m = m2.k; + const n = m1.k; + const o = n, p = m2.k; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleConst.types b/tests/baselines/reference/es6ModuleConst.types new file mode 100644 index 00000000000..cceb74a5e1e --- /dev/null +++ b/tests/baselines/reference/es6ModuleConst.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/es6ModuleConst.ts === +export const a = "hello"; +>a : string + +export const x: string = a, y = x; +>x : string +>a : string +>y : string +>x : string + +const b = y; +>b : string +>y : string + +const c: string = b, d = c; +>c : string +>b : string +>d : string +>c : string + +export module m1 { +>m1 : typeof m1 + + export const k = a; +>k : string +>a : string + + export const l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + const n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + const o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} +module m2 { +>m2 : typeof m2 + + export const k = a; +>k : string +>a : string + + export const l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + const n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + const o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration.js b/tests/baselines/reference/es6ModuleConstEnumDeclaration.js new file mode 100644 index 00000000000..c8096c76c8e --- /dev/null +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration.js @@ -0,0 +1,66 @@ +//// [es6ModuleConstEnumDeclaration.ts] +export const enum e1 { + a, + b, + c +} +const enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export const enum e3 { + a, + b, + c + } + const enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export const enum e5 { + a, + b, + c + } + const enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} + +//// [es6ModuleConstEnumDeclaration.js] +var x = 0 /* a */; +var y = 0 /* x */; +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 */; + var y1 = 0 /* x */; + var x2 = 0 /* a */; + var y2 = 0 /* x */; + var x3 = 0 /* a */; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration.types b/tests/baselines/reference/es6ModuleConstEnumDeclaration.types new file mode 100644 index 00000000000..fae819f93b0 --- /dev/null +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration.types @@ -0,0 +1,147 @@ +=== tests/cases/compiler/es6ModuleConstEnumDeclaration.ts === +export const enum e1 { +>e1 : e1 + + a, +>a : e1 + + b, +>b : e1 + + c +>c : e1 +} +const enum e2 { +>e2 : e2 + + x, +>x : e2 + + y, +>y : e2 + + z +>z : e2 +} +var x = e1.a; +>x : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + +var y = e2.x; +>y : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + +export module m1 { +>m1 : typeof m1 + + export const enum e3 { +>e3 : e3 + + a, +>a : e3 + + b, +>b : e3 + + c +>c : e3 + } + const enum e4 { +>e4 : e4 + + x, +>x : e4 + + y, +>y : e4 + + z +>z : e4 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e3.a; +>x2 : e3 +>e3.a : e3 +>e3 : typeof e3 +>a : e3 + + var y2 = e4.x; +>y2 : e4 +>e4.x : e4 +>e4 : typeof e4 +>x : e4 +} +module m2 { +>m2 : typeof m2 + + export const enum e5 { +>e5 : e5 + + a, +>a : e5 + + b, +>b : e5 + + c +>c : e5 + } + const enum e6 { +>e6 : e6 + + x, +>x : e6 + + y, +>y : e6 + + z +>z : e6 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e5.a; +>x2 : e5 +>e5.a : e5 +>e5 : typeof e5 +>a : e5 + + var y2 = e6.x; +>y2 : e6 +>e6.x : e6 +>e6 : typeof e6 +>x : e6 + + var x3 = m1.e3.a; +>x3 : m1.e3 +>m1.e3.a : m1.e3 +>m1.e3 : typeof m1.e3 +>m1 : typeof m1 +>e3 : typeof m1.e3 +>a : m1.e3 +} diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js new file mode 100644 index 00000000000..5ec953aca88 --- /dev/null +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.js @@ -0,0 +1,104 @@ +//// [es6ModuleConstEnumDeclaration2.ts] + +export const enum e1 { + a, + b, + c +} +const enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export const enum e3 { + a, + b, + c + } + const enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export const enum e5 { + a, + b, + c + } + const enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} + +//// [es6ModuleConstEnumDeclaration2.js] +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"; + e2[e2["y"] = 1] = "y"; + e2[e2["z"] = 2] = "z"; +})(e2 || (e2 = {})); +var x = 0 /* a */; +var y = 0 /* x */; +var m1; +(function (m1) { + (function (e3) { + e3[e3["a"] = 0] = "a"; + e3[e3["b"] = 1] = "b"; + e3[e3["c"] = 2] = "c"; + })(m1.e3 || (m1.e3 = {})); + var e3 = m1.e3; + var e4; + (function (e4) { + e4[e4["x"] = 0] = "x"; + e4[e4["y"] = 1] = "y"; + e4[e4["z"] = 2] = "z"; + })(e4 || (e4 = {})); + var x1 = 0 /* a */; + var y1 = 0 /* x */; + var x2 = 0 /* a */; + var y2 = 0 /* x */; +})(m1 || (m1 = {})); +export { m1 }; +var m2; +(function (m2) { + (function (e5) { + e5[e5["a"] = 0] = "a"; + e5[e5["b"] = 1] = "b"; + e5[e5["c"] = 2] = "c"; + })(m2.e5 || (m2.e5 = {})); + var e5 = m2.e5; + var e6; + (function (e6) { + e6[e6["x"] = 0] = "x"; + e6[e6["y"] = 1] = "y"; + e6[e6["z"] = 2] = "z"; + })(e6 || (e6 = {})); + var x1 = 0 /* a */; + var y1 = 0 /* x */; + var x2 = 0 /* a */; + var y2 = 0 /* x */; + var x3 = 0 /* a */; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types new file mode 100644 index 00000000000..c43a938c9b6 --- /dev/null +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types @@ -0,0 +1,148 @@ +=== tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts === + +export const enum e1 { +>e1 : e1 + + a, +>a : e1 + + b, +>b : e1 + + c +>c : e1 +} +const enum e2 { +>e2 : e2 + + x, +>x : e2 + + y, +>y : e2 + + z +>z : e2 +} +var x = e1.a; +>x : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + +var y = e2.x; +>y : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + +export module m1 { +>m1 : typeof m1 + + export const enum e3 { +>e3 : e3 + + a, +>a : e3 + + b, +>b : e3 + + c +>c : e3 + } + const enum e4 { +>e4 : e4 + + x, +>x : e4 + + y, +>y : e4 + + z +>z : e4 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e3.a; +>x2 : e3 +>e3.a : e3 +>e3 : typeof e3 +>a : e3 + + var y2 = e4.x; +>y2 : e4 +>e4.x : e4 +>e4 : typeof e4 +>x : e4 +} +module m2 { +>m2 : typeof m2 + + export const enum e5 { +>e5 : e5 + + a, +>a : e5 + + b, +>b : e5 + + c +>c : e5 + } + const enum e6 { +>e6 : e6 + + x, +>x : e6 + + y, +>y : e6 + + z +>z : e6 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e5.a; +>x2 : e5 +>e5.a : e5 +>e5 : typeof e5 +>a : e5 + + var y2 = e6.x; +>y2 : e6 +>e6.x : e6 +>e6 : typeof e6 +>x : e6 + + var x3 = m1.e3.a; +>x3 : m1.e3 +>m1.e3.a : m1.e3 +>m1.e3 : typeof m1.e3 +>m1 : typeof m1 +>e3 : typeof m1.e3 +>a : m1.e3 +} diff --git a/tests/baselines/reference/es6ModuleEnumDeclaration.js b/tests/baselines/reference/es6ModuleEnumDeclaration.js new file mode 100644 index 00000000000..08792149818 --- /dev/null +++ b/tests/baselines/reference/es6ModuleEnumDeclaration.js @@ -0,0 +1,103 @@ +//// [es6ModuleEnumDeclaration.ts] +export enum e1 { + a, + b, + c +} +enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export enum e3 { + a, + b, + c + } + enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export enum e5 { + a, + b, + c + } + enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} + +//// [es6ModuleEnumDeclaration.js] +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"; + e2[e2["y"] = 1] = "y"; + e2[e2["z"] = 2] = "z"; +})(e2 || (e2 = {})); +var x = e1.a; +var y = e2.x; +var m1; +(function (m1) { + (function (e3) { + e3[e3["a"] = 0] = "a"; + e3[e3["b"] = 1] = "b"; + e3[e3["c"] = 2] = "c"; + })(m1.e3 || (m1.e3 = {})); + var e3 = m1.e3; + var e4; + (function (e4) { + e4[e4["x"] = 0] = "x"; + e4[e4["y"] = 1] = "y"; + e4[e4["z"] = 2] = "z"; + })(e4 || (e4 = {})); + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +})(m1 || (m1 = {})); +export { m1 }; +var m2; +(function (m2) { + (function (e5) { + e5[e5["a"] = 0] = "a"; + e5[e5["b"] = 1] = "b"; + e5[e5["c"] = 2] = "c"; + })(m2.e5 || (m2.e5 = {})); + var e5 = m2.e5; + var e6; + (function (e6) { + e6[e6["x"] = 0] = "x"; + e6[e6["y"] = 1] = "y"; + e6[e6["z"] = 2] = "z"; + })(e6 || (e6 = {})); + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleEnumDeclaration.types b/tests/baselines/reference/es6ModuleEnumDeclaration.types new file mode 100644 index 00000000000..4b856fee009 --- /dev/null +++ b/tests/baselines/reference/es6ModuleEnumDeclaration.types @@ -0,0 +1,147 @@ +=== tests/cases/compiler/es6ModuleEnumDeclaration.ts === +export enum e1 { +>e1 : e1 + + a, +>a : e1 + + b, +>b : e1 + + c +>c : e1 +} +enum e2 { +>e2 : e2 + + x, +>x : e2 + + y, +>y : e2 + + z +>z : e2 +} +var x = e1.a; +>x : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + +var y = e2.x; +>y : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + +export module m1 { +>m1 : typeof m1 + + export enum e3 { +>e3 : e3 + + a, +>a : e3 + + b, +>b : e3 + + c +>c : e3 + } + enum e4 { +>e4 : e4 + + x, +>x : e4 + + y, +>y : e4 + + z +>z : e4 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e3.a; +>x2 : e3 +>e3.a : e3 +>e3 : typeof e3 +>a : e3 + + var y2 = e4.x; +>y2 : e4 +>e4.x : e4 +>e4 : typeof e4 +>x : e4 +} +module m2 { +>m2 : typeof m2 + + export enum e5 { +>e5 : e5 + + a, +>a : e5 + + b, +>b : e5 + + c +>c : e5 + } + enum e6 { +>e6 : e6 + + x, +>x : e6 + + y, +>y : e6 + + z +>z : e6 + } + var x1 = e1.a; +>x1 : e1 +>e1.a : e1 +>e1 : typeof e1 +>a : e1 + + var y1 = e2.x; +>y1 : e2 +>e2.x : e2 +>e2 : typeof e2 +>x : e2 + + var x2 = e5.a; +>x2 : e5 +>e5.a : e5 +>e5 : typeof e5 +>a : e5 + + var y2 = e6.x; +>y2 : e6 +>e6.x : e6 +>e6 : typeof e6 +>x : e6 + + var x3 = m1.e3.a; +>x3 : m1.e3 +>m1.e3.a : m1.e3 +>m1.e3 : typeof m1.e3 +>m1 : typeof m1 +>e3 : typeof m1.e3 +>a : m1.e3 +} diff --git a/tests/baselines/reference/es6ModuleFunctionDeclaration.js b/tests/baselines/reference/es6ModuleFunctionDeclaration.js new file mode 100644 index 00000000000..4c1fc33647c --- /dev/null +++ b/tests/baselines/reference/es6ModuleFunctionDeclaration.js @@ -0,0 +1,63 @@ +//// [es6ModuleFunctionDeclaration.ts] +export function foo() { +} +function foo2() { +} +foo(); +foo2(); + +export module m1 { + export function foo3() { + } + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); +} +module m2 { + export function foo3() { + } + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); + m1.foo3(); +} + +//// [es6ModuleFunctionDeclaration.js] +export function foo() { +} +function foo2() { +} +foo(); +foo2(); +var m1; +(function (m1) { + function foo3() { + } + m1.foo3 = foo3; + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); +})(m1 || (m1 = {})); +export { m1 }; +var m2; +(function (m2) { + function foo3() { + } + m2.foo3 = foo3; + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); + m1.foo3(); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleFunctionDeclaration.types b/tests/baselines/reference/es6ModuleFunctionDeclaration.types new file mode 100644 index 00000000000..b1252c1e8bc --- /dev/null +++ b/tests/baselines/reference/es6ModuleFunctionDeclaration.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/es6ModuleFunctionDeclaration.ts === +export function foo() { +>foo : () => void +} +function foo2() { +>foo2 : () => void +} +foo(); +>foo() : void +>foo : () => void + +foo2(); +>foo2() : void +>foo2 : () => void + +export module m1 { +>m1 : typeof m1 + + export function foo3() { +>foo3 : () => void + } + function foo4() { +>foo4 : () => void + } + foo(); +>foo() : void +>foo : () => void + + foo2(); +>foo2() : void +>foo2 : () => void + + foo3(); +>foo3() : void +>foo3 : () => void + + foo4(); +>foo4() : void +>foo4 : () => void +} +module m2 { +>m2 : typeof m2 + + export function foo3() { +>foo3 : () => void + } + function foo4() { +>foo4 : () => void + } + foo(); +>foo() : void +>foo : () => void + + foo2(); +>foo2() : void +>foo2 : () => void + + foo3(); +>foo3() : void +>foo3 : () => void + + foo4(); +>foo4() : void +>foo4 : () => void + + m1.foo3(); +>m1.foo3() : void +>m1.foo3 : () => void +>m1 : typeof m1 +>foo3 : () => void +} diff --git a/tests/baselines/reference/es6ModuleInternalImport.js b/tests/baselines/reference/es6ModuleInternalImport.js new file mode 100644 index 00000000000..4a1659cb901 --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalImport.js @@ -0,0 +1,46 @@ +//// [es6ModuleInternalImport.ts] +export module m { + export var a = 10; +} +export import a1 = m.a; +import a2 = m.a; +var x = a1 + a2; +export module m1 { + export import a3 = m.a; + import a4 = m.a; + var x = a1 + a2; + var x2 = a3 + a4; +} +module m2 { + export import a3 = m.a; + import a4 = m.a; + var x = a1 + a2; + var x2 = a3 + a4; + var x4 = m1.a3 + m2.a3; +} + +//// [es6ModuleInternalImport.js] +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; +(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; + var a4 = m.a; + var x = a1 + a2; + var x2 = m2.a3 + a4; + var x4 = m1.a3 + m2.a3; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleInternalImport.types b/tests/baselines/reference/es6ModuleInternalImport.types new file mode 100644 index 00000000000..50db69d8edb --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalImport.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/es6ModuleInternalImport.ts === +export module m { +>m : typeof m + + export var a = 10; +>a : number +} +export import a1 = m.a; +>a1 : number +>m : typeof m +>a : number + +import a2 = m.a; +>a2 : number +>m : typeof m +>a : number + +var x = a1 + a2; +>x : number +>a1 + a2 : number +>a1 : number +>a2 : number + +export module m1 { +>m1 : typeof m1 + + export import a3 = m.a; +>a3 : number +>m : typeof m +>a : number + + import a4 = m.a; +>a4 : number +>m : typeof m +>a : number + + var x = a1 + a2; +>x : number +>a1 + a2 : number +>a1 : number +>a2 : number + + var x2 = a3 + a4; +>x2 : number +>a3 + a4 : number +>a3 : number +>a4 : number +} +module m2 { +>m2 : typeof m2 + + export import a3 = m.a; +>a3 : number +>m : typeof m +>a : number + + import a4 = m.a; +>a4 : number +>m : typeof m +>a : number + + var x = a1 + a2; +>x : number +>a1 + a2 : number +>a1 : number +>a2 : number + + var x2 = a3 + a4; +>x2 : number +>a3 + a4 : number +>a3 : number +>a4 : number + + var x4 = m1.a3 + m2.a3; +>x4 : number +>m1.a3 + m2.a3 : number +>m1.a3 : number +>m1 : typeof m1 +>a3 : number +>m2.a3 : number +>m2 : typeof m2 +>a3 : number +} diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports.js b/tests/baselines/reference/es6ModuleInternalNamedImports.js new file mode 100644 index 00000000000..532025c4ee6 --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalNamedImports.js @@ -0,0 +1,69 @@ +//// [es6ModuleInternalNamedImports.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; + + // 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}; +} + + +//// [es6ModuleInternalNamedImports.js] +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; + // 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 || (M = {})); +export { M }; diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports.types b/tests/baselines/reference/es6ModuleInternalNamedImports.types new file mode 100644 index 00000000000..6b614926a0a --- /dev/null +++ b/tests/baselines/reference/es6ModuleInternalNamedImports.types @@ -0,0 +1,77 @@ +=== 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/es6ModuleLet.js b/tests/baselines/reference/es6ModuleLet.js new file mode 100644 index 00000000000..275fd39579e --- /dev/null +++ b/tests/baselines/reference/es6ModuleLet.js @@ -0,0 +1,38 @@ +//// [es6ModuleLet.ts] +export let a = "hello"; +export let x: string = a, y = x; +let b = y; +let c: string = b, d = c; +export module m1 { + export let k = a; + export let l: string = b, m = k; + let n = m1.k; + let o: string = n, p = k; +} +module m2 { + export let k = a; + export let l: string = b, m = k; + let n = m1.k; + let o: string = n, p = k; +} + +//// [es6ModuleLet.js] +export let a = "hello"; +export let x = a, y = x; +let b = y; +let c = b, d = c; +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; + m2.l = b, m2.m = m2.k; + let n = m1.k; + let o = n, p = m2.k; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleLet.types b/tests/baselines/reference/es6ModuleLet.types new file mode 100644 index 00000000000..4b30c89cc81 --- /dev/null +++ b/tests/baselines/reference/es6ModuleLet.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/es6ModuleLet.ts === +export let a = "hello"; +>a : string + +export let x: string = a, y = x; +>x : string +>a : string +>y : string +>x : string + +let b = y; +>b : string +>y : string + +let c: string = b, d = c; +>c : string +>b : string +>d : string +>c : string + +export module m1 { +>m1 : typeof m1 + + export let k = a; +>k : string +>a : string + + export let l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + let n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + let o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} +module m2 { +>m2 : typeof m2 + + export let k = a; +>k : string +>a : string + + export let l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + let n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + let o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} diff --git a/tests/baselines/reference/es6ModuleModuleDeclaration.js b/tests/baselines/reference/es6ModuleModuleDeclaration.js new file mode 100644 index 00000000000..1e3716ac8c2 --- /dev/null +++ b/tests/baselines/reference/es6ModuleModuleDeclaration.js @@ -0,0 +1,58 @@ +//// [es6ModuleModuleDeclaration.ts] +export module m1 { + export var a = 10; + var b = 10; + export module innerExportedModule { + export var k = 10; + var l = 10; + } + export module innerNonExportedModule { + export var x = 10; + var y = 10; + } +} +module m2 { + export var a = 10; + var b = 10; + export module innerExportedModule { + export var k = 10; + var l = 10; + } + export module innerNonExportedModule { + export var x = 10; + var y = 10; + } +} + +//// [es6ModuleModuleDeclaration.js] +var m1; +(function (m1) { + m1.a = 10; + var b = 10; + var innerExportedModule; + (function (innerExportedModule) { + innerExportedModule.k = 10; + var l = 10; + })(innerExportedModule = m1.innerExportedModule || (m1.innerExportedModule = {})); + var innerNonExportedModule; + (function (innerNonExportedModule) { + innerNonExportedModule.x = 10; + var y = 10; + })(innerNonExportedModule = m1.innerNonExportedModule || (m1.innerNonExportedModule = {})); +})(m1 || (m1 = {})); +export { m1 }; +var m2; +(function (m2) { + m2.a = 10; + var b = 10; + var innerExportedModule; + (function (innerExportedModule) { + innerExportedModule.k = 10; + var l = 10; + })(innerExportedModule = m2.innerExportedModule || (m2.innerExportedModule = {})); + var innerNonExportedModule; + (function (innerNonExportedModule) { + innerNonExportedModule.x = 10; + var y = 10; + })(innerNonExportedModule = m2.innerNonExportedModule || (m2.innerNonExportedModule = {})); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleModuleDeclaration.types b/tests/baselines/reference/es6ModuleModuleDeclaration.types new file mode 100644 index 00000000000..c174fe6f8c7 --- /dev/null +++ b/tests/baselines/reference/es6ModuleModuleDeclaration.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/es6ModuleModuleDeclaration.ts === +export module m1 { +>m1 : typeof m1 + + export var a = 10; +>a : number + + var b = 10; +>b : number + + export module innerExportedModule { +>innerExportedModule : typeof innerExportedModule + + export var k = 10; +>k : number + + var l = 10; +>l : number + } + export module innerNonExportedModule { +>innerNonExportedModule : typeof innerNonExportedModule + + export var x = 10; +>x : number + + var y = 10; +>y : number + } +} +module m2 { +>m2 : typeof m2 + + export var a = 10; +>a : number + + var b = 10; +>b : number + + export module innerExportedModule { +>innerExportedModule : typeof innerExportedModule + + export var k = 10; +>k : number + + var l = 10; +>l : number + } + export module innerNonExportedModule { +>innerNonExportedModule : typeof innerNonExportedModule + + export var x = 10; +>x : number + + var y = 10; +>y : number + } +} diff --git a/tests/baselines/reference/es6ModuleVariableStatement.js b/tests/baselines/reference/es6ModuleVariableStatement.js new file mode 100644 index 00000000000..11b60555b0d --- /dev/null +++ b/tests/baselines/reference/es6ModuleVariableStatement.js @@ -0,0 +1,38 @@ +//// [es6ModuleVariableStatement.ts] +export var a = "hello"; +export var x: string = a, y = x; +var b = y; +var c: string = b, d = c; +export module m1 { + export var k = a; + export var l: string = b, m = k; + var n = m1.k; + var o: string = n, p = k; +} +module m2 { + export var k = a; + export var l: string = b, m = k; + var n = m1.k; + var o: string = n, p = k; +} + +//// [es6ModuleVariableStatement.js] +export var a = "hello"; +export var x = a, y = x; +var b = y; +var c = b, d = c; +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; + m2.l = b, m2.m = m2.k; + var n = m1.k; + var o = n, p = m2.k; +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/es6ModuleVariableStatement.types b/tests/baselines/reference/es6ModuleVariableStatement.types new file mode 100644 index 00000000000..a10d8f6cacb --- /dev/null +++ b/tests/baselines/reference/es6ModuleVariableStatement.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/es6ModuleVariableStatement.ts === +export var a = "hello"; +>a : string + +export var x: string = a, y = x; +>x : string +>a : string +>y : string +>x : string + +var b = y; +>b : string +>y : string + +var c: string = b, d = c; +>c : string +>b : string +>d : string +>c : string + +export module m1 { +>m1 : typeof m1 + + export var k = a; +>k : string +>a : string + + export var l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + var n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + var o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} +module m2 { +>m2 : typeof m2 + + export var k = a; +>k : string +>a : string + + export var l: string = b, m = k; +>l : string +>b : string +>m : string +>k : string + + var n = m1.k; +>n : string +>m1.k : string +>m1 : typeof m1 +>k : string + + var o: string = n, p = k; +>o : string +>n : string +>p : string +>k : string +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt new file mode 100644 index 00000000000..bbe0d8b78b6 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt @@ -0,0 +1,16 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ==== + export class A + { + constructor () + { + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js new file mode 100644 index 00000000000..8757bd1c88f --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js @@ -0,0 +1,21 @@ +//// [es6ModuleWithModuleGenTargetAmd.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es6ModuleWithModuleGenTargetAmd.js] +export class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt new file mode 100644 index 00000000000..87f53cb7810 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt @@ -0,0 +1,16 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. + + +!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ==== + export class A + { + constructor () + { + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js new file mode 100644 index 00000000000..2df98e20826 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js @@ -0,0 +1,21 @@ +//// [es6ModuleWithModuleGenTargetCommonjs.ts] +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} + +//// [es6ModuleWithModuleGenTargetCommonjs.js] +export class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/exportAssignmentEnum.js b/tests/baselines/reference/exportAssignmentEnum.js index 7b9981d9733..a484e43738f 100644 --- a/tests/baselines/reference/exportAssignmentEnum.js +++ b/tests/baselines/reference/exportAssignmentEnum.js @@ -26,6 +26,6 @@ var E; module.exports = E; //// [exportAssignmentEnum_B.js] var EnumE = require("exportAssignmentEnum_A"); -var a = 0 /* A */; -var b = 1 /* B */; -var c = 2 /* C */; +var a = EnumE.A; +var b = EnumE.B; +var c = EnumE.C; diff --git a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js index fe6b80292d5..791fc4fbd7f 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js +++ b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js @@ -34,7 +34,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { var color; - if (color === 1 /* green */) { + if (color === foo.green) { color = foo.answer; } }); diff --git a/tests/baselines/reference/fileWithNextLine1.js b/tests/baselines/reference/fileWithNextLine1.js new file mode 100644 index 00000000000..a89c5b3e207 --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine1.js @@ -0,0 +1,9 @@ +//// [fileWithNextLine1.ts] +// Note: there is a nextline (0x85) in the string +// 0. It should be counted as a space and should not cause an error. +var v = 'Â…'; + +//// [fileWithNextLine1.js] +// Note: there is a nextline (0x85) in the string +// 0. It should be counted as a space and should not cause an error. +var v = 'Â…'; diff --git a/tests/baselines/reference/fileWithNextLine1.types b/tests/baselines/reference/fileWithNextLine1.types new file mode 100644 index 00000000000..721b3d6fb10 --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/fileWithNextLine1.ts === +// Note: there is a nextline (0x85) in the string +// 0. It should be counted as a space and should not cause an error. +var v = 'Â…'; +>v : string + diff --git a/tests/baselines/reference/fileWithNextLine2.js b/tests/baselines/reference/fileWithNextLine2.js new file mode 100644 index 00000000000..439b9bd42f9 --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine2.js @@ -0,0 +1,9 @@ +//// [fileWithNextLine2.ts] +// Note: there is a nextline (0x85) char between the = and the 0. +// it should be treated like a space +var v =Â…0; + +//// [fileWithNextLine2.js] +// Note: there is a nextline (0x85) char between the = and the 0. +// it should be treated like a space +var v = 0; diff --git a/tests/baselines/reference/fileWithNextLine2.types b/tests/baselines/reference/fileWithNextLine2.types new file mode 100644 index 00000000000..8a6de1a4b2f --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine2.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/fileWithNextLine2.ts === +// Note: there is a nextline (0x85) char between the = and the 0. +// it should be treated like a space +var v =Â…0; +>v : number + diff --git a/tests/baselines/reference/fileWithNextLine3.errors.txt b/tests/baselines/reference/fileWithNextLine3.errors.txt new file mode 100644 index 00000000000..647ec722549 --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine3.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/fileWithNextLine3.ts(3,1): error TS1108: A 'return' statement can only be used within a function body. + + +==== tests/cases/compiler/fileWithNextLine3.ts (1 errors) ==== + // Note: there is a nextline (0x85) between the return and the + // 0. It should be counted as a space and should not trigger ASI + returnÂ…0; + ~~~~~~ +!!! error TS1108: A 'return' statement can only be used within a function body. \ No newline at end of file diff --git a/tests/baselines/reference/fileWithNextLine3.js b/tests/baselines/reference/fileWithNextLine3.js new file mode 100644 index 00000000000..c1d4204bcae --- /dev/null +++ b/tests/baselines/reference/fileWithNextLine3.js @@ -0,0 +1,9 @@ +//// [fileWithNextLine3.ts] +// Note: there is a nextline (0x85) between the return and the +// 0. It should be counted as a space and should not trigger ASI +returnÂ…0; + +//// [fileWithNextLine3.js] +// Note: there is a nextline (0x85) between the return and the +// 0. It should be counted as a space and should not trigger ASI +return 0; diff --git a/tests/baselines/reference/for-inStatements.js b/tests/baselines/reference/for-inStatements.js index 08ef1dbcccd..3787887923c 100644 --- a/tests/baselines/reference/for-inStatements.js +++ b/tests/baselines/reference/for-inStatements.js @@ -200,5 +200,5 @@ var Color; })(Color || (Color = {})); for (var x in Color) { } -for (var x in 1 /* Blue */) { +for (var x in Color.Blue) { } diff --git a/tests/baselines/reference/for-of47.js b/tests/baselines/reference/for-of47.js index f5e03dce571..f1e9295c367 100644 --- a/tests/baselines/reference/for-of47.js +++ b/tests/baselines/reference/for-of47.js @@ -21,7 +21,7 @@ var E; })(E || (E = {})); for ({ x, - y: y = 0 /* x */ + y: y = E.x } of array) { x; y; diff --git a/tests/baselines/reference/for-of48.js b/tests/baselines/reference/for-of48.js index 3b96f460e97..3030f07e605 100644 --- a/tests/baselines/reference/for-of48.js +++ b/tests/baselines/reference/for-of48.js @@ -21,7 +21,7 @@ var E; })(E || (E = {})); for ({ x, - y: = 0 /* x */ + y: = E.x } of array) { x; y; diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js index 4c0d57b9acf..758852a918b 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.js @@ -125,10 +125,10 @@ var onlyT; var r; return r; } - var r7 = foo3(0 /* A */, function (x) { - return 0 /* A */; + var r7 = foo3(E.A, function (x) { + return E.A; }, function (x) { - return 0 /* A */; + return F.A; }); // error })(onlyT || (onlyT = {})); var TU; @@ -179,9 +179,9 @@ var TU; var r; return r; } - var r7 = foo3(0 /* A */, function (x) { - return 0 /* A */; + var r7 = foo3(E.A, function (x) { + return E.A; }, function (x) { - return 0 /* A */; + return F.A; }); })(TU || (TU = {})); diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js index 8f691d936ec..b7cc833b9d9 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.js @@ -78,10 +78,10 @@ var F; (function (F) { F[F["A"] = 0] = "A"; })(F || (F = {})); -var r6 = foo(0 /* A */, function (x) { - return 0 /* A */; +var r6 = foo(E.A, function (x) { + return E.A; }, function (x) { - return 0 /* A */; + return F.A; }); // number => number function foo2(x, a, b) { var r; diff --git a/tests/baselines/reference/inOperatorWithInvalidOperands.js b/tests/baselines/reference/inOperatorWithInvalidOperands.js index 29293f880ed..005681b6285 100644 --- a/tests/baselines/reference/inOperatorWithInvalidOperands.js +++ b/tests/baselines/reference/inOperatorWithInvalidOperands.js @@ -61,7 +61,7 @@ var ra3 = a3 in x; var ra4 = a4 in x; var ra5 = null in x; var ra6 = undefined in x; -var ra7 = 0 /* a */ in x; +var ra7 = E.a in x; var ra8 = false in x; var ra9 = {} in x; // invalid right operands diff --git a/tests/baselines/reference/incrementAndDecrement.js b/tests/baselines/reference/incrementAndDecrement.js index 96794e3c956..09c0b3ae490 100644 --- a/tests/baselines/reference/incrementAndDecrement.js +++ b/tests/baselines/reference/incrementAndDecrement.js @@ -70,7 +70,7 @@ var E; })(E || (E = {})); ; var x = 4; -var e = 1 /* B */; +var e = E.B; var a; var w = window; // Assign to expression++ diff --git a/tests/baselines/reference/incrementOperatorWithEnumType.js b/tests/baselines/reference/incrementOperatorWithEnumType.js index 590815ffec5..e3e843a45da 100644 --- a/tests/baselines/reference/incrementOperatorWithEnumType.js +++ b/tests/baselines/reference/incrementOperatorWithEnumType.js @@ -22,8 +22,8 @@ var ENUM1; })(ENUM1 || (ENUM1 = {})); ; // expression -var ResultIsNumber1 = ++1 /* "B" */; -var ResultIsNumber2 = 1 /* B */++; +var ResultIsNumber1 = ++ENUM1["B"]; +var ResultIsNumber2 = ENUM1.B++; // miss assignment operator -++1 /* "B" */; -1 /* B */++; +++ENUM1["B"]; +ENUM1.B++; diff --git a/tests/baselines/reference/instantiatedModule.js b/tests/baselines/reference/instantiatedModule.js index 7993628f898..2b1871aea9d 100644 --- a/tests/baselines/reference/instantiatedModule.js +++ b/tests/baselines/reference/instantiatedModule.js @@ -115,7 +115,7 @@ var m3 = M3; var a3; var a3 = m3.Color; var a3 = M3.Color; -var blue = 0 /* Blue */; +var blue = a3.Blue; var p3; -var p3 = 1 /* Red */; -var p3 = 0 /* Blue */; +var p3 = M3.Color.Red; +var p3 = m3.Color.Blue; diff --git a/tests/baselines/reference/interfaceAssignmentCompat.js b/tests/baselines/reference/interfaceAssignmentCompat.js index dbad8eabd78..7ddd22ee863 100644 --- a/tests/baselines/reference/interfaceAssignmentCompat.js +++ b/tests/baselines/reference/interfaceAssignmentCompat.js @@ -73,13 +73,13 @@ var M; var x = []; var result = ""; x[0] = { - color: 2 /* Brown */ + color: Color.Brown }; x[1] = { - color: 1 /* Blue */ + color: Color.Blue }; x[2] = { - color: 0 /* Green */ + color: Color.Green }; x = x.sort(CompareYeux); // parameter mismatch // type of z inferred from specialized array type diff --git a/tests/baselines/reference/interfaceWithPropertyOfEveryType.js b/tests/baselines/reference/interfaceWithPropertyOfEveryType.js index 4f8d8919563..e10b83297bc 100644 --- a/tests/baselines/reference/interfaceWithPropertyOfEveryType.js +++ b/tests/baselines/reference/interfaceWithPropertyOfEveryType.js @@ -79,5 +79,5 @@ var a = { l: f1, m: M, n: {}, - o: 0 /* A */ + o: E.A }; diff --git a/tests/baselines/reference/internalAliasEnum.js b/tests/baselines/reference/internalAliasEnum.js index b5c68ea5c16..6400cf26ddc 100644 --- a/tests/baselines/reference/internalAliasEnum.js +++ b/tests/baselines/reference/internalAliasEnum.js @@ -26,7 +26,7 @@ var a; var c; (function (c) { var b = a.weekend; - c.bVal = 2 /* Sunday */; + c.bVal = b.Sunday; })(c || (c = {})); diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js index e21dd355322..f2223b197e0 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js @@ -26,7 +26,7 @@ var a; var c; (function (c) { c.b = a.weekend; - c.bVal = 2 /* Sunday */; + c.bVal = c.b.Sunday; })(c = exports.c || (exports.c = {})); diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js index 3d60e055ede..afd6597869b 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js @@ -26,7 +26,7 @@ var a; var c; (function (c) { var b = a.weekend; - c.bVal = 2 /* Sunday */; + c.bVal = b.Sunday; })(c = exports.c || (exports.c = {})); diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js index f050d6f9a55..acd3f4c61b1 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js @@ -27,6 +27,6 @@ var a; var c; (function (c) { var b = a.weekend; - c.bVal = 2 /* Sunday */; + c.bVal = b.Sunday; })(c = exports.c || (exports.c = {})); var happyFriday = c.b.Friday; diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js index e4dc73b2403..96e17c6f6e3 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js @@ -23,7 +23,7 @@ define(["require", "exports"], function (require, exports) { var weekend = a.weekend; })(a = exports.a || (exports.a = {})); exports.b = a.weekend; - exports.bVal = 2 /* Sunday */; + exports.bVal = exports.b.Sunday; }); diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js index e81093147e8..b224c22f45e 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js @@ -23,7 +23,7 @@ define(["require", "exports"], function (require, exports) { var weekend = a.weekend; })(a = exports.a || (exports.a = {})); var b = a.weekend; - exports.bVal = 2 /* Sunday */; + exports.bVal = b.Sunday; }); diff --git a/tests/baselines/reference/invalidEnumAssignments.js b/tests/baselines/reference/invalidEnumAssignments.js index b9bb9e12ced..dfdd0600ed0 100644 --- a/tests/baselines/reference/invalidEnumAssignments.js +++ b/tests/baselines/reference/invalidEnumAssignments.js @@ -35,8 +35,8 @@ var E2; })(E2 || (E2 = {})); var e; var e2; -e = 0 /* A */; -e2 = 0 /* A */; +e = E2.A; +e2 = E.A; e = null; e = {}; e = ''; diff --git a/tests/baselines/reference/invalidUndefinedAssignments.js b/tests/baselines/reference/invalidUndefinedAssignments.js index 0b37316e085..7617e5eae8e 100644 --- a/tests/baselines/reference/invalidUndefinedAssignments.js +++ b/tests/baselines/reference/invalidUndefinedAssignments.js @@ -28,7 +28,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); E = x; -0 /* A */ = x; +E.A = x; var C = (function () { function C() { } diff --git a/tests/baselines/reference/invalidUndefinedValues.js b/tests/baselines/reference/invalidUndefinedValues.js index b4751cf25d8..9361f43bbae 100644 --- a/tests/baselines/reference/invalidUndefinedValues.js +++ b/tests/baselines/reference/invalidUndefinedValues.js @@ -67,4 +67,4 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = 0 /* A */; +x = E.A; diff --git a/tests/baselines/reference/invalidVoidAssignments.js b/tests/baselines/reference/invalidVoidAssignments.js index c8c395b0e4f..b821b0ca796 100644 --- a/tests/baselines/reference/invalidVoidAssignments.js +++ b/tests/baselines/reference/invalidVoidAssignments.js @@ -58,7 +58,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = 0 /* A */; +x = E.A; x = { f: function () { } diff --git a/tests/baselines/reference/invalidVoidValues.js b/tests/baselines/reference/invalidVoidValues.js index 6740eb3fc1b..13f2d681f26 100644 --- a/tests/baselines/reference/invalidVoidValues.js +++ b/tests/baselines/reference/invalidVoidValues.js @@ -36,7 +36,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = 0 /* A */; +x = E.A; var C = (function () { function C() { } diff --git a/tests/baselines/reference/localImportNameVsGlobalName.js b/tests/baselines/reference/localImportNameVsGlobalName.js index f27e7d648d1..8ba7ec567a0 100644 --- a/tests/baselines/reference/localImportNameVsGlobalName.js +++ b/tests/baselines/reference/localImportNameVsGlobalName.js @@ -30,7 +30,7 @@ var App; function foo(key) { } App.foo = foo; - foo(0 /* UP */); - foo(1 /* DOWN */); - foo(2 /* LEFT */); + foo(Key.UP); + foo(Key.DOWN); + foo(Key.LEFT); })(App || (App = {})); diff --git a/tests/baselines/reference/logicalNotOperatorWithEnumType.js b/tests/baselines/reference/logicalNotOperatorWithEnumType.js index 89ee1a14833..382cf577713 100644 --- a/tests/baselines/reference/logicalNotOperatorWithEnumType.js +++ b/tests/baselines/reference/logicalNotOperatorWithEnumType.js @@ -37,13 +37,13 @@ var ENUM1; // enum type var var ResultIsBoolean1 = !ENUM; // enum type expressions -var ResultIsBoolean2 = !1 /* "B" */; -var ResultIsBoolean3 = !(1 /* B */ + 2 /* "C" */); +var ResultIsBoolean2 = !ENUM["B"]; +var ResultIsBoolean3 = !(ENUM.B + ENUM["C"]); // multiple ! operators var ResultIsBoolean4 = !!ENUM; -var ResultIsBoolean5 = !!!(1 /* "B" */ + 2 /* C */); +var ResultIsBoolean5 = !!!(ENUM["B"] + ENUM.C); // miss assignment operators !ENUM; !ENUM1; -!1 /* B */; +!ENUM.B; !ENUM, ENUM1; diff --git a/tests/baselines/reference/mergedDeclarations2.js b/tests/baselines/reference/mergedDeclarations2.js index 1e9254bb0bb..962346541cc 100644 --- a/tests/baselines/reference/mergedDeclarations2.js +++ b/tests/baselines/reference/mergedDeclarations2.js @@ -17,7 +17,7 @@ var Foo; })(Foo || (Foo = {})); var Foo; (function (Foo) { - Foo[Foo["a"] = Foo.b] = "a"; + Foo[Foo["a"] = 0] = "a"; })(Foo || (Foo = {})); var Foo; (function (Foo) { diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.js b/tests/baselines/reference/mergedEnumDeclarationCodeGen.js index 574ef6fa2d0..57b6e8051f8 100644 --- a/tests/baselines/reference/mergedEnumDeclarationCodeGen.js +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.js @@ -11,9 +11,9 @@ enum E { var E; (function (E) { E[E["a"] = 0] = "a"; - E[E["b"] = E.a] = "b"; + E[E["b"] = 0] = "b"; })(E || (E = {})); var E; (function (E) { - E[E["c"] = E.a] = "c"; + E[E["c"] = 0] = "c"; })(E || (E = {})); diff --git a/tests/baselines/reference/moduleCodeGenTest5.js b/tests/baselines/reference/moduleCodeGenTest5.js index 6f5f0a4e912..6f56f44c684 100644 --- a/tests/baselines/reference/moduleCodeGenTest5.js +++ b/tests/baselines/reference/moduleCodeGenTest5.js @@ -50,9 +50,9 @@ var C2 = (function () { E1[E1["A"] = 0] = "A"; })(exports.E1 || (exports.E1 = {})); var E1 = exports.E1; -var u = 0 /* A */; +var u = E1.A; var E2; (function (E2) { E2[E2["B"] = 0] = "B"; })(E2 || (E2 = {})); -var v = 0 /* B */; +var v = E2.B; diff --git a/tests/baselines/reference/moduleVisibilityTest1.js b/tests/baselines/reference/moduleVisibilityTest1.js index d8bdedfafe2..8f129f545de 100644 --- a/tests/baselines/reference/moduleVisibilityTest1.js +++ b/tests/baselines/reference/moduleVisibilityTest1.js @@ -137,11 +137,11 @@ var M; var M; (function (M) { M.c = M.x; - M.meb = 1 /* B */; + M.meb = M.E.B; })(M || (M = {})); var cprime = null; var c = new M.C(); var z = M.x; -var alpha = 0 /* A */; +var alpha = M.E.A; var omega = M.exported_var; c.someMethodThatCallsAnOuterMethod(); diff --git a/tests/baselines/reference/negateOperatorWithEnumType.js b/tests/baselines/reference/negateOperatorWithEnumType.js index 77458f442df..e33e7811077 100644 --- a/tests/baselines/reference/negateOperatorWithEnumType.js +++ b/tests/baselines/reference/negateOperatorWithEnumType.js @@ -33,10 +33,10 @@ var ENUM1; // enum type var var ResultIsNumber1 = -ENUM; // expressions -var ResultIsNumber2 = -1 /* "B" */; -var ResultIsNumber3 = -(1 /* B */ + 2 /* "" */); +var ResultIsNumber2 = -ENUM1["B"]; +var ResultIsNumber3 = -(ENUM1.B + ENUM1[""]); // miss assignment operators -ENUM; -ENUM1; --1 /* "B" */; +-ENUM1["B"]; -ENUM, ENUM1; diff --git a/tests/baselines/reference/noImplicitAnyIndexing.js b/tests/baselines/reference/noImplicitAnyIndexing.js index 91dbcae730c..8451a1426a6 100644 --- a/tests/baselines/reference/noImplicitAnyIndexing.js +++ b/tests/baselines/reference/noImplicitAnyIndexing.js @@ -57,11 +57,11 @@ var MyEmusEnum; // Should be okay; should be a string. var strRepresentation1 = MyEmusEnum[0]; // Should be okay; should be a string. -var strRepresentation2 = MyEmusEnum[0 /* emu */]; +var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]; // Should be implicit 'any' ; property access fails, no string indexer. var strRepresentation3 = MyEmusEnum["monehh"]; // Should be okay; should be a MyEmusEnum -var strRepresentation4 = 0 /* "emu" */; +var strRepresentation4 = MyEmusEnum["emu"]; // Should report an implicit 'any'. var x = {}["hi"]; // Should report an implicit 'any'. @@ -77,6 +77,6 @@ var m = { "2": 2, "Okay that's enough for today.": NaN }; -var mResult1 = m[0 /* emu */]; -var mResult2 = m[MyEmusEnum[0 /* emu */]]; +var mResult1 = m[MyEmusEnum.emu]; +var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; var mResult3 = m[hi]; diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js index 5185a9b8db8..6d91d8eb838 100644 --- a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js @@ -56,11 +56,11 @@ var MyEmusEnum; // Should be okay; should be a string. var strRepresentation1 = MyEmusEnum[0]; // Should be okay; should be a string. -var strRepresentation2 = MyEmusEnum[0 /* emu */]; +var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]; // Should be okay, as we suppress implicit 'any' property access checks var strRepresentation3 = MyEmusEnum["monehh"]; // Should be okay; should be a MyEmusEnum -var strRepresentation4 = 0 /* "emu" */; +var strRepresentation4 = MyEmusEnum["emu"]; // Should be okay, as we suppress implicit 'any' property access checks var x = {}["hi"]; // Should be okay, as we suppress implicit 'any' property access checks @@ -76,6 +76,6 @@ var m = { "2": 2, "Okay that's enough for today.": NaN }; -var mResult1 = m[0 /* emu */]; -var mResult2 = m[MyEmusEnum[0 /* emu */]]; +var mResult1 = m[MyEmusEnum.emu]; +var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; var mResult3 = m[hi]; diff --git a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.js b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.js index f69fe668f34..b47a591444c 100644 --- a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.js +++ b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.js @@ -149,8 +149,8 @@ var E; })(E || (E = {})); var r13 = true ? E : null; var r13 = true ? null : E; -var r14 = true ? 0 /* A */ : null; -var r14 = true ? null : 0 /* A */; +var r14 = true ? E.A : null; +var r14 = true ? null : E.A; function f() { } var f; diff --git a/tests/baselines/reference/objectTypesIdentity2.js b/tests/baselines/reference/objectTypesIdentity2.js index bdd20d8ac5e..f721fb04b52 100644 --- a/tests/baselines/reference/objectTypesIdentity2.js +++ b/tests/baselines/reference/objectTypesIdentity2.js @@ -88,7 +88,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var b = { - foo: 0 /* A */ + foo: E.A }; function foo5(x) { } diff --git a/tests/baselines/reference/operatorAddNullUndefined.js b/tests/baselines/reference/operatorAddNullUndefined.js index f6b4fd240b2..4d52dbb234c 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.js +++ b/tests/baselines/reference/operatorAddNullUndefined.js @@ -34,7 +34,7 @@ var x9 = "test" + null; var x10 = "test" + undefined; var x11 = null + "test"; var x12 = undefined + "test"; -var x13 = null + 0 /* x */; -var x14 = undefined + 0 /* x */; -var x15 = 0 /* x */ + null; -var x16 = 0 /* x */ + undefined; +var x13 = null + E.x; +var x14 = undefined + E.x; +var x15 = E.x + null; +var x16 = E.x + undefined; diff --git a/tests/baselines/reference/parserEnum1.js b/tests/baselines/reference/parserEnum1.js index 8bd9d128233..3b71eee5e49 100644 --- a/tests/baselines/reference/parserEnum1.js +++ b/tests/baselines/reference/parserEnum1.js @@ -12,7 +12,7 @@ (function (SignatureFlags) { SignatureFlags[SignatureFlags["None"] = 0] = "None"; SignatureFlags[SignatureFlags["IsIndexer"] = 1] = "IsIndexer"; - SignatureFlags[SignatureFlags["IsStringIndexer"] = 1 << 1] = "IsStringIndexer"; - SignatureFlags[SignatureFlags["IsNumberIndexer"] = 1 << 2] = "IsNumberIndexer"; + SignatureFlags[SignatureFlags["IsStringIndexer"] = 2] = "IsStringIndexer"; + SignatureFlags[SignatureFlags["IsNumberIndexer"] = 4] = "IsNumberIndexer"; })(exports.SignatureFlags || (exports.SignatureFlags = {})); var SignatureFlags = exports.SignatureFlags; diff --git a/tests/baselines/reference/parserEnum2.js b/tests/baselines/reference/parserEnum2.js index 22946153449..9a49b145954 100644 --- a/tests/baselines/reference/parserEnum2.js +++ b/tests/baselines/reference/parserEnum2.js @@ -12,7 +12,7 @@ (function (SignatureFlags) { SignatureFlags[SignatureFlags["None"] = 0] = "None"; SignatureFlags[SignatureFlags["IsIndexer"] = 1] = "IsIndexer"; - SignatureFlags[SignatureFlags["IsStringIndexer"] = 1 << 1] = "IsStringIndexer"; - SignatureFlags[SignatureFlags["IsNumberIndexer"] = 1 << 2] = "IsNumberIndexer"; + SignatureFlags[SignatureFlags["IsStringIndexer"] = 2] = "IsStringIndexer"; + SignatureFlags[SignatureFlags["IsNumberIndexer"] = 4] = "IsNumberIndexer"; })(exports.SignatureFlags || (exports.SignatureFlags = {})); var SignatureFlags = exports.SignatureFlags; diff --git a/tests/baselines/reference/parserEnumDeclaration6.js b/tests/baselines/reference/parserEnumDeclaration6.js index 5810ffc0620..a29226fbd1d 100644 --- a/tests/baselines/reference/parserEnumDeclaration6.js +++ b/tests/baselines/reference/parserEnumDeclaration6.js @@ -11,6 +11,6 @@ var E; (function (E) { E[E["A"] = 1] = "A"; E[E["B"] = 2] = "B"; - E[E["C"] = 1 << 1] = "C"; - E[E["D"] = undefined] = "D"; + E[E["C"] = 2] = "C"; + E[E["D"] = 3] = "D"; })(E || (E = {})); diff --git a/tests/baselines/reference/parserRealSource10.js b/tests/baselines/reference/parserRealSource10.js index 0dd944a7721..871b9019edc 100644 --- a/tests/baselines/reference/parserRealSource10.js +++ b/tests/baselines/reference/parserRealSource10.js @@ -583,26 +583,26 @@ var TypeScript; TokenID[TokenID["Whitespace"] = 110] = "Whitespace"; TokenID[TokenID["Comment"] = 111] = "Comment"; TokenID[TokenID["Lim"] = 112] = "Lim"; - TokenID[TokenID["LimFixed"] = TokenID.EqualsGreaterThan] = "LimFixed"; - TokenID[TokenID["LimKeyword"] = TokenID.Yield] = "LimKeyword"; + TokenID[TokenID["LimFixed"] = 105] = "LimFixed"; + TokenID[TokenID["LimKeyword"] = 53] = "LimKeyword"; })(TypeScript.TokenID || (TypeScript.TokenID = {})); var TokenID = TypeScript.TokenID; TypeScript.tokenTable = new TokenInfo[]; TypeScript.nodeTypeTable = new string[]; TypeScript.nodeTypeToTokTable = new number[]; TypeScript.noRegexTable = new boolean[]; - TypeScript.noRegexTable[106 /* Identifier */] = true; - TypeScript.noRegexTable[107 /* StringLiteral */] = true; - TypeScript.noRegexTable[109 /* NumberLiteral */] = true; - TypeScript.noRegexTable[108 /* RegularExpressionLiteral */] = true; - TypeScript.noRegexTable[44 /* This */] = true; - TypeScript.noRegexTable[99 /* PlusPlus */] = true; - TypeScript.noRegexTable[100 /* MinusMinus */] = true; - TypeScript.noRegexTable[56 /* CloseParen */] = true; - TypeScript.noRegexTable[58 /* CloseBracket */] = true; - TypeScript.noRegexTable[60 /* CloseBrace */] = true; - TypeScript.noRegexTable[46 /* True */] = true; - TypeScript.noRegexTable[17 /* False */] = true; + TypeScript.noRegexTable[TokenID.Identifier] = true; + TypeScript.noRegexTable[TokenID.StringLiteral] = true; + TypeScript.noRegexTable[TokenID.NumberLiteral] = true; + TypeScript.noRegexTable[TokenID.RegularExpressionLiteral] = true; + TypeScript.noRegexTable[TokenID.This] = true; + TypeScript.noRegexTable[TokenID.PlusPlus] = true; + TypeScript.noRegexTable[TokenID.MinusMinus] = true; + TypeScript.noRegexTable[TokenID.CloseParen] = true; + TypeScript.noRegexTable[TokenID.CloseBracket] = true; + TypeScript.noRegexTable[TokenID.CloseBrace] = true; + TypeScript.noRegexTable[TokenID.True] = true; + TypeScript.noRegexTable[TokenID.False] = true; (function (OperatorPrecedence) { OperatorPrecedence[OperatorPrecedence["None"] = 0] = "None"; OperatorPrecedence[OperatorPrecedence["Comma"] = 1] = "Comma"; @@ -628,9 +628,9 @@ var TypeScript; Reservation[Reservation["JavascriptFuture"] = 2] = "JavascriptFuture"; Reservation[Reservation["TypeScript"] = 4] = "TypeScript"; Reservation[Reservation["JavascriptFutureStrict"] = 8] = "JavascriptFutureStrict"; - Reservation[Reservation["TypeScriptAndJS"] = Reservation.Javascript | Reservation.TypeScript] = "TypeScriptAndJS"; - Reservation[Reservation["TypeScriptAndJSFuture"] = Reservation.JavascriptFuture | Reservation.TypeScript] = "TypeScriptAndJSFuture"; - Reservation[Reservation["TypeScriptAndJSFutureStrict"] = Reservation.JavascriptFutureStrict | Reservation.TypeScript] = "TypeScriptAndJSFutureStrict"; + Reservation[Reservation["TypeScriptAndJS"] = 5] = "TypeScriptAndJS"; + Reservation[Reservation["TypeScriptAndJSFuture"] = 6] = "TypeScriptAndJSFuture"; + Reservation[Reservation["TypeScriptAndJSFutureStrict"] = 12] = "TypeScriptAndJSFutureStrict"; })(TypeScript.Reservation || (TypeScript.Reservation = {})); var Reservation = TypeScript.Reservation; var TokenInfo = (function () { @@ -659,117 +659,117 @@ var TypeScript; } } } - setTokenInfo(0 /* Any */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "any", ErrorRecoverySet.PrimType); - setTokenInfo(1 /* Bool */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "boolean", ErrorRecoverySet.PrimType); - setTokenInfo(2 /* Break */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "break", ErrorRecoverySet.Stmt); - setTokenInfo(3 /* Case */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "case", ErrorRecoverySet.SCase); - setTokenInfo(4 /* Catch */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "catch", ErrorRecoverySet.Catch); - setTokenInfo(5 /* Class */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "class", ErrorRecoverySet.TypeScriptS); - setTokenInfo(6 /* Const */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "const", ErrorRecoverySet.Var); - setTokenInfo(7 /* Continue */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "continue", ErrorRecoverySet.Stmt); - setTokenInfo(8 /* Debugger */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.Debugger, "debugger", ErrorRecoverySet.Stmt); - setTokenInfo(9 /* Default */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "default", ErrorRecoverySet.SCase); - setTokenInfo(10 /* Delete */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.Delete, "delete", ErrorRecoverySet.Prefix); - setTokenInfo(11 /* Do */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "do", ErrorRecoverySet.Stmt); - setTokenInfo(12 /* Else */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "else", ErrorRecoverySet.Else); - setTokenInfo(13 /* Enum */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "enum", ErrorRecoverySet.TypeScriptS); - setTokenInfo(14 /* Export */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "export", ErrorRecoverySet.TypeScriptS); - setTokenInfo(15 /* Extends */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "extends", ErrorRecoverySet.None); - setTokenInfo(16 /* Declare */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "declare", ErrorRecoverySet.Stmt); - setTokenInfo(17 /* False */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "false", ErrorRecoverySet.RLit); - setTokenInfo(18 /* Finally */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "finally", ErrorRecoverySet.Catch); - setTokenInfo(19 /* For */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "for", ErrorRecoverySet.Stmt); - setTokenInfo(20 /* Function */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "function", ErrorRecoverySet.Func); - setTokenInfo(21 /* Constructor */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "constructor", ErrorRecoverySet.Func); - setTokenInfo(22 /* Get */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "get", ErrorRecoverySet.Func); - setTokenInfo(39 /* Set */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "set", ErrorRecoverySet.Func); - setTokenInfo(23 /* If */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "if", ErrorRecoverySet.Stmt); - setTokenInfo(24 /* Implements */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "implements", ErrorRecoverySet.None); - setTokenInfo(25 /* Import */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "import", ErrorRecoverySet.TypeScriptS); - setTokenInfo(26 /* In */, Reservation.TypeScriptAndJS, 10 /* Relational */, NodeType.In, 0 /* None */, NodeType.None, "in", ErrorRecoverySet.None); - setTokenInfo(27 /* InstanceOf */, Reservation.TypeScriptAndJS, 10 /* Relational */, NodeType.InstOf, 0 /* None */, NodeType.None, "instanceof", ErrorRecoverySet.BinOp); - setTokenInfo(28 /* Interface */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "interface", ErrorRecoverySet.TypeScriptS); - setTokenInfo(29 /* Let */, 8 /* JavascriptFutureStrict */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "let", ErrorRecoverySet.None); - setTokenInfo(30 /* Module */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "module", ErrorRecoverySet.TypeScriptS); - setTokenInfo(31 /* New */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "new", ErrorRecoverySet.PreOp); - setTokenInfo(32 /* Number */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "number", ErrorRecoverySet.PrimType); - setTokenInfo(33 /* Null */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "null", ErrorRecoverySet.RLit); - setTokenInfo(34 /* Package */, 8 /* JavascriptFutureStrict */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "package", ErrorRecoverySet.None); - setTokenInfo(35 /* Private */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "private", ErrorRecoverySet.TypeScriptS); - setTokenInfo(36 /* Protected */, 8 /* JavascriptFutureStrict */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "protected", ErrorRecoverySet.None); - setTokenInfo(37 /* Public */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "public", ErrorRecoverySet.TypeScriptS); - setTokenInfo(38 /* Return */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "return", ErrorRecoverySet.Stmt); - setTokenInfo(40 /* Static */, Reservation.TypeScriptAndJSFutureStrict, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "static", ErrorRecoverySet.None); - setTokenInfo(41 /* String */, 4 /* TypeScript */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "string", ErrorRecoverySet.PrimType); - setTokenInfo(42 /* Super */, Reservation.TypeScriptAndJSFuture, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "super", ErrorRecoverySet.RLit); - setTokenInfo(43 /* Switch */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "switch", ErrorRecoverySet.Stmt); - setTokenInfo(44 /* This */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "this", ErrorRecoverySet.RLit); - setTokenInfo(45 /* Throw */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "throw", ErrorRecoverySet.Stmt); - setTokenInfo(46 /* True */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "true", ErrorRecoverySet.RLit); - setTokenInfo(47 /* Try */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "try", ErrorRecoverySet.Stmt); - setTokenInfo(48 /* TypeOf */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.Typeof, "typeof", ErrorRecoverySet.Prefix); - setTokenInfo(49 /* Var */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "var", ErrorRecoverySet.Var); - setTokenInfo(50 /* Void */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.Void, "void", ErrorRecoverySet.Prefix); - setTokenInfo(51 /* With */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.With, "with", ErrorRecoverySet.Stmt); - setTokenInfo(52 /* While */, Reservation.TypeScriptAndJS, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "while", ErrorRecoverySet.While); - setTokenInfo(53 /* Yield */, 8 /* JavascriptFutureStrict */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "yield", ErrorRecoverySet.None); - setTokenInfo(106 /* Identifier */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "identifier", ErrorRecoverySet.ID); - setTokenInfo(109 /* NumberLiteral */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "numberLiteral", ErrorRecoverySet.Literal); - setTokenInfo(108 /* RegularExpressionLiteral */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "regex", ErrorRecoverySet.RegExp); - setTokenInfo(107 /* StringLiteral */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "qstring", ErrorRecoverySet.Literal); + setTokenInfo(TokenID.Any, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "any", ErrorRecoverySet.PrimType); + setTokenInfo(TokenID.Bool, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "boolean", ErrorRecoverySet.PrimType); + setTokenInfo(TokenID.Break, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "break", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Case, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "case", ErrorRecoverySet.SCase); + setTokenInfo(TokenID.Catch, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "catch", ErrorRecoverySet.Catch); + setTokenInfo(TokenID.Class, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "class", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Const, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "const", ErrorRecoverySet.Var); + setTokenInfo(TokenID.Continue, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "continue", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Debugger, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.Debugger, "debugger", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Default, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "default", ErrorRecoverySet.SCase); + setTokenInfo(TokenID.Delete, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.Delete, "delete", ErrorRecoverySet.Prefix); + setTokenInfo(TokenID.Do, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "do", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Else, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "else", ErrorRecoverySet.Else); + setTokenInfo(TokenID.Enum, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "enum", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Export, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "export", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Extends, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "extends", ErrorRecoverySet.None); + setTokenInfo(TokenID.Declare, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "declare", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.False, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "false", ErrorRecoverySet.RLit); + setTokenInfo(TokenID.Finally, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "finally", ErrorRecoverySet.Catch); + setTokenInfo(TokenID.For, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "for", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Function, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "function", ErrorRecoverySet.Func); + setTokenInfo(TokenID.Constructor, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "constructor", ErrorRecoverySet.Func); + setTokenInfo(TokenID.Get, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "get", ErrorRecoverySet.Func); + setTokenInfo(TokenID.Set, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "set", ErrorRecoverySet.Func); + setTokenInfo(TokenID.If, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "if", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Implements, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "implements", ErrorRecoverySet.None); + setTokenInfo(TokenID.Import, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "import", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.In, Reservation.TypeScriptAndJS, OperatorPrecedence.Relational, NodeType.In, OperatorPrecedence.None, NodeType.None, "in", ErrorRecoverySet.None); + setTokenInfo(TokenID.InstanceOf, Reservation.TypeScriptAndJS, OperatorPrecedence.Relational, NodeType.InstOf, OperatorPrecedence.None, NodeType.None, "instanceof", ErrorRecoverySet.BinOp); + setTokenInfo(TokenID.Interface, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "interface", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Let, Reservation.JavascriptFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "let", ErrorRecoverySet.None); + setTokenInfo(TokenID.Module, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "module", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.New, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "new", ErrorRecoverySet.PreOp); + setTokenInfo(TokenID.Number, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "number", ErrorRecoverySet.PrimType); + setTokenInfo(TokenID.Null, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "null", ErrorRecoverySet.RLit); + setTokenInfo(TokenID.Package, Reservation.JavascriptFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "package", ErrorRecoverySet.None); + setTokenInfo(TokenID.Private, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "private", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Protected, Reservation.JavascriptFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "protected", ErrorRecoverySet.None); + setTokenInfo(TokenID.Public, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "public", ErrorRecoverySet.TypeScriptS); + setTokenInfo(TokenID.Return, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "return", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.Static, Reservation.TypeScriptAndJSFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "static", ErrorRecoverySet.None); + setTokenInfo(TokenID.String, Reservation.TypeScript, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "string", ErrorRecoverySet.PrimType); + setTokenInfo(TokenID.Super, Reservation.TypeScriptAndJSFuture, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "super", ErrorRecoverySet.RLit); + setTokenInfo(TokenID.Switch, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "switch", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.This, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "this", ErrorRecoverySet.RLit); + setTokenInfo(TokenID.Throw, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "throw", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.True, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "true", ErrorRecoverySet.RLit); + setTokenInfo(TokenID.Try, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "try", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.TypeOf, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.Typeof, "typeof", ErrorRecoverySet.Prefix); + setTokenInfo(TokenID.Var, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "var", ErrorRecoverySet.Var); + setTokenInfo(TokenID.Void, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.Void, "void", ErrorRecoverySet.Prefix); + setTokenInfo(TokenID.With, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.With, "with", ErrorRecoverySet.Stmt); + setTokenInfo(TokenID.While, Reservation.TypeScriptAndJS, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "while", ErrorRecoverySet.While); + setTokenInfo(TokenID.Yield, Reservation.JavascriptFutureStrict, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "yield", ErrorRecoverySet.None); + setTokenInfo(TokenID.Identifier, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "identifier", ErrorRecoverySet.ID); + setTokenInfo(TokenID.NumberLiteral, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "numberLiteral", ErrorRecoverySet.Literal); + setTokenInfo(TokenID.RegularExpressionLiteral, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "regex", ErrorRecoverySet.RegExp); + setTokenInfo(TokenID.StringLiteral, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "qstring", ErrorRecoverySet.Literal); // Non-operator non-identifier tokens - setTokenInfo(54 /* Semicolon */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, ";", ErrorRecoverySet.SColon); // ; - setTokenInfo(56 /* CloseParen */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, ")", ErrorRecoverySet.RParen); // ) - setTokenInfo(58 /* CloseBracket */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "]", ErrorRecoverySet.RBrack); // ] - setTokenInfo(59 /* OpenBrace */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "{", ErrorRecoverySet.LCurly); // { - setTokenInfo(60 /* CloseBrace */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "}", ErrorRecoverySet.RCurly); // } - setTokenInfo(102 /* DotDotDot */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "...", ErrorRecoverySet.None); // ... + setTokenInfo(TokenID.Semicolon, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, ";", ErrorRecoverySet.SColon); // ; + setTokenInfo(TokenID.CloseParen, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, ")", ErrorRecoverySet.RParen); // ) + setTokenInfo(TokenID.CloseBracket, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "]", ErrorRecoverySet.RBrack); // ] + setTokenInfo(TokenID.OpenBrace, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "{", ErrorRecoverySet.LCurly); // { + setTokenInfo(TokenID.CloseBrace, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "}", ErrorRecoverySet.RCurly); // } + setTokenInfo(TokenID.DotDotDot, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "...", ErrorRecoverySet.None); // ... // Operator non-identifier tokens - setTokenInfo(61 /* Comma */, 0 /* None */, 1 /* Comma */, NodeType.Comma, 0 /* None */, NodeType.None, ",", ErrorRecoverySet.Comma); // , - setTokenInfo(62 /* Equals */, 0 /* None */, 2 /* Assignment */, NodeType.Asg, 0 /* None */, NodeType.None, "=", ErrorRecoverySet.Asg); // = - setTokenInfo(63 /* PlusEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgAdd, 0 /* None */, NodeType.None, "+=", ErrorRecoverySet.BinOp); // += - setTokenInfo(64 /* MinusEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgSub, 0 /* None */, NodeType.None, "-=", ErrorRecoverySet.BinOp); // -= - setTokenInfo(65 /* AsteriskEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgMul, 0 /* None */, NodeType.None, "*=", ErrorRecoverySet.BinOp); // *= - setTokenInfo(66 /* SlashEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgDiv, 0 /* None */, NodeType.None, "/=", ErrorRecoverySet.BinOp); // /= - setTokenInfo(67 /* PercentEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgMod, 0 /* None */, NodeType.None, "%=", ErrorRecoverySet.BinOp); // %= - setTokenInfo(68 /* AmpersandEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgAnd, 0 /* None */, NodeType.None, "&=", ErrorRecoverySet.BinOp); // &= - setTokenInfo(69 /* CaretEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgXor, 0 /* None */, NodeType.None, "^=", ErrorRecoverySet.BinOp); // ^= - setTokenInfo(70 /* BarEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgOr, 0 /* None */, NodeType.None, "|=", ErrorRecoverySet.BinOp); // |= - setTokenInfo(71 /* LessThanLessThanEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgLsh, 0 /* None */, NodeType.None, "<<=", ErrorRecoverySet.BinOp); // <<= - setTokenInfo(72 /* GreaterThanGreaterThanEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgRsh, 0 /* None */, NodeType.None, ">>=", ErrorRecoverySet.BinOp); // >>= - setTokenInfo(73 /* GreaterThanGreaterThanGreaterThanEquals */, 0 /* None */, 2 /* Assignment */, NodeType.AsgRs2, 0 /* None */, NodeType.None, ">>>=", ErrorRecoverySet.BinOp); // >>>= - setTokenInfo(74 /* Question */, 0 /* None */, 3 /* Conditional */, NodeType.ConditionalExpression, 0 /* None */, NodeType.None, "?", ErrorRecoverySet.BinOp); // ? - setTokenInfo(75 /* Colon */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, ":", ErrorRecoverySet.Colon); // : - setTokenInfo(76 /* BarBar */, 0 /* None */, 4 /* LogicalOr */, NodeType.LogOr, 0 /* None */, NodeType.None, "||", ErrorRecoverySet.BinOp); // || - setTokenInfo(77 /* AmpersandAmpersand */, 0 /* None */, 5 /* LogicalAnd */, NodeType.LogAnd, 0 /* None */, NodeType.None, "&&", ErrorRecoverySet.BinOp); // && - setTokenInfo(78 /* Bar */, 0 /* None */, 6 /* BitwiseOr */, NodeType.Or, 0 /* None */, NodeType.None, "|", ErrorRecoverySet.BinOp); // | - setTokenInfo(79 /* Caret */, 0 /* None */, 7 /* BitwiseExclusiveOr */, NodeType.Xor, 0 /* None */, NodeType.None, "^", ErrorRecoverySet.BinOp); // ^ - setTokenInfo(80 /* And */, 0 /* None */, 8 /* BitwiseAnd */, NodeType.And, 0 /* None */, NodeType.None, "&", ErrorRecoverySet.BinOp); // & - setTokenInfo(81 /* EqualsEquals */, 0 /* None */, 9 /* Equality */, NodeType.Eq, 0 /* None */, NodeType.None, "==", ErrorRecoverySet.BinOp); // == - setTokenInfo(82 /* ExclamationEquals */, 0 /* None */, 9 /* Equality */, NodeType.Ne, 0 /* None */, NodeType.None, "!=", ErrorRecoverySet.BinOp); // != - setTokenInfo(83 /* EqualsEqualsEquals */, 0 /* None */, 9 /* Equality */, NodeType.Eqv, 0 /* None */, NodeType.None, "===", ErrorRecoverySet.BinOp); // === - setTokenInfo(84 /* ExclamationEqualsEquals */, 0 /* None */, 9 /* Equality */, NodeType.NEqv, 0 /* None */, NodeType.None, "!==", ErrorRecoverySet.BinOp); // !== - setTokenInfo(85 /* LessThan */, 0 /* None */, 10 /* Relational */, NodeType.Lt, 0 /* None */, NodeType.None, "<", ErrorRecoverySet.BinOp); // < - setTokenInfo(86 /* LessThanEquals */, 0 /* None */, 10 /* Relational */, NodeType.Le, 0 /* None */, NodeType.None, "<=", ErrorRecoverySet.BinOp); // <= - setTokenInfo(87 /* GreaterThan */, 0 /* None */, 10 /* Relational */, NodeType.Gt, 0 /* None */, NodeType.None, ">", ErrorRecoverySet.BinOp); // > - setTokenInfo(88 /* GreaterThanEquals */, 0 /* None */, 10 /* Relational */, NodeType.Ge, 0 /* None */, NodeType.None, ">=", ErrorRecoverySet.BinOp); // >= - setTokenInfo(89 /* LessThanLessThan */, 0 /* None */, 11 /* Shift */, NodeType.Lsh, 0 /* None */, NodeType.None, "<<", ErrorRecoverySet.BinOp); // << - setTokenInfo(90 /* GreaterThanGreaterThan */, 0 /* None */, 11 /* Shift */, NodeType.Rsh, 0 /* None */, NodeType.None, ">>", ErrorRecoverySet.BinOp); // >> - setTokenInfo(91 /* GreaterThanGreaterThanGreaterThan */, 0 /* None */, 11 /* Shift */, NodeType.Rs2, 0 /* None */, NodeType.None, ">>>", ErrorRecoverySet.BinOp); // >>> - setTokenInfo(92 /* Plus */, 0 /* None */, 12 /* Additive */, NodeType.Add, 14 /* Unary */, NodeType.Pos, "+", ErrorRecoverySet.AddOp); // + - setTokenInfo(93 /* Minus */, 0 /* None */, 12 /* Additive */, NodeType.Sub, 14 /* Unary */, NodeType.Neg, "-", ErrorRecoverySet.AddOp); // - - setTokenInfo(94 /* Asterisk */, 0 /* None */, 13 /* Multiplicative */, NodeType.Mul, 0 /* None */, NodeType.None, "*", ErrorRecoverySet.BinOp); // * - setTokenInfo(95 /* Slash */, 0 /* None */, 13 /* Multiplicative */, NodeType.Div, 0 /* None */, NodeType.None, "/", ErrorRecoverySet.BinOp); // / - setTokenInfo(96 /* Percent */, 0 /* None */, 13 /* Multiplicative */, NodeType.Mod, 0 /* None */, NodeType.None, "%", ErrorRecoverySet.BinOp); // % - setTokenInfo(97 /* Tilde */, 0 /* None */, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.Not, "~", ErrorRecoverySet.PreOp); // ~ - setTokenInfo(98 /* Exclamation */, 0 /* None */, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.LogNot, "!", ErrorRecoverySet.PreOp); // ! - setTokenInfo(99 /* PlusPlus */, 0 /* None */, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.IncPre, "++", ErrorRecoverySet.PreOp); // ++ - setTokenInfo(100 /* MinusMinus */, 0 /* None */, 0 /* None */, NodeType.None, 14 /* Unary */, NodeType.DecPre, "--", ErrorRecoverySet.PreOp); // -- - setTokenInfo(55 /* OpenParen */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "(", ErrorRecoverySet.LParen); // ( - setTokenInfo(57 /* OpenBracket */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "[", ErrorRecoverySet.LBrack); // [ - setTokenInfo(101 /* Dot */, 0 /* None */, 14 /* Unary */, NodeType.None, 0 /* None */, NodeType.None, ".", ErrorRecoverySet.Dot); // . - setTokenInfo(104 /* EndOfFile */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "", ErrorRecoverySet.EOF); // EOF - setTokenInfo(105 /* EqualsGreaterThan */, 0 /* None */, 0 /* None */, NodeType.None, 0 /* None */, NodeType.None, "=>", ErrorRecoverySet.None); // => + setTokenInfo(TokenID.Comma, Reservation.None, OperatorPrecedence.Comma, NodeType.Comma, OperatorPrecedence.None, NodeType.None, ",", ErrorRecoverySet.Comma); // , + setTokenInfo(TokenID.Equals, Reservation.None, OperatorPrecedence.Assignment, NodeType.Asg, OperatorPrecedence.None, NodeType.None, "=", ErrorRecoverySet.Asg); // = + setTokenInfo(TokenID.PlusEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgAdd, OperatorPrecedence.None, NodeType.None, "+=", ErrorRecoverySet.BinOp); // += + setTokenInfo(TokenID.MinusEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgSub, OperatorPrecedence.None, NodeType.None, "-=", ErrorRecoverySet.BinOp); // -= + setTokenInfo(TokenID.AsteriskEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgMul, OperatorPrecedence.None, NodeType.None, "*=", ErrorRecoverySet.BinOp); // *= + setTokenInfo(TokenID.SlashEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgDiv, OperatorPrecedence.None, NodeType.None, "/=", ErrorRecoverySet.BinOp); // /= + setTokenInfo(TokenID.PercentEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgMod, OperatorPrecedence.None, NodeType.None, "%=", ErrorRecoverySet.BinOp); // %= + setTokenInfo(TokenID.AmpersandEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgAnd, OperatorPrecedence.None, NodeType.None, "&=", ErrorRecoverySet.BinOp); // &= + setTokenInfo(TokenID.CaretEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgXor, OperatorPrecedence.None, NodeType.None, "^=", ErrorRecoverySet.BinOp); // ^= + setTokenInfo(TokenID.BarEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgOr, OperatorPrecedence.None, NodeType.None, "|=", ErrorRecoverySet.BinOp); // |= + setTokenInfo(TokenID.LessThanLessThanEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgLsh, OperatorPrecedence.None, NodeType.None, "<<=", ErrorRecoverySet.BinOp); // <<= + setTokenInfo(TokenID.GreaterThanGreaterThanEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgRsh, OperatorPrecedence.None, NodeType.None, ">>=", ErrorRecoverySet.BinOp); // >>= + setTokenInfo(TokenID.GreaterThanGreaterThanGreaterThanEquals, Reservation.None, OperatorPrecedence.Assignment, NodeType.AsgRs2, OperatorPrecedence.None, NodeType.None, ">>>=", ErrorRecoverySet.BinOp); // >>>= + setTokenInfo(TokenID.Question, Reservation.None, OperatorPrecedence.Conditional, NodeType.ConditionalExpression, OperatorPrecedence.None, NodeType.None, "?", ErrorRecoverySet.BinOp); // ? + setTokenInfo(TokenID.Colon, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, ":", ErrorRecoverySet.Colon); // : + setTokenInfo(TokenID.BarBar, Reservation.None, OperatorPrecedence.LogicalOr, NodeType.LogOr, OperatorPrecedence.None, NodeType.None, "||", ErrorRecoverySet.BinOp); // || + setTokenInfo(TokenID.AmpersandAmpersand, Reservation.None, OperatorPrecedence.LogicalAnd, NodeType.LogAnd, OperatorPrecedence.None, NodeType.None, "&&", ErrorRecoverySet.BinOp); // && + setTokenInfo(TokenID.Bar, Reservation.None, OperatorPrecedence.BitwiseOr, NodeType.Or, OperatorPrecedence.None, NodeType.None, "|", ErrorRecoverySet.BinOp); // | + setTokenInfo(TokenID.Caret, Reservation.None, OperatorPrecedence.BitwiseExclusiveOr, NodeType.Xor, OperatorPrecedence.None, NodeType.None, "^", ErrorRecoverySet.BinOp); // ^ + setTokenInfo(TokenID.And, Reservation.None, OperatorPrecedence.BitwiseAnd, NodeType.And, OperatorPrecedence.None, NodeType.None, "&", ErrorRecoverySet.BinOp); // & + setTokenInfo(TokenID.EqualsEquals, Reservation.None, OperatorPrecedence.Equality, NodeType.Eq, OperatorPrecedence.None, NodeType.None, "==", ErrorRecoverySet.BinOp); // == + setTokenInfo(TokenID.ExclamationEquals, Reservation.None, OperatorPrecedence.Equality, NodeType.Ne, OperatorPrecedence.None, NodeType.None, "!=", ErrorRecoverySet.BinOp); // != + setTokenInfo(TokenID.EqualsEqualsEquals, Reservation.None, OperatorPrecedence.Equality, NodeType.Eqv, OperatorPrecedence.None, NodeType.None, "===", ErrorRecoverySet.BinOp); // === + setTokenInfo(TokenID.ExclamationEqualsEquals, Reservation.None, OperatorPrecedence.Equality, NodeType.NEqv, OperatorPrecedence.None, NodeType.None, "!==", ErrorRecoverySet.BinOp); // !== + setTokenInfo(TokenID.LessThan, Reservation.None, OperatorPrecedence.Relational, NodeType.Lt, OperatorPrecedence.None, NodeType.None, "<", ErrorRecoverySet.BinOp); // < + setTokenInfo(TokenID.LessThanEquals, Reservation.None, OperatorPrecedence.Relational, NodeType.Le, OperatorPrecedence.None, NodeType.None, "<=", ErrorRecoverySet.BinOp); // <= + setTokenInfo(TokenID.GreaterThan, Reservation.None, OperatorPrecedence.Relational, NodeType.Gt, OperatorPrecedence.None, NodeType.None, ">", ErrorRecoverySet.BinOp); // > + setTokenInfo(TokenID.GreaterThanEquals, Reservation.None, OperatorPrecedence.Relational, NodeType.Ge, OperatorPrecedence.None, NodeType.None, ">=", ErrorRecoverySet.BinOp); // >= + setTokenInfo(TokenID.LessThanLessThan, Reservation.None, OperatorPrecedence.Shift, NodeType.Lsh, OperatorPrecedence.None, NodeType.None, "<<", ErrorRecoverySet.BinOp); // << + setTokenInfo(TokenID.GreaterThanGreaterThan, Reservation.None, OperatorPrecedence.Shift, NodeType.Rsh, OperatorPrecedence.None, NodeType.None, ">>", ErrorRecoverySet.BinOp); // >> + setTokenInfo(TokenID.GreaterThanGreaterThanGreaterThan, Reservation.None, OperatorPrecedence.Shift, NodeType.Rs2, OperatorPrecedence.None, NodeType.None, ">>>", ErrorRecoverySet.BinOp); // >>> + setTokenInfo(TokenID.Plus, Reservation.None, OperatorPrecedence.Additive, NodeType.Add, OperatorPrecedence.Unary, NodeType.Pos, "+", ErrorRecoverySet.AddOp); // + + setTokenInfo(TokenID.Minus, Reservation.None, OperatorPrecedence.Additive, NodeType.Sub, OperatorPrecedence.Unary, NodeType.Neg, "-", ErrorRecoverySet.AddOp); // - + setTokenInfo(TokenID.Asterisk, Reservation.None, OperatorPrecedence.Multiplicative, NodeType.Mul, OperatorPrecedence.None, NodeType.None, "*", ErrorRecoverySet.BinOp); // * + setTokenInfo(TokenID.Slash, Reservation.None, OperatorPrecedence.Multiplicative, NodeType.Div, OperatorPrecedence.None, NodeType.None, "/", ErrorRecoverySet.BinOp); // / + setTokenInfo(TokenID.Percent, Reservation.None, OperatorPrecedence.Multiplicative, NodeType.Mod, OperatorPrecedence.None, NodeType.None, "%", ErrorRecoverySet.BinOp); // % + setTokenInfo(TokenID.Tilde, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.Not, "~", ErrorRecoverySet.PreOp); // ~ + setTokenInfo(TokenID.Exclamation, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.LogNot, "!", ErrorRecoverySet.PreOp); // ! + setTokenInfo(TokenID.PlusPlus, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.IncPre, "++", ErrorRecoverySet.PreOp); // ++ + setTokenInfo(TokenID.MinusMinus, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.Unary, NodeType.DecPre, "--", ErrorRecoverySet.PreOp); // -- + setTokenInfo(TokenID.OpenParen, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "(", ErrorRecoverySet.LParen); // ( + setTokenInfo(TokenID.OpenBracket, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "[", ErrorRecoverySet.LBrack); // [ + setTokenInfo(TokenID.Dot, Reservation.None, OperatorPrecedence.Unary, NodeType.None, OperatorPrecedence.None, NodeType.None, ".", ErrorRecoverySet.Dot); // . + setTokenInfo(TokenID.EndOfFile, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "", ErrorRecoverySet.EOF); // EOF + setTokenInfo(TokenID.EqualsGreaterThan, Reservation.None, OperatorPrecedence.None, NodeType.None, OperatorPrecedence.None, NodeType.None, "=>", ErrorRecoverySet.None); // => function lookupToken(tokenId) { return TypeScript.tokenTable[tokenId]; } @@ -808,17 +808,17 @@ var TypeScript; }; Token.prototype.classification = function () { if (this.tokenId <= TokenID.LimKeyword) { - return 1 /* Keyword */; + return TokenClass.Keyword; } else { var tokenInfo = lookupToken(this.tokenId); if (tokenInfo != undefined) { if ((tokenInfo.unopNodeType != NodeType.None) || (tokenInfo.binopNodeType != NodeType.None)) { - return 2 /* Operator */; + return TokenClass.Operator; } } } - return 0 /* Punctuation */; + return TokenClass.Punctuation; }; return Token; })(); @@ -826,7 +826,7 @@ var TypeScript; var NumberLiteralToken = (function (_super) { __extends(NumberLiteralToken, _super); function NumberLiteralToken(value, hasEmptyFraction) { - _super.call(this, 109 /* NumberLiteral */); + _super.call(this, TokenID.NumberLiteral); this.value = value; this.hasEmptyFraction = hasEmptyFraction; } @@ -834,7 +834,7 @@ var TypeScript; return this.hasEmptyFraction ? this.value.toString() + ".0" : this.value.toString(); }; NumberLiteralToken.prototype.classification = function () { - return 6 /* Literal */; + return TokenClass.Literal; }; return NumberLiteralToken; })(Token); @@ -842,14 +842,14 @@ var TypeScript; var StringLiteralToken = (function (_super) { __extends(StringLiteralToken, _super); function StringLiteralToken(value) { - _super.call(this, 107 /* StringLiteral */); + _super.call(this, TokenID.StringLiteral); this.value = value; } StringLiteralToken.prototype.getText = function () { return this.value; }; StringLiteralToken.prototype.classification = function () { - return 6 /* Literal */; + return TokenClass.Literal; }; return StringLiteralToken; })(Token); @@ -857,7 +857,7 @@ var TypeScript; var IdentifierToken = (function (_super) { __extends(IdentifierToken, _super); function IdentifierToken(value, hasEscapeSequence) { - _super.call(this, 106 /* Identifier */); + _super.call(this, TokenID.Identifier); this.value = value; this.hasEscapeSequence = hasEscapeSequence; } @@ -865,7 +865,7 @@ var TypeScript; return this.value; }; IdentifierToken.prototype.classification = function () { - return 5 /* Identifier */; + return TokenClass.Identifier; }; return IdentifierToken; })(Token); @@ -880,7 +880,7 @@ var TypeScript; return this.value; }; WhitespaceToken.prototype.classification = function () { - return 4 /* Whitespace */; + return TokenClass.Whitespace; }; return WhitespaceToken; })(Token); @@ -899,7 +899,7 @@ var TypeScript; return this.value; }; CommentToken.prototype.classification = function () { - return 3 /* Comment */; + return TokenClass.Comment; }; return CommentToken; })(Token); @@ -907,14 +907,14 @@ var TypeScript; var RegularExpressionLiteralToken = (function (_super) { __extends(RegularExpressionLiteralToken, _super); function RegularExpressionLiteralToken(regex) { - _super.call(this, 108 /* RegularExpressionLiteral */); + _super.call(this, TokenID.RegularExpressionLiteral); this.regex = regex; } RegularExpressionLiteralToken.prototype.getText = function () { return this.regex.toString(); }; RegularExpressionLiteralToken.prototype.classification = function () { - return 6 /* Literal */; + return TokenClass.Literal; }; return RegularExpressionLiteralToken; })(Token); diff --git a/tests/baselines/reference/parserRealSource14.js b/tests/baselines/reference/parserRealSource14.js index 9b9ee2bcf84..f36f00235ff 100644 --- a/tests/baselines/reference/parserRealSource14.js +++ b/tests/baselines/reference/parserRealSource14.js @@ -848,14 +848,14 @@ var TypeScript; // the "{" character, meaning we don't traverse the tree down to the stmt list of the class, meaning // we don't find the "precomment" attached to the errorneous empty stmt. //TODO: It would be nice to be able to get rid of this. - GetAstPathOptions[GetAstPathOptions["DontPruneSearchBasedOnPosition"] = 1 << 1] = "DontPruneSearchBasedOnPosition"; + GetAstPathOptions[GetAstPathOptions["DontPruneSearchBasedOnPosition"] = 2] = "DontPruneSearchBasedOnPosition"; })(TypeScript.GetAstPathOptions || (TypeScript.GetAstPathOptions = {})); var GetAstPathOptions = TypeScript.GetAstPathOptions; /// /// Return the stack of AST nodes containing "position" /// function getAstPathToPosition(script, pos, options) { - if (options === void 0) { options = 0 /* Default */; } + if (options === void 0) { options = GetAstPathOptions.Default; } var lookInComments = function (comments) { if (comments && comments.length > 0) { for (var i = 0; i < comments.length; i++) { @@ -879,7 +879,7 @@ var TypeScript; // bar // 0123 // If "position == 3", the caret is at the "right" of the "r" character, which should be considered valid - var inclusive = hasFlag(options, 1 /* EdgeInclusive */) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar; // Special "EOF" case + var inclusive = hasFlag(options, GetAstPathOptions.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar; // Special "EOF" case var minChar = cur.minChar; var limChar = cur.limChar + (inclusive ? 1 : 0); if (pos >= minChar && pos < limChar) { diff --git a/tests/baselines/reference/parserRealSource2.js b/tests/baselines/reference/parserRealSource2.js index 0dbe7dfef40..c41f88bc9c2 100644 --- a/tests/baselines/reference/parserRealSource2.js +++ b/tests/baselines/reference/parserRealSource2.js @@ -284,190 +284,190 @@ var TypeScript; (function (ErrorRecoverySet) { ErrorRecoverySet[ErrorRecoverySet["None"] = 0] = "None"; ErrorRecoverySet[ErrorRecoverySet["Comma"] = 1] = "Comma"; - ErrorRecoverySet[ErrorRecoverySet["SColon"] = 1 << 1] = "SColon"; - ErrorRecoverySet[ErrorRecoverySet["Asg"] = 1 << 2] = "Asg"; - ErrorRecoverySet[ErrorRecoverySet["BinOp"] = 1 << 3] = "BinOp"; + ErrorRecoverySet[ErrorRecoverySet["SColon"] = 2] = "SColon"; + ErrorRecoverySet[ErrorRecoverySet["Asg"] = 4] = "Asg"; + ErrorRecoverySet[ErrorRecoverySet["BinOp"] = 8] = "BinOp"; // AsgMod, AsgAdd, AsgSub, AsgLsh, AsgRsh, AsgRs2, AsgAnd, AsgXor, AsgOr, QMark, Mult, Div, // Pct, GT, LT, And, Xor, Or - ErrorRecoverySet[ErrorRecoverySet["RBrack"] = 1 << 4] = "RBrack"; - ErrorRecoverySet[ErrorRecoverySet["RCurly"] = 1 << 5] = "RCurly"; - ErrorRecoverySet[ErrorRecoverySet["RParen"] = 1 << 6] = "RParen"; - ErrorRecoverySet[ErrorRecoverySet["Dot"] = 1 << 7] = "Dot"; - ErrorRecoverySet[ErrorRecoverySet["Colon"] = 1 << 8] = "Colon"; - ErrorRecoverySet[ErrorRecoverySet["PrimType"] = 1 << 9] = "PrimType"; - ErrorRecoverySet[ErrorRecoverySet["AddOp"] = 1 << 10] = "AddOp"; - ErrorRecoverySet[ErrorRecoverySet["LCurly"] = 1 << 11] = "LCurly"; - ErrorRecoverySet[ErrorRecoverySet["PreOp"] = 1 << 12] = "PreOp"; - ErrorRecoverySet[ErrorRecoverySet["RegExp"] = 1 << 13] = "RegExp"; - ErrorRecoverySet[ErrorRecoverySet["LParen"] = 1 << 14] = "LParen"; - ErrorRecoverySet[ErrorRecoverySet["LBrack"] = 1 << 15] = "LBrack"; - ErrorRecoverySet[ErrorRecoverySet["Scope"] = 1 << 16] = "Scope"; - ErrorRecoverySet[ErrorRecoverySet["In"] = 1 << 17] = "In"; - ErrorRecoverySet[ErrorRecoverySet["SCase"] = 1 << 18] = "SCase"; - ErrorRecoverySet[ErrorRecoverySet["Else"] = 1 << 19] = "Else"; - ErrorRecoverySet[ErrorRecoverySet["Catch"] = 1 << 20] = "Catch"; - ErrorRecoverySet[ErrorRecoverySet["Var"] = 1 << 21] = "Var"; - ErrorRecoverySet[ErrorRecoverySet["Stmt"] = 1 << 22] = "Stmt"; - ErrorRecoverySet[ErrorRecoverySet["While"] = 1 << 23] = "While"; - ErrorRecoverySet[ErrorRecoverySet["ID"] = 1 << 24] = "ID"; - ErrorRecoverySet[ErrorRecoverySet["Prefix"] = 1 << 25] = "Prefix"; - ErrorRecoverySet[ErrorRecoverySet["Literal"] = 1 << 26] = "Literal"; - ErrorRecoverySet[ErrorRecoverySet["RLit"] = 1 << 27] = "RLit"; - ErrorRecoverySet[ErrorRecoverySet["Func"] = 1 << 28] = "Func"; - ErrorRecoverySet[ErrorRecoverySet["EOF"] = 1 << 29] = "EOF"; + ErrorRecoverySet[ErrorRecoverySet["RBrack"] = 16] = "RBrack"; + ErrorRecoverySet[ErrorRecoverySet["RCurly"] = 32] = "RCurly"; + ErrorRecoverySet[ErrorRecoverySet["RParen"] = 64] = "RParen"; + ErrorRecoverySet[ErrorRecoverySet["Dot"] = 128] = "Dot"; + ErrorRecoverySet[ErrorRecoverySet["Colon"] = 256] = "Colon"; + ErrorRecoverySet[ErrorRecoverySet["PrimType"] = 512] = "PrimType"; + ErrorRecoverySet[ErrorRecoverySet["AddOp"] = 1024] = "AddOp"; + ErrorRecoverySet[ErrorRecoverySet["LCurly"] = 2048] = "LCurly"; + ErrorRecoverySet[ErrorRecoverySet["PreOp"] = 4096] = "PreOp"; + ErrorRecoverySet[ErrorRecoverySet["RegExp"] = 8192] = "RegExp"; + ErrorRecoverySet[ErrorRecoverySet["LParen"] = 16384] = "LParen"; + ErrorRecoverySet[ErrorRecoverySet["LBrack"] = 32768] = "LBrack"; + ErrorRecoverySet[ErrorRecoverySet["Scope"] = 65536] = "Scope"; + ErrorRecoverySet[ErrorRecoverySet["In"] = 131072] = "In"; + ErrorRecoverySet[ErrorRecoverySet["SCase"] = 262144] = "SCase"; + ErrorRecoverySet[ErrorRecoverySet["Else"] = 524288] = "Else"; + ErrorRecoverySet[ErrorRecoverySet["Catch"] = 1048576] = "Catch"; + ErrorRecoverySet[ErrorRecoverySet["Var"] = 2097152] = "Var"; + ErrorRecoverySet[ErrorRecoverySet["Stmt"] = 4194304] = "Stmt"; + ErrorRecoverySet[ErrorRecoverySet["While"] = 8388608] = "While"; + ErrorRecoverySet[ErrorRecoverySet["ID"] = 16777216] = "ID"; + ErrorRecoverySet[ErrorRecoverySet["Prefix"] = 33554432] = "Prefix"; + ErrorRecoverySet[ErrorRecoverySet["Literal"] = 67108864] = "Literal"; + ErrorRecoverySet[ErrorRecoverySet["RLit"] = 134217728] = "RLit"; + ErrorRecoverySet[ErrorRecoverySet["Func"] = 268435456] = "Func"; + ErrorRecoverySet[ErrorRecoverySet["EOF"] = 536870912] = "EOF"; // REVIEW: Name this something clearer. - ErrorRecoverySet[ErrorRecoverySet["TypeScriptS"] = 1 << 30] = "TypeScriptS"; - ErrorRecoverySet[ErrorRecoverySet["ExprStart"] = ErrorRecoverySet.SColon | ErrorRecoverySet.AddOp | ErrorRecoverySet.LCurly | ErrorRecoverySet.PreOp | ErrorRecoverySet.RegExp | ErrorRecoverySet.LParen | ErrorRecoverySet.LBrack | ErrorRecoverySet.ID | ErrorRecoverySet.Prefix | ErrorRecoverySet.RLit | ErrorRecoverySet.Func | ErrorRecoverySet.Literal] = "ExprStart"; - ErrorRecoverySet[ErrorRecoverySet["StmtStart"] = ErrorRecoverySet.ExprStart | ErrorRecoverySet.SColon | ErrorRecoverySet.Var | ErrorRecoverySet.Stmt | ErrorRecoverySet.While | ErrorRecoverySet.TypeScriptS] = "StmtStart"; - ErrorRecoverySet[ErrorRecoverySet["Postfix"] = ErrorRecoverySet.Dot | ErrorRecoverySet.LParen | ErrorRecoverySet.LBrack] = "Postfix"; + ErrorRecoverySet[ErrorRecoverySet["TypeScriptS"] = 1073741824] = "TypeScriptS"; + ErrorRecoverySet[ErrorRecoverySet["ExprStart"] = 520158210] = "ExprStart"; + ErrorRecoverySet[ErrorRecoverySet["StmtStart"] = 1608580098] = "StmtStart"; + ErrorRecoverySet[ErrorRecoverySet["Postfix"] = 49280] = "Postfix"; })(TypeScript.ErrorRecoverySet || (TypeScript.ErrorRecoverySet = {})); var ErrorRecoverySet = TypeScript.ErrorRecoverySet; (function (AllowedElements) { AllowedElements[AllowedElements["None"] = 0] = "None"; - AllowedElements[AllowedElements["ModuleDeclarations"] = 1 << 2] = "ModuleDeclarations"; - AllowedElements[AllowedElements["ClassDeclarations"] = 1 << 3] = "ClassDeclarations"; - AllowedElements[AllowedElements["InterfaceDeclarations"] = 1 << 4] = "InterfaceDeclarations"; - AllowedElements[AllowedElements["AmbientDeclarations"] = 1 << 10] = "AmbientDeclarations"; - AllowedElements[AllowedElements["Properties"] = 1 << 11] = "Properties"; - AllowedElements[AllowedElements["Global"] = AllowedElements.ModuleDeclarations | AllowedElements.ClassDeclarations | AllowedElements.InterfaceDeclarations | AllowedElements.AmbientDeclarations] = "Global"; - AllowedElements[AllowedElements["QuickParse"] = AllowedElements.Global | AllowedElements.Properties] = "QuickParse"; + AllowedElements[AllowedElements["ModuleDeclarations"] = 4] = "ModuleDeclarations"; + AllowedElements[AllowedElements["ClassDeclarations"] = 8] = "ClassDeclarations"; + AllowedElements[AllowedElements["InterfaceDeclarations"] = 16] = "InterfaceDeclarations"; + AllowedElements[AllowedElements["AmbientDeclarations"] = 1024] = "AmbientDeclarations"; + AllowedElements[AllowedElements["Properties"] = 2048] = "Properties"; + AllowedElements[AllowedElements["Global"] = 1052] = "Global"; + AllowedElements[AllowedElements["QuickParse"] = 3100] = "QuickParse"; })(TypeScript.AllowedElements || (TypeScript.AllowedElements = {})); var AllowedElements = TypeScript.AllowedElements; (function (Modifiers) { Modifiers[Modifiers["None"] = 0] = "None"; Modifiers[Modifiers["Private"] = 1] = "Private"; - Modifiers[Modifiers["Public"] = 1 << 1] = "Public"; - Modifiers[Modifiers["Readonly"] = 1 << 2] = "Readonly"; - Modifiers[Modifiers["Ambient"] = 1 << 3] = "Ambient"; - Modifiers[Modifiers["Exported"] = 1 << 4] = "Exported"; - Modifiers[Modifiers["Getter"] = 1 << 5] = "Getter"; - Modifiers[Modifiers["Setter"] = 1 << 6] = "Setter"; - Modifiers[Modifiers["Static"] = 1 << 7] = "Static"; + Modifiers[Modifiers["Public"] = 2] = "Public"; + Modifiers[Modifiers["Readonly"] = 4] = "Readonly"; + Modifiers[Modifiers["Ambient"] = 8] = "Ambient"; + Modifiers[Modifiers["Exported"] = 16] = "Exported"; + Modifiers[Modifiers["Getter"] = 32] = "Getter"; + Modifiers[Modifiers["Setter"] = 64] = "Setter"; + Modifiers[Modifiers["Static"] = 128] = "Static"; })(TypeScript.Modifiers || (TypeScript.Modifiers = {})); var Modifiers = TypeScript.Modifiers; (function (ASTFlags) { ASTFlags[ASTFlags["None"] = 0] = "None"; ASTFlags[ASTFlags["ExplicitSemicolon"] = 1] = "ExplicitSemicolon"; - ASTFlags[ASTFlags["AutomaticSemicolon"] = 1 << 1] = "AutomaticSemicolon"; - ASTFlags[ASTFlags["Writeable"] = 1 << 2] = "Writeable"; - ASTFlags[ASTFlags["Error"] = 1 << 3] = "Error"; - ASTFlags[ASTFlags["DotLHSPartial"] = 1 << 4] = "DotLHSPartial"; - ASTFlags[ASTFlags["DotLHS"] = 1 << 5] = "DotLHS"; - ASTFlags[ASTFlags["IsStatement"] = 1 << 6] = "IsStatement"; - ASTFlags[ASTFlags["StrictMode"] = 1 << 7] = "StrictMode"; - ASTFlags[ASTFlags["PossibleOptionalParameter"] = 1 << 8] = "PossibleOptionalParameter"; - ASTFlags[ASTFlags["ClassBaseConstructorCall"] = 1 << 9] = "ClassBaseConstructorCall"; - ASTFlags[ASTFlags["OptionalName"] = 1 << 10] = "OptionalName"; + ASTFlags[ASTFlags["AutomaticSemicolon"] = 2] = "AutomaticSemicolon"; + ASTFlags[ASTFlags["Writeable"] = 4] = "Writeable"; + ASTFlags[ASTFlags["Error"] = 8] = "Error"; + ASTFlags[ASTFlags["DotLHSPartial"] = 16] = "DotLHSPartial"; + ASTFlags[ASTFlags["DotLHS"] = 32] = "DotLHS"; + ASTFlags[ASTFlags["IsStatement"] = 64] = "IsStatement"; + ASTFlags[ASTFlags["StrictMode"] = 128] = "StrictMode"; + ASTFlags[ASTFlags["PossibleOptionalParameter"] = 256] = "PossibleOptionalParameter"; + ASTFlags[ASTFlags["ClassBaseConstructorCall"] = 512] = "ClassBaseConstructorCall"; + ASTFlags[ASTFlags["OptionalName"] = 1024] = "OptionalName"; // REVIEW: This flag is to mark lambda nodes to note that the LParen of an expression has already been matched in the lambda header. // The flag is used to communicate this piece of information to the calling parseTerm, which intern will remove it. // Once we have a better way to associate information with nodes, this flag should not be used. - ASTFlags[ASTFlags["SkipNextRParen"] = 1 << 11] = "SkipNextRParen"; + ASTFlags[ASTFlags["SkipNextRParen"] = 2048] = "SkipNextRParen"; })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); var ASTFlags = TypeScript.ASTFlags; (function (DeclFlags) { DeclFlags[DeclFlags["None"] = 0] = "None"; DeclFlags[DeclFlags["Exported"] = 1] = "Exported"; - DeclFlags[DeclFlags["Private"] = 1 << 1] = "Private"; - DeclFlags[DeclFlags["Public"] = 1 << 2] = "Public"; - DeclFlags[DeclFlags["Ambient"] = 1 << 3] = "Ambient"; - DeclFlags[DeclFlags["Static"] = 1 << 4] = "Static"; - DeclFlags[DeclFlags["LocalStatic"] = 1 << 5] = "LocalStatic"; - DeclFlags[DeclFlags["GetAccessor"] = 1 << 6] = "GetAccessor"; - DeclFlags[DeclFlags["SetAccessor"] = 1 << 7] = "SetAccessor"; + DeclFlags[DeclFlags["Private"] = 2] = "Private"; + DeclFlags[DeclFlags["Public"] = 4] = "Public"; + DeclFlags[DeclFlags["Ambient"] = 8] = "Ambient"; + DeclFlags[DeclFlags["Static"] = 16] = "Static"; + DeclFlags[DeclFlags["LocalStatic"] = 32] = "LocalStatic"; + DeclFlags[DeclFlags["GetAccessor"] = 64] = "GetAccessor"; + DeclFlags[DeclFlags["SetAccessor"] = 128] = "SetAccessor"; })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); var DeclFlags = TypeScript.DeclFlags; (function (ModuleFlags) { ModuleFlags[ModuleFlags["None"] = 0] = "None"; ModuleFlags[ModuleFlags["Exported"] = 1] = "Exported"; - ModuleFlags[ModuleFlags["Private"] = 1 << 1] = "Private"; - ModuleFlags[ModuleFlags["Public"] = 1 << 2] = "Public"; - ModuleFlags[ModuleFlags["Ambient"] = 1 << 3] = "Ambient"; - ModuleFlags[ModuleFlags["Static"] = 1 << 4] = "Static"; - ModuleFlags[ModuleFlags["LocalStatic"] = 1 << 5] = "LocalStatic"; - ModuleFlags[ModuleFlags["GetAccessor"] = 1 << 6] = "GetAccessor"; - ModuleFlags[ModuleFlags["SetAccessor"] = 1 << 7] = "SetAccessor"; - ModuleFlags[ModuleFlags["IsEnum"] = 1 << 8] = "IsEnum"; - ModuleFlags[ModuleFlags["ShouldEmitModuleDecl"] = 1 << 9] = "ShouldEmitModuleDecl"; - ModuleFlags[ModuleFlags["IsWholeFile"] = 1 << 10] = "IsWholeFile"; - ModuleFlags[ModuleFlags["IsDynamic"] = 1 << 11] = "IsDynamic"; - ModuleFlags[ModuleFlags["MustCaptureThis"] = 1 << 12] = "MustCaptureThis"; + ModuleFlags[ModuleFlags["Private"] = 2] = "Private"; + ModuleFlags[ModuleFlags["Public"] = 4] = "Public"; + ModuleFlags[ModuleFlags["Ambient"] = 8] = "Ambient"; + ModuleFlags[ModuleFlags["Static"] = 16] = "Static"; + ModuleFlags[ModuleFlags["LocalStatic"] = 32] = "LocalStatic"; + ModuleFlags[ModuleFlags["GetAccessor"] = 64] = "GetAccessor"; + ModuleFlags[ModuleFlags["SetAccessor"] = 128] = "SetAccessor"; + ModuleFlags[ModuleFlags["IsEnum"] = 256] = "IsEnum"; + ModuleFlags[ModuleFlags["ShouldEmitModuleDecl"] = 512] = "ShouldEmitModuleDecl"; + ModuleFlags[ModuleFlags["IsWholeFile"] = 1024] = "IsWholeFile"; + ModuleFlags[ModuleFlags["IsDynamic"] = 2048] = "IsDynamic"; + ModuleFlags[ModuleFlags["MustCaptureThis"] = 4096] = "MustCaptureThis"; })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); var ModuleFlags = TypeScript.ModuleFlags; (function (SymbolFlags) { SymbolFlags[SymbolFlags["None"] = 0] = "None"; SymbolFlags[SymbolFlags["Exported"] = 1] = "Exported"; - SymbolFlags[SymbolFlags["Private"] = 1 << 1] = "Private"; - SymbolFlags[SymbolFlags["Public"] = 1 << 2] = "Public"; - SymbolFlags[SymbolFlags["Ambient"] = 1 << 3] = "Ambient"; - SymbolFlags[SymbolFlags["Static"] = 1 << 4] = "Static"; - SymbolFlags[SymbolFlags["LocalStatic"] = 1 << 5] = "LocalStatic"; - SymbolFlags[SymbolFlags["GetAccessor"] = 1 << 6] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 1 << 7] = "SetAccessor"; - SymbolFlags[SymbolFlags["Property"] = 1 << 8] = "Property"; - SymbolFlags[SymbolFlags["Readonly"] = 1 << 9] = "Readonly"; - SymbolFlags[SymbolFlags["ModuleMember"] = 1 << 10] = "ModuleMember"; - SymbolFlags[SymbolFlags["InterfaceMember"] = 1 << 11] = "InterfaceMember"; - SymbolFlags[SymbolFlags["ClassMember"] = 1 << 12] = "ClassMember"; - SymbolFlags[SymbolFlags["BuiltIn"] = 1 << 13] = "BuiltIn"; - SymbolFlags[SymbolFlags["TypeSetDuringScopeAssignment"] = 1 << 14] = "TypeSetDuringScopeAssignment"; - SymbolFlags[SymbolFlags["Constant"] = 1 << 15] = "Constant"; - SymbolFlags[SymbolFlags["Optional"] = 1 << 16] = "Optional"; - SymbolFlags[SymbolFlags["RecursivelyReferenced"] = 1 << 17] = "RecursivelyReferenced"; - SymbolFlags[SymbolFlags["Bound"] = 1 << 18] = "Bound"; - SymbolFlags[SymbolFlags["CompilerGenerated"] = 1 << 19] = "CompilerGenerated"; + SymbolFlags[SymbolFlags["Private"] = 2] = "Private"; + SymbolFlags[SymbolFlags["Public"] = 4] = "Public"; + SymbolFlags[SymbolFlags["Ambient"] = 8] = "Ambient"; + SymbolFlags[SymbolFlags["Static"] = 16] = "Static"; + SymbolFlags[SymbolFlags["LocalStatic"] = 32] = "LocalStatic"; + SymbolFlags[SymbolFlags["GetAccessor"] = 64] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 128] = "SetAccessor"; + SymbolFlags[SymbolFlags["Property"] = 256] = "Property"; + SymbolFlags[SymbolFlags["Readonly"] = 512] = "Readonly"; + SymbolFlags[SymbolFlags["ModuleMember"] = 1024] = "ModuleMember"; + SymbolFlags[SymbolFlags["InterfaceMember"] = 2048] = "InterfaceMember"; + SymbolFlags[SymbolFlags["ClassMember"] = 4096] = "ClassMember"; + SymbolFlags[SymbolFlags["BuiltIn"] = 8192] = "BuiltIn"; + SymbolFlags[SymbolFlags["TypeSetDuringScopeAssignment"] = 16384] = "TypeSetDuringScopeAssignment"; + SymbolFlags[SymbolFlags["Constant"] = 32768] = "Constant"; + SymbolFlags[SymbolFlags["Optional"] = 65536] = "Optional"; + SymbolFlags[SymbolFlags["RecursivelyReferenced"] = 131072] = "RecursivelyReferenced"; + SymbolFlags[SymbolFlags["Bound"] = 262144] = "Bound"; + SymbolFlags[SymbolFlags["CompilerGenerated"] = 524288] = "CompilerGenerated"; })(TypeScript.SymbolFlags || (TypeScript.SymbolFlags = {})); var SymbolFlags = TypeScript.SymbolFlags; (function (VarFlags) { VarFlags[VarFlags["None"] = 0] = "None"; VarFlags[VarFlags["Exported"] = 1] = "Exported"; - VarFlags[VarFlags["Private"] = 1 << 1] = "Private"; - VarFlags[VarFlags["Public"] = 1 << 2] = "Public"; - VarFlags[VarFlags["Ambient"] = 1 << 3] = "Ambient"; - VarFlags[VarFlags["Static"] = 1 << 4] = "Static"; - VarFlags[VarFlags["LocalStatic"] = 1 << 5] = "LocalStatic"; - VarFlags[VarFlags["GetAccessor"] = 1 << 6] = "GetAccessor"; - VarFlags[VarFlags["SetAccessor"] = 1 << 7] = "SetAccessor"; - VarFlags[VarFlags["AutoInit"] = 1 << 8] = "AutoInit"; - VarFlags[VarFlags["Property"] = 1 << 9] = "Property"; - VarFlags[VarFlags["Readonly"] = 1 << 10] = "Readonly"; - VarFlags[VarFlags["Class"] = 1 << 11] = "Class"; - VarFlags[VarFlags["ClassProperty"] = 1 << 12] = "ClassProperty"; - VarFlags[VarFlags["ClassBodyProperty"] = 1 << 13] = "ClassBodyProperty"; - VarFlags[VarFlags["ClassConstructorProperty"] = 1 << 14] = "ClassConstructorProperty"; - VarFlags[VarFlags["ClassSuperMustBeFirstCallInConstructor"] = 1 << 15] = "ClassSuperMustBeFirstCallInConstructor"; - VarFlags[VarFlags["Constant"] = 1 << 16] = "Constant"; - VarFlags[VarFlags["MustCaptureThis"] = 1 << 17] = "MustCaptureThis"; + VarFlags[VarFlags["Private"] = 2] = "Private"; + VarFlags[VarFlags["Public"] = 4] = "Public"; + VarFlags[VarFlags["Ambient"] = 8] = "Ambient"; + VarFlags[VarFlags["Static"] = 16] = "Static"; + VarFlags[VarFlags["LocalStatic"] = 32] = "LocalStatic"; + VarFlags[VarFlags["GetAccessor"] = 64] = "GetAccessor"; + VarFlags[VarFlags["SetAccessor"] = 128] = "SetAccessor"; + VarFlags[VarFlags["AutoInit"] = 256] = "AutoInit"; + VarFlags[VarFlags["Property"] = 512] = "Property"; + VarFlags[VarFlags["Readonly"] = 1024] = "Readonly"; + VarFlags[VarFlags["Class"] = 2048] = "Class"; + VarFlags[VarFlags["ClassProperty"] = 4096] = "ClassProperty"; + VarFlags[VarFlags["ClassBodyProperty"] = 8192] = "ClassBodyProperty"; + VarFlags[VarFlags["ClassConstructorProperty"] = 16384] = "ClassConstructorProperty"; + VarFlags[VarFlags["ClassSuperMustBeFirstCallInConstructor"] = 32768] = "ClassSuperMustBeFirstCallInConstructor"; + VarFlags[VarFlags["Constant"] = 65536] = "Constant"; + VarFlags[VarFlags["MustCaptureThis"] = 131072] = "MustCaptureThis"; })(TypeScript.VarFlags || (TypeScript.VarFlags = {})); var VarFlags = TypeScript.VarFlags; (function (FncFlags) { FncFlags[FncFlags["None"] = 0] = "None"; FncFlags[FncFlags["Exported"] = 1] = "Exported"; - FncFlags[FncFlags["Private"] = 1 << 1] = "Private"; - FncFlags[FncFlags["Public"] = 1 << 2] = "Public"; - FncFlags[FncFlags["Ambient"] = 1 << 3] = "Ambient"; - FncFlags[FncFlags["Static"] = 1 << 4] = "Static"; - FncFlags[FncFlags["LocalStatic"] = 1 << 5] = "LocalStatic"; - FncFlags[FncFlags["GetAccessor"] = 1 << 6] = "GetAccessor"; - FncFlags[FncFlags["SetAccessor"] = 1 << 7] = "SetAccessor"; - FncFlags[FncFlags["Definition"] = 1 << 8] = "Definition"; - FncFlags[FncFlags["Signature"] = 1 << 9] = "Signature"; - FncFlags[FncFlags["Method"] = 1 << 10] = "Method"; - FncFlags[FncFlags["HasReturnExpression"] = 1 << 11] = "HasReturnExpression"; - FncFlags[FncFlags["CallMember"] = 1 << 12] = "CallMember"; - FncFlags[FncFlags["ConstructMember"] = 1 << 13] = "ConstructMember"; - FncFlags[FncFlags["HasSelfReference"] = 1 << 14] = "HasSelfReference"; - FncFlags[FncFlags["IsFatArrowFunction"] = 1 << 15] = "IsFatArrowFunction"; - FncFlags[FncFlags["IndexerMember"] = 1 << 16] = "IndexerMember"; - FncFlags[FncFlags["IsFunctionExpression"] = 1 << 17] = "IsFunctionExpression"; - FncFlags[FncFlags["ClassMethod"] = 1 << 18] = "ClassMethod"; - FncFlags[FncFlags["ClassPropertyMethodExported"] = 1 << 19] = "ClassPropertyMethodExported"; + FncFlags[FncFlags["Private"] = 2] = "Private"; + FncFlags[FncFlags["Public"] = 4] = "Public"; + FncFlags[FncFlags["Ambient"] = 8] = "Ambient"; + FncFlags[FncFlags["Static"] = 16] = "Static"; + FncFlags[FncFlags["LocalStatic"] = 32] = "LocalStatic"; + FncFlags[FncFlags["GetAccessor"] = 64] = "GetAccessor"; + FncFlags[FncFlags["SetAccessor"] = 128] = "SetAccessor"; + FncFlags[FncFlags["Definition"] = 256] = "Definition"; + FncFlags[FncFlags["Signature"] = 512] = "Signature"; + FncFlags[FncFlags["Method"] = 1024] = "Method"; + FncFlags[FncFlags["HasReturnExpression"] = 2048] = "HasReturnExpression"; + FncFlags[FncFlags["CallMember"] = 4096] = "CallMember"; + FncFlags[FncFlags["ConstructMember"] = 8192] = "ConstructMember"; + FncFlags[FncFlags["HasSelfReference"] = 16384] = "HasSelfReference"; + FncFlags[FncFlags["IsFatArrowFunction"] = 32768] = "IsFatArrowFunction"; + FncFlags[FncFlags["IndexerMember"] = 65536] = "IndexerMember"; + FncFlags[FncFlags["IsFunctionExpression"] = 131072] = "IsFunctionExpression"; + FncFlags[FncFlags["ClassMethod"] = 262144] = "ClassMethod"; + FncFlags[FncFlags["ClassPropertyMethodExported"] = 524288] = "ClassPropertyMethodExported"; })(TypeScript.FncFlags || (TypeScript.FncFlags = {})); var FncFlags = TypeScript.FncFlags; (function (SignatureFlags) { SignatureFlags[SignatureFlags["None"] = 0] = "None"; SignatureFlags[SignatureFlags["IsIndexer"] = 1] = "IsIndexer"; - SignatureFlags[SignatureFlags["IsStringIndexer"] = 1 << 1] = "IsStringIndexer"; - SignatureFlags[SignatureFlags["IsNumberIndexer"] = 1 << 2] = "IsNumberIndexer"; + SignatureFlags[SignatureFlags["IsStringIndexer"] = 2] = "IsStringIndexer"; + SignatureFlags[SignatureFlags["IsNumberIndexer"] = 4] = "IsNumberIndexer"; })(TypeScript.SignatureFlags || (TypeScript.SignatureFlags = {})); var SignatureFlags = TypeScript.SignatureFlags; function ToDeclFlags(fncOrVarOrSymbolOrModuleFlags) { @@ -477,24 +477,24 @@ var TypeScript; (function (TypeFlags) { TypeFlags[TypeFlags["None"] = 0] = "None"; TypeFlags[TypeFlags["HasImplementation"] = 1] = "HasImplementation"; - TypeFlags[TypeFlags["HasSelfReference"] = 1 << 1] = "HasSelfReference"; - TypeFlags[TypeFlags["MergeResult"] = 1 << 2] = "MergeResult"; - TypeFlags[TypeFlags["IsEnum"] = 1 << 3] = "IsEnum"; - TypeFlags[TypeFlags["BuildingName"] = 1 << 4] = "BuildingName"; - TypeFlags[TypeFlags["HasBaseType"] = 1 << 5] = "HasBaseType"; - TypeFlags[TypeFlags["HasBaseTypeOfObject"] = 1 << 6] = "HasBaseTypeOfObject"; - TypeFlags[TypeFlags["IsClass"] = 1 << 7] = "IsClass"; + TypeFlags[TypeFlags["HasSelfReference"] = 2] = "HasSelfReference"; + TypeFlags[TypeFlags["MergeResult"] = 4] = "MergeResult"; + TypeFlags[TypeFlags["IsEnum"] = 8] = "IsEnum"; + TypeFlags[TypeFlags["BuildingName"] = 16] = "BuildingName"; + TypeFlags[TypeFlags["HasBaseType"] = 32] = "HasBaseType"; + TypeFlags[TypeFlags["HasBaseTypeOfObject"] = 64] = "HasBaseTypeOfObject"; + TypeFlags[TypeFlags["IsClass"] = 128] = "IsClass"; })(TypeScript.TypeFlags || (TypeScript.TypeFlags = {})); var TypeFlags = TypeScript.TypeFlags; (function (TypeRelationshipFlags) { TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; TypeRelationshipFlags[TypeRelationshipFlags["SourceIsNullTargetIsVoidOrUndefined"] = 1] = "SourceIsNullTargetIsVoidOrUndefined"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 2] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 4] = "IncompatibleSignatures"; TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 16] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 32] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 64] = "IncompatibleParameterTypes"; })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; (function (CodeGenTarget) { @@ -505,13 +505,13 @@ var TypeScript; (function (ModuleGenTarget) { ModuleGenTarget[ModuleGenTarget["Synchronous"] = 0] = "Synchronous"; ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 1] = "Asynchronous"; - ModuleGenTarget[ModuleGenTarget["Local"] = 1 << 1] = "Local"; + ModuleGenTarget[ModuleGenTarget["Local"] = 2] = "Local"; })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); var ModuleGenTarget = TypeScript.ModuleGenTarget; // Compiler defaults to generating ES5-compliant code for // - getters and setters - TypeScript.codeGenTarget = 0 /* ES3 */; - TypeScript.moduleGenTarget = 0 /* Synchronous */; + TypeScript.codeGenTarget = CodeGenTarget.ES3; + TypeScript.moduleGenTarget = ModuleGenTarget.Synchronous; TypeScript.optimizeModuleCodeGen = true; function flagsToString(e, flags) { var builder = ""; diff --git a/tests/baselines/reference/parserRealSource3.js b/tests/baselines/reference/parserRealSource3.js index cfe6800fcf5..38e9028297b 100644 --- a/tests/baselines/reference/parserRealSource3.js +++ b/tests/baselines/reference/parserRealSource3.js @@ -234,8 +234,8 @@ var TypeScript; NodeType[NodeType["Error"] = 104] = "Error"; NodeType[NodeType["Comment"] = 105] = "Comment"; NodeType[NodeType["Debugger"] = 106] = "Debugger"; - NodeType[NodeType["GeneralNode"] = NodeType.FuncDecl] = "GeneralNode"; - NodeType[NodeType["LastAsg"] = NodeType.AsgRs2] = "LastAsg"; + NodeType[NodeType["GeneralNode"] = 71] = "GeneralNode"; + NodeType[NodeType["LastAsg"] = 41] = "LastAsg"; })(TypeScript.NodeType || (TypeScript.NodeType = {})); var NodeType = TypeScript.NodeType; })(TypeScript || (TypeScript = {})); diff --git a/tests/baselines/reference/pinnedComments1.js b/tests/baselines/reference/pinnedComments1.js new file mode 100644 index 00000000000..c4b8b41fbd7 --- /dev/null +++ b/tests/baselines/reference/pinnedComments1.js @@ -0,0 +1,14 @@ +//// [pinnedComments1.ts] + +/* unpinned comment */ +/*! pinned comment */ +class C { +} + +//// [pinnedComments1.js] +/*! pinned comment */ +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/pinnedComments1.types b/tests/baselines/reference/pinnedComments1.types new file mode 100644 index 00000000000..d55feb67659 --- /dev/null +++ b/tests/baselines/reference/pinnedComments1.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/pinnedComments1.ts === + +/* unpinned comment */ +/*! pinned comment */ +class C { +>C : C +} diff --git a/tests/baselines/reference/plusOperatorWithEnumType.js b/tests/baselines/reference/plusOperatorWithEnumType.js index 1ce6036d5ce..39bd1777f6f 100644 --- a/tests/baselines/reference/plusOperatorWithEnumType.js +++ b/tests/baselines/reference/plusOperatorWithEnumType.js @@ -35,10 +35,10 @@ var ENUM1; var ResultIsNumber1 = +ENUM; var ResultIsNumber2 = +ENUM1; // enum type expressions -var ResultIsNumber3 = +0 /* "A" */; -var ResultIsNumber4 = +(ENUM[0] + 1 /* "B" */); +var ResultIsNumber3 = +ENUM1["A"]; +var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); // miss assignment operators +ENUM; +ENUM1; -+1 /* B */; ++ENUM1.B; +ENUM, ENUM1; diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js index c3c5ba3a7af..9093787a6fc 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js @@ -222,8 +222,8 @@ var import_public; // Usage of privacy error imports var privateUse_im_public_c_private = new import_public.im_public_c_private(); import_public.publicUse_im_public_c_private = new import_public.im_public_c_private(); - var privateUse_im_public_e_private = 0 /* Happy */; - import_public.publicUse_im_public_e_private = 1 /* Grumpy */; + var privateUse_im_public_e_private = import_public.im_public_e_private.Happy; + import_public.publicUse_im_public_e_private = import_public.im_public_e_private.Grumpy; var privateUse_im_public_f_private = import_public.im_public_f_private(); import_public.publicUse_im_public_f_private = import_public.im_public_f_private(); var privateUse_im_public_v_private = import_public.im_public_v_private; @@ -243,8 +243,8 @@ var import_public; // Usage of above var privateUse_im_public_c_public = new import_public.im_public_c_public(); import_public.publicUse_im_public_c_public = new import_public.im_public_c_public(); - var privateUse_im_public_e_public = 0 /* Happy */; - import_public.publicUse_im_public_e_public = 1 /* Grumpy */; + var privateUse_im_public_e_public = import_public.im_public_e_public.Happy; + import_public.publicUse_im_public_e_public = import_public.im_public_e_public.Grumpy; var privateUse_im_public_f_public = import_public.im_public_f_public(); import_public.publicUse_im_public_f_public = import_public.im_public_f_public(); var privateUse_im_public_v_public = import_public.im_public_v_public; @@ -267,8 +267,8 @@ var import_private; // Usage of above decls var privateUse_im_private_c_private = new import_private.im_private_c_private(); import_private.publicUse_im_private_c_private = new import_private.im_private_c_private(); - var privateUse_im_private_e_private = 0 /* Happy */; - import_private.publicUse_im_private_e_private = 1 /* Grumpy */; + var privateUse_im_private_e_private = import_private.im_private_e_private.Happy; + import_private.publicUse_im_private_e_private = import_private.im_private_e_private.Grumpy; var privateUse_im_private_f_private = import_private.im_private_f_private(); import_private.publicUse_im_private_f_private = import_private.im_private_f_private(); var privateUse_im_private_v_private = import_private.im_private_v_private; @@ -288,8 +288,8 @@ var import_private; // Usage of no privacy error imports var privateUse_im_private_c_public = new import_private.im_private_c_public(); import_private.publicUse_im_private_c_public = new import_private.im_private_c_public(); - var privateUse_im_private_e_public = 0 /* Happy */; - import_private.publicUse_im_private_e_public = 1 /* Grumpy */; + var privateUse_im_private_e_public = import_private.im_private_e_public.Happy; + import_private.publicUse_im_private_e_public = import_private.im_private_e_public.Grumpy; var privateUse_im_private_f_public = import_private.im_private_f_public(); import_private.publicUse_im_private_f_public = import_private.im_private_f_public(); var privateUse_im_private_v_public = import_private.im_private_v_public; diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js index 9dae3ce7ce9..f3b8da0de82 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js @@ -223,8 +223,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_private = new im_private_c_private(); import_public.publicUse_im_private_c_private = new im_private_c_private(); - var privateUse_im_private_e_private = 0 /* Happy */; - import_public.publicUse_im_private_e_private = 1 /* Grumpy */; + var privateUse_im_private_e_private = im_private_e_private.Happy; + import_public.publicUse_im_private_e_private = im_private_e_private.Grumpy; var privateUse_im_private_f_private = im_private_f_private(); import_public.publicUse_im_private_f_private = im_private_f_private(); var privateUse_im_private_v_private = im_private_v_private; @@ -244,8 +244,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_public = new im_private_c_public(); import_public.publicUse_im_private_c_public = new im_private_c_public(); - var privateUse_im_private_e_public = 0 /* Happy */; - import_public.publicUse_im_private_e_public = 1 /* Grumpy */; + var privateUse_im_private_e_public = im_private_e_public.Happy; + import_public.publicUse_im_private_e_public = im_private_e_public.Grumpy; var privateUse_im_private_f_public = im_private_f_public(); import_public.publicUse_im_private_f_public = im_private_f_public(); var privateUse_im_private_v_public = im_private_v_public; @@ -268,8 +268,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_private = new im_private_c_private(); import_private.publicUse_im_private_c_private = new im_private_c_private(); - var privateUse_im_private_e_private = 0 /* Happy */; - import_private.publicUse_im_private_e_private = 1 /* Grumpy */; + var privateUse_im_private_e_private = im_private_e_private.Happy; + import_private.publicUse_im_private_e_private = im_private_e_private.Grumpy; var privateUse_im_private_f_private = im_private_f_private(); import_private.publicUse_im_private_f_private = im_private_f_private(); var privateUse_im_private_v_private = im_private_v_private; @@ -289,8 +289,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_public = new im_private_c_public(); import_private.publicUse_im_private_c_public = new im_private_c_public(); - var privateUse_im_private_e_public = 0 /* Happy */; - import_private.publicUse_im_private_e_public = 1 /* Grumpy */; + var privateUse_im_private_e_public = im_private_e_public.Happy; + import_private.publicUse_im_private_e_public = im_private_e_public.Grumpy; var privateUse_im_private_f_public = im_private_f_public(); import_private.publicUse_im_private_f_public = im_private_f_public(); var privateUse_im_private_v_public = im_private_v_public; diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js index 54f018fe475..e73e398d437 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js @@ -168,8 +168,8 @@ define(["require", "exports"], function (require, exports) { // Usage of privacy error imports var privateUse_im_public_c_private = new exports.im_public_c_private(); exports.publicUse_im_public_c_private = new exports.im_public_c_private(); - var privateUse_im_public_e_private = 0 /* Happy */; - exports.publicUse_im_public_e_private = 1 /* Grumpy */; + var privateUse_im_public_e_private = exports.im_public_e_private.Happy; + exports.publicUse_im_public_e_private = exports.im_public_e_private.Grumpy; var privateUse_im_public_f_private = exports.im_public_f_private(); exports.publicUse_im_public_f_private = exports.im_public_f_private(); var privateUse_im_public_v_private = exports.im_public_v_private; @@ -189,8 +189,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_public_c_public = new exports.im_public_c_public(); exports.publicUse_im_public_c_public = new exports.im_public_c_public(); - var privateUse_im_public_e_public = 0 /* Happy */; - exports.publicUse_im_public_e_public = 1 /* Grumpy */; + var privateUse_im_public_e_public = exports.im_public_e_public.Happy; + exports.publicUse_im_public_e_public = exports.im_public_e_public.Grumpy; var privateUse_im_public_f_public = exports.im_public_f_public(); exports.publicUse_im_public_f_public = exports.im_public_f_public(); var privateUse_im_public_v_public = exports.im_public_v_public; diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js index d2f051bf331..11cd8c260b7 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js @@ -169,8 +169,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_private = new im_private_c_private(); exports.publicUse_im_private_c_private = new im_private_c_private(); - var privateUse_im_private_e_private = 0 /* Happy */; - exports.publicUse_im_private_e_private = 1 /* Grumpy */; + var privateUse_im_private_e_private = im_private_e_private.Happy; + exports.publicUse_im_private_e_private = im_private_e_private.Grumpy; var privateUse_im_private_f_private = im_private_f_private(); exports.publicUse_im_private_f_private = im_private_f_private(); var privateUse_im_private_v_private = im_private_v_private; @@ -190,8 +190,8 @@ define(["require", "exports"], function (require, exports) { // Usage of above decls var privateUse_im_private_c_public = new im_private_c_public(); exports.publicUse_im_private_c_public = new im_private_c_public(); - var privateUse_im_private_e_public = 0 /* Happy */; - exports.publicUse_im_private_e_public = 1 /* Grumpy */; + var privateUse_im_private_e_public = im_private_e_public.Happy; + exports.publicUse_im_private_e_public = im_private_e_public.Grumpy; var privateUse_im_private_f_public = im_private_f_public(); exports.publicUse_im_private_f_public = im_private_f_public(); var privateUse_im_private_v_public = im_private_v_public; diff --git a/tests/baselines/reference/propertyAccess.js b/tests/baselines/reference/propertyAccess.js index f47b850a954..d646ca40763 100644 --- a/tests/baselines/reference/propertyAccess.js +++ b/tests/baselines/reference/propertyAccess.js @@ -181,8 +181,8 @@ var numIndex = { 'three': 'three' }; var strIndex = { - 'N': 0 /* North */, - 'E': 2 /* East */ + 'N': Compass.North, + 'E': Compass.East }; var bothIndex; function noIndex() { @@ -229,7 +229,7 @@ var gg; var hh = numIndex[3.0]; var hh; // Bracket notation property access using enum value on type with numeric index signature -var ii = numIndex[1 /* South */]; +var ii = numIndex[Compass.South]; var ii; // Bracket notation property access using value of type 'any' on type with numeric index signature var jj = numIndex[anyVar]; @@ -248,7 +248,7 @@ var mm2; var nn = strIndex[10]; var nn; // Bracket notation property access using enum value on type with string index signature and no numeric index signature -var oo = strIndex[2 /* East */]; +var oo = strIndex[Compass.East]; var oo; // Bracket notation property access using value of type 'any' on type with string index signature and no numeric index signature var pp = strIndex[null]; @@ -260,7 +260,7 @@ var qq; var rr = noIndex['zzzz']; var rr; // Bracket notation property access using enum value on type with no index signatures -var ss = noIndex[1 /* South */]; +var ss = noIndex[Compass.South]; var ss; // Bracket notation property access using value of type 'any' on type with no index signatures var tt = noIndex[null]; @@ -271,7 +271,7 @@ var uu = noIndex[someObject]; // Error var vv = noIndex[32]; var vv; // Bracket notation property access using enum value on type with numeric index signature and string index signature -var ww = bothIndex[2 /* East */]; +var ww = bothIndex[Compass.East]; var ww; // Bracket notation property access using value of type 'any' on type with numeric index signature and string index signature var xx = bothIndex[null]; diff --git a/tests/baselines/reference/propertyNamesOfReservedWords.js b/tests/baselines/reference/propertyNamesOfReservedWords.js index 471787f43ee..b2332345712 100644 --- a/tests/baselines/reference/propertyNamesOfReservedWords.js +++ b/tests/baselines/reference/propertyNamesOfReservedWords.js @@ -357,5 +357,5 @@ var E; E[E["while"] = 61] = "while"; E[E["with"] = 62] = "with"; })(E || (E = {})); -var r7 = 0 /* abstract */; -var r8 = 1 /* as */; +var r7 = E.abstract; +var r8 = E.as; diff --git a/tests/baselines/reference/sourceMap-LineBreaks.js.map b/tests/baselines/reference/sourceMap-LineBreaks.js.map index 59f3381d355..7726aa00eaf 100644 --- a/tests/baselines/reference/sourceMap-LineBreaks.js.map +++ b/tests/baselines/reference/sourceMap-LineBreaks.js.map @@ -1,2 +1,2 @@ //// [sourceMap-LineBreaks.js.map] -{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":"AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACzB,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACzB,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG;OACzB,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":"AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,gBAAgB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-LineBreaks.sourcemap.txt b/tests/baselines/reference/sourceMap-LineBreaks.sourcemap.txt index 5cda2ad1f82..413853250b6 100644 --- a/tests/baselines/reference/sourceMap-LineBreaks.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-LineBreaks.sourcemap.txt @@ -78,18 +78,18 @@ sourceFile:sourceMap-LineBreaks.ts 5 > ^ 6 > ^ 7 > ^^^^^^^^^^^^^^^-> -1->Â… > +1->Â… 2 >var 3 > endsWithLineFeed 4 > = 5 > 1 6 > ; -1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) -3 >Emitted(4, 21) Source(4, 21) + SourceIndex(0) -4 >Emitted(4, 24) Source(4, 24) + SourceIndex(0) -5 >Emitted(4, 25) Source(4, 25) + SourceIndex(0) -6 >Emitted(4, 26) Source(4, 26) + SourceIndex(0) +1->Emitted(4, 1) Source(3, 27) + SourceIndex(0) +2 >Emitted(4, 5) Source(3, 31) + SourceIndex(0) +3 >Emitted(4, 21) Source(3, 47) + SourceIndex(0) +4 >Emitted(4, 24) Source(3, 50) + SourceIndex(0) +5 >Emitted(4, 25) Source(3, 51) + SourceIndex(0) +6 >Emitted(4, 26) Source(3, 52) + SourceIndex(0) --- >>>var endsWithCarriageReturnLineFeed = 1; 1-> @@ -105,12 +105,12 @@ sourceFile:sourceMap-LineBreaks.ts 4 > = 5 > 1 6 > ; -1->Emitted(5, 1) Source(5, 1) + SourceIndex(0) -2 >Emitted(5, 5) Source(5, 5) + SourceIndex(0) -3 >Emitted(5, 35) Source(5, 35) + SourceIndex(0) -4 >Emitted(5, 38) Source(5, 38) + SourceIndex(0) -5 >Emitted(5, 39) Source(5, 39) + SourceIndex(0) -6 >Emitted(5, 40) Source(5, 40) + SourceIndex(0) +1->Emitted(5, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(5, 5) Source(4, 5) + SourceIndex(0) +3 >Emitted(5, 35) Source(4, 35) + SourceIndex(0) +4 >Emitted(5, 38) Source(4, 38) + SourceIndex(0) +5 >Emitted(5, 39) Source(4, 39) + SourceIndex(0) +6 >Emitted(5, 40) Source(4, 40) + SourceIndex(0) --- >>>var endsWithCarriageReturn = 1; 1 > @@ -127,12 +127,12 @@ sourceFile:sourceMap-LineBreaks.ts 4 > = 5 > 1 6 > ; -1 >Emitted(6, 1) Source(6, 1) + SourceIndex(0) -2 >Emitted(6, 5) Source(6, 5) + SourceIndex(0) -3 >Emitted(6, 27) Source(6, 27) + SourceIndex(0) -4 >Emitted(6, 30) Source(6, 30) + SourceIndex(0) -5 >Emitted(6, 31) Source(6, 31) + SourceIndex(0) -6 >Emitted(6, 32) Source(6, 32) + SourceIndex(0) +1 >Emitted(6, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(6, 5) Source(5, 5) + SourceIndex(0) +3 >Emitted(6, 27) Source(5, 27) + SourceIndex(0) +4 >Emitted(6, 30) Source(5, 30) + SourceIndex(0) +5 >Emitted(6, 31) Source(5, 31) + SourceIndex(0) +6 >Emitted(6, 32) Source(5, 32) + SourceIndex(0) --- >>>var endsWithLineFeedCarriageReturn = 1; 1-> @@ -148,12 +148,12 @@ sourceFile:sourceMap-LineBreaks.ts 4 > = 5 > 1 6 > ; -1->Emitted(7, 1) Source(7, 1) + SourceIndex(0) -2 >Emitted(7, 5) Source(7, 5) + SourceIndex(0) -3 >Emitted(7, 35) Source(7, 35) + SourceIndex(0) -4 >Emitted(7, 38) Source(7, 38) + SourceIndex(0) -5 >Emitted(7, 39) Source(7, 39) + SourceIndex(0) -6 >Emitted(7, 40) Source(7, 40) + SourceIndex(0) +1->Emitted(7, 1) Source(6, 1) + SourceIndex(0) +2 >Emitted(7, 5) Source(6, 5) + SourceIndex(0) +3 >Emitted(7, 35) Source(6, 35) + SourceIndex(0) +4 >Emitted(7, 38) Source(6, 38) + SourceIndex(0) +5 >Emitted(7, 39) Source(6, 39) + SourceIndex(0) +6 >Emitted(7, 40) Source(6, 40) + SourceIndex(0) --- >>>var endsWithLineFeedCarriageReturnLineFeed = 1; 1-> @@ -169,12 +169,12 @@ sourceFile:sourceMap-LineBreaks.ts 4 > = 5 > 1 6 > ; -1->Emitted(8, 1) Source(9, 1) + SourceIndex(0) -2 >Emitted(8, 5) Source(9, 5) + SourceIndex(0) -3 >Emitted(8, 43) Source(9, 43) + SourceIndex(0) -4 >Emitted(8, 46) Source(9, 46) + SourceIndex(0) -5 >Emitted(8, 47) Source(9, 47) + SourceIndex(0) -6 >Emitted(8, 48) Source(9, 48) + SourceIndex(0) +1->Emitted(8, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(8, 5) Source(8, 5) + SourceIndex(0) +3 >Emitted(8, 43) Source(8, 43) + SourceIndex(0) +4 >Emitted(8, 46) Source(8, 46) + SourceIndex(0) +5 >Emitted(8, 47) Source(8, 47) + SourceIndex(0) +6 >Emitted(8, 48) Source(8, 48) + SourceIndex(0) --- >>>var stringLiteralWithLineFeed = "line 1\ 1 > @@ -187,10 +187,10 @@ sourceFile:sourceMap-LineBreaks.ts 2 >var 3 > stringLiteralWithLineFeed 4 > = -1 >Emitted(9, 1) Source(11, 1) + SourceIndex(0) -2 >Emitted(9, 5) Source(11, 5) + SourceIndex(0) -3 >Emitted(9, 30) Source(11, 30) + SourceIndex(0) -4 >Emitted(9, 33) Source(11, 33) + SourceIndex(0) +1 >Emitted(9, 1) Source(10, 1) + SourceIndex(0) +2 >Emitted(9, 5) Source(10, 5) + SourceIndex(0) +3 >Emitted(9, 30) Source(10, 30) + SourceIndex(0) +4 >Emitted(9, 33) Source(10, 33) + SourceIndex(0) --- >>>line 2"; 1 >^^^^^^^ @@ -199,8 +199,8 @@ sourceFile:sourceMap-LineBreaks.ts 1 >"line 1\ >line 2" 2 > ; -1 >Emitted(10, 8) Source(12, 8) + SourceIndex(0) -2 >Emitted(10, 9) Source(12, 9) + SourceIndex(0) +1 >Emitted(10, 8) Source(11, 8) + SourceIndex(0) +2 >Emitted(10, 9) Source(11, 9) + SourceIndex(0) --- >>>var stringLiteralWithCarriageReturnLineFeed = "line 1\ 1-> @@ -212,10 +212,10 @@ sourceFile:sourceMap-LineBreaks.ts 2 >var 3 > stringLiteralWithCarriageReturnLineFeed 4 > = -1->Emitted(11, 1) Source(13, 1) + SourceIndex(0) -2 >Emitted(11, 5) Source(13, 5) + SourceIndex(0) -3 >Emitted(11, 44) Source(13, 44) + SourceIndex(0) -4 >Emitted(11, 47) Source(13, 47) + SourceIndex(0) +1->Emitted(11, 1) Source(12, 1) + SourceIndex(0) +2 >Emitted(11, 5) Source(12, 5) + SourceIndex(0) +3 >Emitted(11, 44) Source(12, 44) + SourceIndex(0) +4 >Emitted(11, 47) Source(12, 47) + SourceIndex(0) --- >>>line 2"; 1 >^^^^^^^ @@ -224,8 +224,8 @@ sourceFile:sourceMap-LineBreaks.ts 1 >"line 1\ >line 2" 2 > ; -1 >Emitted(12, 8) Source(14, 8) + SourceIndex(0) -2 >Emitted(12, 9) Source(14, 9) + SourceIndex(0) +1 >Emitted(12, 8) Source(13, 8) + SourceIndex(0) +2 >Emitted(12, 9) Source(13, 9) + SourceIndex(0) --- >>>var stringLiteralWithCarriageReturn = "line 1\ 1-> 2 >^^^^ @@ -236,10 +236,10 @@ sourceFile:sourceMap-LineBreaks.ts 2 >var 3 > stringLiteralWithCarriageReturn 4 > = -1->Emitted(13, 1) Source(15, 1) + SourceIndex(0) -2 >Emitted(13, 5) Source(15, 5) + SourceIndex(0) -3 >Emitted(13, 36) Source(15, 36) + SourceIndex(0) -4 >Emitted(13, 39) Source(15, 39) + SourceIndex(0) +1->Emitted(13, 1) Source(14, 1) + SourceIndex(0) +2 >Emitted(13, 5) Source(14, 5) + SourceIndex(0) +3 >Emitted(13, 36) Source(14, 36) + SourceIndex(0) +4 >Emitted(13, 39) Source(14, 39) + SourceIndex(0) --- >>>line 2"; 1 >^^^^^^^ @@ -247,8 +247,8 @@ sourceFile:sourceMap-LineBreaks.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >"line 1\ >line 2" 2 > ; -1 >Emitted(14, 8) Source(16, 8) + SourceIndex(0) -2 >Emitted(14, 9) Source(16, 9) + SourceIndex(0) +1 >Emitted(14, 8) Source(15, 8) + SourceIndex(0) +2 >Emitted(14, 9) Source(15, 9) + SourceIndex(0) --- >>>var stringLiteralWithLineSeparator = "line 1\
1-> 2 >^^^^ @@ -260,10 +260,10 @@ sourceFile:sourceMap-LineBreaks.ts 2 >var 3 > stringLiteralWithLineSeparator 4 > = -1->Emitted(15, 1) Source(18, 1) + SourceIndex(0) -2 >Emitted(15, 5) Source(18, 5) + SourceIndex(0) -3 >Emitted(15, 35) Source(18, 35) + SourceIndex(0) -4 >Emitted(15, 38) Source(18, 38) + SourceIndex(0) +1->Emitted(15, 1) Source(17, 1) + SourceIndex(0) +2 >Emitted(15, 5) Source(17, 5) + SourceIndex(0) +3 >Emitted(15, 35) Source(17, 35) + SourceIndex(0) +4 >Emitted(15, 38) Source(17, 38) + SourceIndex(0) --- >>>line 2"; 1 >^^^^^^^ @@ -271,8 +271,8 @@ sourceFile:sourceMap-LineBreaks.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >"line 1\
 >line 2" 2 > ; -1 >Emitted(16, 8) Source(19, 8) + SourceIndex(0) -2 >Emitted(16, 9) Source(19, 9) + SourceIndex(0) +1 >Emitted(16, 8) Source(18, 8) + SourceIndex(0) +2 >Emitted(16, 9) Source(18, 9) + SourceIndex(0) --- >>>var stringLiteralWithParagraphSeparator = "line 1\
1-> 2 >^^^^ @@ -282,40 +282,38 @@ sourceFile:sourceMap-LineBreaks.ts 2 >var 3 > stringLiteralWithParagraphSeparator 4 > = -1->Emitted(17, 1) Source(20, 1) + SourceIndex(0) -2 >Emitted(17, 5) Source(20, 5) + SourceIndex(0) -3 >Emitted(17, 40) Source(20, 40) + SourceIndex(0) -4 >Emitted(17, 43) Source(20, 43) + SourceIndex(0) +1->Emitted(17, 1) Source(19, 1) + SourceIndex(0) +2 >Emitted(17, 5) Source(19, 5) + SourceIndex(0) +3 >Emitted(17, 40) Source(19, 40) + SourceIndex(0) +4 >Emitted(17, 43) Source(19, 43) + SourceIndex(0) --- >>>line 2"; 1 >^^^^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >"line 1\
 >line 2" 2 > ; -1 >Emitted(18, 8) Source(21, 8) + SourceIndex(0) -2 >Emitted(18, 9) Source(21, 9) + SourceIndex(0) +1 >Emitted(18, 8) Source(20, 8) + SourceIndex(0) +2 >Emitted(18, 9) Source(20, 9) + SourceIndex(0) --- ->>>var stringLiteralWithNextLine = "line 1\Â…1-> +>>>var stringLiteralWithNextLine = "line 1\Â…line 2"; +1-> 2 >^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 > ^^^ +5 > ^^^^^^^^^^^^^^^^ +6 > ^ 1->
 > 2 >var 3 > stringLiteralWithNextLine 4 > = -1->Emitted(19, 1) Source(22, 1) + SourceIndex(0) -2 >Emitted(19, 5) Source(22, 5) + SourceIndex(0) -3 >Emitted(19, 30) Source(22, 30) + SourceIndex(0) -4 >Emitted(19, 33) Source(22, 33) + SourceIndex(0) ---- ->>>line 2"; -1 >^^^^^^^ -2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >"line 1\Â… >line 2" -2 > ; -1 >Emitted(20, 8) Source(23, 8) + SourceIndex(0) -2 >Emitted(20, 9) Source(23, 9) + SourceIndex(0) +5 > "line 1\Â…line 2" +6 > ; +1->Emitted(19, 1) Source(21, 1) + SourceIndex(0) +2 >Emitted(19, 5) Source(21, 5) + SourceIndex(0) +3 >Emitted(19, 30) Source(21, 30) + SourceIndex(0) +4 >Emitted(19, 33) Source(21, 33) + SourceIndex(0) +5 >Emitted(19, 49) Source(21, 49) + SourceIndex(0) +6 >Emitted(19, 50) Source(21, 50) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMap-LineBreaks.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-LineBreaks.types b/tests/baselines/reference/sourceMap-LineBreaks.types index 6e5456e8f9f..cc2eebc973d 100644 --- a/tests/baselines/reference/sourceMap-LineBreaks.types +++ b/tests/baselines/reference/sourceMap-LineBreaks.types @@ -7,24 +7,24 @@ var endsWithCarriageReturnLineFeed = 1; var endsWithCarriageReturn = 1; var endsWithLineFeedCarriageReturn = 1; >endsWithNextLine : number - - var endsWithLineFeedCarriageReturnLineFeed = 1; >endsWithLineFeed : number + var endsWithLineFeedCarriageReturnLineFeed = 1; >endsWithCarriageReturnLineFeed : number -var stringLiteralWithLineFeed = "line 1\ >endsWithCarriageReturn : number -line 2"; +var stringLiteralWithLineFeed = "line 1\ >endsWithLineFeedCarriageReturn : number -var stringLiteralWithCarriageReturnLineFeed = "line 1\ line 2"; +var stringLiteralWithCarriageReturnLineFeed = "line 1\ >endsWithLineFeedCarriageReturnLineFeed : number +line 2"; var stringLiteralWithCarriageReturn = "line 1\ line 2"; - >stringLiteralWithLineFeed : string var stringLiteralWithLineSeparator = "line 1\
line 2";
var stringLiteralWithParagraphSeparator = "line 1\
line 2";
var stringLiteralWithNextLine = "line 1\Â…line 2"; +>stringLiteralWithCarriageReturnLineFeed : string + diff --git a/tests/baselines/reference/sourceMapValidationEnums.js.map b/tests/baselines/reference/sourceMapValidationEnums.js.map index 1627788c6b6..4729c3749b3 100644 --- a/tests/baselines/reference/sourceMapValidationEnums.js.map +++ b/tests/baselines/reference/sourceMapValidationEnums.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationEnums.js.map] -{"version":3,"file":"sourceMapValidationEnums.js","sourceRoot":"","sources":["sourceMapValidationEnums.ts"],"names":["e","e2","e3"],"mappings":"AAAA,IAAK,CAIJ;AAJD,WAAK,CAAC;IACFA,mBAACA,CAAAA;IACDA,mBAACA,CAAAA;IACDA,mBAACA,CAAAA;AACLA,CAACA,EAJI,CAAC,KAAD,CAAC,QAIL;AACD,IAAK,EAKJ;AALD,WAAK,EAAE;IACHC,aAAIA,EAAEA,OAAAA,CAAAA;IACNA,aAAIA,EAAEA,OAAAA,CAAAA;IACNA,sBAACA,CAAAA;IACDA,wBAAEA,CAAAA;AACNA,CAACA,EALI,EAAE,KAAF,EAAE,QAKN;AACD,IAAK,EACJ;AADD,WAAK,EAAE;AACPC,CAACA,EADI,EAAE,KAAF,EAAE,QACN"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationEnums.js","sourceRoot":"","sources":["sourceMapValidationEnums.ts"],"names":["e","e2","e3"],"mappings":"AAAA,IAAK,CAIJ;AAJD,WAAK,CAAC;IACFA,mBAACA,CAAAA;IACDA,mBAACA,CAAAA;IACDA,mBAACA,CAAAA;AACLA,CAACA,EAJI,CAAC,KAAD,CAAC,QAIL;AACD,IAAK,EAKJ;AALD,WAAK,EAAE;IACHC,sBAAMA,CAAAA;IACNA,sBAAMA,CAAAA;IACNA,sBAACA,CAAAA;IACDA,wBAAEA,CAAAA;AACNA,CAACA,EALI,EAAE,KAAF,EAAE,QAKN;AACD,IAAK,EACJ;AADD,WAAK,EAAE;AACPC,CAACA,EADI,EAAE,KAAF,EAAE,QACN"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationEnums.sourcemap.txt b/tests/baselines/reference/sourceMapValidationEnums.sourcemap.txt index 337aa0989d3..9d8b36ca5ed 100644 --- a/tests/baselines/reference/sourceMapValidationEnums.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationEnums.sourcemap.txt @@ -134,41 +134,29 @@ sourceFile:sourceMapValidationEnums.ts --- >>> e2[e2["x"] = 10] = "x"; 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^ -4 > ^^^^^^^ -5 > ^ -6 > ^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^-> 1-> { > -2 > x = -3 > 10 -4 > -5 > +2 > x = 10 +3 > 1->Emitted(9, 5) Source(7, 5) + SourceIndex(0) name (e2) -2 >Emitted(9, 18) Source(7, 9) + SourceIndex(0) name (e2) -3 >Emitted(9, 20) Source(7, 11) + SourceIndex(0) name (e2) -4 >Emitted(9, 27) Source(7, 11) + SourceIndex(0) name (e2) -5 >Emitted(9, 28) Source(7, 11) + SourceIndex(0) name (e2) +2 >Emitted(9, 27) Source(7, 11) + SourceIndex(0) name (e2) +3 >Emitted(9, 28) Source(7, 11) + SourceIndex(0) name (e2) --- >>> e2[e2["y"] = 10] = "y"; 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^ -4 > ^^^^^^^ -5 > ^ -6 > ^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^-> 1->, > -2 > y = -3 > 10 -4 > -5 > +2 > y = 10 +3 > 1->Emitted(10, 5) Source(8, 5) + SourceIndex(0) name (e2) -2 >Emitted(10, 18) Source(8, 9) + SourceIndex(0) name (e2) -3 >Emitted(10, 20) Source(8, 11) + SourceIndex(0) name (e2) -4 >Emitted(10, 27) Source(8, 11) + SourceIndex(0) name (e2) -5 >Emitted(10, 28) Source(8, 11) + SourceIndex(0) name (e2) +2 >Emitted(10, 27) Source(8, 11) + SourceIndex(0) name (e2) +3 >Emitted(10, 28) Source(8, 11) + SourceIndex(0) name (e2) --- >>> e2[e2["z"] = 11] = "z"; 1->^^^^ diff --git a/tests/baselines/reference/subtypesOfTypeParameter.js b/tests/baselines/reference/subtypesOfTypeParameter.js index c14e5c01a26..d9901e6cea4 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.js +++ b/tests/baselines/reference/subtypesOfTypeParameter.js @@ -202,8 +202,8 @@ function f2(x, y) { var r12 = true ? x : c2; var r13 = true ? E : x; var r13 = true ? x : E; - var r14 = true ? 0 /* A */ : x; - var r14 = true ? x : 0 /* A */; + var r14 = true ? E.A : x; + var r14 = true ? x : E.A; var af; var r15 = true ? af : x; var r15 = true ? x : af; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js index 9c52fa671e5..07f2170aca1 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.js @@ -281,8 +281,8 @@ function f15(x) { function f16(x) { var r13 = true ? E : x; // ok var r13 = true ? x : E; // ok - var r14 = true ? 0 /* A */ : x; // ok - var r14 = true ? x : 0 /* A */; // ok + var r14 = true ? E.A : x; // ok + var r14 = true ? x : E.A; // ok } function f17(x) { var af; diff --git a/tests/baselines/reference/symbolDeclarationEmit12.js b/tests/baselines/reference/symbolDeclarationEmit12.js index 9a75f6d573c..ab930b41580 100644 --- a/tests/baselines/reference/symbolDeclarationEmit12.js +++ b/tests/baselines/reference/symbolDeclarationEmit12.js @@ -15,7 +15,7 @@ module M { //// [symbolDeclarationEmit12.js] var M; (function (M) { - export class C { + class C { [Symbol.toPrimitive](x) { } [Symbol.isConcatSpreadable]() { @@ -27,4 +27,5 @@ var M; set [Symbol.isRegExp](x) { } } + M.C = C; })(M || (M = {})); diff --git a/tests/baselines/reference/typeAliases.js b/tests/baselines/reference/typeAliases.js index 7f1597939ea..062a7410927 100644 --- a/tests/baselines/reference/typeAliases.js +++ b/tests/baselines/reference/typeAliases.js @@ -119,7 +119,7 @@ var E; (function (E) { E[E["x"] = 10] = "x"; })(E || (E = {})); -f15(10 /* x */).toLowerCase(); +f15(E.x).toLowerCase(); var x; f16(x); var y = [ diff --git a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.js b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.js index 7b0708c38a9..95220d4fdcf 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.js +++ b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.js @@ -81,13 +81,13 @@ var v1 = f1({ r: function () { return 0; } -}, 0 /* X */); +}, E1.X); var v1 = f1({ w: function (x) { return x; }, r: function () { - return 0 /* X */; + return E1.X; } }, 0); var v2; @@ -96,14 +96,14 @@ var v2 = f1({ return x; }, r: function () { - return 0 /* X */; + return E1.X; } -}, 0 /* X */); +}, E1.X); var v3 = f1({ w: function (x) { return x; }, r: function () { - return 0 /* X */; + return E1.X; } -}, 0 /* X */); // Error +}, E2.X); // Error diff --git a/tests/baselines/reference/typeofEnum.js b/tests/baselines/reference/typeofEnum.js index 388c6250aef..b8286fac713 100644 --- a/tests/baselines/reference/typeofEnum.js +++ b/tests/baselines/reference/typeofEnum.js @@ -14,4 +14,4 @@ var E; E[E["e2"] = 1] = "e2"; })(E || (E = {})); var e1; -0 /* e1 */; +e1.e1; diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.js b/tests/baselines/reference/typeofOperatorWithEnumType.js index 900b610cef4..2e2963b0955 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.js +++ b/tests/baselines/reference/typeofOperatorWithEnumType.js @@ -44,15 +44,15 @@ var ENUM1; var ResultIsString1 = typeof ENUM; var ResultIsString2 = typeof ENUM1; // enum type expressions -var ResultIsString3 = typeof 0 /* "A" */; -var ResultIsString4 = typeof (ENUM[0] + 1 /* "B" */); +var ResultIsString3 = typeof ENUM1["A"]; +var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); // multiple typeof operators var ResultIsString5 = typeof typeof ENUM; -var ResultIsString6 = typeof typeof typeof (ENUM[0] + 1 /* B */); +var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); // miss assignment operators typeof ENUM; typeof ENUM1; -typeof 1 /* "B" */; +typeof ENUM1["B"]; typeof ENUM, ENUM1; // use typeof in type query var z; diff --git a/tests/baselines/reference/unaryPlus.js b/tests/baselines/reference/unaryPlus.js index 7daf873c324..bc070c9655b 100644 --- a/tests/baselines/reference/unaryPlus.js +++ b/tests/baselines/reference/unaryPlus.js @@ -21,7 +21,7 @@ var E; E[E["thing"] = 1] = "thing"; })(E || (E = {})); ; -var c = +0 /* some */; +var c = +E.some; // also allowed, used to be errors var x = +"3"; //should be valid var y = -"3"; // should be valid diff --git a/tests/baselines/reference/validEnumAssignments.js b/tests/baselines/reference/validEnumAssignments.js index 1d733882800..4cb975c42e4 100644 --- a/tests/baselines/reference/validEnumAssignments.js +++ b/tests/baselines/reference/validEnumAssignments.js @@ -36,13 +36,13 @@ var n; var a; var e; n = e; -n = 0 /* A */; +n = E.A; a = n; a = e; -a = 0 /* A */; +a = E.A; e = e; -e = 0 /* A */; -e = 1 /* B */; +e = E.A; +e = E.B; e = n; e = null; e = undefined; diff --git a/tests/baselines/reference/validNullAssignments.js b/tests/baselines/reference/validNullAssignments.js index 896e888b28f..46ef3807464 100644 --- a/tests/baselines/reference/validNullAssignments.js +++ b/tests/baselines/reference/validNullAssignments.js @@ -41,7 +41,7 @@ var E; (function (E) { E[E["A"] = 0] = "A"; })(E || (E = {})); -0 /* A */ = null; // error +E.A = null; // error var C = (function () { function C() { } diff --git a/tests/baselines/reference/validNumberAssignments.js b/tests/baselines/reference/validNumberAssignments.js index ec15502afa4..e81a5fd1ecb 100644 --- a/tests/baselines/reference/validNumberAssignments.js +++ b/tests/baselines/reference/validNumberAssignments.js @@ -20,5 +20,5 @@ var E; })(E || (E = {})); ; var d = x; -var e = 0 /* A */; +var e = E.A; e = x; diff --git a/tests/baselines/reference/voidOperatorWithEnumType.js b/tests/baselines/reference/voidOperatorWithEnumType.js index 478ac85651b..d11245b3475 100644 --- a/tests/baselines/reference/voidOperatorWithEnumType.js +++ b/tests/baselines/reference/voidOperatorWithEnumType.js @@ -39,13 +39,13 @@ var ENUM1; var ResultIsAny1 = void ENUM; var ResultIsAny2 = void ENUM1; // enum type expressions -var ResultIsAny3 = void 0 /* "A" */; -var ResultIsAny4 = void (ENUM[0] + 1 /* "B" */); +var ResultIsAny3 = void ENUM1["A"]; +var ResultIsAny4 = void (ENUM[0] + ENUM1["B"]); // multiple void operators var ResultIsAny5 = void void ENUM; -var ResultIsAny6 = void void void (ENUM[0] + 1 /* B */); +var ResultIsAny6 = void void void (ENUM[0] + ENUM1.B); // miss assignment operators void ENUM; void ENUM1; -void 1 /* "B" */; +void ENUM1["B"]; void ENUM, ENUM1; diff --git a/tests/cases/compiler/declarationEmitDefaultExport1.ts b/tests/cases/compiler/declarationEmitDefaultExport1.ts new file mode 100644 index 00000000000..3ce76e2f3b3 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport1.ts @@ -0,0 +1,4 @@ +// @declaration: true +// @target: es6 +export default class C { +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDefaultExport2.ts b/tests/cases/compiler/declarationEmitDefaultExport2.ts new file mode 100644 index 00000000000..ee691f3bdcf --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport2.ts @@ -0,0 +1,4 @@ +// @declaration: true +// @target: es6 +export default class { +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDefaultExport3.ts b/tests/cases/compiler/declarationEmitDefaultExport3.ts new file mode 100644 index 00000000000..fceefe32f7d --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport3.ts @@ -0,0 +1,5 @@ +// @declaration: true +// @target: es6 +export default function foo() { + return "" +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDefaultExport4.ts b/tests/cases/compiler/declarationEmitDefaultExport4.ts new file mode 100644 index 00000000000..9daad837f73 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport4.ts @@ -0,0 +1,5 @@ +// @declaration: true +// @target: es6 +export default function () { + return 1; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDefaultExport5.ts b/tests/cases/compiler/declarationEmitDefaultExport5.ts new file mode 100644 index 00000000000..3265753c514 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport5.ts @@ -0,0 +1,3 @@ +// @declaration: true +// @target: es6 +export default 1 + 2; diff --git a/tests/cases/compiler/declarationEmitDefaultExport6.ts b/tests/cases/compiler/declarationEmitDefaultExport6.ts new file mode 100644 index 00000000000..468486b9bb0 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport6.ts @@ -0,0 +1,4 @@ +// @declaration: true +// @target: es6 +export class A {} +export default new A(); diff --git a/tests/cases/compiler/declarationEmitDefaultExport7.ts b/tests/cases/compiler/declarationEmitDefaultExport7.ts new file mode 100644 index 00000000000..960c203dcab --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExport7.ts @@ -0,0 +1,4 @@ +// @declaration: true +// @target: es6 +class A {} +export default new A(); diff --git a/tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts b/tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts new file mode 100644 index 00000000000..fc3dac87ae0 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts @@ -0,0 +1,10 @@ +// @declaration: true + +var [] = [1, "hello"]; // Dont emit anything +var [x] = [1, "hello"]; // emit x: number +var [x1, y1] = [1, "hello"]; // emit x1: number, y1: string +var [, , z1] = [0, 1, 2]; // emit z1: number + +var a = [1, "hello"]; +var [x2] = a; // emit x2: number | string +var [x3, y3, z3] = a; // emit x3, y3, z3 \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts b/tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts new file mode 100644 index 00000000000..f116423715a --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts @@ -0,0 +1,10 @@ +// @declaration: true +var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; + +var [x11 = 0, y11 = ""] = [1, "hello"]; +var [a11, b11, c11] = []; + +var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; + +var [x13, y13] = [1, "hello"]; +var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; diff --git a/tests/cases/compiler/declarationEmitDestructuringArrayPattern3.ts b/tests/cases/compiler/declarationEmitDestructuringArrayPattern3.ts new file mode 100644 index 00000000000..9cdc6c2ec90 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringArrayPattern3.ts @@ -0,0 +1,4 @@ +// @declaration: true +module M { + export var [a, b] = [1, 2]; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringArrayPattern4.ts b/tests/cases/compiler/declarationEmitDestructuringArrayPattern4.ts new file mode 100644 index 00000000000..8f162e33da3 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringArrayPattern4.ts @@ -0,0 +1,10 @@ +// @declaration: true +var [...a5] = [1, 2, 3]; +var [x14, ...a6] = [1, 2, 3]; +var [x15, y15, ...a7] = [1, 2, 3]; +var [x16, y16, z16, ...a8] = [1, 2, 3]; + +var [...a9] = [1, "hello", true]; +var [x17, ...a10] = [1, "hello", true]; +var [x18, y18, ...a12] = [1, "hello", true]; +var [x19, y19, z19, ...a13] = [1, "hello", true]; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts new file mode 100644 index 00000000000..89e5b65a9d3 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts @@ -0,0 +1,23 @@ +// @declaration: true + +var { } = { x: 5, y: "hello" }; +var { x4 } = { x4: 5, y4: "hello" }; +var { y5 } = { x5: 5, y5: "hello" }; +var { x6, y6 } = { x6: 5, y6: "hello" }; +var { x7: a1 } = { x7: 5, y7: "hello" }; +var { y8: b1 } = { x8: 5, y8: "hello" }; +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; +} +var { a4, b4, c4 } = f15(); + +module m { + export var { a4, b4, c4 } = f15(); +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts new file mode 100644 index 00000000000..6a65c925465 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts @@ -0,0 +1,9 @@ +// @declaration: true + +var { } = { x: 5, y: "hello" }; +var { x4 } = { x4: 5, y4: "hello" }; +var { y5 } = { x5: 5, y5: "hello" }; +var { x6, y6 } = { x6: 5, y6: "hello" }; +var { x7: a1 } = { x7: 5, y7: "hello" }; +var { y8: b1 } = { x8: 5, y8: "hello" }; +var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts new file mode 100644 index 00000000000..f700e68e397 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts @@ -0,0 +1,15 @@ +// @declaration: true + +var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + +function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; +} +var { a4, b4, c4 } = f15(); + +module m { + export var { a4, b4, c4 } = f15(); +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts b/tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts new file mode 100644 index 00000000000..020a29ba219 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringOptionalBindingParametersInOverloads.ts @@ -0,0 +1,10 @@ +// @declaration: true + +function foo([x, y, z] ?: [string, number, boolean]); +function foo(...rest: any[]) { +} + +function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); +function foo2(...rest: any[]) { + +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts b/tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts new file mode 100644 index 00000000000..597497feac0 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts @@ -0,0 +1,17 @@ +// @declaration: true +class C1 { + constructor(public [x, y, z]: string[]) { + } +} + +type TupleType1 =[string, number, boolean]; +class C2 { + constructor(public [x, y, z]: TupleType1) { + } +} + +type ObjType1 = { x: number; y: string; z: boolean } +class C3 { + constructor(public { x, y, z }: ObjType1) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts b/tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts new file mode 100644 index 00000000000..987fb67a08b --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts @@ -0,0 +1,6 @@ +// @declaration: true +module m { + class c { + } + export var [x, y, z] = [10, new c(), 30]; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts b/tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts new file mode 100644 index 00000000000..c3785acd09a --- /dev/null +++ b/tests/cases/compiler/declarationEmitDestructuringWithOptionalBindingParameters.ts @@ -0,0 +1,5 @@ +// @declaration: true +function foo([x,y,z]?: [string, number, boolean]) { +} +function foo1( { x, y, z }?: { x: string; y: number; z: boolean }) { +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitImportInExportAssignmentModule.ts b/tests/cases/compiler/declarationEmitImportInExportAssignmentModule.ts new file mode 100644 index 00000000000..b246ba32ba4 --- /dev/null +++ b/tests/cases/compiler/declarationEmitImportInExportAssignmentModule.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @module: commonjs + +module m { + export module c { + export class c { + } + } + import x = c; + export var a: typeof x; +} +export = m; \ No newline at end of file diff --git a/tests/cases/compiler/es5ExportDefaultClassDeclaration.ts b/tests/cases/compiler/es5ExportDefaultClassDeclaration.ts new file mode 100644 index 00000000000..bea07832cd5 --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultClassDeclaration.ts @@ -0,0 +1,7 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export default class C { + method() { } +} diff --git a/tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts b/tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts new file mode 100644 index 00000000000..e7ae24f5d87 --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultClassDeclaration2.ts @@ -0,0 +1,7 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export default class { + method() { } +} diff --git a/tests/cases/compiler/es5ExportDefaultExpression.ts b/tests/cases/compiler/es5ExportDefaultExpression.ts new file mode 100644 index 00000000000..772998decef --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultExpression.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export default (1 + 2); diff --git a/tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts b/tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts new file mode 100644 index 00000000000..ef9da753ab0 --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultFunctionDeclaration.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export default function f() { } diff --git a/tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts b/tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts new file mode 100644 index 00000000000..2b8a99a3817 --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export default function () { } diff --git a/tests/cases/compiler/es5ExportDefaultIdentifier.ts b/tests/cases/compiler/es5ExportDefaultIdentifier.ts new file mode 100644 index 00000000000..8f34253208e --- /dev/null +++ b/tests/cases/compiler/es5ExportDefaultIdentifier.ts @@ -0,0 +1,7 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export function f() { } + +export default f; diff --git a/tests/cases/compiler/es5ExportEquals.ts b/tests/cases/compiler/es5ExportEquals.ts new file mode 100644 index 00000000000..5016bdb7b1b --- /dev/null +++ b/tests/cases/compiler/es5ExportEquals.ts @@ -0,0 +1,7 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +export function f() { } + +export = f; diff --git a/tests/cases/compiler/es5ModuleInternalNamedImports.ts b/tests/cases/compiler/es5ModuleInternalNamedImports.ts new file mode 100644 index 00000000000..05943d1c67e --- /dev/null +++ b/tests/cases/compiler/es5ModuleInternalNamedImports.ts @@ -0,0 +1,33 @@ +// @target: ES5 +// @module: AMD + +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}; + 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}; +} diff --git a/tests/cases/compiler/es5ModuleWithModuleGenAmd.ts b/tests/cases/compiler/es5ModuleWithModuleGenAmd.ts new file mode 100644 index 00000000000..051c77f808e --- /dev/null +++ b/tests/cases/compiler/es5ModuleWithModuleGenAmd.ts @@ -0,0 +1,13 @@ +// @target: ES5 +// @module: amd +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts b/tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts new file mode 100644 index 00000000000..31720bddbcb --- /dev/null +++ b/tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts @@ -0,0 +1,13 @@ +// @target: ES5 +// @module: commonjs +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts b/tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts new file mode 100644 index 00000000000..c9504ef9fcb --- /dev/null +++ b/tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts @@ -0,0 +1,12 @@ +// @target: ES5 +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportAll.ts b/tests/cases/compiler/es6ExportAll.ts new file mode 100644 index 00000000000..ed2b47c23c4 --- /dev/null +++ b/tests/cases/compiler/es6ExportAll.ts @@ -0,0 +1,17 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export * from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportAllInEs5.ts b/tests/cases/compiler/es6ExportAllInEs5.ts new file mode 100644 index 00000000000..ed754e5cacb --- /dev/null +++ b/tests/cases/compiler/es6ExportAllInEs5.ts @@ -0,0 +1,18 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export * from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportAssignment.ts b/tests/cases/compiler/es6ExportAssignment.ts new file mode 100644 index 00000000000..f1f2cce9923 --- /dev/null +++ b/tests/cases/compiler/es6ExportAssignment.ts @@ -0,0 +1,4 @@ +// @target: es6 + +var a = 10; +export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClause.ts b/tests/cases/compiler/es6ExportClause.ts new file mode 100644 index 00000000000..a16e2c9e7aa --- /dev/null +++ b/tests/cases/compiler/es6ExportClause.ts @@ -0,0 +1,19 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseInEs5.ts b/tests/cases/compiler/es6ExportClauseInEs5.ts new file mode 100644 index 00000000000..675f302bcb6 --- /dev/null +++ b/tests/cases/compiler/es6ExportClauseInEs5.ts @@ -0,0 +1,20 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: server.ts +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts new file mode 100644 index 00000000000..22a6cef4203 --- /dev/null +++ b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts @@ -0,0 +1,21 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts new file mode 100644 index 00000000000..6361c013367 --- /dev/null +++ b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts @@ -0,0 +1,22 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts b/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts new file mode 100644 index 00000000000..3d731753ee4 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export default class C { + method() { } +} diff --git a/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts b/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts new file mode 100644 index 00000000000..7092d15ef52 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export default class { + method() { } +} diff --git a/tests/cases/compiler/es6ExportDefaultExpression.ts b/tests/cases/compiler/es6ExportDefaultExpression.ts new file mode 100644 index 00000000000..ef476210541 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultExpression.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default (1 + 2); diff --git a/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts new file mode 100644 index 00000000000..19984bde2a6 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default function f() { } diff --git a/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts new file mode 100644 index 00000000000..022fbd81233 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default function () { } diff --git a/tests/cases/compiler/es6ExportDefaultIdentifier.ts b/tests/cases/compiler/es6ExportDefaultIdentifier.ts new file mode 100644 index 00000000000..1590677d4ce --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultIdentifier.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export function f() { } + +export default f; diff --git a/tests/cases/compiler/es6ExportEquals.ts b/tests/cases/compiler/es6ExportEquals.ts new file mode 100644 index 00000000000..5dfc98b4c93 --- /dev/null +++ b/tests/cases/compiler/es6ExportEquals.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export function f() { } + +export = f; diff --git a/tests/cases/compiler/es6ImportDefaultBinding.ts b/tests/cases/compiler/es6ImportDefaultBinding.ts index dc5b4ab98d6..3007a9e82fa 100644 --- a/tests/cases/compiler/es6ImportDefaultBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBinding.ts @@ -1,8 +1,12 @@ // @target: es6 -// @module: commonjs +// @declaration: true +// @declaration: true // @filename: es6ImportDefaultBinding_0.ts -export var a = 10; +var a = 10; +export = a; // @filename: es6ImportDefaultBinding_1.ts -import defaultBinding from "es6ImportDefaultBinding_0"; \ No newline at end of file +import defaultBinding from "es6ImportDefaultBinding_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingAmd.ts b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts new file mode 100644 index 00000000000..85e06b8c99d --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts @@ -0,0 +1,11 @@ +// @module: amd +// @declaration: true + +// @filename: es6ImportDefaultBindingAmd_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingAmd_1.ts +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingDts.ts new file mode 100644 index 00000000000..4700782b78e --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingDts.ts @@ -0,0 +1,11 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +class c { } +export = c; + +// @filename: client.ts +import defaultBinding from "server"; +export var x = new defaultBinding(); +import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts index 96b277d6640..a0524dd2138 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts @@ -1,5 +1,6 @@ // @target: es6 // @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImport_0.ts export var a = 10; @@ -7,9 +8,15 @@ export var x = a; export var m = a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport_1.ts -import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; \ No newline at end of file +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = a; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = b; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = x; +var x1: number = y; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = z; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts new file mode 100644 index 00000000000..c1ac752426e --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts @@ -0,0 +1,20 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1_1.ts +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts new file mode 100644 index 00000000000..80bc2a4474e --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts @@ -0,0 +1,21 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +var x: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts new file mode 100644 index 00000000000..fef56560dcf --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts @@ -0,0 +1,20 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +var a = 10; +export = a; + +// @filename: client.ts +export import defaultBinding1, { } from "server"; +export var x1: number = defaultBinding1; +export import defaultBinding2, { a } from "server"; +export var x1: number = defaultBinding2; +export import defaultBinding3, { a as b } from "server"; +export var x1: number = defaultBinding3; +export import defaultBinding4, { x, a as y } from "server"; +export var x1: number = defaultBinding4; +export import defaultBinding5, { x as z, } from "server"; +export var x1: number = defaultBinding5; +export import defaultBinding6, { m, } from "server"; +export var x1: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts new file mode 100644 index 00000000000..a84dab94033 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts @@ -0,0 +1,24 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class a { } +export class x { } +export class m { } +export class a11 { } +export class a12 { } +export class x11 { } + +// @filename: client.ts +import defaultBinding1, { } from "server"; +import defaultBinding2, { a } from "server"; +export var x1 = new a(); +import defaultBinding3, { a11 as b } from "server"; +export var x2 = new b(); +import defaultBinding4, { x, a12 as y } from "server"; +export var x4 = new x(); +export var x5 = new y(); +import defaultBinding5, { x11 as z, } from "server"; +export var x3 = new z(); +import defaultBinding6, { m, } from "server"; +export var x6 = new m(); diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts new file mode 100644 index 00000000000..1951a8a6b30 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts @@ -0,0 +1,20 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +class a { } +export = a; + +// @filename: client.ts +import defaultBinding1, { } from "server"; +export var x1 = new defaultBinding1(); +import defaultBinding2, { a } from "server"; +export var x2 = new defaultBinding2(); +import defaultBinding3, { a as b } from "server"; +export var x3 = new defaultBinding3(); +import defaultBinding4, { x, a as y } from "server"; +export var x4 = new defaultBinding4(); +import defaultBinding5, { x as z, } from "server"; +export var x5 = new defaultBinding5(); +import defaultBinding6, { m, } from "server"; +export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts index bf34687f791..6e42898d1bc 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts @@ -1,5 +1,6 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.ts export var a = 10; @@ -7,9 +8,15 @@ export var x = a; export var m = a; // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts -import defaultBinding, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; \ No newline at end of file +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = a; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = b; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = x; +var x1: number = y; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = z; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts new file mode 100644 index 00000000000..6e3ac5786d1 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts @@ -0,0 +1,21 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +export var a = 10; +export var x = a; +export var m = a; + +// @filename: client.ts +export import defaultBinding1, { } from "server"; +export import defaultBinding2, { a } from "server"; +export var x1: number = a; +export import defaultBinding3, { a as b } from "server"; +export var x1: number = b; +export import defaultBinding4, { x, a as y } from "server"; +export var x1: number = x; +export var x1: number = y; +export import defaultBinding5, { x as z, } from "server"; +export var x1: number = z; +export import defaultBinding6, { m, } from "server"; +export var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts index 3d029e28738..e0f9d953afe 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts @@ -1,8 +1,10 @@ // @target: es6 -// @module: commonjs +// @declaration: true +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; \ No newline at end of file +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts new file mode 100644 index 00000000000..81113b776b4 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts @@ -0,0 +1,10 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts new file mode 100644 index 00000000000..db076b87c9a --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts new file mode 100644 index 00000000000..ce42814a918 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.ts @@ -0,0 +1,10 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +var a = 10; +export = a; + +// @filename: client.ts +export import defaultBinding, * as nameSpaceBinding from "server"; +export var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts new file mode 100644 index 00000000000..732f7ef7ba0 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class a { } + +// @filename: client.ts +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts new file mode 100644 index 00000000000..1f026af8f34 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts @@ -0,0 +1,10 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +class a { } +export = a; + +// @filename: client.ts +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new defaultBinding(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts index 5943fa8bfc4..c58ba286e0a 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts @@ -1,8 +1,10 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; \ No newline at end of file +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts new file mode 100644 index 00000000000..cafcace08a0 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export var a = 10; + +// @filename: client.ts +export import defaultBinding, * as nameSpaceBinding from "server"; +export var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts index c037d283dfa..e0877bd74c1 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts @@ -1,8 +1,10 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingInEs5_0.ts -export var a = 10; +var a = 10; +export = a; // @filename: es6ImportDefaultBindingInEs5_1.ts import defaultBinding from "es6ImportDefaultBindingInEs5_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts new file mode 100644 index 00000000000..cd1bad83716 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -0,0 +1,15 @@ +// @module: commonjs + +// @filename: es6ImportDefaultBindingMergeErrors_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingMergeErrors_1.ts +import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +interface defaultBinding { // This is ok +} +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +var defaultBinding2 = "hello world"; +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error diff --git a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts new file mode 100644 index 00000000000..5ab1c743721 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts @@ -0,0 +1,7 @@ +// @module: commonjs + +// @filename: es6ImportDefaultBindingNoDefaultProperty_0.ts +export var a = 10; + +// @filename: es6ImportDefaultBindingNoDefaultProperty_1.ts +import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts new file mode 100644 index 00000000000..87494c8a622 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingWithExport.ts @@ -0,0 +1,11 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +var a = 10; +export = a; + +// @filename: client.ts +export import defaultBinding from "server"; +export var x = defaultBinding; +export import defaultBinding2 from "server"; // non referenced \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportEqualsDeclaration.ts b/tests/cases/compiler/es6ImportEqualsDeclaration.ts new file mode 100644 index 00000000000..7df85a31d75 --- /dev/null +++ b/tests/cases/compiler/es6ImportEqualsDeclaration.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// @filename: server.ts +var a = 10; +export = a; + +// @filename: client.ts +import a = require("server"); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImport.ts b/tests/cases/compiler/es6ImportNameSpaceImport.ts index 9937606c41f..0c831d323d1 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImport.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImport.ts @@ -1,8 +1,11 @@ // @target: es6 // @module: commonjs +// @declaration: true // @filename: es6ImportNameSpaceImport_0.ts export var a = 10; // @filename: es6ImportNameSpaceImport_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; \ No newline at end of file +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportAmd.ts b/tests/cases/compiler/es6ImportNameSpaceImportAmd.ts new file mode 100644 index 00000000000..89a5ad7bc2c --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportAmd.ts @@ -0,0 +1,10 @@ +// @module: amd +// @declaration: true + +// @filename: es6ImportNameSpaceImportAmd_0.ts +export var a = 10; + +// @filename: es6ImportNameSpaceImportAmd_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImportAmd_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportAmd_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportDts.ts b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts new file mode 100644 index 00000000000..95b85e53edc --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class c { }; + +// @filename: client.ts +import * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.c(); +import * as nameSpaceBinding2 from "server"; // unreferenced \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts index ca00ac3f981..8104fe8b3c0 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts @@ -1,8 +1,11 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportNameSpaceImportInEs5_0.ts export var a = 10; // @filename: es6ImportNameSpaceImportInEs5_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; \ No newline at end of file +import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts new file mode 100644 index 00000000000..d4b69e8bcf4 --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts @@ -0,0 +1,15 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNameSpaceImportMergeErrors_0.ts +export var a = 10; + +// @filename: es6ImportNameSpaceImportMergeErrors_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +interface nameSpaceBinding { } // this should be ok + +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + +import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +var nameSpaceBinding3 = 10; diff --git a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts new file mode 100644 index 00000000000..7d3bdcec94c --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNameSpaceImportNoNamedExports_0.ts +var a = 10; +export = a; + +// @filename: es6ImportNameSpaceImportNoNamedExports_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImportWithExport.ts b/tests/cases/compiler/es6ImportNameSpaceImportWithExport.ts new file mode 100644 index 00000000000..4110270d7dd --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportWithExport.ts @@ -0,0 +1,10 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +export var a = 10; + +// @filename: client.ts +export import * as nameSpaceBinding from "server"; +export var x = nameSpaceBinding.a; +export import * as nameSpaceBinding2 from "server"; // Not referenced imports diff --git a/tests/cases/compiler/es6ImportNamedImport.ts b/tests/cases/compiler/es6ImportNamedImport.ts index ed34434bd29..0a12e10169b 100644 --- a/tests/cases/compiler/es6ImportNamedImport.ts +++ b/tests/cases/compiler/es6ImportNamedImport.ts @@ -1,5 +1,6 @@ // @target: es6 // @module: commonjs +// @declaration: true // @filename: es6ImportNamedImport_0.ts export var a = 10; @@ -7,13 +8,35 @@ export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; // @filename: es6ImportNamedImport_1.ts import { } from "es6ImportNamedImport_0"; import { a } from "es6ImportNamedImport_0"; +var xxxx = a; import { a as b } from "es6ImportNamedImport_0"; +var xxxx = b; import { x, a as y } from "es6ImportNamedImport_0"; +var xxxx = x; +var xxxx = y; import { x as z, } from "es6ImportNamedImport_0"; +var xxxx = z; import { m, } from "es6ImportNamedImport_0"; +var xxxx = m; import { a1, x1 } from "es6ImportNamedImport_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; \ No newline at end of file +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImport_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImport_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImport_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImport_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportAmd.ts b/tests/cases/compiler/es6ImportNamedImportAmd.ts new file mode 100644 index 00000000000..3ddf1a4cf52 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportAmd.ts @@ -0,0 +1,41 @@ +// @module: amd +// @declaration: true + +// @filename: es6ImportNamedImportAmd_0.ts +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; + +// @filename: es6ImportNamedImportAmd_1.ts +import { } from "es6ImportNamedImportAmd_0"; +import { a } from "es6ImportNamedImportAmd_0"; +var xxxx = a; +import { a as b } from "es6ImportNamedImportAmd_0"; +var xxxx = b; +import { x, a as y } from "es6ImportNamedImportAmd_0"; +var xxxx = x; +var xxxx = y; +import { x as z, } from "es6ImportNamedImportAmd_0"; +var xxxx = z; +import { m, } from "es6ImportNamedImportAmd_0"; +var xxxx = m; +import { a1, x1 } from "es6ImportNamedImportAmd_0"; +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImportAmd_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImportAmd_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImportAmd_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImportAmd_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportAmd_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportDts.ts b/tests/cases/compiler/es6ImportNamedImportDts.ts new file mode 100644 index 00000000000..d83672f3754 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportDts.ts @@ -0,0 +1,46 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class a { } +export class a11 { } +export class a12 { } +export class x { } +export class x11 { } +export class m { } +export class a1 { } +export class x1 { } +export class a111 { } +export class x111 { } +export class z1 { } +export class z2 { } +export class aaaa { } +export class aaaa1 { } + +// @filename: client.ts +import { } from "server"; +import { a } from "server"; +export var xxxx = new a(); +import { a11 as b } from "server"; +export var xxxx1 = new b(); +import { x, a12 as y } from "server"; +export var xxxx2 = new x(); +export var xxxx3 = new y(); +import { x11 as z, } from "server"; +export var xxxx4 = new z(); +import { m, } from "server"; +export var xxxx5 = new m(); +import { a1, x1 } from "server"; +export var xxxx6 = new a1(); +export var xxxx7 = new x1(); +import { a111 as a11, x111 as x11 } from "server"; +export var xxxx8 = new a11(); +export var xxxx9 = new x11(); +import { z1 } from "server"; +export var z111 = new z1(); +import { z2 as z3 } from "server"; +export var z2 = new z3(); // z2 shouldn't give redeclare error + +// not referenced +import { aaaa } from "server"; +import { aaaa1 as bbbb } from "server"; diff --git a/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts b/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts index e1be293e446..ea1ed5cbff6 100644 --- a/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts +++ b/tests/cases/compiler/es6ImportNamedImportIdentifiersParsing.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs import { yield } from "somemodule"; // Allowed import { default } from "somemodule"; // Error - as this is keyword that is not allowed as identifier diff --git a/tests/cases/compiler/es6ImportNamedImportInEs5.ts b/tests/cases/compiler/es6ImportNamedImportInEs5.ts index 22e66bc95fa..e12a8d032d3 100644 --- a/tests/cases/compiler/es6ImportNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNamedImportInEs5.ts @@ -1,5 +1,6 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportNamedImportInEs5_0.ts export var a = 10; @@ -7,13 +8,35 @@ export var x = a; export var m = a; export var a1 = 10; export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; // @filename: es6ImportNamedImportInEs5_1.ts import { } from "es6ImportNamedImportInEs5_0"; import { a } from "es6ImportNamedImportInEs5_0"; +var xxxx = a; import { a as b } from "es6ImportNamedImportInEs5_0"; +var xxxx = b; import { x, a as y } from "es6ImportNamedImportInEs5_0"; +var xxxx = x; +var xxxx = y; import { x as z, } from "es6ImportNamedImportInEs5_0"; +var xxxx = z; import { m, } from "es6ImportNamedImportInEs5_0"; +var xxxx = m; import { a1, x1 } from "es6ImportNamedImportInEs5_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; \ No newline at end of file +var xxxx = a1; +var xxxx = x1; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +var xxxx = a11; +var xxxx = x11; +import { z1 } from "es6ImportNamedImportInEs5_0"; +var z111 = z1; +import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +var z2 = z3; // z2 shouldn't give redeclare error + +// These are elided +import { aaaa } from "es6ImportNamedImportInEs5_0"; +// These are elided +import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts new file mode 100644 index 00000000000..7a4519c68bb --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts @@ -0,0 +1,10 @@ +// @target: es6 +// @module: commonjs +// @declaration: true + +// @filename: es6ImportNamedImportInExportAssignment_0.ts +export var a = 10; + +// @filename: es6ImportNamedImportInExportAssignment_1.ts +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts new file mode 100644 index 00000000000..16d11d4e19f --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @declaration: true + +// @filename: es6ImportNamedImportInIndirectExportAssignment_0.ts +export module a { + export class c { + } +} + +// @filename: es6ImportNamedImportInIndirectExportAssignment_1.ts +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import x = a; +export = x; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts new file mode 100644 index 00000000000..54e30be1e23 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts @@ -0,0 +1,19 @@ +// @module: commonjs + +// @filename: es6ImportNamedImportMergeErrors_0.ts +export var a = 10; +export var x = a; +export var z = a; +export var z1 = a; + +// @filename: es6ImportNamedImportMergeErrors_1.ts +import { a } from "es6ImportNamedImportMergeErrors_0"; +interface a { } // shouldnt be error +import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +interface x1 { } // shouldnt be error +import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x = 10; +import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x44 = 10; +import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error diff --git a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts new file mode 100644 index 00000000000..bd507308d8d --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts @@ -0,0 +1,9 @@ +// @module: commonjs + +// @filename: es6ImportNamedImportNoExportMember_0.ts +export var a = 10; +export var x = a; + +// @filename: es6ImportNamedImport_1.ts +import { a1 } from "es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts new file mode 100644 index 00000000000..9dd243ff36d --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts @@ -0,0 +1,10 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNamedImportNoNamedExports_0.ts +var a = 10; +export = a; + +// @filename: es6ImportNamedImportNoNamedExports_1.ts +import { a } from "es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportParsingError.ts b/tests/cases/compiler/es6ImportNamedImportParsingError.ts index a836acc1140..26bd9b69153 100644 --- a/tests/cases/compiler/es6ImportNamedImportParsingError.ts +++ b/tests/cases/compiler/es6ImportNamedImportParsingError.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs // @filename: es6ImportNamedImportParsingError_0.ts export var a = 10; diff --git a/tests/cases/compiler/es6ImportNamedImportWithExport.ts b/tests/cases/compiler/es6ImportNamedImportWithExport.ts new file mode 100644 index 00000000000..f25a3779b99 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportWithExport.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; +export var z1 = 10; +export var z2 = 10; +export var aaaa = 10; + +// @filename: client.ts +export import { } from "server"; +export import { a } from "server"; +export var xxxx = a; +export import { a as b } from "server"; +export var xxxx = b; +export import { x, a as y } from "server"; +export var xxxx = x; +export var xxxx = y; +export import { x as z, } from "server"; +export var xxxx = z; +export import { m, } from "server"; +export var xxxx = m; +export import { a1, x1 } from "server"; +export var xxxx = a1; +export var xxxx = x1; +export import { a1 as a11, x1 as x11 } from "server"; +export var xxxx = a11; +export var xxxx = x11; +export import { z1 } from "server"; +export var z111 = z1; +export import { z2 as z3 } from "server"; +export var z2 = z3; // z2 shouldn't give redeclare error + +// Non referenced imports +export import { aaaa } from "server"; +export import { aaaa as bbbb } from "server"; diff --git a/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts new file mode 100644 index 00000000000..08294e57232 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts @@ -0,0 +1,21 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export interface I { + prop: string; +} +export interface I2 { + prop2: string; +} +export class C implements I { + prop = "hello"; +} +export class C2 implements I2 { + prop2 = "world"; +} + +// @filename: client.ts +import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +export type cValInterface = I; +export var cVal = new C(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportParseErrors.ts b/tests/cases/compiler/es6ImportParseErrors.ts index 2cc21dad746..9eb3ccba82a 100644 --- a/tests/cases/compiler/es6ImportParseErrors.ts +++ b/tests/cases/compiler/es6ImportParseErrors.ts @@ -1,4 +1,3 @@ // @target: es6 -// @module: commonjs import 10; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportWithoutFromClause.ts b/tests/cases/compiler/es6ImportWithoutFromClause.ts index 70a15a9bc54..657532e7a4b 100644 --- a/tests/cases/compiler/es6ImportWithoutFromClause.ts +++ b/tests/cases/compiler/es6ImportWithoutFromClause.ts @@ -1,8 +1,9 @@ // @target: es6 -// @module: commonjs +// @declaration: true +// @declaration: true // @filename: es6ImportWithoutFromClause_0.ts export var a = 10; // @filename: es6ImportWithoutFromClause_1.ts -import "es6ImportWithoutFromClause_0"; \ No newline at end of file +import "es6ImportWithoutFromClause_0"; diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts b/tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts new file mode 100644 index 00000000000..8c43a19e409 --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClauseAmd.ts @@ -0,0 +1,14 @@ +// @module: amd +// @declaration: true + +// @filename: es6ImportWithoutFromClauseAmd_0.ts +export var a = 10; + +// @filename: es6ImportWithoutFromClauseAmd_1.ts +export var b = 10; + +// @filename: es6ImportWithoutFromClauseAmd_2.ts +import "es6ImportWithoutFromClauseAmd_0"; +import "es6ImportWithoutFromClauseAmd_2"; +var _a = 10; +var _b = 10; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseInEs5.ts b/tests/cases/compiler/es6ImportWithoutFromClauseInEs5.ts index 339880ee097..08c21c23644 100644 --- a/tests/cases/compiler/es6ImportWithoutFromClauseInEs5.ts +++ b/tests/cases/compiler/es6ImportWithoutFromClauseInEs5.ts @@ -1,5 +1,6 @@ // @target: es5 // @module: commonjs +// @declaration: true // @filename: es6ImportWithoutFromClauseInEs5_0.ts export var a = 10; diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts new file mode 100644 index 00000000000..22b250435c8 --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts @@ -0,0 +1,9 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_0.ts +export interface i { +} + +// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_1.ts +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts b/tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts new file mode 100644 index 00000000000..8c7ec108538 --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClauseWithExport.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export var a = 10; + +// @filename: client.ts +export import "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6Module.ts b/tests/cases/compiler/es6Module.ts new file mode 100644 index 00000000000..33d70cd133f --- /dev/null +++ b/tests/cases/compiler/es6Module.ts @@ -0,0 +1,12 @@ +// @target: ES6 +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleClassDeclaration.ts b/tests/cases/compiler/es6ModuleClassDeclaration.ts new file mode 100644 index 00000000000..3b36e53037f --- /dev/null +++ b/tests/cases/compiler/es6ModuleClassDeclaration.ts @@ -0,0 +1,113 @@ +// @target: ES6 +export class c { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } +} +class c2 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } +} +new c(); +new c2(); + +export module m1 { + export class c3 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + class c4 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + new c(); + new c2(); + new c3(); + new c4(); +} +module m2 { + export class c3 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + class c4 { + constructor() { + } + private x = 10; + public y = 30; + static k = 20; + private static l = 30; + private method1() { + } + public method2() { + } + static method3() { + } + private static method4() { + } + } + new c(); + new c2(); + new c3(); + new c4(); + new m1.c3(); +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleConst.ts b/tests/cases/compiler/es6ModuleConst.ts new file mode 100644 index 00000000000..42bf24698a9 --- /dev/null +++ b/tests/cases/compiler/es6ModuleConst.ts @@ -0,0 +1,17 @@ +// @target: ES6 +export const a = "hello"; +export const x: string = a, y = x; +const b = y; +const c: string = b, d = c; +export module m1 { + export const k = a; + export const l: string = b, m = k; + const n = m1.k; + const o: string = n, p = k; +} +module m2 { + export const k = a; + export const l: string = b, m = k; + const n = m1.k; + const o: string = n, p = k; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleConstEnumDeclaration.ts b/tests/cases/compiler/es6ModuleConstEnumDeclaration.ts new file mode 100644 index 00000000000..c3490093d3e --- /dev/null +++ b/tests/cases/compiler/es6ModuleConstEnumDeclaration.ts @@ -0,0 +1,46 @@ +// @target: ES6 +export const enum e1 { + a, + b, + c +} +const enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export const enum e3 { + a, + b, + c + } + const enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export const enum e5 { + a, + b, + c + } + const enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts b/tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts new file mode 100644 index 00000000000..6dddea09d8a --- /dev/null +++ b/tests/cases/compiler/es6ModuleConstEnumDeclaration2.ts @@ -0,0 +1,48 @@ +// @target: ES6 +// @preserveConstEnums: true + +export const enum e1 { + a, + b, + c +} +const enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export const enum e3 { + a, + b, + c + } + const enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export const enum e5 { + a, + b, + c + } + const enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleEnumDeclaration.ts b/tests/cases/compiler/es6ModuleEnumDeclaration.ts new file mode 100644 index 00000000000..a0cebde9947 --- /dev/null +++ b/tests/cases/compiler/es6ModuleEnumDeclaration.ts @@ -0,0 +1,46 @@ +// @target: ES6 +export enum e1 { + a, + b, + c +} +enum e2 { + x, + y, + z +} +var x = e1.a; +var y = e2.x; +export module m1 { + export enum e3 { + a, + b, + c + } + enum e4 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e3.a; + var y2 = e4.x; +} +module m2 { + export enum e5 { + a, + b, + c + } + enum e6 { + x, + y, + z + } + var x1 = e1.a; + var y1 = e2.x; + var x2 = e5.a; + var y2 = e6.x; + var x3 = m1.e3.a; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleFunctionDeclaration.ts b/tests/cases/compiler/es6ModuleFunctionDeclaration.ts new file mode 100644 index 00000000000..82eebb1580e --- /dev/null +++ b/tests/cases/compiler/es6ModuleFunctionDeclaration.ts @@ -0,0 +1,29 @@ +// @target: ES6 +export function foo() { +} +function foo2() { +} +foo(); +foo2(); + +export module m1 { + export function foo3() { + } + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); +} +module m2 { + export function foo3() { + } + function foo4() { + } + foo(); + foo2(); + foo3(); + foo4(); + m1.foo3(); +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleInternalImport.ts b/tests/cases/compiler/es6ModuleInternalImport.ts new file mode 100644 index 00000000000..24e209a87f6 --- /dev/null +++ b/tests/cases/compiler/es6ModuleInternalImport.ts @@ -0,0 +1,20 @@ +// @target: ES6 +export module m { + export var a = 10; +} +export import a1 = m.a; +import a2 = m.a; +var x = a1 + a2; +export module m1 { + export import a3 = m.a; + import a4 = m.a; + var x = a1 + a2; + var x2 = a3 + a4; +} +module m2 { + export import a3 = m.a; + import a4 = m.a; + var x = a1 + a2; + var x2 = a3 + a4; + var x4 = m1.a3 + m2.a3; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleInternalNamedImports.ts b/tests/cases/compiler/es6ModuleInternalNamedImports.ts new file mode 100644 index 00000000000..f696cee0aa3 --- /dev/null +++ b/tests/cases/compiler/es6ModuleInternalNamedImports.ts @@ -0,0 +1,32 @@ +// @target: ES6 + +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}; + 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}; +} diff --git a/tests/cases/compiler/es6ModuleLet.ts b/tests/cases/compiler/es6ModuleLet.ts new file mode 100644 index 00000000000..fc5dfc94bd5 --- /dev/null +++ b/tests/cases/compiler/es6ModuleLet.ts @@ -0,0 +1,17 @@ +// @target: ES6 +export let a = "hello"; +export let x: string = a, y = x; +let b = y; +let c: string = b, d = c; +export module m1 { + export let k = a; + export let l: string = b, m = k; + let n = m1.k; + let o: string = n, p = k; +} +module m2 { + export let k = a; + export let l: string = b, m = k; + let n = m1.k; + let o: string = n, p = k; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleModuleDeclaration.ts b/tests/cases/compiler/es6ModuleModuleDeclaration.ts new file mode 100644 index 00000000000..99868f6087b --- /dev/null +++ b/tests/cases/compiler/es6ModuleModuleDeclaration.ts @@ -0,0 +1,25 @@ +// @target: ES6 +export module m1 { + export var a = 10; + var b = 10; + export module innerExportedModule { + export var k = 10; + var l = 10; + } + export module innerNonExportedModule { + export var x = 10; + var y = 10; + } +} +module m2 { + export var a = 10; + var b = 10; + export module innerExportedModule { + export var k = 10; + var l = 10; + } + export module innerNonExportedModule { + export var x = 10; + var y = 10; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleVariableStatement.ts b/tests/cases/compiler/es6ModuleVariableStatement.ts new file mode 100644 index 00000000000..a3ae29fbe6a --- /dev/null +++ b/tests/cases/compiler/es6ModuleVariableStatement.ts @@ -0,0 +1,17 @@ +// @target: ES6 +export var a = "hello"; +export var x: string = a, y = x; +var b = y; +var c: string = b, d = c; +export module m1 { + export var k = a; + export var l: string = b, m = k; + var n = m1.k; + var o: string = n, p = k; +} +module m2 { + export var k = a; + export var l: string = b, m = k; + var n = m1.k; + var o: string = n, p = k; +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts b/tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts new file mode 100644 index 00000000000..9521ec6cbdb --- /dev/null +++ b/tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @module: amd +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts b/tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts new file mode 100644 index 00000000000..616a375d970 --- /dev/null +++ b/tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts @@ -0,0 +1,13 @@ +// @target: ES6 +// @module: commonjs +export class A +{ + constructor () + { + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/fileWithNextLine1.ts b/tests/cases/compiler/fileWithNextLine1.ts new file mode 100644 index 00000000000..4126c2c868b --- /dev/null +++ b/tests/cases/compiler/fileWithNextLine1.ts @@ -0,0 +1,3 @@ +// Note: there is a nextline (0x85) in the string +// 0. It should be counted as a space and should not cause an error. +var v = 'Â…'; \ No newline at end of file diff --git a/tests/cases/compiler/fileWithNextLine2.ts b/tests/cases/compiler/fileWithNextLine2.ts new file mode 100644 index 00000000000..cc5a3863b78 --- /dev/null +++ b/tests/cases/compiler/fileWithNextLine2.ts @@ -0,0 +1,3 @@ +// Note: there is a nextline (0x85) char between the = and the 0. +// it should be treated like a space +var v =Â…0; \ No newline at end of file diff --git a/tests/cases/compiler/fileWithNextLine3.ts b/tests/cases/compiler/fileWithNextLine3.ts new file mode 100644 index 00000000000..5177230848e --- /dev/null +++ b/tests/cases/compiler/fileWithNextLine3.ts @@ -0,0 +1,3 @@ +// Note: there is a nextline (0x85) between the return and the +// 0. It should be counted as a space and should not trigger ASI +returnÂ…0; \ No newline at end of file diff --git a/tests/cases/compiler/pinnedComments1.ts b/tests/cases/compiler/pinnedComments1.ts new file mode 100644 index 00000000000..474769e9b20 --- /dev/null +++ b/tests/cases/compiler/pinnedComments1.ts @@ -0,0 +1,6 @@ +// @comments: false + +/* unpinned comment */ +/*! pinned comment */ +class C { +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAtBeginningOfFile01.ts b/tests/cases/fourslash/completionListAtBeginningOfFile01.ts new file mode 100644 index 00000000000..f811fec4c67 --- /dev/null +++ b/tests/cases/fourslash/completionListAtBeginningOfFile01.ts @@ -0,0 +1,13 @@ +/// + +/////*1*/ +////var x = 0, y = 1, z = 2; +////enum E { +//// A, B, C +////} + +goTo.marker("1"); +verify.completionListContains("x"); +verify.completionListContains("y"); +verify.completionListContains("z"); +verify.completionListContains("E"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBeforeNewScope01.ts b/tests/cases/fourslash/completionListBeforeNewScope01.ts new file mode 100644 index 00000000000..79159744b81 --- /dev/null +++ b/tests/cases/fourslash/completionListBeforeNewScope01.ts @@ -0,0 +1,11 @@ +/// + +////p/*1*/ +//// +////function fun(param) { +//// let party = Math.random() < 0.99; +////} + +goTo.marker("1"); +verify.not.completionListContains("param"); +verify.not.completionListContains("party"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBeforeNewScope02.ts b/tests/cases/fourslash/completionListBeforeNewScope02.ts new file mode 100644 index 00000000000..9fb1182b56e --- /dev/null +++ b/tests/cases/fourslash/completionListBeforeNewScope02.ts @@ -0,0 +1,10 @@ +/// + +////a/*1*/ +//// +////{ +//// let aaaaaa = 10; +////} + +goTo.marker("1"); +verify.not.completionListContains("aaaaa"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts b/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts new file mode 100644 index 00000000000..633dc00a941 --- /dev/null +++ b/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts @@ -0,0 +1,11 @@ +/// + +////declare function foo(...params: any[]): any; +////function getAllFiles(rootFileNames: string[]) { +//// var processedFiles = rootFileNames.map(fileName => foo(/*1*/ + +goTo.marker("1"); +verify.completionListContains("fileName"); +verify.completionListContains("rootFileNames"); +verify.completionListContains("getAllFiles"); +verify.completionListContains("foo"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction01.ts b/tests/cases/fourslash/completionListInClosedFunction01.ts new file mode 100644 index 00000000000..7c9c2a20139 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction01.ts @@ -0,0 +1,12 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction02.ts b/tests/cases/fourslash/completionListInClosedFunction02.ts new file mode 100644 index 00000000000..a2ae8a9da83 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction02.ts @@ -0,0 +1,18 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof /*1*/) { +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction03.ts b/tests/cases/fourslash/completionListInClosedFunction03.ts new file mode 100644 index 00000000000..b1a10a4a4b2 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction03.ts @@ -0,0 +1,19 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof x = /*1*/) { +//// +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction04.ts b/tests/cases/fourslash/completionListInClosedFunction04.ts new file mode 100644 index 00000000000..fcc7d070eb7 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction04.ts @@ -0,0 +1,19 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello") { +//// +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // definitely questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction05.ts b/tests/cases/fourslash/completionListInClosedFunction05.ts new file mode 100644 index 00000000000..7ec3985caf0 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction05.ts @@ -0,0 +1,21 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = /*1*/ +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction06.ts b/tests/cases/fourslash/completionListInClosedFunction06.ts new file mode 100644 index 00000000000..f1aed3ad1a4 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction06.ts @@ -0,0 +1,14 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (x: /*1*/); +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("MyType"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedFunction07.ts b/tests/cases/fourslash/completionListInClosedFunction07.ts new file mode 100644 index 00000000000..13b9f5787de --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedFunction07.ts @@ -0,0 +1,25 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => /*1*/; +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts new file mode 100644 index 00000000000..690fb583f67 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: T/*1*/ } + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts new file mode 100644 index 00000000000..57af3592d44 --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: TStr/*1*/ } + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); // REVIEW: Is this intended behavior? + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts new file mode 100644 index 00000000000..1e5e6256d6e --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: TString/*1*/ } + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); // REVIEW: Is this intended behavior? + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts new file mode 100644 index 00000000000..a45d98ad4df --- /dev/null +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts @@ -0,0 +1,16 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { /*1*/ } + +goTo.marker("1"); + +verify.not.memberListContains("I"); +verify.not.memberListContains("TString"); +verify.not.memberListContains("TNumber"); +verify.not.memberListContains("foo"); +verify.not.memberListContains("obj"); diff --git a/tests/cases/fourslash/completionListInUnclosedCommaExpression01.ts b/tests/cases/fourslash/completionListInUnclosedCommaExpression01.ts new file mode 100644 index 00000000000..de0f26eb86e --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedCommaExpression01.ts @@ -0,0 +1,8 @@ +/// + +////// should NOT see a and b +////foo((a, b) => a,/*1*/ + +goTo.marker("1"); +verify.not.completionListContains("a"); +verify.not.completionListContains("b"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts b/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts new file mode 100644 index 00000000000..e0ea3abbd38 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts @@ -0,0 +1,8 @@ +/// + +////// should NOT see a and b +////foo((a, b) => (a,/*1*/ + +goTo.marker("1"); +verify.completionListContains("a"); +verify.completionListContains("b"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts b/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts new file mode 100644 index 00000000000..fdb67dfc335 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts @@ -0,0 +1,7 @@ +/// + +////var x; +////var y = delete /*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts b/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts new file mode 100644 index 00000000000..3573c345285 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => delete /*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); +verify.completionListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts new file mode 100644 index 00000000000..59c4922671e --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts @@ -0,0 +1,7 @@ +/// + +////var x; +////var y = x[/*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts new file mode 100644 index 00000000000..1d6403cfa10 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => x[/*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedForLoop01.ts b/tests/cases/fourslash/completionListInUnclosedForLoop01.ts new file mode 100644 index 00000000000..35e5efdd304 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedForLoop01.ts @@ -0,0 +1,6 @@ +/// + +////for (let i = 0; /*1*/ + +goTo.marker("1"); +verify.completionListContains("i"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedForLoop02.ts b/tests/cases/fourslash/completionListInUnclosedForLoop02.ts new file mode 100644 index 00000000000..e79f428b2b0 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedForLoop02.ts @@ -0,0 +1,6 @@ +/// + +////for (let i = 0; i < 10; i++) /*1*/ + +goTo.marker("1"); +verify.completionListContains("i"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction01.ts b/tests/cases/fourslash/completionListInUnclosedFunction01.ts new file mode 100644 index 00000000000..4d33d1220f7 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction01.ts @@ -0,0 +1,12 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// /*1*/ +//// + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction02.ts b/tests/cases/fourslash/completionListInUnclosedFunction02.ts new file mode 100644 index 00000000000..c0c79e94433 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction02.ts @@ -0,0 +1,16 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction03.ts b/tests/cases/fourslash/completionListInUnclosedFunction03.ts new file mode 100644 index 00000000000..d8b3a0a132f --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction03.ts @@ -0,0 +1,17 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction04.ts b/tests/cases/fourslash/completionListInUnclosedFunction04.ts new file mode 100644 index 00000000000..e56978732c2 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction04.ts @@ -0,0 +1,16 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof x = /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction05.ts b/tests/cases/fourslash/completionListInUnclosedFunction05.ts new file mode 100644 index 00000000000..748a334f860 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction05.ts @@ -0,0 +1,17 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string, c: typeof x = /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction06.ts b/tests/cases/fourslash/completionListInUnclosedFunction06.ts new file mode 100644 index 00000000000..3ceaff78039 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction06.ts @@ -0,0 +1,17 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello" +//// + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // definitely questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction07.ts b/tests/cases/fourslash/completionListInUnclosedFunction07.ts new file mode 100644 index 00000000000..6968a878a77 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction07.ts @@ -0,0 +1,17 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello" +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); // definitely questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction08.ts b/tests/cases/fourslash/completionListInUnclosedFunction08.ts new file mode 100644 index 00000000000..5e8b15941c1 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction08.ts @@ -0,0 +1,19 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction09.ts b/tests/cases/fourslash/completionListInUnclosedFunction09.ts new file mode 100644 index 00000000000..0171ef96342 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction09.ts @@ -0,0 +1,20 @@ +/// + +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); // questionable \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction10.ts b/tests/cases/fourslash/completionListInUnclosedFunction10.ts new file mode 100644 index 00000000000..1d0162b600b --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction10.ts @@ -0,0 +1,12 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: /*1*/ + +goTo.marker("1"); + +verify.memberListContains("MyType"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction11.ts b/tests/cases/fourslash/completionListInUnclosedFunction11.ts new file mode 100644 index 00000000000..1d0162b600b --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction11.ts @@ -0,0 +1,12 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: /*1*/ + +goTo.marker("1"); + +verify.memberListContains("MyType"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction12.ts b/tests/cases/fourslash/completionListInUnclosedFunction12.ts new file mode 100644 index 00000000000..b0e36b2fb8a --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction12.ts @@ -0,0 +1,13 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("MyType"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction13.ts b/tests/cases/fourslash/completionListInUnclosedFunction13.ts new file mode 100644 index 00000000000..8e1334941ad --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction13.ts @@ -0,0 +1,14 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: /*1*/ +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("MyType"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction14.ts b/tests/cases/fourslash/completionListInUnclosedFunction14.ts new file mode 100644 index 00000000000..412fcd86670 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction14.ts @@ -0,0 +1,25 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => /*1*/ +//// } +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction15.ts b/tests/cases/fourslash/completionListInUnclosedFunction15.ts new file mode 100644 index 00000000000..73a59795396 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction15.ts @@ -0,0 +1,24 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction16.ts b/tests/cases/fourslash/completionListInUnclosedFunction16.ts new file mode 100644 index 00000000000..4ec5f41df53 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction16.ts @@ -0,0 +1,23 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction17.ts b/tests/cases/fourslash/completionListInUnclosedFunction17.ts new file mode 100644 index 00000000000..8cded845673 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction17.ts @@ -0,0 +1,23 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => y + /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction18.ts b/tests/cases/fourslash/completionListInUnclosedFunction18.ts new file mode 100644 index 00000000000..182694d73d2 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction18.ts @@ -0,0 +1,24 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => y + /*1*/ +////} + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedFunction19.ts b/tests/cases/fourslash/completionListInUnclosedFunction19.ts new file mode 100644 index 00000000000..6f49f270250 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedFunction19.ts @@ -0,0 +1,23 @@ +/// + +////interface MyType { +////} +//// +////function foo(x: string, y: number, z: boolean) { +//// function bar(a: number, b: string = "hello", c: typeof x = "hello") { +//// var v = (p: MyType) => { return y + /*1*/ + +goTo.marker("1"); + +verify.memberListContains("foo"); +verify.memberListContains("x"); +verify.memberListContains("y"); +verify.memberListContains("z"); + +verify.memberListContains("bar"); +verify.memberListContains("a"); +verify.memberListContains("b"); +verify.memberListContains("c"); + +verify.memberListContains("v"); +verify.memberListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts new file mode 100644 index 00000000000..0667742d4cb --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts @@ -0,0 +1,10 @@ +/// + + +////class C { +//// [foo: string]: typeof /*1*/ +////} + +goTo.marker("1"); +verify.completionListContains("foo"); +verify.completionListContains("C"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts new file mode 100644 index 00000000000..318730e41a6 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts @@ -0,0 +1,13 @@ +/// + + +////class C { +//// [foo: /*1*/ +////} + +goTo.marker("1"); +verify.completionListContains("C"); +verify.completionListContains("foo"); // ideally this shouldn't show up for a type +edit.insert("typeof "); +verify.completionListContains("C"); +verify.completionListContains("foo"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts new file mode 100644 index 00000000000..bb4ef808bff --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts @@ -0,0 +1,10 @@ +/// + + +////class C { +//// [foo: string]: { x: typeof /*1*/ +////} + +goTo.marker("1"); +verify.completionListContains("foo"); +verify.completionListContains("C"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts new file mode 100644 index 00000000000..a931bed6a4b --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: T/*1*/ + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts new file mode 100644 index 00000000000..32a9504ebc3 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature02.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: TStr/*1*/ + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); // REVIEW: Is this intended behavior? + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts new file mode 100644 index 00000000000..455f122888c --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts @@ -0,0 +1,18 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { str: TString/*1*/ + +goTo.marker("1"); + +verify.memberListContains("I"); +verify.memberListContains("TString"); +verify.memberListContains("TNumber"); // REVIEW: Is this intended behavior? + +// Ideally the following shouldn't show up since they're not types. +verify.memberListContains("foo"); +verify.memberListContains("obj"); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts new file mode 100644 index 00000000000..c7f53e0e0df --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts @@ -0,0 +1,16 @@ +/// + +////interface I { +//// [s: string]: TString; +//// [s: number]: TNumber; +////} +//// +////declare function foo(obj: I): { /*1*/ + +goTo.marker("1"); + +verify.not.memberListContains("I"); +verify.not.memberListContains("TString"); +verify.not.memberListContains("TNumber"); +verify.not.memberListContains("foo"); +verify.not.memberListContains("obj"); diff --git a/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts b/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts new file mode 100644 index 00000000000..b9cc01f0a66 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts @@ -0,0 +1,7 @@ +/// + +////var x; +////var y = [1,2,.../*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts b/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts new file mode 100644 index 00000000000..40d90370232 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => [1,2,.../*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts new file mode 100644 index 00000000000..20e2a5d0663 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => x `abc ${ /*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts new file mode 100644 index 00000000000..d4bbd5992c6 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => x `abc ${ 123 } ${ /*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTemplate01.ts b/tests/cases/fourslash/completionListInUnclosedTemplate01.ts new file mode 100644 index 00000000000..c7b8f628170 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTemplate01.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => `abc ${ /*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTemplate02.ts b/tests/cases/fourslash/completionListInUnclosedTemplate02.ts new file mode 100644 index 00000000000..5fd5c94ee3e --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTemplate02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => `abc ${ 123 } ${ /*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts new file mode 100644 index 00000000000..3da8b4fd616 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts @@ -0,0 +1,7 @@ +/// + +////var x; +////var y = typeof /*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts new file mode 100644 index 00000000000..b1d347211ac --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => typeof /*1*/ + +goTo.marker("1"); +verify.completionListContains("x"); +verify.completionListContains("p"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts b/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts new file mode 100644 index 00000000000..d1cfecbffec --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts @@ -0,0 +1,8 @@ +/// + +////var x; +////var y = (p) => void /*1*/ + +goTo.marker("1"); +verify.completionListContains("p"); +verify.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts new file mode 100644 index 00000000000..658b0de7dc8 --- /dev/null +++ b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts @@ -0,0 +1,10 @@ +/// + +////var x; +////var y = function* gen(p) { yield /*1*/ + +goTo.marker("1"); +// These tentatively don't work. +verify.not.completionListContains("p"); +verify.not.completionListContains("gen"); +verify.not.completionListContains("x"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts new file mode 100644 index 00000000000..d775371796f --- /dev/null +++ b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts @@ -0,0 +1,8 @@ +/// + +////// no a or b +/////*1*/(a, b) => { } + +goTo.marker("1"); +verify.not.completionListContains("a"); +verify.not.completionListContains("b"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts new file mode 100644 index 00000000000..d9195ce5b97 --- /dev/null +++ b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts @@ -0,0 +1,8 @@ +/// + +////// no a or b +////(a, b) => { }/*1*/ + +goTo.marker("1"); +verify.not.completionListContains("a"); +verify.not.completionListContains("b"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts b/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts new file mode 100644 index 00000000000..8b6077e0f8b --- /dev/null +++ b/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts @@ -0,0 +1,8 @@ +/// + +////// no a or b +/////*1*/function f (a, b) {} + +goTo.marker("1"); +verify.not.completionListContains("a"); +verify.not.completionListContains("b"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOutsideOfForLoop01.ts b/tests/cases/fourslash/completionListOutsideOfForLoop01.ts new file mode 100644 index 00000000000..473a39a453d --- /dev/null +++ b/tests/cases/fourslash/completionListOutsideOfForLoop01.ts @@ -0,0 +1,6 @@ +/// + +////for (let i = 0; i < 10; i++) i;/*1*/ + +goTo.marker("1"); +verify.not.completionListContains("i"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListOutsideOfForLoop02.ts b/tests/cases/fourslash/completionListOutsideOfForLoop02.ts new file mode 100644 index 00000000000..b1186ac7cce --- /dev/null +++ b/tests/cases/fourslash/completionListOutsideOfForLoop02.ts @@ -0,0 +1,6 @@ +/// + +////for (let i = 0; i < 10; i++);/*1*/ + +goTo.marker("1"); +verify.not.completionListContains("i"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingChangeSettings.ts b/tests/cases/fourslash/formattingChangeSettings.ts new file mode 100644 index 00000000000..190de4c3e92 --- /dev/null +++ b/tests/cases/fourslash/formattingChangeSettings.ts @@ -0,0 +1,24 @@ +/// + +////module M { +/////*1*/var x=1; +////} + +var originalOptions = format.copyFormatOptions(); + +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs(" var x = 1;"); + +var copy = format.copyFormatOptions(); +copy.TabSize = 2; +copy.IndentSize = 2; + +format.setFormatOptions(copy); +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs(" var x = 1;"); + +format.setFormatOptions(originalOptions); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst.ts b/tests/cases/fourslash/getOccurrencesConst01.ts similarity index 100% rename from tests/cases/fourslash/getOccurrencesConst.ts rename to tests/cases/fourslash/getOccurrencesConst01.ts diff --git a/tests/cases/fourslash/getOccurrencesConst02.ts b/tests/cases/fourslash/getOccurrencesConst02.ts new file mode 100644 index 00000000000..0dc96fcca6c --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst02.ts @@ -0,0 +1,16 @@ +/// + +////module m { +//// declare [|const|] x; +//// declare [|const|] enum E { +//// } +////} +//// +////declare [|const|] x; +////declare [|const|] enum E { +////} + +test.ranges().forEach(range => { + goTo.position(range.start); + verify.occurrencesAtPositionCount(0); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst03.ts b/tests/cases/fourslash/getOccurrencesConst03.ts new file mode 100644 index 00000000000..404ff655044 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst03.ts @@ -0,0 +1,16 @@ +/// + +////module m { +//// export [|const|] x; +//// export [|const|] enum E { +//// } +////} +//// +////export [|const|] x; +////export [|const|] enum E { +////} + +test.ranges().forEach(range => { + goTo.position(range.start); + verify.occurrencesAtPositionCount(0); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst04.ts b/tests/cases/fourslash/getOccurrencesConst04.ts new file mode 100644 index 00000000000..c7f293450d3 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst04.ts @@ -0,0 +1,12 @@ +/// + +////export const class C { +//// private static c/*1*/onst foo; +//// constructor(public con/*2*/st foo) { +//// } +////} + +goTo.marker("1"); +verify.occurrencesAtPositionCount(1); +goTo.marker("2"); +verify.occurrencesAtPositionCount(0); \ No newline at end of file diff --git a/tests/cases/fourslash/getSemanticDiagnosticForDeclaration1.ts b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration1.ts new file mode 100644 index 00000000000..13a2dccfd26 --- /dev/null +++ b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration1.ts @@ -0,0 +1,9 @@ +/// + +// @declaration: true +// @Filename: File.d.ts +//// declare var v: string; + +verify.numberOfErrorsInCurrentFile(0); + + diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts similarity index 100% rename from tests/cases/fourslash/goToDefinitionShorthandProperty.ts rename to tests/cases/fourslash/goToDefinitionShorthandProperty01.ts diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts new file mode 100644 index 00000000000..1f8fe466277 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts @@ -0,0 +1,8 @@ +/// + +////let x = { +//// f/*1*/oo +////} + +goTo.marker("1"); +verify.not.definitionLocationExists(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts new file mode 100644 index 00000000000..eb21b159f5a --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts @@ -0,0 +1,16 @@ +/// + +////var /*varDef*/x = { +//// /*varProp*/x +////} +////let /*letDef*/y = { +//// /*letProp*/y +////} + +goTo.marker("varProp"); +goTo.definition(); +verify.caretAtMarker("varDef"); + +goTo.marker("letProp"); +goTo.definition(); +verify.caretAtMarker("letDef"); \ No newline at end of file