diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..74f5f4a6409 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.js linguist-language=TypeScript \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 305fad1e4a7..572ac835cd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,4 @@ language: node_js node_js: - '0.10' -sudo: false - -before_script: npm install -g codeclimate-test-reporter - -after_script: - - cat coverage/lcov.info | codeclimate - -addons: - code_climate: - repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656 +sudo: false \ No newline at end of file diff --git a/package.json b/package.json index 9261174b68f..c33f2a93ec1 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,9 @@ "mocha": "latest", "chai": "latest", "browserify": "latest", - "istanbul": "latest", - "codeclimate-test-reporter": "latest" + "istanbul": "latest" }, "scripts": { - "test": "jake generate-code-coverage" + "test": "jake runtests" } } 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/binder.ts b/src/compiler/binder.ts index f951fe49269..3535aaffb27 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -322,13 +322,14 @@ module ts { } else { bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); - if (state === ModuleInstanceState.ConstEnumOnly) { - // mark value module as module that contains only enums - node.symbol.constEnumOnlyModule = true; + let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; } - else if (node.symbol.constEnumOnlyModule) { - // const only value module was merged with instantiated module - reset flag - node.symbol.constEnumOnlyModule = false; + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; } } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d95f790c8f5..7b200b92fe0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -79,8 +79,7 @@ module ts { let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - let inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - + let anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); @@ -797,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) { @@ -3577,6 +3576,7 @@ module ts { return t => { for (let i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { + context.inferences[i].isFixed = true; return getInferredType(context, i); } } @@ -4435,8 +4435,11 @@ module ts { } function reportNoCommonSupertypeError(types: Type[], errorLocation: Node, errorMessageChainHead: DiagnosticMessageChain): void { + // The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate + // to not be the common supertype. So if it weren't for this one downfallType (and possibly others), + // the type in question could have been the common supertype. let bestSupertype: Type; - let bestSupertypeDownfallType: Type; // The type that caused bestSupertype not to be the common supertype + let bestSupertypeDownfallType: Type; let bestSupertypeScore = 0; for (let i = 0; i < types.length; i++) { @@ -4451,6 +4454,8 @@ module ts { } } + Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType"); + if (score > bestSupertypeScore) { bestSupertype = types[i]; bestSupertypeDownfallType = downfallType; @@ -4633,13 +4638,12 @@ module ts { function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext { let inferences: TypeInferences[] = []; for (let unused of typeParameters) { - inferences.push({ primary: undefined, secondary: undefined }); + inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); } return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferenceCount: 0, - inferences: inferences, + typeParameters, + inferUnionTypes, + inferences, inferredTypes: new Array(typeParameters.length), }; } @@ -4685,11 +4689,21 @@ module ts { for (let i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { let inferences = context.inferences[i]; - let candidates = inferiority ? - inferences.secondary || (inferences.secondary = []) : - inferences.primary || (inferences.primary = []); - if (!contains(candidates, source)) candidates.push(source); - break; + if (!inferences.isFixed) { + // Any inferences that are made to a type parameter in a union type are inferior + // to inferences made to a flat (non-union) type. This is because if we infer to + // T | string[], we really don't know if we should be inferring to T or not (because + // the correct constituent on the target side could be string[]). Therefore, we put + // such inferior inferences into a secondary bucket, and only use them if the primary + // bucket is empty. + let candidates = inferiority ? + inferences.secondary || (inferences.secondary = []) : + inferences.primary || (inferences.primary = []); + if (!contains(candidates, source)) { + candidates.push(source); + } + } + return; } } } @@ -4795,21 +4809,35 @@ module ts { function getInferredType(context: InferenceContext, index: number): Type { let inferredType = context.inferredTypes[index]; + let inferenceSucceeded: boolean; if (!inferredType) { let inferences = getInferenceCandidates(context, index); if (inferences.length) { - // Infer widened union or supertype, or the undefined type for no common supertype + // Infer widened union or supertype, or the unknown type for no common supertype let unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; + inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; + inferenceSucceeded = !!unionOrSuperType; } else { - // Infer the empty object type when no inferences were made + // Infer the empty object type when no inferences were made. It is important to remember that + // in this case, inference still succeeds, meaning there is no error for not having inference + // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. + // candidates with no common supertype. inferredType = emptyObjectType; + inferenceSucceeded = true; } - if (inferredType !== inferenceFailureType) { + + // Only do the constraint check if inference succeeded (to prevent cascading errors) + if (inferenceSucceeded) { let constraint = getConstraintOfTypeParameter(context.typeParameters[index]); inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; } + else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { + // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). + // It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments. + // So if this failure is on preceding type parameter, this type parameter is the new failure index. + context.failedTypeParameterIndex = index; + } context.inferredTypes[index] = inferredType; } return inferredType; @@ -6406,11 +6434,32 @@ module ts { return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[]): InferenceContext { + function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { let typeParameters = signature.typeParameters; - let context = createInferenceContext(typeParameters, /*inferUnionTypes*/ false); let inferenceMapper = createInferenceMapper(context); + // Clear out all the inference results from the last time inferTypeArguments was called on this context + for (let i = 0; i < typeParameters.length; i++) { + // As an optimization, we don't have to clear (and later recompute) inferred types + // for type parameters that have already been fixed on the previous call to inferTypeArguments. + // It would be just as correct to reset all of them. But then we'd be repeating the same work + // for the type parameters that were fixed, namely the work done by getInferredType. + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } + } + + // On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not + // fixed last time. This means that a type parameter that failed inference last time may succeed this time, + // or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter, + // because it may change. So here we reset it. However, getInferredType will not revisit any type parameters + // that were previously fixed. So if a fixed type parameter failed previously, it will fail again because + // it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter, + // we will lose information that we won't recover this time around. + if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { + context.failedTypeParameterIndex = undefined; + } + // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. for (let i = 0; i < args.length; i++) { @@ -6445,18 +6494,7 @@ module ts { } } - let inferredTypes = getInferredTypes(context); - // Inference has failed if the inferenceFailureType type is in list of inferences - context.failedTypeParameterIndex = indexOf(inferredTypes, inferenceFailureType); - - // Wipe out the inferenceFailureType from the array so that error recovery can work properly - for (let i = 0; i < inferredTypes.length; i++) { - if (inferredTypes[i] === inferenceFailureType) { - inferredTypes[i] = unknownType; - } - } - - return context; + getInferredTypes(context); } function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean): boolean { @@ -6690,15 +6728,17 @@ module ts { return resolveErrorCall(node); function chooseOverload(candidates: Signature[], relation: Map) { - for (let current of candidates) { - if (!hasCorrectArity(node, args, current)) { + for (let originalCandidate of candidates) { + if (!hasCorrectArity(node, args, originalCandidate)) { continue; } - - let originalCandidate = current; - let inferenceResult: InferenceContext; + let candidate: Signature; let typeArgumentsAreValid: boolean; + let inferenceContext = originalCandidate.typeParameters + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) + : undefined; + while (true) { candidate = originalCandidate; if (candidate.typeParameters) { @@ -6708,9 +6748,9 @@ module ts { typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false) } else { - inferenceResult = inferTypeArguments(candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; + inferTypeArguments(candidate, args, excludeArgument, inferenceContext); + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; + typeArgumentTypes = inferenceContext.inferredTypes; } if (!typeArgumentsAreValid) { break; @@ -6740,7 +6780,7 @@ module ts { else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } @@ -10116,6 +10156,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); + } + } } } @@ -10163,6 +10209,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[] { @@ -10205,7 +10256,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); } @@ -11028,7 +11079,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); @@ -11056,7 +11115,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); } } @@ -11092,7 +11151,6 @@ module ts { return true; } } - return forEachChild(node, isReferencedAliasDeclaration); } function isImplementationOfOverload(node: FunctionLikeDeclaration) { @@ -12148,8 +12206,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 @@ -12163,7 +12221,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/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 506104ff3bc..feadd63abd7 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e2a89b91e33..fbd9866f967 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", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e8f7ef77e52..cda43ba511f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3492,7 +3492,7 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - if (compilerOptions.target >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6) { emit(node.tag); write(" "); emit(node.template); @@ -4092,8 +4092,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); @@ -4448,10 +4454,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) { @@ -4570,6 +4587,19 @@ 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); @@ -4583,12 +4613,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); @@ -4659,7 +4696,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); @@ -5094,7 +5131,7 @@ module ts { } function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { - if (node.flags & NodeFlags.Export) { + if (isES6ModuleMemberDeclaration(node)) { write("export "); if (node.flags & NodeFlags.Default) { @@ -5103,7 +5140,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 "); @@ -5127,6 +5167,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) { @@ -5169,6 +5221,7 @@ module ts { } write(");"); emitEnd(node); + if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { writeLine(); emitStart(node); @@ -5178,6 +5231,7 @@ module ts { emitEnd(node); write(";"); } + if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } @@ -5198,7 +5252,7 @@ module ts { return; } - if (!(node.flags & NodeFlags.Export)) { + if (!(node.flags & NodeFlags.Export) || isES6ModuleMemberDeclaration(node)) { emitStart(node); write("var "); emit(node.name); @@ -5225,7 +5279,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 "); @@ -5331,7 +5388,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(" = "); } @@ -5340,11 +5398,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("); @@ -5359,7 +5429,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; @@ -5401,7 +5559,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 @@ -5411,7 +5569,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); @@ -5422,77 +5586,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) { @@ -5529,9 +5737,7 @@ module ts { else { let info = createExternalImportInfo(node); if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); - } + externalImports.push(info); } } }); @@ -5547,14 +5753,6 @@ module ts { } } - function getFirstExportAssignment(sourceFile: SourceFile) { - return forEach(sourceFile.statements, node => { - if (node.kind === SyntaxKind.ExportAssignment) { - return node; - } - }); - } - function sortAMDModules(amdModules: {name: string; path: string}[]) { // AMD modules with declared variable names go first return amdModules.sort((moduleA, moduleB) => { @@ -5569,6 +5767,7 @@ module ts { } function emitAMDModule(node: SourceFile, startIndex: number) { + createExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -5619,28 +5818,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 statment emit. + } + + function emitExportAssignment(node: ExportAssignment) { + // Only emit exportAssignment/export default if we are in ES6 + // Other modules will handel it diffrentlly + 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); } } @@ -5687,8 +5918,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 { @@ -5912,10 +6145,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); } @@ -6093,3 +6331,4 @@ module ts { } } } + diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b6bff3c0937..253daff86d3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2,8 +2,10 @@ /// module ts { + /* @internal */ export let programTime = 0; /* @internal */ export let emitTime = 0; /* @internal */ export let ioReadTime = 0; + /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ export let version = "1.5.0.0"; @@ -36,33 +38,34 @@ module ts { } text = ""; } - return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined; } + function directoryExists(directoryPath: string): boolean { + if (hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + + function ensureDirectoriesExist(directoryPath: string) { + if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { + let parentDirectory = getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + sys.createDirectory(directoryPath); + } + } + function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { - function directoryExists(directoryPath: string): boolean { - if (hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - - function ensureDirectoriesExist(directoryPath: string) { - if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) { - let parentDirectory = getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - sys.createDirectory(directoryPath); - } - } - try { + var start = new Date().getTime(); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); sys.writeFile(fileName, data, writeByteOrderMark); + ioWriteTime += new Date().getTime() - start; } catch (e) { if (onError) { @@ -120,16 +123,19 @@ module ts { let diagnostics = createDiagnosticCollection(); let seenNoDefaultLib = options.noLib; let commonSourceDirectory: string; - host = host || createCompilerHost(options); + let diagnosticsProducingTypeChecker: TypeChecker; + let noDiagnosticsTypeChecker: TypeChecker; + let start = new Date().getTime(); + + host = host || createCompilerHost(options); forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFileName(options), true); } verifyCompilerOptions(); - let diagnosticsProducingTypeChecker: TypeChecker; - let noDiagnosticsTypeChecker: TypeChecker; + programTime += new Date().getTime() - start; program = { getSourceFile: getSourceFile, @@ -430,11 +436,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/tsc.ts b/src/compiler/tsc.ts index e9c5e17c751..3f82d6c8cf5 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -320,22 +320,16 @@ module ts { } function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) { - ts.ioReadTime = 0; - ts.parseTime = 0; - ts.bindTime = 0; - ts.checkTime = 0; - ts.emitTime = 0; - - var start = new Date().getTime(); + ioReadTime = 0; + ioWriteTime = 0; + programTime = 0; + bindTime = 0; + checkTime = 0; + emitTime = 0; var program = createProgram(fileNames, compilerOptions, compilerHost); - var programTime = new Date().getTime() - start; - var exitStatus = compileProgram(); - var end = new Date().getTime() - start; - var compileTime = end - programTime; - if (compilerOptions.listFiles) { forEach(program.getSourceFiles(), file => { sys.write(file.fileName + sys.newLine); @@ -356,19 +350,16 @@ module ts { } // Individual component times. - // Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3 - // measured parse time along with read IO as a single counter. We preserve that - // behavior so we can accurately compare times. For actual parse times (in isolation) - // is reported below. + // Note: To match the behavior of previous versions of the compiler, the reported parse time includes + // I/O read time and processing time for triple-slash references and module imports, and the reported + // emit time includes I/O write time. We preserve this behavior so we can accurately compare times. + reportTimeStatistic("I/O read", ioReadTime); + reportTimeStatistic("I/O write", ioWriteTime); reportTimeStatistic("Parse time", programTime); - reportTimeStatistic("Bind time", ts.bindTime); - reportTimeStatistic("Check time", ts.checkTime); - reportTimeStatistic("Emit time", ts.emitTime); - - reportTimeStatistic("Parse time w/o IO", ts.parseTime); - reportTimeStatistic("IO read", ts.ioReadTime); - reportTimeStatistic("Compile time", compileTime); - reportTimeStatistic("Total time", end); + reportTimeStatistic("Bind time", bindTime); + reportTimeStatistic("Check time", checkTime); + reportTimeStatistic("Emit time", emitTime); + reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime); } return { program, exitStatus }; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 675ccfbfc39..4209d424555 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1491,11 +1491,15 @@ module ts { (t: Type): Type; } + // @internal export interface TypeInferences { primary: Type[]; // Inferences made directly to a type parameter secondary: Type[]; // Inferences made to a type parameter in a union type + isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec + // If a type parameter is fixed, no more inferences can be made for the type parameter } + // @internal export interface InferenceContext { typeParameters: TypeParameter[]; // Type parameters for which inferences are made inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d8b7c358a55..95a320ac052 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1621,8 +1621,9 @@ module FourSlash { this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI'; var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition); - if (actual != numberOfSpaces) { - this.raiseError('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual); + var lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); + if (actual !== numberOfSpaces) { + this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); } } @@ -1630,8 +1631,9 @@ module FourSlash { this.taoInvalidReason = 'verifyIndentationAtPosition NYI'; var actual = this.getIndentation(fileName, position); + var lineCol = this.getLineColStringAtPosition(position); if (actual !== numberOfSpaces) { - this.raiseError('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual); + this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); } } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index e7beebf6866..1a52c72c9d8 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -359,6 +359,7 @@ module ts.formatting { case SyntaxKind.ModuleBlock: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TypeLiteral: + case SyntaxKind.TupleType: case SyntaxKind.CaseBlock: case SyntaxKind.DefaultClause: case SyntaxKind.CaseClause: @@ -370,6 +371,8 @@ module ts.formatting { case SyntaxKind.ExportAssignment: case SyntaxKind.ReturnStatement: case SyntaxKind.ConditionalExpression: + case SyntaxKind.ArrayBindingPattern: + case SyntaxKind.ObjectBindingPattern: return true; } return false; @@ -390,6 +393,7 @@ module ts.formatting { case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: case SyntaxKind.ArrowFunction: case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: @@ -431,46 +435,85 @@ module ts.formatting { 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.ParenthesizedExpression: - case SyntaxKind.CallSignature: + case SyntaxKind.NewExpression: + if (!(n).arguments) { + return true; + } + // fall through case SyntaxKind.CallExpression: - case SyntaxKind.ConstructSignature: + 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: - return !(n).body || isCompletedNode((n).body, sourceFile); + 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 + // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; + case SyntaxKind.ForStatement: - return isCompletedNode((n).statement, sourceFile); case SyntaxKind.ForInStatement: - return isCompletedNode((n).statement, sourceFile); case SyntaxKind.ForOfStatement: - return isCompletedNode((n).statement, sourceFile); case SyntaxKind.WhileStatement: - return isCompletedNode((n).statement, sourceFile); + 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); @@ -478,6 +521,7 @@ module ts.formatting { return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); } return isCompletedNode((n).statement, sourceFile); + default: return true; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 452395f454a..7671ee3f88d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -79,6 +79,10 @@ module ts { }; } + export function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean { + return !!findChildOfKind(n, kind, sourceFile); + } + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index ff68d4039f5..b3f3b8bbd76 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1179,17 +1179,6 @@ declare module "typescript" { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index fcccdc4dcd0..abaaff0dee6 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -3791,38 +3791,6 @@ declare module "typescript" { >t : Type >Type : Type >Type : Type - } - interface TypeInferences { ->TypeInferences : TypeInferences - - primary: Type[]; ->primary : Type[] ->Type : Type - - secondary: Type[]; ->secondary : Type[] ->Type : Type - } - interface InferenceContext { ->InferenceContext : InferenceContext - - typeParameters: TypeParameter[]; ->typeParameters : TypeParameter[] ->TypeParameter : TypeParameter - - inferUnionTypes: boolean; ->inferUnionTypes : boolean - - inferences: TypeInferences[]; ->inferences : TypeInferences[] ->TypeInferences : TypeInferences - - inferredTypes: Type[]; ->inferredTypes : Type[] ->Type : Type - - failedTypeParameterIndex?: number; ->failedTypeParameterIndex : number } interface DiagnosticMessage { >DiagnosticMessage : DiagnosticMessage diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 1fb0e1d8407..b36e7438145 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1210,17 +1210,6 @@ declare module "typescript" { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index a13ce915920..019fb66d79f 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3937,38 +3937,6 @@ declare module "typescript" { >t : Type >Type : Type >Type : Type - } - interface TypeInferences { ->TypeInferences : TypeInferences - - primary: Type[]; ->primary : Type[] ->Type : Type - - secondary: Type[]; ->secondary : Type[] ->Type : Type - } - interface InferenceContext { ->InferenceContext : InferenceContext - - typeParameters: TypeParameter[]; ->typeParameters : TypeParameter[] ->TypeParameter : TypeParameter - - inferUnionTypes: boolean; ->inferUnionTypes : boolean - - inferences: TypeInferences[]; ->inferences : TypeInferences[] ->TypeInferences : TypeInferences - - inferredTypes: Type[]; ->inferredTypes : Type[] ->Type : Type - - failedTypeParameterIndex?: number; ->failedTypeParameterIndex : number } interface DiagnosticMessage { >DiagnosticMessage : DiagnosticMessage diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 07f7519d721..83fad82daee 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1211,17 +1211,6 @@ declare module "typescript" { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 87ed0c073f2..fac36eb3891 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3887,38 +3887,6 @@ declare module "typescript" { >t : Type >Type : Type >Type : Type - } - interface TypeInferences { ->TypeInferences : TypeInferences - - primary: Type[]; ->primary : Type[] ->Type : Type - - secondary: Type[]; ->secondary : Type[] ->Type : Type - } - interface InferenceContext { ->InferenceContext : InferenceContext - - typeParameters: TypeParameter[]; ->typeParameters : TypeParameter[] ->TypeParameter : TypeParameter - - inferUnionTypes: boolean; ->inferUnionTypes : boolean - - inferences: TypeInferences[]; ->inferences : TypeInferences[] ->TypeInferences : TypeInferences - - inferredTypes: Type[]; ->inferredTypes : Type[] ->Type : Type - - failedTypeParameterIndex?: number; ->failedTypeParameterIndex : number } interface DiagnosticMessage { >DiagnosticMessage : DiagnosticMessage diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 2eb306fd049..90e8df87203 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1248,17 +1248,6 @@ declare module "typescript" { interface TypeMapper { (t: Type): Type; } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - } - interface InferenceContext { - typeParameters: TypeParameter[]; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - failedTypeParameterIndex?: number; - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 9b947a91d9a..c65b549a4b4 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -4060,38 +4060,6 @@ declare module "typescript" { >t : Type >Type : Type >Type : Type - } - interface TypeInferences { ->TypeInferences : TypeInferences - - primary: Type[]; ->primary : Type[] ->Type : Type - - secondary: Type[]; ->secondary : Type[] ->Type : Type - } - interface InferenceContext { ->InferenceContext : InferenceContext - - typeParameters: TypeParameter[]; ->typeParameters : TypeParameter[] ->TypeParameter : TypeParameter - - inferUnionTypes: boolean; ->inferUnionTypes : boolean - - inferences: TypeInferences[]; ->inferences : TypeInferences[] ->TypeInferences : TypeInferences - - inferredTypes: Type[]; ->inferredTypes : Type[] ->Type : Type - - failedTypeParameterIndex?: number; ->failedTypeParameterIndex : number } interface DiagnosticMessage { >DiagnosticMessage : DiagnosticMessage 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/constEnumOnlyModuleMerging.js b/tests/baselines/reference/constEnumOnlyModuleMerging.js new file mode 100644 index 00000000000..1d32fe748ab --- /dev/null +++ b/tests/baselines/reference/constEnumOnlyModuleMerging.js @@ -0,0 +1,26 @@ +//// [constEnumOnlyModuleMerging.ts] +module Outer { + export var x = 1; +} + +module Outer { + export const enum A { X } +} + +module B { + import O = Outer; + var x = O.A.X; + var y = O.x; +} + +//// [constEnumOnlyModuleMerging.js] +var Outer; +(function (Outer) { + Outer.x = 1; +})(Outer || (Outer = {})); +var B; +(function (B) { + var O = Outer; + var x = 0 /* X */; + var y = O.x; +})(B || (B = {})); diff --git a/tests/baselines/reference/constEnumOnlyModuleMerging.types b/tests/baselines/reference/constEnumOnlyModuleMerging.types new file mode 100644 index 00000000000..30426e3fa4c --- /dev/null +++ b/tests/baselines/reference/constEnumOnlyModuleMerging.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/constEnumOnlyModuleMerging.ts === +module Outer { +>Outer : typeof Outer + + export var x = 1; +>x : number +} + +module Outer { +>Outer : typeof Outer + + export const enum A { X } +>A : A +>X : A +} + +module B { +>B : typeof B + + import O = Outer; +>O : typeof O +>Outer : typeof O + + var x = O.A.X; +>x : O.A +>O.A.X : O.A +>O.A : typeof O.A +>O : typeof O +>A : typeof O.A +>X : O.A + + var y = O.x; +>y : number +>O.x : number +>O : typeof O +>x : number +} diff --git a/tests/baselines/reference/declarationEmitDefaultExport1.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport1.errors.txt deleted file mode 100644 index bf52e453002..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport1.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport1.ts(1,22): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/declarationEmitDefaultExport1.ts (1 errors) ==== - export default class C { - ~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport1.js b/tests/baselines/reference/declarationEmitDefaultExport1.js index 72c65b4576c..197e4fc9cc8 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport1.js +++ b/tests/baselines/reference/declarationEmitDefaultExport1.js @@ -3,12 +3,8 @@ export default class C { } //// [declarationEmitDefaultExport1.js] -var C = (function () { - function C() { - } - return C; -})(); -module.exports = C; +export default class C { +} //// [declarationEmitDefaultExport1.d.ts] 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.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport2.errors.txt deleted file mode 100644 index 95b7ace24d1..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport2.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport2.ts(1,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/declarationEmitDefaultExport2.ts (1 errors) ==== - export default class { - ~~~~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport2.js b/tests/baselines/reference/declarationEmitDefaultExport2.js index c1841deefad..388bd41e4f8 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport2.js +++ b/tests/baselines/reference/declarationEmitDefaultExport2.js @@ -3,12 +3,8 @@ export default class { } //// [declarationEmitDefaultExport2.js] -var _default = (function () { - function _default() { - } - return _default; -})(); -module.exports = _default; +export default class { +} //// [declarationEmitDefaultExport2.d.ts] 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.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport3.errors.txt deleted file mode 100644 index b6f85522651..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport3.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport3.ts(1,25): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/declarationEmitDefaultExport3.ts (1 errors) ==== - export default function foo() { - ~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - return "" - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport3.js b/tests/baselines/reference/declarationEmitDefaultExport3.js index 4cc84d09fc6..ba412a1b4b7 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport3.js +++ b/tests/baselines/reference/declarationEmitDefaultExport3.js @@ -4,10 +4,9 @@ export default function foo() { } //// [declarationEmitDefaultExport3.js] -function foo() { +export default function foo() { return ""; } -module.exports = foo; //// [declarationEmitDefaultExport3.d.ts] 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.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport4.errors.txt deleted file mode 100644 index dbd0c8b139f..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport4.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport4.ts(1,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/declarationEmitDefaultExport4.ts (1 errors) ==== - export default function () { - ~~~~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - return 1; - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport4.js b/tests/baselines/reference/declarationEmitDefaultExport4.js index 0913a047afa..92f8ef8bb81 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport4.js +++ b/tests/baselines/reference/declarationEmitDefaultExport4.js @@ -4,10 +4,9 @@ export default function () { } //// [declarationEmitDefaultExport4.js] -function _default() { +export default function () { return 1; } -module.exports = _default; //// [declarationEmitDefaultExport4.d.ts] 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.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport5.errors.txt deleted file mode 100644 index 79307703dee..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport5.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport5.ts(1,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/declarationEmitDefaultExport5.ts (1 errors) ==== - export default 1 + 2; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport5.js b/tests/baselines/reference/declarationEmitDefaultExport5.js index 435ffc3bfda..a8794d92c63 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport5.js +++ b/tests/baselines/reference/declarationEmitDefaultExport5.js @@ -3,7 +3,7 @@ export default 1 + 2; //// [declarationEmitDefaultExport5.js] -module.exports = 1 + 2; +export default 1 + 2; //// [declarationEmitDefaultExport5.d.ts] 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.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport6.errors.txt deleted file mode 100644 index f0d6a7a6c2a..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport6.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport6.ts(1,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided. -tests/cases/compiler/declarationEmitDefaultExport6.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== tests/cases/compiler/declarationEmitDefaultExport6.ts (2 errors) ==== - export class A {} - ~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - export default new A(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! 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/declarationEmitDefaultExport6.js b/tests/baselines/reference/declarationEmitDefaultExport6.js index b78706efdc1..d328458366e 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport6.js +++ b/tests/baselines/reference/declarationEmitDefaultExport6.js @@ -4,13 +4,9 @@ export default new A(); //// [declarationEmitDefaultExport6.js] -var A = (function () { - function A() { - } - return A; -})(); -exports.A = A; -module.exports = new A(); +export class A { +} +export default new A(); //// [declarationEmitDefaultExport6.d.ts] 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 index 3e67b0856fc..2fb5bdab12c 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt +++ b/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt @@ -1,12 +1,9 @@ -tests/cases/compiler/declarationEmitDefaultExport7.ts(2,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. tests/cases/compiler/declarationEmitDefaultExport7.ts(2,1): error TS4081: Default export of the module has or is using private name 'A'. -==== tests/cases/compiler/declarationEmitDefaultExport7.ts (2 errors) ==== +==== tests/cases/compiler/declarationEmitDefaultExport7.ts (1 errors) ==== class A {} export default new A(); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS4081: 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 index 9e334552e04..99751113dd6 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport7.js +++ b/tests/baselines/reference/declarationEmitDefaultExport7.js @@ -4,9 +4,6 @@ export default new A(); //// [declarationEmitDefaultExport7.js] -var A = (function () { - function A() { - } - return A; -})(); -module.exports = new A(); +class A { +} +export default new A(); 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.errors.txt b/tests/baselines/reference/es6ExportAll.errors.txt deleted file mode 100644 index 98d40006854..00000000000 --- a/tests/baselines/reference/es6ExportAll.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/compiler/server.ts(2,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/server.ts (1 errors) ==== - - export class c { - ~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - } - export interface i { - } - export module m { - export var x = 10; - } - export var x = 10; - export module uninstantiated { - } - -==== tests/cases/compiler/client.ts (0 errors) ==== - export * from "server"; \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAll.js b/tests/baselines/reference/es6ExportAll.js index 7b99a3819e2..05c8a794e91 100644 --- a/tests/baselines/reference/es6ExportAll.js +++ b/tests/baselines/reference/es6ExportAll.js @@ -17,20 +17,16 @@ export module uninstantiated { export * from "server"; //// [server.js] -var c = (function () { - function c() { - } - return c; -})(); -exports.c = c; +export class c { +} var m; (function (m) { m.x = 10; -})(m = exports.m || (exports.m = {})); -exports.x = 10; +})(m || (m = {})); +export { m }; +export var x = 10; //// [client.js] -var _server = require("server"); -for (var _a in _server) if (!exports.hasOwnProperty(_a)) exports[_a] = _server[_a]; +export * from "server"; //// [server.d.ts] 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/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.errors.txt b/tests/baselines/reference/es6ExportClause.errors.txt deleted file mode 100644 index 464839e03a4..00000000000 --- a/tests/baselines/reference/es6ExportClause.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -tests/cases/compiler/es6ExportClause.ts(12,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/es6ExportClause.ts (1 errors) ==== - - class c { - } - interface i { - } - module m { - export var x = 10; - } - var x = 10; - module uninstantiated { - } - export { c }; - ~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - export { c as c2 }; - export { i, m as instantiatedModule }; - export { uninstantiated }; - export { x }; \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js index 27fc611692d..4fba47ea7d1 100644 --- a/tests/baselines/reference/es6ExportClause.js +++ b/tests/baselines/reference/es6ExportClause.js @@ -17,16 +17,18 @@ export { uninstantiated }; export { x }; //// [es6ExportClause.js] -var c = (function () { - function c() { - } - return c; -})(); +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] 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 index f987b48aeca..93c1015d207 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.js +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -31,6 +31,12 @@ var m; exports.instantiatedModule = m; var x = 10; exports.x = x; +exports.c = c; +exports.c2 = c; +exports.i = i; +exports.instantiatedModule = m; +exports.uninstantiated = uninstantiated; +exports.x = x; //// [es6ExportClauseInEs5.d.ts] diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.errors.txt b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.errors.txt deleted file mode 100644 index 7ac6946aedf..00000000000 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -tests/cases/compiler/server.ts(2,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided. - - -==== tests/cases/compiler/server.ts (1 errors) ==== - - export class c { - ~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. - } - export interface i { - } - export module m { - export var x = 10; - } - export var x = 10; - export module uninstantiated { - } - -==== tests/cases/compiler/client.ts (0 errors) ==== - 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/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js index 69bb325ec75..7952bdb0bcc 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js @@ -21,29 +21,20 @@ export { uninstantiated } from "server"; export { x } from "server"; //// [server.js] -var c = (function () { - function c() { - } - return c; -})(); -exports.c = c; +export class c { +} var m; (function (m) { m.x = 10; -})(m = exports.m || (exports.m = {})); -exports.x = 10; +})(m || (m = {})); +export { m }; +export var 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; +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] 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/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 new file mode 100644 index 00000000000..9ff3c1b3f04 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/es6ImportDefaultBinding_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/es6ImportDefaultBinding_0.ts (1 errors) ==== + + var a = 10; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + +==== tests/cases/compiler/es6ImportDefaultBinding_1.ts (0 errors) ==== + import defaultBinding from "es6ImportDefaultBinding_0"; + var x = defaultBinding; + import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBinding.js b/tests/baselines/reference/es6ImportDefaultBinding.js index b3c6b71a422..b169f9e80e4 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBinding.js @@ -13,9 +13,9 @@ import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import si //// [es6ImportDefaultBinding_0.js] var a = 10; -module.exports = a; +export default a; //// [es6ImportDefaultBinding_1.js] -var defaultBinding = require("es6ImportDefaultBinding_0"); +import defaultBinding from "es6ImportDefaultBinding_0"; var x = defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBinding.types b/tests/baselines/reference/es6ImportDefaultBinding.types deleted file mode 100644 index 588940250fe..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBinding.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/compiler/es6ImportDefaultBinding_0.ts === - -var a = 10; ->a : number - -export = a; ->a : number - -=== tests/cases/compiler/es6ImportDefaultBinding_1.ts === -import defaultBinding from "es6ImportDefaultBinding_0"; ->defaultBinding : number - -var x = defaultBinding; ->x : number ->defaultBinding : number - -import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used ->defaultBinding2 : number - diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index eb09d25bb1a..5e71478e5a1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -1,3 +1,4 @@ +error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(2,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(4,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. @@ -6,6 +7,7 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(9,8): e 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; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index ab7a3e205dd..7d0d4b2582d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -22,21 +22,21 @@ 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] -var defaultBinding2 = require("es6ImportDefaultBindingFollowedWithNamedImport_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_1.a; -var defaultBinding3 = require("es6ImportDefaultBindingFollowedWithNamedImport_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_2.a; -var defaultBinding4 = require("es6ImportDefaultBindingFollowedWithNamedImport_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_3.x; -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_3.a; -var defaultBinding5 = require("es6ImportDefaultBindingFollowedWithNamedImport_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_4.x; -var defaultBinding6 = require("es6ImportDefaultBindingFollowedWithNamedImport_0"); -var x1 = _es6ImportDefaultBindingFollowedWithNamedImport_0_5.m; +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] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt index bdf2841ab08..a780f7cec30 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt @@ -1,3 +1,4 @@ +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'. @@ -6,10 +7,12 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (0 errors) ==== +==== 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"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js index 765d09fae79..3c8a4080ba7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js @@ -22,19 +22,19 @@ var x1: number = defaultBinding6; //// [es6ImportDefaultBindingFollowedWithNamedImport1_0.js] var a = 10; -module.exports = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1_1.js] -var defaultBinding1 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding1 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding1; -var defaultBinding2 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding2 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding2; -var defaultBinding3 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding3 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding3; -var defaultBinding4 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding4 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding4; -var defaultBinding5 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding5 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding5; -var defaultBinding6 = require("es6ImportDefaultBindingFollowedWithNamedImport1_0"); +import defaultBinding6 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding6; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js index e2593a5d131..6c85e281150 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -62,16 +62,16 @@ var x11 = (function () { })(); exports.x11 = x11; //// [client.js] -var defaultBinding2 = require("server"); +var _server_1 = require("server"); exports.x1 = new _server_1.a(); -var defaultBinding3 = require("server"); +var _server_2 = require("server"); exports.x2 = new _server_2.a11(); -var defaultBinding4 = require("server"); +var _server_3 = require("server"); exports.x4 = new _server_3.x(); exports.x5 = new _server_3.a12(); -var defaultBinding5 = require("server"); +var _server_4 = require("server"); exports.x3 = new _server_4.x11(); -var defaultBinding6 = require("server"); +var _server_5 = require("server"); exports.x6 = new _server_5.m(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index dd31e82901a..1c63005bb06 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -26,16 +26,16 @@ exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] -var defaultBinding2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; -var defaultBinding3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; -var defaultBinding4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; -var defaultBinding5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; -var defaultBinding6 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = _es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js index edf84876964..5497a82b041 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -28,7 +28,7 @@ define(["require", "exports"], function (require, exports) { exports.m = exports.a; }); //// [client.js] -define(["require", "exports", "server", "server", "server", "server", "server"], function (require, exports, defaultBinding2, defaultBinding3, defaultBinding4, defaultBinding5, defaultBinding6) { +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; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js index 1241140b121..2b24fda0755 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js @@ -9,9 +9,9 @@ import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollo var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] -var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBinding_0"); +import * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x = nameSpaceBinding.a; 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 index 7f67628c18e..927ed3243e7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js @@ -11,9 +11,9 @@ var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] var a = 10; -module.exports = a; +export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] -var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBinding_0"); +import defaultBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x = defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types deleted file mode 100644 index ef6c7ac3221..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts === - -var a = 10; ->a : number - -export = a; ->a : number - -=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; ->defaultBinding : number ->nameSpaceBinding : typeof nameSpaceBinding - -var x: number = defaultBinding; ->x : number ->defaultBinding : number - diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 99ad9fd57ab..4bde6e25b10 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -16,7 +16,7 @@ var a = (function () { })(); exports.a = a; //// [client.js] -var defaultBinding = require("server"); +var nameSpaceBinding = require("server"); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index e8ce8b28875..9131fcc75db 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -11,7 +11,7 @@ var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var nameSpaceBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index a386a42b524..b219b5e7876 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -11,7 +11,7 @@ export var x: number = nameSpaceBinding.a; //// [server.js] exports.a = 10; //// [client.js] -var defaultBinding = require("server"); +var nameSpaceBinding = require("server"); exports.x = nameSpaceBinding.a; 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 4e53d54893d..653feeb22b7 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -11,9 +11,9 @@ import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this //// [es6ImportNameSpaceImport_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportNameSpaceImport_1.js] -var nameSpaceBinding = require("es6ImportNameSpaceImport_0"); +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.types b/tests/baselines/reference/es6ImportNameSpaceImport.types deleted file mode 100644 index d764a68eede..00000000000 --- a/tests/baselines/reference/es6ImportNameSpaceImport.types +++ /dev/null @@ -1,18 +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 - -var x = nameSpaceBinding.a; ->x : number ->nameSpaceBinding.a : number ->nameSpaceBinding : typeof nameSpaceBinding ->a : number - -import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this ->nameSpaceBinding2 : typeof nameSpaceBinding - 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 eb27c096951..9606c59351b 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -42,36 +42,36 @@ 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; -exports.z1 = 10; -exports.z2 = 10; -exports.aaaa = 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] -var _es6ImportNamedImport_0_1 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_1.a; -var _es6ImportNamedImport_0_2 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_2.a; -var _es6ImportNamedImport_0_3 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_3.x; -var xxxx = _es6ImportNamedImport_0_3.a; -var _es6ImportNamedImport_0_4 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_4.x; -var _es6ImportNamedImport_0_5 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_5.m; -var _es6ImportNamedImport_0_6 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_6.a1; -var xxxx = _es6ImportNamedImport_0_6.x1; -var _es6ImportNamedImport_0_7 = require("es6ImportNamedImport_0"); -var xxxx = _es6ImportNamedImport_0_7.a1; -var xxxx = _es6ImportNamedImport_0_7.x1; -var _es6ImportNamedImport_0_8 = require("es6ImportNamedImport_0"); -var z111 = _es6ImportNamedImport_0_8.z1; -var _es6ImportNamedImport_0_9 = require("es6ImportNamedImport_0"); -var z2 = _es6ImportNamedImport_0_9.z2; // z2 shouldn't give redeclare error +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] 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 index d05e10e1421..ea9e65db34a 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -9,10 +9,10 @@ import { a } from "es6ImportNamedImportInExportAssignment_0"; export = a; //// [es6ImportNamedImportInExportAssignment_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] -var _es6ImportNamedImportInExportAssignment_0 = require("es6ImportNamedImportInExportAssignment_0"); -module.exports = _es6ImportNamedImportInExportAssignment_0.a; +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export default a; //// [es6ImportNamedImportInExportAssignment_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types deleted file mode 100644 index cd72f35c8bf..00000000000 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts === - -export var a = 10; ->a : number - -=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === -import { a } from "es6ImportNamedImportInExportAssignment_0"; ->a : number - -export = a; ->a : number - 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/es6ImportWithoutFromClause.js b/tests/baselines/reference/es6ImportWithoutFromClause.js index b5eb7a1ba0d..cc8509baade 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.js +++ b/tests/baselines/reference/es6ImportWithoutFromClause.js @@ -9,9 +9,9 @@ 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] diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js index 1c75b15c7d1..51bb0f3338d 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js @@ -10,7 +10,7 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; //// [es6ImportWithoutFromClauseNonInstantiatedModule_0.js] //// [es6ImportWithoutFromClauseNonInstantiatedModule_1.js] -require("es6ImportWithoutFromClauseNonInstantiatedModule_0"); +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; //// [es6ImportWithoutFromClauseNonInstantiatedModule_0.d.ts] 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..955fe3ed8d3 --- /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 = 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/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/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/typeParameterFixingWithConstraints.js b/tests/baselines/reference/typeParameterFixingWithConstraints.js new file mode 100644 index 00000000000..49b2c48fbe2 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.js @@ -0,0 +1,21 @@ +//// [typeParameterFixingWithConstraints.ts] +interface IBar { + [barId: string]: any; +} + +interface IFoo { + foo(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar; +} + +var foo: IFoo; +foo.foo({ bar: null }, bar => null, bar => null); + +//// [typeParameterFixingWithConstraints.js] +var foo; +foo.foo({ + bar: null +}, function (bar) { + return null; +}, function (bar) { + return null; +}); diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types new file mode 100644 index 00000000000..c15f22fc974 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/typeParameterFixingWithConstraints.ts === +interface IBar { +>IBar : IBar + + [barId: string]: any; +>barId : string +} + +interface IFoo { +>IFoo : IFoo + + foo(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar; +>foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar +>TBar : TBar +>IBar : IBar +>bar : TBar +>TBar : TBar +>bar1 : (bar: TBar) => TBar +>bar : TBar +>TBar : TBar +>TBar : TBar +>bar2 : (bar: TBar) => TBar +>bar : TBar +>TBar : TBar +>TBar : TBar +>TBar : TBar +} + +var foo: IFoo; +>foo : IFoo +>IFoo : IFoo + +foo.foo({ bar: null }, bar => null, bar => null); +>foo.foo({ bar: null }, bar => null, bar => null) : IBar +>foo.foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar +>foo : IFoo +>foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar +>{ bar: null } : { [x: string]: null; bar: null; } +>bar : null +>bar => null : (bar: IBar) => any +>bar : IBar +>bar => null : (bar: IBar) => any +>bar : IBar + diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.js b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.js new file mode 100644 index 00000000000..170bd711b61 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.js @@ -0,0 +1,28 @@ +//// [typeParameterFixingWithContextSensitiveArguments.ts] +function f(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(b, x => x.a, a); // type [A, A] +var d2 = f(b, x => x.a, null); // type [B, A] +var d3 = f(b, x => x.b, null); // type [B, any] + +//// [typeParameterFixingWithContextSensitiveArguments.js] +function f(y, f, x) { + return [ + y, + f(x) + ]; +} +var a, b; +var d = f(b, function (x) { + return x.a; +}, a); // type [A, A] +var d2 = f(b, function (x) { + return x.a; +}, null); // type [B, A] +var d3 = f(b, function (x) { + return x.b; +}, null); // type [B, any] diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.types b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.types new file mode 100644 index 00000000000..d6bd1b3b271 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts === +function f(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; } +>f : (y: T, f: (x: T) => U, x: T) => [T, U] +>T : T +>U : U +>y : T +>T : T +>f : (x: T) => U +>x : T +>T : T +>U : U +>x : T +>T : T +>T : T +>U : U +>[y, f(x)] : [T, U] +>y : T +>f(x) : U +>f : (x: T) => U +>x : T + +interface A { a: A; } +>A : A +>a : A +>A : A + +interface B extends A { b; } +>B : B +>A : A +>b : any + +var a: A, b: B; +>a : A +>A : A +>b : B +>B : B + +var d = f(b, x => x.a, a); // type [A, A] +>d : [A, A] +>f(b, x => x.a, a) : [A, A] +>f : (y: T, f: (x: T) => U, x: T) => [T, U] +>b : B +>x => x.a : (x: A) => A +>x : A +>x.a : A +>x : A +>a : A +>a : A + +var d2 = f(b, x => x.a, null); // type [B, A] +>d2 : [B, A] +>f(b, x => x.a, null) : [B, A] +>f : (y: T, f: (x: T) => U, x: T) => [T, U] +>b : B +>x => x.a : (x: B) => A +>x : B +>x.a : A +>x : B +>a : A + +var d3 = f(b, x => x.b, null); // type [B, any] +>d3 : [B, any] +>f(b, x => x.b, null) : [B, any] +>f : (y: T, f: (x: T) => U, x: T) => [T, U] +>b : B +>x => x.b : (x: B) => any +>x : B +>x.b : any +>x : B +>b : any + diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt new file mode 100644 index 00000000000..6a7975b4b62 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts(7,25): error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'. + Type 'A' is not assignable to type 'B'. + + +==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts (1 errors) ==== + function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } + interface A { a: A; } + interface B extends A { b; } + + var a: A, b: B; + + var d = f(a, b, x => x, x => x); // A => A not assignable to A => B + ~~~~~~ +!!! error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'. +!!! error TS2345: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.js b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.js new file mode 100644 index 00000000000..1b97f04953e --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.js @@ -0,0 +1,22 @@ +//// [typeParameterFixingWithContextSensitiveArguments2.ts] +function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(a, b, x => x, x => x); // A => A not assignable to A => B + +//// [typeParameterFixingWithContextSensitiveArguments2.js] +function f(y, y1, p, p1) { + return [ + y, + p1(y) + ]; +} +var a, b; +var d = f(a, b, function (x) { + return x; +}, function (x) { + return x; +}); // A => A not assignable to A => B diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt new file mode 100644 index 00000000000..89be3c06c64 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts(7,29): error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'. + Type 'A' is not assignable to type 'B'. + + +==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts (1 errors) ==== + function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } + interface A { a: A; } + interface B extends A { b: B; } + + var a: A, b: B; + + var d = f(a, b, u2 => u2.b, t2 => t2); + ~~~~~~~~ +!!! error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'. +!!! error TS2345: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.js b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.js new file mode 100644 index 00000000000..4b5370cfc1c --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.js @@ -0,0 +1,22 @@ +//// [typeParameterFixingWithContextSensitiveArguments3.ts] +function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } +interface A { a: A; } +interface B extends A { b: B; } + +var a: A, b: B; + +var d = f(a, b, u2 => u2.b, t2 => t2); + +//// [typeParameterFixingWithContextSensitiveArguments3.js] +function f(t1, u1, pf1, pf2) { + return [ + t1, + pf2(t1) + ]; +} +var a, b; +var d = f(a, b, function (u2) { + return u2.b; +}, function (t2) { + return t2; +}); diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.js b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.js new file mode 100644 index 00000000000..7efab1f62c5 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.js @@ -0,0 +1,22 @@ +//// [typeParameterFixingWithContextSensitiveArguments4.ts] +function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(a, b, x => x, x => x); // Type [A, B] + +//// [typeParameterFixingWithContextSensitiveArguments4.js] +function f(y, y1, p, p1) { + return [ + y, + p1(y) + ]; +} +var a, b; +var d = f(a, b, function (x) { + return x; +}, function (x) { + return x; +}); // Type [A, B] diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.types b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.types new file mode 100644 index 00000000000..61158ae9738 --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments4.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments4.ts === +function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } +>f : (y: T, y1: U, p: (z: U) => T, p1: (x: T) => U) => [T, U] +>T : T +>U : U +>y : T +>T : T +>y1 : U +>U : U +>p : (z: U) => T +>z : U +>U : U +>T : T +>p1 : (x: T) => U +>x : T +>T : T +>U : U +>T : T +>U : U +>[y, p1(y)] : [T, U] +>y : T +>p1(y) : U +>p1 : (x: T) => U +>y : T + +interface A { a: A; } +>A : A +>a : A +>A : A + +interface B extends A { b; } +>B : B +>A : A +>b : any + +var a: A, b: B; +>a : A +>A : A +>b : B +>B : B + +var d = f(a, b, x => x, x => x); // Type [A, B] +>d : [A, B] +>f(a, b, x => x, x => x) : [A, B] +>f : (y: T, y1: U, p: (z: U) => T, p1: (x: T) => U) => [T, U] +>a : A +>b : B +>x => x : (x: B) => B +>x : B +>x : B +>x => x : (x: A) => any +>x : A +>x : any +>x : A + diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.js b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.js new file mode 100644 index 00000000000..7ab2502e02c --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.js @@ -0,0 +1,22 @@ +//// [typeParameterFixingWithContextSensitiveArguments5.ts] +function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } +interface A { a: A; } +interface B extends A { b: any; } + +var a: A, b: B; + +var d = f(a, b, u2 => u2.b, t2 => t2); + +//// [typeParameterFixingWithContextSensitiveArguments5.js] +function f(t1, u1, pf1, pf2) { + return [ + t1, + pf2(t1) + ]; +} +var a, b; +var d = f(a, b, function (u2) { + return u2.b; +}, function (t2) { + return t2; +}); diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.types b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.types new file mode 100644 index 00000000000..3eb7d07bc3c --- /dev/null +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments5.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts === +function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } +>f : (t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U) => [T, U] +>T : T +>U : U +>t1 : T +>T : T +>u1 : U +>U : U +>pf1 : (u2: U) => T +>u2 : U +>U : U +>T : T +>pf2 : (t2: T) => U +>t2 : T +>T : T +>U : U +>T : T +>U : U +>[t1, pf2(t1)] : [T, U] +>t1 : T +>pf2(t1) : U +>pf2 : (t2: T) => U +>t1 : T + +interface A { a: A; } +>A : A +>a : A +>A : A + +interface B extends A { b: any; } +>B : B +>A : A +>b : any + +var a: A, b: B; +>a : A +>A : A +>b : B +>B : B + +var d = f(a, b, u2 => u2.b, t2 => t2); +>d : [any, B] +>f(a, b, u2 => u2.b, t2 => t2) : [any, B] +>f : (t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U) => [T, U] +>a : A +>b : B +>u2 => u2.b : (u2: B) => any +>u2 : B +>u2.b : any +>u2 : B +>b : any +>t2 => t2 : (t2: any) => any +>t2 : any +>t2 : any + diff --git a/tests/cases/compiler/constEnumOnlyModuleMerging.ts b/tests/cases/compiler/constEnumOnlyModuleMerging.ts new file mode 100644 index 00000000000..0b1b9e3f0cb --- /dev/null +++ b/tests/cases/compiler/constEnumOnlyModuleMerging.ts @@ -0,0 +1,13 @@ +module Outer { + export var x = 1; +} + +module Outer { + export const enum A { X } +} + +module B { + import O = Outer; + var x = O.A.X; + var y = O.x; +} \ 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/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/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 f5897128226..3007a9e82fa 100644 --- a/tests/cases/compiler/es6ImportDefaultBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBinding.ts @@ -1,5 +1,5 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @declaration: true // @filename: es6ImportDefaultBinding_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBinding.ts.orig b/tests/cases/compiler/es6ImportDefaultBinding.ts.orig new file mode 100644 index 00000000000..90ac95e7add --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBinding.ts.orig @@ -0,0 +1,18 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true + +// @filename: es6ImportDefaultBinding_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBinding_1.ts +import defaultBinding from "es6ImportDefaultBinding_0"; +<<<<<<< HEAD +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used +======= +>>>>>>> master diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts.orig new file mode 100644 index 00000000000..1605ecde578 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts.orig @@ -0,0 +1,34 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport_0.ts +export var a = 10; +export var x = a; +export var m = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport_1.ts +<<<<<<< HEAD +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; +======= +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"; +>>>>>>> master diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts index 0db237a9c31..c1ac752426e 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImport1_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts.orig new file mode 100644 index 00000000000..8c55ca97fe5 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts.orig @@ -0,0 +1,24 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @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/es6ImportDefaultBindingFollowedWithNamedImportDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts index 64ae625c892..a84dab94033 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @declaration: true diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts.orig new file mode 100644 index 00000000000..a55cc6059d4 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts.orig @@ -0,0 +1,28 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts index e5d2bfefb39..e0f9d953afe 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts @@ -1,5 +1,5 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts.orig new file mode 100644 index 00000000000..dfc2a669e46 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts.orig @@ -0,0 +1,13 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts +export var a = 10; + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts +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 index 6590829e618..81113b776b4 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs // @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts.orig new file mode 100644 index 00000000000..c0acefb4525 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts.orig @@ -0,0 +1,14 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @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/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts index 5aaf1e14c34..cd1bad83716 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @filename: es6ImportDefaultBindingMergeErrors_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts.orig new file mode 100644 index 00000000000..0cff021cae6 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts.orig @@ -0,0 +1,19 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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 index 0436e8f4cdf..5ab1c743721 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @filename: es6ImportDefaultBindingNoDefaultProperty_0.ts diff --git a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts.orig b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts.orig new file mode 100644 index 00000000000..73515821e69 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts.orig @@ -0,0 +1,11 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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/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.orig b/tests/cases/compiler/es6ImportNameSpaceImport.ts.orig new file mode 100644 index 00000000000..370696911b3 --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImport.ts.orig @@ -0,0 +1,17 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true + +// @filename: es6ImportNameSpaceImport_0.ts +export var a = 10; + +// @filename: es6ImportNameSpaceImport_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +<<<<<<< HEAD +var x = nameSpaceBinding.a; +import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this +======= +>>>>>>> master diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts index 1d491ce146a..d4b69e8bcf4 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts @@ -1,4 +1,4 @@ -// @target: es6 +// @target: es5 // @module: commonjs // @filename: es6ImportNameSpaceImportMergeErrors_0.ts diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts.orig b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts.orig new file mode 100644 index 00000000000..a101a65368c --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts.orig @@ -0,0 +1,19 @@ +<<<<<<< HEAD +// @target: es6 +======= +// @target: es5 +>>>>>>> master +// @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 index 237fe3649ea..7d3bdcec94c 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts @@ -1,4 +1,4 @@ -// @target: es6 +// @target: es5 // @module: commonjs // @filename: es6ImportNameSpaceImportNoNamedExports_0.ts diff --git a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts.orig b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts.orig new file mode 100644 index 00000000000..9a885642788 --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts.orig @@ -0,0 +1,13 @@ +<<<<<<< HEAD +// @target: es6 +======= +// @target: es5 +>>>>>>> master +// @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/baselines/reference/es6ImportNamedImport.types b/tests/cases/compiler/es6ImportNamedImport.ts.orig similarity index 50% rename from tests/baselines/reference/es6ImportNamedImport.types rename to tests/cases/compiler/es6ImportNamedImport.ts.orig index 23dfe51c53d..d2e1eec5ca7 100644 --- a/tests/baselines/reference/es6ImportNamedImport.types +++ b/tests/cases/compiler/es6ImportNamedImport.ts.orig @@ -1,123 +1,49 @@ -=== tests/cases/compiler/es6ImportNamedImport_0.ts === +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true +// @filename: 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 - export var z1 = 10; ->z1 : number - export var z2 = 10; ->z2 : number - export var aaaa = 10; ->aaaa : number -=== tests/cases/compiler/es6ImportNamedImport_1.ts === +// @filename: es6ImportNamedImport_1.ts import { } from "es6ImportNamedImport_0"; import { a } from "es6ImportNamedImport_0"; ->a : number - var xxxx = a; ->xxxx : number ->a : number - import { a as b } from "es6ImportNamedImport_0"; ->a : number ->b : number - var xxxx = b; ->xxxx : number ->b : number - import { x, a as y } from "es6ImportNamedImport_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 "es6ImportNamedImport_0"; ->x : number ->z : number - var xxxx = z; ->xxxx : number ->z : number - import { m, } from "es6ImportNamedImport_0"; ->m : number - var xxxx = m; ->xxxx : number ->m : number - import { a1, x1 } from "es6ImportNamedImport_0"; ->a1 : number ->x1 : number - +<<<<<<< HEAD var xxxx = a1; ->xxxx : number ->a1 : number - var xxxx = x1; ->xxxx : number ->x1 : number - import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_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 "es6ImportNamedImport_0"; ->z1 : number - var z111 = z1; ->z111 : number ->z1 : number - import { z2 as z3 } from "es6ImportNamedImport_0"; ->z2 : number ->z3 : number - var z2 = z3; // z2 shouldn't give redeclare error ->z2 : number ->z3 : number // These are elided import { aaaa } from "es6ImportNamedImport_0"; ->aaaa : number - // These are elided import { aaaa as bbbb } from "es6ImportNamedImport_0"; ->aaaa : number ->bbbb : number - +======= +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +>>>>>>> master 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/es6ImportNamedImportInExportAssignment.ts.orig b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts.orig new file mode 100644 index 00000000000..b5f34c33468 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts.orig @@ -0,0 +1,13 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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 index 2f6073f2a1e..16d11d4e19f 100644 --- a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @declaration: true diff --git a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts.orig b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts.orig new file mode 100644 index 00000000000..9d21fa7973a --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts.orig @@ -0,0 +1,17 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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 index 950554b971d..54e30be1e23 100644 --- a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @filename: es6ImportNamedImportMergeErrors_0.ts diff --git a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts.orig b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts.orig new file mode 100644 index 00000000000..833710871d2 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts.orig @@ -0,0 +1,23 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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 index 2dcb2364660..bd507308d8d 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts @@ -1,4 +1,3 @@ -// @target: es6 // @module: commonjs // @filename: es6ImportNamedImportNoExportMember_0.ts diff --git a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts.orig b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts.orig new file mode 100644 index 00000000000..999c1d985b3 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts.orig @@ -0,0 +1,13 @@ +<<<<<<< HEAD +// @target: es6 +======= +>>>>>>> master +// @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 index a51d70ad50e..9dd243ff36d 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts @@ -1,4 +1,4 @@ -// @target: es6 +// @target: es5 // @module: commonjs // @filename: es6ImportNamedImportNoNamedExports_0.ts diff --git a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts.orig b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts.orig new file mode 100644 index 00000000000..3b9e6341229 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts.orig @@ -0,0 +1,14 @@ +<<<<<<< HEAD +// @target: es6 +======= +// @target: es5 +>>>>>>> master +// @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/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 d43aac9b638..657532e7a4b 100644 --- a/tests/cases/compiler/es6ImportWithoutFromClause.ts +++ b/tests/cases/compiler/es6ImportWithoutFromClause.ts @@ -1,9 +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"; +import "es6ImportWithoutFromClause_0"; diff --git a/tests/cases/compiler/es6ImportWithoutFromClause.ts.orig b/tests/cases/compiler/es6ImportWithoutFromClause.ts.orig new file mode 100644 index 00000000000..b2c72541d3d --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClause.ts.orig @@ -0,0 +1,16 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @declaration: true + +// @filename: es6ImportWithoutFromClause_0.ts +export var a = 10; + +// @filename: es6ImportWithoutFromClause_1.ts +<<<<<<< HEAD +import "es6ImportWithoutFromClause_0"; +======= +import "es6ImportWithoutFromClause_0"; +>>>>>>> master diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts index 8d364f75a9b..22b250435c8 100644 --- a/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts +++ b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs // @declaration: true // @filename: es6ImportWithoutFromClauseNonInstantiatedModule_0.ts diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts.orig b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts.orig new file mode 100644 index 00000000000..7ffeae2cbaa --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts.orig @@ -0,0 +1,13 @@ +// @target: es6 +<<<<<<< HEAD +// @module: commonjs +======= +>>>>>>> master +// @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/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/typeParameterFixingWithConstraints.ts b/tests/cases/compiler/typeParameterFixingWithConstraints.ts new file mode 100644 index 00000000000..3d8536ab4cf --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithConstraints.ts @@ -0,0 +1,10 @@ +interface IBar { + [barId: string]: any; +} + +interface IFoo { + foo(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar; +} + +var foo: IFoo; +foo.foo({ bar: null }, bar => null, bar => null); \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts new file mode 100644 index 00000000000..c05b26fd2fc --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts @@ -0,0 +1,9 @@ +function f(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(b, x => x.a, a); // type [A, A] +var d2 = f(b, x => x.a, null); // type [B, A] +var d3 = f(b, x => x.b, null); // type [B, any] \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts new file mode 100644 index 00000000000..f4f001c9f27 --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts @@ -0,0 +1,7 @@ +function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(a, b, x => x, x => x); // A => A not assignable to A => B \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts new file mode 100644 index 00000000000..1bf4169624d --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts @@ -0,0 +1,7 @@ +function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } +interface A { a: A; } +interface B extends A { b: B; } + +var a: A, b: B; + +var d = f(a, b, u2 => u2.b, t2 => t2); \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments4.ts b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments4.ts new file mode 100644 index 00000000000..8fa501906b8 --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments4.ts @@ -0,0 +1,7 @@ +function f(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; } +interface A { a: A; } +interface B extends A { b; } + +var a: A, b: B; + +var d = f(a, b, x => x, x => x); // Type [A, B] \ No newline at end of file diff --git a/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts new file mode 100644 index 00000000000..a74eb042692 --- /dev/null +++ b/tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts @@ -0,0 +1,7 @@ +function f(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; } +interface A { a: A; } +interface B extends A { b: any; } + +var a: A, b: B; + +var d = f(a, b, u2 => u2.b, t2 => t2); \ No newline at end of file diff --git a/tests/cases/fourslash/indentation.ts b/tests/cases/fourslash/indentation.ts index 2a2090c1d87..356d076b9f2 100644 --- a/tests/cases/fourslash/indentation.ts +++ b/tests/cases/fourslash/indentation.ts @@ -176,8 +176,8 @@ ////// the purpose of this test is to verity smart indent ////// works for unterminated function arguments at the end of a file. ////function unterminatedListIndentation(a, -////{| "indent": 0 |} +////{| "indent": 4 |} -test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); - }); +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentAfterNewExpression.ts b/tests/cases/fourslash/smartIndentAfterNewExpression.ts new file mode 100644 index 00000000000..f2d699f988b --- /dev/null +++ b/tests/cases/fourslash/smartIndentAfterNewExpression.ts @@ -0,0 +1,17 @@ +/// + +//// +////new Array +////{| "indent": 0 |} +////new Array; +////{| "indent": 0 |} +////new Array(0); +////{| "indent": 0 |} +////new Array(; +////{| "indent": 0 |} +////new Array( +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts b/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts new file mode 100644 index 00000000000..980f2383299 --- /dev/null +++ b/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts @@ -0,0 +1,14 @@ +/// + +////var /*1*/[/*2*/a,/*3*/b,/*4*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 8); +verifyIndentationAfterNewLine("3", 8); +verifyIndentationAfterNewLine("4", 8); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts b/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts new file mode 100644 index 00000000000..b9a1da7796a --- /dev/null +++ b/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts @@ -0,0 +1,15 @@ +/// + +////var /*1*/[/*2*/a,/*3*/b/*4*/]/*5*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 8); +verifyIndentationAfterNewLine("3", 8); +verifyIndentationAfterNewLine("4", 8); +verifyIndentationAfterNewLine("5", 0); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts b/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts new file mode 100644 index 00000000000..253f58071d9 --- /dev/null +++ b/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts @@ -0,0 +1,13 @@ +/// + +////var x = (/*1*/1/*2*/)/*3*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 4); +verifyIndentationAfterNewLine("3", 0); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentInParenthesizedExpression02.ts b/tests/cases/fourslash/smartIndentInParenthesizedExpression02.ts new file mode 100644 index 00000000000..ac169d0b17e --- /dev/null +++ b/tests/cases/fourslash/smartIndentInParenthesizedExpression02.ts @@ -0,0 +1,8 @@ +/// + +////var y = ( +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts b/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts index b2b1f746a32..a533eca1d67 100644 --- a/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts +++ b/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts @@ -4,4 +4,4 @@ /////**/ goTo.marker(); -verify.indentationIs(0); +verify.indentationIs(4); diff --git a/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts b/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts new file mode 100644 index 00000000000..8bfcbe83b72 --- /dev/null +++ b/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts @@ -0,0 +1,15 @@ +/// + +////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 8); +verifyIndentationAfterNewLine("3", 8); +verifyIndentationAfterNewLine("4", 8); +verifyIndentationAfterNewLine("5", 8); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts b/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts new file mode 100644 index 00000000000..e1612dffbb4 --- /dev/null +++ b/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts @@ -0,0 +1,16 @@ +/// + +////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/}/*6*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 8); +verifyIndentationAfterNewLine("3", 8); +verifyIndentationAfterNewLine("4", 8); +verifyIndentationAfterNewLine("5", 8); +verifyIndentationAfterNewLine("6", 0); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnAccessors.ts b/tests/cases/fourslash/smartIndentOnAccessors.ts new file mode 100644 index 00000000000..a7972b1f48b --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnAccessors.ts @@ -0,0 +1,36 @@ +/// + +////class Foo { +//// get foo(a, +//// /*1*/b,/*0*/ +//// //comment/*2*/ +//// /*3*/c +//// ) { +//// } +//// set foo(a, +//// /*5*/b,/*4*/ +//// //comment/*6*/ +//// /*7*/c +//// ) { +//// } +////} + + +goTo.marker("0"); +edit.insert("\r\n"); +verify.indentationIs(8); +goTo.marker("1"); +verify.currentLineContentIs(" b,"); +goTo.marker("2"); +verify.currentLineContentIs(" //comment"); +goTo.marker("3"); +verify.currentLineContentIs(" c"); +goTo.marker("4"); +edit.insert("\r\n"); +verify.indentationIs(8); +goTo.marker("5"); +verify.currentLineContentIs(" b,"); +goTo.marker("6"); +verify.currentLineContentIs(" //comment"); +goTo.marker("7"); +verify.currentLineContentIs(" c"); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnAccessors01.ts b/tests/cases/fourslash/smartIndentOnAccessors01.ts new file mode 100644 index 00000000000..a7972b1f48b --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnAccessors01.ts @@ -0,0 +1,36 @@ +/// + +////class Foo { +//// get foo(a, +//// /*1*/b,/*0*/ +//// //comment/*2*/ +//// /*3*/c +//// ) { +//// } +//// set foo(a, +//// /*5*/b,/*4*/ +//// //comment/*6*/ +//// /*7*/c +//// ) { +//// } +////} + + +goTo.marker("0"); +edit.insert("\r\n"); +verify.indentationIs(8); +goTo.marker("1"); +verify.currentLineContentIs(" b,"); +goTo.marker("2"); +verify.currentLineContentIs(" //comment"); +goTo.marker("3"); +verify.currentLineContentIs(" c"); +goTo.marker("4"); +edit.insert("\r\n"); +verify.indentationIs(8); +goTo.marker("5"); +verify.currentLineContentIs(" b,"); +goTo.marker("6"); +verify.currentLineContentIs(" //comment"); +goTo.marker("7"); +verify.currentLineContentIs(" c"); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnAccessors02.ts b/tests/cases/fourslash/smartIndentOnAccessors02.ts new file mode 100644 index 00000000000..08f0083f2f2 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnAccessors02.ts @@ -0,0 +1,9 @@ +/// + +////class Foo { +//// get foo() { +////{| "indent": 8 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedArrowType01.ts b/tests/cases/fourslash/smartIndentOnUnclosedArrowType01.ts new file mode 100644 index 00000000000..44a47d984ab --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedArrowType01.ts @@ -0,0 +1,8 @@ +/// + +////var x: () => { +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedComputedProperty01.ts b/tests/cases/fourslash/smartIndentOnUnclosedComputedProperty01.ts new file mode 100644 index 00000000000..0b57a2cb466 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedComputedProperty01.ts @@ -0,0 +1,11 @@ +/// + +////var x = { +//// [1123123123132 +////{| "indent": 4 |} +////} + +// Note that we currently do NOT indent further in a computed property. +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedConstructorType01.ts b/tests/cases/fourslash/smartIndentOnUnclosedConstructorType01.ts new file mode 100644 index 00000000000..ae76cbf06c9 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedConstructorType01.ts @@ -0,0 +1,8 @@ +/// + +////var x: new () => { +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts new file mode 100644 index 00000000000..3e08fe5975e --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts @@ -0,0 +1,13 @@ +/// + +////function /*1*/f/*2*/ + + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts new file mode 100644 index 00000000000..3de8b5ec6c3 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts @@ -0,0 +1,14 @@ +/// + +////function f + +////function f/*1*/ + + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts new file mode 100644 index 00000000000..3931433e51f --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -0,0 +1,17 @@ +/// + +////function f/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/ + + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 4); +verifyIndentationAfterNewLine("3", 4); +verifyIndentationAfterNewLine("4", 4); +verifyIndentationAfterNewLine("5", 4); +verifyIndentationAfterNewLine("6", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration05.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration05.ts new file mode 100644 index 00000000000..24c2bca72f7 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration05.ts @@ -0,0 +1,9 @@ +/// + +////function f(a: A, b:B, c, d: C): { +////{| "indent": 4 |} +//// + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration06.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration06.ts new file mode 100644 index 00000000000..782a85c908a --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration06.ts @@ -0,0 +1,10 @@ +/// + +////function f(a: A, b:B, c, d: C): { +////{| "indent": 4 |} +////} { +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedIndexSignature01.ts b/tests/cases/fourslash/smartIndentOnUnclosedIndexSignature01.ts new file mode 100644 index 00000000000..da88bc9d0c1 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedIndexSignature01.ts @@ -0,0 +1,11 @@ +/// + +////class C { +////[x: string +////{| "indent": 4 |} +//// + +// Note that we currently do NOT indent further in an index signature. +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedObjectTypeLiteral01.ts b/tests/cases/fourslash/smartIndentOnUnclosedObjectTypeLiteral01.ts new file mode 100644 index 00000000000..f2f900ce5d8 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedObjectTypeLiteral01.ts @@ -0,0 +1,8 @@ +/// + +////var x: { +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedTupleTypeLiteral01.ts b/tests/cases/fourslash/smartIndentOnUnclosedTupleTypeLiteral01.ts new file mode 100644 index 00000000000..f2346e6bddc --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnUnclosedTupleTypeLiteral01.ts @@ -0,0 +1,8 @@ +/// + +////var x: [string, number, +////{| "indent": 4 |} + +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); +}); \ No newline at end of file