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 7c1e4c57a4c..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; } } } @@ -505,7 +506,7 @@ module ts { bindChildren(node, 0, /*isBlockScopeContainer*/ false); break; case SyntaxKind.ExportAssignment: - if ((node).expression.kind === SyntaxKind.Identifier) { + if ((node).expression && (node).expression.kind === SyntaxKind.Identifier) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f27d1e217a..423c3c31627 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); @@ -567,7 +566,7 @@ module ts { } function getTargetOfExportAssignment(node: ExportAssignment): Symbol { - return resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); + return node.expression && resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); } function getTargetOfImportDeclaration(node: Declaration): Symbol { @@ -623,7 +622,7 @@ module ts { if (!links.referenced) { links.referenced = true; let node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === SyntaxKind.ExportAssignment) { + if (node.kind === SyntaxKind.ExportAssignment && (node).expression) { // export default checkExpressionCached((node).expression); } @@ -784,7 +783,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) { @@ -1813,6 +1812,11 @@ module ts { case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); + case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportSpecifier: + return false; + // Type parameters are always visible case SyntaxKind.TypeParameter: // Source file is always visible @@ -2073,7 +2077,16 @@ module ts { } // Handle export default expressions if (declaration.kind === SyntaxKind.ExportAssignment) { - return links.type = checkExpression((declaration).expression); + var exportAssignment = declaration; + if (exportAssignment.expression) { + return links.type = checkExpression(exportAssignment.expression); + } + else if (exportAssignment.type) { + return links.type = getTypeFromTypeNode(exportAssignment.type); + } + else { + return links.type = anyType; + } } // Handle variable, parameter or property links.type = resolvingType; @@ -3505,6 +3518,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); } } @@ -4363,8 +4377,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++) { @@ -4379,6 +4396,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; @@ -4561,13 +4580,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), }; } @@ -4613,11 +4631,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; } } } @@ -4723,21 +4751,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; @@ -6334,11 +6376,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++) { @@ -6373,18 +6436,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 { @@ -6618,15 +6670,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) { @@ -6636,9 +6690,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; @@ -6668,7 +6722,7 @@ module ts { else { candidateForTypeArgumentError = originalCandidate; if (!typeArguments) { - resultOfFailedInference = inferenceResult; + resultOfFailedInference = inferenceContext; } } } @@ -10044,6 +10098,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); + } + } } } @@ -10075,13 +10135,27 @@ module ts { if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === SyntaxKind.Identifier) { - markExportAsReferenced(node); + if (node.expression) { + if (node.expression.kind === SyntaxKind.Identifier) { + markExportAsReferenced(node); + } + else { + checkExpressionCached(node.expression); + } } - else { - checkExpressionCached(node.expression); + if (node.type) { + checkSourceElement(node.type); + if (!isInAmbientContext(node)) { + grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration); + } } + 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[] { @@ -10124,7 +10198,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); } @@ -10914,7 +10988,7 @@ module ts { } function generateNameForExportAssignment(node: ExportAssignment) { - if (node.expression.kind !== SyntaxKind.Identifier) { + if (node.expression && node.expression.kind !== SyntaxKind.Identifier) { assignGeneratedName(node, makeUniqueName("default")); } } @@ -10947,7 +11021,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); @@ -10975,7 +11057,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); } } @@ -11011,7 +11093,6 @@ module ts { return true; } } - return forEachChild(node, isReferencedAliasDeclaration); } function isImplementationOfOverload(node: FunctionLikeDeclaration) { @@ -11085,26 +11166,11 @@ module ts { function getBlockScopedVariableId(n: Identifier): number { Debug.assert(!nodeIsSynthesized(n)); - // ignore name parts of property access expressions - if (n.parent.kind === SyntaxKind.PropertyAccessExpression && - (n.parent).name === n) { - return undefined; - } + let isVariableDeclarationOrBindingElement = + n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n); - // ignore property names in object binding patterns - if (n.parent.kind === SyntaxKind.BindingElement && - (n.parent).propertyName === n) { - return undefined; - } - - // for names in variable declarations and binding elements try to short circuit and fetch symbol from the node - let declarationSymbol: Symbol = - (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n) || - n.parent.kind === SyntaxKind.BindingElement - ? getSymbolOfNode(n.parent) - : undefined; - - let symbol = declarationSymbol || + let symbol = + (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 556df1565b0..dd26ef281c4 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -158,6 +158,10 @@ module ts { An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, 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 0c00d8c974c..e1767fe8de0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -617,12 +617,29 @@ }, "Unterminated Unicode escape sequence.": { "category": "Error", - "code": 1199 + "code": 1199 }, "Line terminator not permitted before arrow.": { "category": "Error", "code": 1200 }, + "A type annotation on an export statement is only allowed in an ambient external module declaration.": { + "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", "code": 2300 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 54ec39a5b55..205f2fe2945 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2074,19 +2074,19 @@ module ts { sourceMapDir = getDirectoryPath(normalizePath(jsFilePath)); } - function emitNodeWithSourceMap(node: Node) { + function emitNodeWithSourceMap(node: Node, allowGeneratedIdentifiers?: boolean) { if (node) { if (nodeIsSynthesized(node)) { - return emitNodeWithoutSourceMap(node); + return emitNodeWithoutSourceMap(node, /*allowGeneratedIdentifiers*/ false); } if (node.kind != SyntaxKind.SourceFile) { recordEmitNodeStartSpan(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); recordEmitNodeEndSpan(node); } else { recordNewSourceFileStart(node); - emitNodeWithoutSourceMap(node); + emitNodeWithoutSourceMap(node, /*allowGeneratedIdentifiers*/ false); } } } @@ -2623,17 +2623,24 @@ module ts { } } - function getBlockScopedVariableId(node: Identifier): number { - // return undefined for synthesized nodes - return !nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + function getGeneratedNameForIdentifier(node: Identifier): string { + if (nodeIsSynthesized(node) || !generatedBlockScopeNames) { + return undefined; + } + + var variableId = resolver.getBlockScopedVariableId(node) + if (variableId === undefined) { + return undefined; + } + + return generatedBlockScopeNames[variableId]; } - function emitIdentifier(node: Identifier) { - let variableId = getBlockScopedVariableId(node); - if (variableId !== undefined && generatedBlockScopeNames) { - let text = generatedBlockScopeNames[variableId]; - if (text) { - write(text); + function emitIdentifier(node: Identifier, allowGeneratedIdentifiers: boolean) { + if (allowGeneratedIdentifiers) { + let generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); return; } } @@ -2658,15 +2665,17 @@ module ts { } function emitSuper(node: Node) { - let flags = resolver.getNodeCheckFlags(node); - if (flags & NodeCheckFlags.SuperInstance) { - write("_super.prototype"); - } - else if (flags & NodeCheckFlags.SuperStatic) { - write("_super"); + if (languageVersion >= ScriptTarget.ES6) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & NodeCheckFlags.SuperInstance) { + write("_super.prototype"); + } + else { + write("_super"); + } } } @@ -2686,7 +2695,7 @@ module ts { function emitBindingElement(node: BindingElement) { if (node.propertyName) { - emit(node.propertyName); + emit(node.propertyName, /*allowGeneratedIdentifiers*/ false); write(": "); } if (node.dotDotDotToken) { @@ -3030,7 +3039,7 @@ module ts { } function emitMethod(node: MethodDeclaration) { - emit(node.name); + emit(node.name, /*allowGeneratedIdentifiers*/ false); if (languageVersion < ScriptTarget.ES6) { write(": function "); } @@ -3038,13 +3047,13 @@ module ts { } function emitPropertyAssignment(node: PropertyDeclaration) { - emit(node.name); + emit(node.name, /*allowGeneratedIdentifiers*/ false); write(": "); emit(node.initializer); } function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) { - emit(node.name); + emit(node.name, /*allowGeneratedIdentifiers*/ false); // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: // module m { // export let y; @@ -3053,7 +3062,20 @@ module ts { // export let obj = { y }; // } // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (languageVersion < ScriptTarget.ES6 || resolver.getExpressionNameSubstitution(node.name)) { + if (languageVersion < ScriptTarget.ES6) { + // Emit identifier as an identifier + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + // Even though this is stored as identifier treat it as an expression + // Short-hand, { x }, is equivalent of normal form { x: x } + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name)) { // Emit identifier as an identifier write(": "); // Even though this is stored as identifier treat it as an expression @@ -3106,7 +3128,7 @@ module ts { let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); write("."); let indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); - emit(node.name); + emit(node.name, /*allowGeneratedIdentifiers*/ false); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } @@ -3202,14 +3224,14 @@ module ts { } let superCall = false; if (node.expression.kind === SyntaxKind.SuperKeyword) { - write("_super"); + emitSuper(node.expression); superCall = true; } else { emit(node.expression); superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).expression.kind === SyntaxKind.SuperKeyword; } - if (superCall) { + if (superCall && languageVersion < ScriptTarget.ES6) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -3236,7 +3258,7 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - if (compilerOptions.target >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6) { emit(node.tag); write(" "); emit(node.template); @@ -3836,8 +3858,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); @@ -4189,10 +4217,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) { @@ -4294,7 +4333,7 @@ module ts { function emitAccessor(node: AccessorDeclaration) { write(node.kind === SyntaxKind.GetAccessor ? "get " : "set "); - emit(node.name); + emit(node.name, /*allowGeneratedIdentifiers*/ false); emitSignatureAndBody(node); } @@ -4311,6 +4350,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); @@ -4324,12 +4376,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); @@ -4400,7 +4459,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); @@ -4607,7 +4666,7 @@ module ts { }); } - function emitMemberFunctions(node: ClassDeclaration) { + function emitMemberFunctionsForES5AndLower(node: ClassDeclaration) { forEach(node.members, member => { if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { @@ -4625,7 +4684,6 @@ module ts { emitMemberAccessForPropertyName((member).name); emitEnd((member).name); write(" = "); - // TODO (drosen): Should we performing emitStart twice on emitStart(member)? emitStart(member); emitFunctionDeclaration(member); emitEnd(member); @@ -4645,7 +4703,6 @@ module ts { write(".prototype"); } write(", "); - // TODO: Shouldn't emitStart on name occur *here*? emitExpressionForPropertyName((member).name); emitEnd((member).name); write(", {"); @@ -4685,7 +4742,209 @@ module ts { }); } - function emitClassDeclaration(node: ClassDeclaration) { + function emitMemberFunctionsForES6AndHigher(node: ClassDeclaration) { + for (let member of node.members) { + if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { + emitPinnedOrTripleSlashComments(member); + } + else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & NodeFlags.Static) { + write("static "); + } + + if (member.kind === SyntaxKind.GetAccessor) { + write("get "); + } + else if (member.kind === SyntaxKind.SetAccessor) { + write("set "); + } + emit((member).name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + + function emitConstructor(node: ClassDeclaration, baseTypeNode: TypeReferenceNode) { + let saveTempCount = tempCount; + let saveTempVariables = tempVariables; + let saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; + + let popFrame = enterNameScope(); + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + let hasInstancePropertyWithInitializer = false; + + // Emit the constructor overload pinned comments + forEach(node.members, member => { + if (member.kind === SyntaxKind.Constructor && !(member).body) { + emitPinnedOrTripleSlashComments(member); + } + // Check if there is any non-static property assignment + if (member.kind === SyntaxKind.PropertyDeclaration && (member).initializer && (member.flags & NodeFlags.Static) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + + let ctor = getFirstConstructorWithBody(node); + + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= ScriptTarget.ES6 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + + if (languageVersion < ScriptTarget.ES6) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < ScriptTarget.ES6) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, /*staticFlag*/0); + if (ctor) { + var statements: Node[] = (ctor.body).statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition((ctor.body).statements.end); + } + decreaseIndent(); + emitToken(SyntaxKind.CloseBraceToken, ctor ? (ctor.body).statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + + exitNameScope(popFrame); + + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + + function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { + if (isES6ModuleMemberDeclaration(node)) { + write("export "); + + if (node.flags & NodeFlags.Default) { + write("default "); + } + } + + write("class "); + // check if this is an "export default class" as it may not have a name + if (node.name || !(node.flags & NodeFlags.Default)) { + emitDeclarationName(node); + } + var baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(SyntaxKind.CloseBraceToken, node.members.end); + scopeEmitEnd(); + + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using + // 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) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -4705,8 +4964,8 @@ module ts { emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, NodeFlags.Static); writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => { @@ -4725,6 +4984,7 @@ module ts { } write(");"); emitEnd(node); + if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) { writeLine(); emitStart(node); @@ -4734,88 +4994,10 @@ module ts { emitEnd(node); write(";"); } + if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - - function emitConstructorOfClass() { - let saveTempCount = tempCount; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - - let popFrame = enterNameScope(); - - // Emit the constructor overload pinned comments - forEach(node.members, member => { - if (member.kind === SyntaxKind.Constructor && !(member).body) { - emitPinnedOrTripleSlashComments(member); - } - }); - - let ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments((ctor.body).statements); - } - emitCaptureThisForNodeIfNecessary(node); - let superCall: ExpressionStatement; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, /*nonstatic*/0); - if (ctor) { - let statements: Node[] = (ctor.body).statements; - if (superCall) statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition((ctor.body).statements.end); - } - decreaseIndent(); - emitToken(SyntaxKind.CloseBraceToken, ctor ? (ctor.body).statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - - exitNameScope(popFrame); - - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } } function emitInterfaceDeclaration(node: InterfaceDeclaration) { @@ -4833,7 +5015,7 @@ module ts { return; } - if (!(node.flags & NodeFlags.Export)) { + if (!(node.flags & NodeFlags.Export) || isES6ModuleMemberDeclaration(node)) { emitStart(node); write("var "); emit(node.name); @@ -4860,7 +5042,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 "); @@ -4966,7 +5151,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(" = "); } @@ -4975,11 +5161,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("); @@ -4994,7 +5192,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; @@ -5036,7 +5322,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 @@ -5046,7 +5332,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); @@ -5057,77 +5349,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) { @@ -5164,9 +5500,7 @@ module ts { else { let info = createExternalImportInfo(node); if (info) { - if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(info); - } + externalImports.push(info); } } }); @@ -5182,14 +5516,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) => { @@ -5204,6 +5530,7 @@ module ts { } function emitAMDModule(node: SourceFile, startIndex: number) { + createExternalModuleInfo(node); writeLine(); write("define("); sortAMDModules(node.amdDependencies); @@ -5254,28 +5581,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); } } @@ -5301,8 +5660,10 @@ module ts { emitDetachedComments(node); // emit prologue directives prior to __extends - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as if. + if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -5320,8 +5681,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 { @@ -5340,7 +5703,7 @@ module ts { emitLeadingComments(node.endOfFileToken); } - function emitNodeWithoutSourceMapWithComments(node: Node): void { + function emitNodeWithoutSourceMapWithComments(node: Node, allowGeneratedIdentifiers?: boolean): void { if (!node) { return; } @@ -5354,14 +5717,14 @@ module ts { emitLeadingComments(node); } - emitJavaScriptWorker(node); + emitJavaScriptWorker(node, allowGeneratedIdentifiers); if (emitComments) { emitTrailingComments(node); } } - function emitNodeWithoutSourceMapWithoutComments(node: Node): void { + function emitNodeWithoutSourceMapWithoutComments(node: Node, allowGeneratedIdentifiers?: boolean): void { if (!node) { return; } @@ -5370,7 +5733,7 @@ module ts { return emitPinnedOrTripleSlashComments(node); } - emitJavaScriptWorker(node); + emitJavaScriptWorker(node, allowGeneratedIdentifiers); } function shouldEmitLeadingAndTrailingComments(node: Node) { @@ -5400,11 +5763,11 @@ module ts { return true; } - function emitJavaScriptWorker(node: Node) { + function emitJavaScriptWorker(node: Node, allowGeneratedIdentifiers: boolean = true) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { case SyntaxKind.Identifier: - return emitIdentifier(node); + return emitIdentifier(node, allowGeneratedIdentifiers); case SyntaxKind.Parameter: return emitParameter(node); case SyntaxKind.MethodDeclaration: @@ -5534,7 +5897,7 @@ module ts { case SyntaxKind.VariableDeclaration: return emitVariableDeclaration(node); case SyntaxKind.ClassDeclaration: - return emitClassDeclaration(node); + return languageVersion < ScriptTarget.ES6 ? emitClassDeclarationBelowES6(node) : emitClassDeclarationForES6AndHigher(node); case SyntaxKind.InterfaceDeclaration: return emitInterfaceDeclaration(node); case SyntaxKind.EnumDeclaration: @@ -5545,10 +5908,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); } @@ -5720,3 +6088,4 @@ module ts { } } } + diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 27f550778c1..9eae67a29b8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -283,7 +283,8 @@ module ts { visitNode(cbNode, (node).name); case SyntaxKind.ExportAssignment: return visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, (node).expression); + visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).type); case SyntaxKind.TemplateExpression: return visitNode(cbNode, (node).head) || visitNodes(cbNodes, (node).templateSpans); case SyntaxKind.TemplateSpan: @@ -613,7 +614,7 @@ module ts { // change the token touching it, we actually need to look back *at least* one token so // that the prior token sees that change. let maxLookahead = 1; - + let start = changeRange.span.start; // the first iteration aligns us with the change start. subsequent iteration move us to @@ -831,7 +832,7 @@ module ts { // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. let result = parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true) - + return result; } @@ -1986,7 +1987,7 @@ module ts { // // let v = new List < A, B >() // - // then we have a problem. "v = new List"); let node = createNode(SyntaxKind.ArrowFunction, identifier.pos); - + let parameter = createNode(SyntaxKind.Parameter, identifier.pos); - parameter.name = identifier; + parameter.name = identifier; finishNode(parameter); node.parameters = >[parameter]; @@ -3140,8 +3141,8 @@ module ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); - // Arrow functions are never generators. - // + // Arrow functions are never generators. + // // If we're speculatively parsing a signature for a parenthesized arrow function, then // we have to have a complete parameter list. Otherwise we might see something like // a => (b => c) @@ -3206,7 +3207,7 @@ module ts { // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. let node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); - node.condition = leftOperand; + node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition:*/ false, @@ -4526,7 +4527,13 @@ module ts { } function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration { - let node = createNode(SyntaxKind.ClassDeclaration, fullStart); + // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code + let savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= ScriptTarget.ES6) { + setStrictModeContext(true); + } + + var node = createNode(SyntaxKind.ClassDeclaration, fullStart); setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); @@ -4546,7 +4553,10 @@ module ts { else { node.members = createMissingList(); } - return finishNode(node); + + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { @@ -4774,7 +4784,7 @@ module ts { // walker. let result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure - // that features like 'find refs' will look inside this file when search for its name. + // that features like 'find refs' will look inside this file when search for its name. if (result.kind === SyntaxKind.StringLiteral) { internIdentifier((result).text); } @@ -4867,12 +4877,17 @@ module ts { setModifiers(node, modifiers); if (parseOptional(SyntaxKind.EqualsToken)) { node.isExportEquals = true; + node.expression = parseAssignmentExpressionOrHigher(); } else { parseExpected(SyntaxKind.DefaultKeyword); + if (parseOptional(SyntaxKind.ColonToken)) { + node.type = parseType(); + } + else { + node.expression = parseAssignmentExpressionOrHigher(); + } } - //node.exportName = parseIdentifier(); - node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } 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 25a8ce75245..87d219c2e84 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -944,7 +944,8 @@ module ts { export interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } export interface FileReference extends TextRange { @@ -1486,11 +1487,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/server/editorServices.ts b/src/server/editorServices.ts index e3ed6914b67..4861c2cdfd3 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -19,15 +19,19 @@ module ts.server { class ScriptInfo { svc: ScriptVersionCache; children: ScriptInfo[] = []; // files referenced by this file - defaultProject: Project; // project to use by default for file - fileWatcher: FileWatcher; + formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { this.svc = ScriptVersionCache.fromString(content); } + setFormatOptions(tabSize: number, indentSize: number) { + this.formatCodeOptions.TabSize = tabSize; + this.formatCodeOptions.IndentSize = indentSize; + } + close() { this.isOpen = false; } @@ -153,15 +157,18 @@ module ts.server { } } - reloadScript(filename: string, tmpfilename: string, tabSize: number, cb: () => any) { + reloadScript(filename: string, tmpfilename: string, cb: () => any) { var script = this.getScriptInfo(filename); if (script) { - script.svc.reloadFromFile(tmpfilename, tabSize, cb); + script.svc.reloadFromFile(tmpfilename, script.formatCodeOptions.TabSize, cb); } } editScript(filename: string, start: number, end: number, newText: string) { var script = this.getScriptInfo(filename); + if (newText && (newText.length > 0)) { + newText = expandTabs(newText, script.formatCodeOptions.TabSize); + } if (script) { script.editContent(start, end, newText); return; @@ -365,6 +372,12 @@ module ts.server { hostInfo: string; } + export function expandTabs(text: string, tabSize: number) { + var spaces = generateSpaces(tabSize); + return text.replace(/\t/g, spaces); + } + + export class ProjectService { filenameToScriptInfo: ts.Map = {}; // open, non-configured files in two lists @@ -386,7 +399,13 @@ module ts.server { } } - getFormatCodeOptions() { + getFormatCodeOptions(file?: string) { + if (file) { + var info = this.filenameToScriptInfo[file]; + if (info) { + return info.formatCodeOptions; + } + } return this.hostConfiguration.formatCodeOptions; } @@ -402,7 +421,7 @@ module ts.server { } else { if (info && (!info.isOpen)) { - info.svc.reloadFromFile(info.fileName, this.hostConfiguration.formatCodeOptions.TabSize); + info.svc.reloadFromFile(info.fileName, info.formatCodeOptions.TabSize); } } } @@ -412,15 +431,19 @@ module ts.server { } setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments) { - this.hostConfiguration.formatCodeOptions.TabSize = args.tabSize; - this.hostConfiguration.formatCodeOptions.IndentSize = args.indentSize; - this.hostConfiguration.hostInfo = args.hostInfo; - this.log("Host information " + args.hostInfo, "Info"); - } - - expandTabs(text: string) { - var spaces = generateSpaces(this.hostConfiguration.formatCodeOptions.TabSize); - return text.replace(/\t/g, spaces); + if (args.file) { + var info = this.filenameToScriptInfo[args.file]; + if (info) { + info.setFormatOptions(args.tabSize, args.indentSize); + this.log("Host configuration update for file " + args.file + " tab size " + args.tabSize); + } + } + else { + this.hostConfiguration.formatCodeOptions.TabSize = args.tabSize; + this.hostConfiguration.formatCodeOptions.IndentSize = args.indentSize; + this.hostConfiguration.hostInfo = args.hostInfo; + this.log("Host information " + args.hostInfo, "Info"); + } } closeLog() { @@ -623,7 +646,7 @@ module ts.server { /** * @param filename is absolute pathname */ - openFile(fileName: string, openedByClient = false) { + openFile(fileName: string, openedByClient: boolean, tabSize?: number) { fileName = ts.normalizePath(fileName); var info = ts.lookUp(this.filenameToScriptInfo, fileName); if (!info) { @@ -637,12 +660,26 @@ module ts.server { } } if (content !== undefined) { - content = this.expandTabs(content); + var indentSize: number; + if (!tabSize) { + tabSize = this.hostConfiguration.formatCodeOptions.TabSize; + indentSize = this.hostConfiguration.formatCodeOptions.IndentSize; + } + else { + indentSize = tabSize; + } + if (openedByClient) { + this.log("Expanding tabs for file " + fileName + " with tab size " + tabSize.toString()); + content = expandTabs(content, tabSize); + } info = new ScriptInfo(this.host, fileName, content, openedByClient); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { info.fileWatcher = this.host.watchFile(fileName, _ => { this.watchedFileChanged(fileName); }); } + else { + info.setFormatOptions(tabSize, indentSize); + } } } if (info) { @@ -658,9 +695,9 @@ module ts.server { * @param filename is absolute pathname */ - openClientFile(filename: string) { + openClientFile(filename: string, tabSize?: number) { // TODO: tsconfig check - var info = this.openFile(filename, true); + var info = this.openFile(filename, true, tabSize); this.addOpenFile(info); this.printProjects(); return info; @@ -760,7 +797,8 @@ module ts.server { var normRootFilename = ts.normalizePath(rootFilename); normRootFilename = getAbsolutePath(normRootFilename, dirPath); if (this.host.fileExists(normRootFilename)) { - var info = this.openFile(normRootFilename); + // TODO: pass true for file exiplicitly opened + var info = this.openFile(normRootFilename, false); proj.addRoot(info); } else { @@ -1123,6 +1161,7 @@ module ts.server { reloadFromFile(filename: string, tabSize: number, cb?: () => any) { var content = ts.sys.readFile(filename); + content = expandTabs(content, tabSize); this.reload(content); if (cb) cb(); diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 0adda71cac2..a7a0642de2e 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -312,6 +312,10 @@ declare module ts.server.protocol { * 'Sublime Text version 3075' */ hostInfo: string; + /** + * If present, tab settings apply only to this file. + */ + file?: string; } /** @@ -329,6 +333,14 @@ declare module ts.server.protocol { export interface ConfigureResponse extends Response { } + /** + * Information found in an "open" request. + */ + export interface OpenRequestArgs extends FileRequestArgs { + /** Initial tab size of file. */ + tabSize?: number; + } + /** * Open request; value of command field is "open". Notify the * server that the client has file open. The server will not @@ -337,7 +349,8 @@ declare module ts.server.protocol { * reload messages) when the file changes. Server does not currently * send a response to an open request. */ - export interface OpenRequest extends FileRequest { + export interface OpenRequest extends Request { + arguments: OpenRequestArgs; } /** diff --git a/src/server/session.ts b/src/server/session.ts index 012c7ad6ae4..d6243e4b7a7 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -5,7 +5,7 @@ /// module ts.server { - var spaceCache = [" ", " ", " ", " "]; + var spaceCache:string[] = []; interface StackTraceError extends Error { stack?: string; @@ -397,9 +397,9 @@ module ts.server { }; } - openClientFile(fileName: string) { + openClientFile(fileName: string, tabSize?: number) { var file = ts.normalizePath(fileName); - this.projectService.openClientFile(file); + this.projectService.openClientFile(file, tabSize); } getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody { @@ -441,7 +441,7 @@ module ts.server { // TODO: avoid duplicate code (with formatonkey) var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, - this.projectService.getFormatCodeOptions()); + this.projectService.getFormatCodeOptions(file)); if (!edits) { return undefined; } @@ -465,7 +465,7 @@ module ts.server { var compilerService = project.compilerService; var position = compilerService.host.lineColToPosition(file, line, col); - var formatOptions = this.projectService.getFormatCodeOptions(); + var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); // Check whether we should auto-indent. This will be when @@ -611,8 +611,7 @@ module ts.server { if (project) { this.changeSeq++; // make sure no changes happen before this one is finished - project.compilerService.host.reloadScript(file, tmpfile, - this.projectService.getFormatCodeOptions().TabSize, () => { + project.compilerService.host.reloadScript(file, tmpfile, () => { this.output(undefined, CommandNames.Reload, reqSeq); }); } @@ -756,8 +755,8 @@ module ts.server { break; } case CommandNames.Open: { - var openArgs = request.arguments; - this.openClientFile(openArgs.file); + var openArgs = request.arguments; + this.openClientFile(openArgs.file,openArgs.tabSize); responseRequired = false; break; } diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index c56ea72cd66..395141cc4cc 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -173,6 +173,10 @@ module ts.BreakpointResolver { return textSpan(node, (node).expression); case SyntaxKind.ExportAssignment: + if (!(node).expression) { + return undefined; + } + // span on export = id return textSpan(node, (node).expression); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 24ddabc2b2b..23a392d7718 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1008,10 +1008,20 @@ module ts.formatting { return SyntaxKind.Unknown; } - let internedTabsIndentation: string[]; - let internedSpacesIndentation: string[]; + var internedSizes: { tabSize: number; indentSize: number }; + var internedTabsIndentation: string[]; + var internedSpacesIndentation: string[]; export function getIndentationString(indentation: number, options: FormatCodeOptions): string { + // reset interned strings if FormatCodeOptions were changed + let resetInternedStrings = + !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + + if (resetInternedStrings) { + internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; + } + if (!options.ConvertTabsToSpaces) { let tabs = Math.floor(indentation / options.TabSize); let spaces = indentation - tabs * options.TabSize; diff --git a/src/services/formatting/indentation.ts b/src/services/formatting/indentation.ts deleted file mode 100644 index f6f8fc0319f..00000000000 --- a/src/services/formatting/indentation.ts +++ /dev/null @@ -1,54 +0,0 @@ -module ts.formatting { - - var internedTabsIndentation: string[]; - var internedSpacesIndentation: string[]; - - export function getIndentationString(indentation: number, options: FormatCodeOptions): string { - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - - var tabString: string; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString: string; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; - } - - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - - - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - - function repeat(value: string, count: number): string { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - - return s; - } - } -} \ No newline at end of file diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 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/shims.ts b/src/services/shims.ts index fc47ff95280..63e3c9e23ae 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -833,3 +833,5 @@ module ts { module TypeScript.Services { export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory; } + +let toolsVersion = "1.4"; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 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 6244dc73951..575c2bdaf36 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -765,7 +765,8 @@ declare module "typescript" { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -1175,17 +1176,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 43e88c27e41..336d70aa1a1 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2333,9 +2333,13 @@ declare module "typescript" { isExportEquals?: boolean; >isExportEquals : boolean - expression: Expression; + expression?: Expression; >expression : Expression >Expression : Expression + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode } interface FileReference extends TextRange { >FileReference : FileReference @@ -3765,38 +3769,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 fd4649f614d..e7145e24070 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -796,7 +796,8 @@ declare module "typescript" { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -1206,17 +1207,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 984b59ca7ee..a40848b9e4c 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2479,9 +2479,13 @@ declare module "typescript" { isExportEquals?: boolean; >isExportEquals : boolean - expression: Expression; + expression?: Expression; >expression : Expression >Expression : Expression + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode } interface FileReference extends TextRange { >FileReference : FileReference @@ -3911,38 +3915,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 4222e1b2d98..da8fe979d17 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -797,7 +797,8 @@ declare module "typescript" { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -1207,17 +1208,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 bea3f1e7231..b694678d4cb 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -2429,9 +2429,13 @@ declare module "typescript" { isExportEquals?: boolean; >isExportEquals : boolean - expression: Expression; + expression?: Expression; >expression : Expression >Expression : Expression + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode } interface FileReference extends TextRange { >FileReference : FileReference @@ -3861,38 +3865,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 0928c2cf139..f380994eba8 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -834,7 +834,8 @@ declare module "typescript" { type ExportSpecifier = ImportOrExportSpecifier; interface ExportAssignment extends Declaration, ModuleElement { isExportEquals?: boolean; - expression: Expression; + expression?: Expression; + type?: TypeNode; } interface FileReference extends TextRange { fileName: string; @@ -1244,17 +1245,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 4498a5538e4..06329de5c96 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -2602,9 +2602,13 @@ declare module "typescript" { isExportEquals?: boolean; >isExportEquals : boolean - expression: Expression; + expression?: Expression; >expression : Expression >Expression : Expression + + type?: TypeNode; +>type : TypeNode +>TypeNode : TypeNode } interface FileReference extends TextRange { >FileReference : FileReference @@ -4034,38 +4038,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/callWithSpreadES6.js b/tests/baselines/reference/callWithSpreadES6.js index 0becb4c6e3e..d1589d7f6fa 100644 --- a/tests/baselines/reference/callWithSpreadES6.js +++ b/tests/baselines/reference/callWithSpreadES6.js @@ -55,12 +55,6 @@ var c = new C(1, 2, ...a); //// [callWithSpreadES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; function foo(x, y, ...z) { } var a; @@ -84,26 +78,23 @@ xa[1].foo(...[ 2, "abc" ]); -var C = (function () { - function C(x, y, ...z) { +class C { + constructor(x, y, ...z) { this.foo(x, y); this.foo(x, y, ...z); } - C.prototype.foo = function (x, y, ...z) { - }; - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.call(this, 1, 2); - _super.call(this, 1, 2, ...a); + foo(x, y, ...z) { } - D.prototype.foo = function () { - _super.prototype.foo.call(this, 1, 2); - _super.prototype.foo.call(this, 1, 2, ...a); - }; - return D; -})(C); +} +class D extends C { + constructor() { + super(1, 2); + super(1, 2, ...a); + } + foo() { + super.foo(1, 2); + super.foo(1, 2, ...a); + } +} // Only supported in when target is ES6 var c = new C(1, 2, ...a); diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.js b/tests/baselines/reference/computedPropertyNames12_ES6.js index 5ab6e4c09b3..fd6ccb6e486 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.js +++ b/tests/baselines/reference/computedPropertyNames12_ES6.js @@ -20,12 +20,11 @@ class C { var s; var n; var a; -var C = (function () { - function C() { +class C { + constructor() { this[n] = n; this[s + n] = 2; this[`hello bye`] = 0; } - C[`hello ${a} bye`] = 0; - return C; -})(); +} +C[`hello ${a} bye`] = 0; diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.js b/tests/baselines/reference/computedPropertyNames13_ES6.js index 07aa1673aba..18d81fcec59 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.js +++ b/tests/baselines/reference/computedPropertyNames13_ES6.js @@ -20,30 +20,27 @@ class C { var s; var n; var a; -var C = (function () { - function C() { +class C { + [s]() { } - C.prototype[s] = function () { - }; - C.prototype[n] = function () { - }; - C[s + s] = function () { - }; - C.prototype[s + n] = function () { - }; - C.prototype[+s] = function () { - }; - C[""] = function () { - }; - C.prototype[0] = function () { - }; - C.prototype[a] = function () { - }; - C[true] = function () { - }; - C.prototype[`hello bye`] = function () { - }; - C[`hello ${a} bye`] = function () { - }; - return C; -})(); + [n]() { + } + static [s + s]() { + } + [s + n]() { + } + [+s]() { + } + static [""]() { + } + [0]() { + } + [a]() { + } + static [true]() { + } + [`hello bye`]() { + } + static [`hello ${a} bye`]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames14_ES6.js b/tests/baselines/reference/computedPropertyNames14_ES6.js index 7a58ad9a80a..b1b2a9bf285 100644 --- a/tests/baselines/reference/computedPropertyNames14_ES6.js +++ b/tests/baselines/reference/computedPropertyNames14_ES6.js @@ -11,20 +11,17 @@ class C { //// [computedPropertyNames14_ES6.js] var b; -var C = (function () { - function C() { +class C { + [b]() { } - C.prototype[b] = function () { - }; - C[true] = function () { - }; - C.prototype[[]] = function () { - }; - C[{}] = function () { - }; - C.prototype[undefined] = function () { - }; - C[null] = function () { - }; - return C; -})(); + static [true]() { + } + [[]]() { + } + static [{}]() { + } + [undefined]() { + } + static [null]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames15_ES6.js b/tests/baselines/reference/computedPropertyNames15_ES6.js index 70c2e7b451c..1a9141ab13d 100644 --- a/tests/baselines/reference/computedPropertyNames15_ES6.js +++ b/tests/baselines/reference/computedPropertyNames15_ES6.js @@ -12,14 +12,11 @@ class C { var p1; var p2; var p3; -var C = (function () { - function C() { +class C { + [p1]() { } - C.prototype[p1] = function () { - }; - C.prototype[p2] = function () { - }; - C.prototype[p3] = function () { - }; - return C; -})(); + [p2]() { + } + [p3]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.js b/tests/baselines/reference/computedPropertyNames16_ES6.js index 90f15f6cf2e..96e175976da 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.js +++ b/tests/baselines/reference/computedPropertyNames16_ES6.js @@ -20,80 +20,33 @@ class C { var s; var n; var a; -var C = (function () { - function C() { +class C { + get [s]() { + return 0; } - Object.defineProperty(C.prototype, s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, n, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, s + s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, s + n, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, +s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "", { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 0, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, a, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, true, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, `hello bye`, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, `hello ${a} bye`, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [n](v) { + } + static get [s + s]() { + return 0; + } + set [s + n](v) { + } + get [+s]() { + return 0; + } + static set [""](v) { + } + get [0]() { + return 0; + } + set [a](v) { + } + static get [true]() { + return 0; + } + set [`hello bye`](v) { + } + get [`hello ${a} bye`]() { + return 0; + } +} diff --git a/tests/baselines/reference/computedPropertyNames17_ES6.js b/tests/baselines/reference/computedPropertyNames17_ES6.js index e9b19202e08..a181a61004e 100644 --- a/tests/baselines/reference/computedPropertyNames17_ES6.js +++ b/tests/baselines/reference/computedPropertyNames17_ES6.js @@ -11,47 +11,20 @@ class C { //// [computedPropertyNames17_ES6.js] var b; -var C = (function () { - function C() { +class C { + get [b]() { + return 0; } - Object.defineProperty(C.prototype, b, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, true, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, [], { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, {}, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, undefined, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, null, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static set [true](v) { + } + get [[]]() { + return 0; + } + set [{}](v) { + } + static get [undefined]() { + return 0; + } + set [null](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames21_ES6.js b/tests/baselines/reference/computedPropertyNames21_ES6.js index f51f6faed24..c5f6b4e22b1 100644 --- a/tests/baselines/reference/computedPropertyNames21_ES6.js +++ b/tests/baselines/reference/computedPropertyNames21_ES6.js @@ -7,13 +7,10 @@ class C { } //// [computedPropertyNames21_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[this.bar()] = function () { - }; - return C; -})(); + } + [this.bar()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames22_ES6.js b/tests/baselines/reference/computedPropertyNames22_ES6.js index 9872605c20e..c88ceb6bc8f 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES6.js +++ b/tests/baselines/reference/computedPropertyNames22_ES6.js @@ -9,15 +9,12 @@ class C { } //// [computedPropertyNames22_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { var obj = { [this.bar()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames23_ES6.js b/tests/baselines/reference/computedPropertyNames23_ES6.js index f5687952b88..0bae1abdad2 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES6.js +++ b/tests/baselines/reference/computedPropertyNames23_ES6.js @@ -9,15 +9,12 @@ class C { } //// [computedPropertyNames23_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[{ + } + [{ [this.bar()]: 1 - }[0]] = function () { - }; - return C; -})(); + }[0]]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt index a1290e06956..121b39450a6 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name. +tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,6): error TS2466: 'super' cannot be referenced in a computed property name. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts (1 errors) ==== @@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9, } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } ~~~~~ !!! error TS2466: 'super' cannot be referenced in a computed property name. diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index d24f406c1ad..cea5240003b 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } } @@ -30,9 +28,7 @@ var C = (function (_super) { function C() { _super.apply(this, arguments); } - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. - C.prototype[super.bar.call(this)] = function () { + C.prototype[_super.bar.call(this)] = function () { }; return C; })(Base); diff --git a/tests/baselines/reference/computedPropertyNames24_ES6.js b/tests/baselines/reference/computedPropertyNames24_ES6.js index 12aef633963..8d33db10f71 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES6.js +++ b/tests/baselines/reference/computedPropertyNames24_ES6.js @@ -11,28 +11,14 @@ class C extends Base { } //// [computedPropertyNames24_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } +} +class C extends Base { // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. - C.prototype[super.bar.call(this)] = function () { - }; - return C; -})(Base); + [super.bar()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames25_ES6.js b/tests/baselines/reference/computedPropertyNames25_ES6.js index 1a600df5040..cc6a0670b21 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES6.js +++ b/tests/baselines/reference/computedPropertyNames25_ES6.js @@ -14,31 +14,17 @@ class C extends Base { } //// [computedPropertyNames25_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } - C.prototype.foo = function () { +} +class C extends Base { + foo() { var obj = { - [_super.prototype.bar.call(this)]() { + [super.bar()]() { } }; return 0; - }; - return C; -})(Base); + } +} diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt index 77408f0a9f8..e7039712734 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name. +tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,12): error TS2466: 'super' cannot be referenced in a computed property name. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts (1 errors) ==== @@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10 } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ~~~~~ diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 217a0dfc74c..5651ee266c9 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ]() { } @@ -32,10 +30,8 @@ var C = (function (_super) { function C() { _super.apply(this, arguments); } - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. C.prototype[(_a = {}, - _a[super.bar.call(this)] = 1, + _a[_super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames26_ES6.js b/tests/baselines/reference/computedPropertyNames26_ES6.js index fc53d91e627..4526368de7a 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES6.js +++ b/tests/baselines/reference/computedPropertyNames26_ES6.js @@ -13,30 +13,16 @@ class C extends Base { } //// [computedPropertyNames26_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } +} +class C extends Base { // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. - C.prototype[{ - [super.bar.call(this)]: 1 - }[0]] = function () { - }; - return C; -})(Base); + [{ + [super.bar()]: 1 + }[0]]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames27_ES6.js b/tests/baselines/reference/computedPropertyNames27_ES6.js index 54a20a52200..57589dfcaf5 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES6.js +++ b/tests/baselines/reference/computedPropertyNames27_ES6.js @@ -6,23 +6,9 @@ class C extends Base { } //// [computedPropertyNames27_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { +class Base { +} +class C extends Base { + [(super(), "prop")]() { } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); - } - C.prototype[(_super.call(this), "prop")] = function () { - }; - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames28_ES6.js b/tests/baselines/reference/computedPropertyNames28_ES6.js index 09e1b33bf98..bc0e32593de 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES6.js +++ b/tests/baselines/reference/computedPropertyNames28_ES6.js @@ -11,25 +11,14 @@ class C extends Base { } //// [computedPropertyNames28_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.call(this); +class Base { +} +class C extends Base { + constructor() { + super(); var obj = { - [(_super.call(this), "prop")]() { + [(super(), "prop")]() { } }; } - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames29_ES6.js b/tests/baselines/reference/computedPropertyNames29_ES6.js index e1e6be51b21..35958b372b0 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES6.js +++ b/tests/baselines/reference/computedPropertyNames29_ES6.js @@ -11,10 +11,8 @@ class C { } //// [computedPropertyNames29_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { (() => { var obj = { [this.bar()]() { @@ -22,6 +20,5 @@ var C = (function () { }; }); return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames2_ES6.js b/tests/baselines/reference/computedPropertyNames2_ES6.js index e5fcfaac8f9..4287cb2c4b8 100644 --- a/tests/baselines/reference/computedPropertyNames2_ES6.js +++ b/tests/baselines/reference/computedPropertyNames2_ES6.js @@ -13,36 +13,17 @@ class C { //// [computedPropertyNames2_ES6.js] var methodName = "method"; var accessorName = "accessor"; -var C = (function () { - function C() { +class C { + [methodName]() { } - C.prototype[methodName] = function () { - }; - C[methodName] = function () { - }; - Object.defineProperty(C.prototype, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static [methodName]() { + } + get [accessorName]() { + } + set [accessorName](v) { + } + static get [accessorName]() { + } + static set [accessorName](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.js b/tests/baselines/reference/computedPropertyNames30_ES6.js index c88fa98be5e..cda2a278d47 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.js +++ b/tests/baselines/reference/computedPropertyNames30_ES6.js @@ -16,30 +16,19 @@ class C extends Base { } //// [computedPropertyNames30_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.call(this); +class Base { +} +class C extends Base { + constructor() { + super(); (() => { var obj = { // Ideally, we would capture this. But the reference is // illegal, and not capturing this is consistent with //treatment of other similar violations. - [(_super.call(this), "prop")]() { + [(super(), "prop")]() { } }; }); } - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames31_ES6.js b/tests/baselines/reference/computedPropertyNames31_ES6.js index 33f5319ded9..777e03bbcac 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES6.js +++ b/tests/baselines/reference/computedPropertyNames31_ES6.js @@ -16,34 +16,20 @@ class C extends Base { } //// [computedPropertyNames31_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } - C.prototype.foo = function () { +} +class C extends Base { + foo() { var _this = this; (() => { var obj = { - [_super.prototype.bar.call(_this)]() { + [super.bar()]() { } // needs capture }; }); return 0; - }; - return C; -})(Base); + } +} diff --git a/tests/baselines/reference/computedPropertyNames32_ES6.js b/tests/baselines/reference/computedPropertyNames32_ES6.js index a87f7715d89..198c5e9981e 100644 --- a/tests/baselines/reference/computedPropertyNames32_ES6.js +++ b/tests/baselines/reference/computedPropertyNames32_ES6.js @@ -11,13 +11,10 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[foo()] = function () { - }; - return C; -})(); + } + [foo()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames33_ES6.js b/tests/baselines/reference/computedPropertyNames33_ES6.js index 03c503caec4..7fb08d2852d 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES6.js +++ b/tests/baselines/reference/computedPropertyNames33_ES6.js @@ -13,15 +13,12 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { var obj = { [foo()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames34_ES6.js b/tests/baselines/reference/computedPropertyNames34_ES6.js index 62e2e151cd3..e73d349bcd7 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES6.js +++ b/tests/baselines/reference/computedPropertyNames34_ES6.js @@ -13,15 +13,12 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.bar = function () { +class C { + static bar() { var obj = { [foo()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.js b/tests/baselines/reference/computedPropertyNames36_ES6.js index 5b71326fbc4..573b8fa0c17 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.js +++ b/tests/baselines/reference/computedPropertyNames36_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames36_ES6.js] -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get ["get1"]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { + set ["set1"](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.js b/tests/baselines/reference/computedPropertyNames37_ES6.js index 992035f6865..d62c95e6f8c 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.js +++ b/tests/baselines/reference/computedPropertyNames37_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames37_ES6.js] -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get ["get1"]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { + set ["set1"](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames38_ES6.js b/tests/baselines/reference/computedPropertyNames38_ES6.js index 0fdcdb1d63c..cf1d01873f2 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES6.js +++ b/tests/baselines/reference/computedPropertyNames38_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames38_ES6.js] -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get [1 << 6]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { + set [1 << 6](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, 1 << 6, { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 1 << 6, { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames39_ES6.js b/tests/baselines/reference/computedPropertyNames39_ES6.js index 8e458ad83d7..9afd60b6464 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES6.js +++ b/tests/baselines/reference/computedPropertyNames39_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames39_ES6.js] -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get [1 << 6]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { + set [1 << 6](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, 1 << 6, { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 1 << 6, { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt index 3df6d6d9744..b9009112347 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (6 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (7 errors) ==== var id; class C { [0 + 1]() { } @@ -18,6 +19,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. + ~~ +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.js b/tests/baselines/reference/computedPropertyNames3_ES6.js index 1a9c9ee465b..b5fb9e88001 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.js +++ b/tests/baselines/reference/computedPropertyNames3_ES6.js @@ -11,40 +11,21 @@ class C { //// [computedPropertyNames3_ES6.js] var id; -var C = (function () { - function C() { +class C { + [0 + 1]() { } - C.prototype[0 + 1] = function () { - }; - C[() => { - }] = function () { - }; - Object.defineProperty(C.prototype, delete id, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, [ + static [() => { + }]() { + } + get [delete id]() { + } + set [[ 0, 1 - ], { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "", { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, id.toString(), { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + ]](v) { + } + static get [""]() { + } + static set [id.toString()](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.js b/tests/baselines/reference/computedPropertyNames40_ES6.js index 99d28688a29..c4820e0ca98 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.js +++ b/tests/baselines/reference/computedPropertyNames40_ES6.js @@ -11,25 +11,16 @@ class C { } //// [computedPropertyNames40_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } +class Foo { +} +class Foo2 { +} +class C { // Computed properties - C.prototype[""] = function () { + [""]() { return new Foo; - }; - C.prototype[""] = function () { + } + [""]() { return new Foo2; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.js b/tests/baselines/reference/computedPropertyNames41_ES6.js index f0c386706a3..5773f892fd5 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.js +++ b/tests/baselines/reference/computedPropertyNames41_ES6.js @@ -10,22 +10,13 @@ class C { } //// [computedPropertyNames41_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } +class Foo { +} +class Foo2 { +} +class C { // Computed properties - C[""] = function () { + static [""]() { return new Foo; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames42_ES6.js b/tests/baselines/reference/computedPropertyNames42_ES6.js index 8538088f450..b6114f06bac 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES6.js +++ b/tests/baselines/reference/computedPropertyNames42_ES6.js @@ -10,18 +10,9 @@ class C { } //// [computedPropertyNames42_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } - return C; -})(); +class Foo { +} +class Foo2 { +} +class C { +} diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.js b/tests/baselines/reference/computedPropertyNames43_ES6.js index ba0c228c307..ab9d09834d2 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.js +++ b/tests/baselines/reference/computedPropertyNames43_ES6.js @@ -13,45 +13,17 @@ class D extends C { } //// [computedPropertyNames43_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { +} +class D extends C { + // Computed properties + get ["get1"]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { + set ["set1"](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); - } - Object.defineProperty(D.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.js b/tests/baselines/reference/computedPropertyNames44_ES6.js index 72729054e07..13d46131e92 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.js +++ b/tests/baselines/reference/computedPropertyNames44_ES6.js @@ -12,44 +12,16 @@ class D extends C { } //// [computedPropertyNames44_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + get ["get1"]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +} +class D extends C { + set ["set1"](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, "get1", { - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); - } - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.js b/tests/baselines/reference/computedPropertyNames45_ES6.js index 23dccc77956..bea5f5211ea 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.js +++ b/tests/baselines/reference/computedPropertyNames45_ES6.js @@ -13,44 +13,16 @@ class D extends C { } //// [computedPropertyNames45_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { +class Foo { +} +class Foo2 { +} +class C { + get ["get1"]() { + return new Foo; } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +} +class D extends C { + set ["set1"](p) { } - return Foo2; -})(); -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, "get1", { - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); - } - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js index eb7dab0b660..f234ae0d97e 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js @@ -6,26 +6,15 @@ class C { } //// [computedPropertyNamesDeclarationEmit1_ES6.js] -var C = (function () { - function C() { +class C { + ["" + ""]() { } - C.prototype["" + ""] = function () { - }; - Object.defineProperty(C.prototype, "" + "", { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "" + "", { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get ["" + ""]() { + return 0; + } + set ["" + ""](x) { + } +} //// [computedPropertyNamesDeclarationEmit1_ES6.d.ts] diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js index 3912113905c..b5e70193b0d 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js @@ -6,26 +6,15 @@ class C { } //// [computedPropertyNamesDeclarationEmit2_ES6.js] -var C = (function () { - function C() { +class C { + static ["" + ""]() { } - C["" + ""] = function () { - }; - Object.defineProperty(C, "" + "", { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "" + "", { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static get ["" + ""]() { + return 0; + } + static set ["" + ""](x) { + } +} //// [computedPropertyNamesDeclarationEmit2_ES6.d.ts] diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js index 264a6a75074..ced0a8d449a 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js @@ -10,10 +10,7 @@ class C { //// [computedPropertyNamesOnOverloads_ES6.js] var methodName = "method"; var accessorName = "accessor"; -var C = (function () { - function C() { +class C { + [methodName](v) { } - C.prototype[methodName] = function (v) { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js index f7dc9e17836..749ab99b18b 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js @@ -6,12 +6,9 @@ class C { } //// [computedPropertyNamesSourceMap1_ES6.js] -var C = (function () { - function C() { - } - C.prototype["hello"] = function () { +class C { + ["hello"]() { debugger; - }; - return C; -})(); + } +} //# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map index 20765a5b2d4..9a2dd60999e 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap1_ES6.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C.constructor","C[\"hello\"]"],"mappings":"AAAA;IAAAA;IAIAC,CAACA;IAHGD,YAACA,OAAOA,CAACA,GAATA;QACIE,QAAQA,CAACA;IACbA,CAACA;IACLF,QAACA;AAADA,CAACA,AAJD,IAIC"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C[\"hello\"]"],"mappings":"AAAA;IACIA,CAACA,OAAOA,CAACA;QACLC,QAAQA,CAACA;IACbA,CAACA;AACLD,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt index 64713447e43..30493b97347 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt @@ -8,96 +8,61 @@ sources: computedPropertyNamesSourceMap1_ES6.ts emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap1_ES6.js sourceFile:computedPropertyNamesSourceMap1_ES6.ts ------------------------------------------------------------------- ->>>var C = (function () { +>>>class C { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^-> 1 > 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) --- ->>> function C() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(2, 5) Source(1, 1) + SourceIndex(0) name (C) ---- ->>> } +>>> ["hello"]() { 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^ +4 > ^ +5 > ^^^^^-> 1->class C { - > ["hello"]() { - > debugger; - > } - > -2 > } -1->Emitted(3, 5) Source(5, 1) + SourceIndex(0) name (C.constructor) -2 >Emitted(3, 6) Source(5, 2) + SourceIndex(0) name (C.constructor) ---- ->>> C.prototype["hello"] = function () { -1->^^^^ -2 > ^^^^^^^^^^^^ -3 > ^^^^^^^ -4 > ^ -5 > ^^^ -1-> + > 2 > [ -3 > "hello" -4 > ] -5 > -1->Emitted(4, 5) Source(2, 5) + SourceIndex(0) name (C) -2 >Emitted(4, 17) Source(2, 6) + SourceIndex(0) name (C) -3 >Emitted(4, 24) Source(2, 13) + SourceIndex(0) name (C) -4 >Emitted(4, 25) Source(2, 14) + SourceIndex(0) name (C) -5 >Emitted(4, 28) Source(2, 5) + SourceIndex(0) name (C) +3 > "hello" +4 > ] +1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (C) +2 >Emitted(2, 6) Source(2, 6) + SourceIndex(0) name (C) +3 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) name (C) +4 >Emitted(2, 14) Source(2, 14) + SourceIndex(0) name (C) --- >>> debugger; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^^^ 3 > ^ -1 >["hello"]() { +1->() { > 2 > debugger 3 > ; -1 >Emitted(5, 9) Source(3, 9) + SourceIndex(0) name (C["hello"]) -2 >Emitted(5, 17) Source(3, 17) + SourceIndex(0) name (C["hello"]) -3 >Emitted(5, 18) Source(3, 18) + SourceIndex(0) name (C["hello"]) +1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (C["hello"]) +2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (C["hello"]) +3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (C["hello"]) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } -1 >Emitted(6, 5) Source(4, 5) + SourceIndex(0) name (C["hello"]) -2 >Emitted(6, 6) Source(4, 6) + SourceIndex(0) name (C["hello"]) +1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (C["hello"]) +2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (C["hello"]) --- ->>> return C; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (C) -2 >Emitted(7, 13) Source(5, 2) + SourceIndex(0) name (C) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class C { - > ["hello"]() { - > debugger; - > } - > } -1 >Emitted(8, 1) Source(5, 1) + SourceIndex(0) name (C) -2 >Emitted(8, 2) Source(5, 2) + SourceIndex(0) name (C) -3 >Emitted(8, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(5, 2) + SourceIndex(0) +1 >Emitted(5, 1) Source(5, 1) + SourceIndex(0) name (C) +2 >Emitted(5, 2) Source(5, 2) + SourceIndex(0) name (C) --- ->>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map \ No newline at end of file +>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(6, 1) Source(5, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js new file mode 100644 index 00000000000..e6b7bd5aae2 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js @@ -0,0 +1,24 @@ +//// [computedPropertyNamesWithStaticProperty.ts] +class C { + static staticProp = 10; + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x: string) { + var y = x; + } + [C.staticProp]() { } +} + +//// [computedPropertyNamesWithStaticProperty.js] +class C { + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x) { + var y = x; + } + [C.staticProp]() { + } +} +C.staticProp = 10; diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types new file mode 100644 index 00000000000..b23d986f894 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts === +class C { +>C : C + + static staticProp = 10; +>staticProp : number + + get [C.staticProp]() { +>C.staticProp : number +>C : typeof C +>staticProp : number + + return "hello"; + } + set [C.staticProp](x: string) { +>C.staticProp : number +>C : typeof C +>staticProp : number +>x : string + + var y = x; +>y : string +>x : string + } + [C.staticProp]() { } +>C.staticProp : number +>C : typeof C +>staticProp : number +} 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/constDeclarations-scopes.js b/tests/baselines/reference/constDeclarations-scopes.js index f8fbc47312b..b144b4f83a5 100644 --- a/tests/baselines/reference/constDeclarations-scopes.js +++ b/tests/baselines/reference/constDeclarations-scopes.js @@ -242,30 +242,25 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { const c = 0; n = c; } - C.prototype.method = function () { + method() { const c = 0; n = c; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - const c = 0; - n = c; - return n; - }, - set: function (value) { - const c = 0; - n = c; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + const c = 0; + n = c; + return n; + } + set v(value) { + const c = 0; + n = c; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/constDeclarations-validContexts.js b/tests/baselines/reference/constDeclarations-validContexts.js index 5a54e915713..7d3269c6683 100644 --- a/tests/baselines/reference/constDeclarations-validContexts.js +++ b/tests/baselines/reference/constDeclarations-validContexts.js @@ -201,26 +201,21 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { const c24 = 0; } - C.prototype.method = function () { + method() { const c25 = 0; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - const c26 = 0; - return c26; - }, - set: function (value) { - const c27 = value; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + const c26 = 0; + return c26; + } + set v(value) { + const c27 = value; + } +} // object literals var o = { f() { 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/destructuringParameterProperties4.js b/tests/baselines/reference/destructuringParameterProperties4.js index 6da6f53a4fe..cd6334c8568 100644 --- a/tests/baselines/reference/destructuringParameterProperties4.js +++ b/tests/baselines/reference/destructuringParameterProperties4.js @@ -28,38 +28,26 @@ class C2 extends C1 { //// [destructuringParameterProperties4.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1(k, [a, b, c]) { +class C1 { + constructor(k, [a, b, c]) { this.k = k; this.[a, b, c] = [a, b, c]; if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { this.a = a || k; } } - C1.prototype.getA = function () { + getA() { return this.a; - }; - C1.prototype.getB = function () { - return this.b; - }; - C1.prototype.getC = function () { - return this.c; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype.doSomethingWithSuperProperties = function () { + getB() { + return this.b; + } + getC() { + return this.c; + } +} +class C2 extends C1 { + doSomethingWithSuperProperties() { return `${this.a} ${this.b} ${this.c}`; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationOverloadInES6.js b/tests/baselines/reference/emitClassDeclarationOverloadInES6.js new file mode 100644 index 00000000000..4cf96778f3f --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationOverloadInES6.js @@ -0,0 +1,21 @@ +//// [emitClassDeclarationOverloadInES6.ts] +class C { + constructor(y: any) + constructor(x: number) { + } +} + +class D { + constructor(y: any) + constructor(x: number, z="hello") {} +} + +//// [emitClassDeclarationOverloadInES6.js] +class C { + constructor(x) { + } +} +class D { + constructor(x, z = "hello") { + } +} diff --git a/tests/baselines/reference/emitClassDeclarationOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types new file mode 100644 index 00000000000..850a5aa5456 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts === +class C { +>C : C + + constructor(y: any) +>y : any + + constructor(x: number) { +>x : number + } +} + +class D { +>D : D + + constructor(y: any) +>y : any + + constructor(x: number, z="hello") {} +>x : number +>z : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js new file mode 100644 index 00000000000..8c115b17e9c --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js @@ -0,0 +1,42 @@ +//// [emitClassDeclarationWithConstructorInES6.ts] +class A { + y: number; + constructor(x: number) { + } + foo(a: any); + foo() { } +} + +class B { + y: number; + x: string = "hello"; + _bar: string; + + constructor(x: number, z = "hello", ...args) { + this.y = 10; + } + baz(...args): string; + baz(z: string, v: number): string { + return this._bar; + } +} + + + + +//// [emitClassDeclarationWithConstructorInES6.js] +class A { + constructor(x) { + } + foo() { + } +} +class B { + constructor(x, z = "hello", ...args) { + this.x = "hello"; + this.y = 10; + } + baz(z, v) { + return this._bar; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types new file mode 100644 index 00000000000..10244bf6170 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types @@ -0,0 +1,59 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts === +class A { +>A : A + + y: number; +>y : number + + constructor(x: number) { +>x : number + } + foo(a: any); +>foo : (a: any) => any +>a : any + + foo() { } +>foo : (a: any) => any +} + +class B { +>B : B + + y: number; +>y : number + + x: string = "hello"; +>x : string + + _bar: string; +>_bar : string + + constructor(x: number, z = "hello", ...args) { +>x : number +>z : string +>args : any[] + + this.y = 10; +>this.y = 10 : number +>this.y : number +>this : B +>y : number + } + baz(...args): string; +>baz : (...args: any[]) => string +>args : any[] + + baz(z: string, v: number): string { +>baz : (...args: any[]) => string +>z : string +>v : number + + return this._bar; +>this._bar : string +>this : B +>_bar : string + } +} + + + diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js new file mode 100644 index 00000000000..cd217af6a81 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js @@ -0,0 +1,24 @@ +//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts] +class B { + constructor(a: T) { } +} +class C extends B { } +class D extends B { + constructor(a: any) + constructor(b: number) { + super(b); + } +} + +//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.js] +class B { + constructor(a) { + } +} +class C extends B { +} +class D extends B { + constructor(b) { + super(b); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types new file mode 100644 index 00000000000..0f546fa7b86 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts === +class B { +>B : B +>T : T + + constructor(a: T) { } +>a : T +>T : T +} +class C extends B { } +>C : C +>B : B + +class D extends B { +>D : D +>B : B + + constructor(a: any) +>a : any + + constructor(b: number) { +>b : number + + super(b); +>super(b) : void +>super : typeof B +>b : number + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js new file mode 100644 index 00000000000..5c64aebd16a --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js @@ -0,0 +1,48 @@ +//// [emitClassDeclarationWithExtensionInES6.ts] +class B { + baz(a: string, y = 10) { } +} +class C extends B { + foo() { } + baz(a: string, y:number) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + + foo() { + super.foo(); + } + + baz() { + super.baz("hello", 10); + } +} + + +//// [emitClassDeclarationWithExtensionInES6.js] +class B { + baz(a, y = 10) { + } +} +class C extends B { + foo() { + } + baz(a, y) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + foo() { + super.foo(); + } + baz() { + super.baz("hello", 10); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types new file mode 100644 index 00000000000..a1549be5df4 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts === +class B { +>B : B + + baz(a: string, y = 10) { } +>baz : (a: string, y?: number) => void +>a : string +>y : number +} +class C extends B { +>C : C +>B : B + + foo() { } +>foo : () => void + + baz(a: string, y:number) { +>baz : (a: string, y: number) => void +>a : string +>y : number + + super.baz(a, y); +>super.baz(a, y) : void +>super.baz : (a: string, y?: number) => void +>super : B +>baz : (a: string, y?: number) => void +>a : string +>y : number + } +} +class D extends C { +>D : D +>C : C + + constructor() { + super(); +>super() : void +>super : typeof C + } + + foo() { +>foo : () => void + + super.foo(); +>super.foo() : void +>super.foo : () => void +>super : C +>foo : () => void + } + + baz() { +>baz : () => void + + super.baz("hello", 10); +>super.baz("hello", 10) : void +>super.baz : (a: string, y: number) => void +>super : C +>baz : (a: string, y: number) => void + } +} + diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js new file mode 100644 index 00000000000..68ccd1568ed --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js @@ -0,0 +1,57 @@ +//// [emitClassDeclarationWithGetterSetterInES6.ts] +class C { + _name: string; + get name(): string { + return this._name; + } + static get name2(): string { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { + } + set ["computedname"](y: string) { + } + + set foo(a: string) { } + static set bar(b: number) { } + static set ["computedname"](b: string) { } +} + +//// [emitClassDeclarationWithGetterSetterInES6.js] +class C { + get name() { + return this._name; + } + static get name2() { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + set ["computedname"](x) { + } + set ["computedname"](y) { + } + set foo(a) { + } + static set bar(b) { + } + static set ["computedname"](b) { + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types new file mode 100644 index 00000000000..83d4fcd0d80 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts === +class C { +>C : C + + _name: string; +>_name : string + + get name(): string { +>name : string + + return this._name; +>this._name : string +>this : C +>_name : string + } + static get name2(): string { +>name2 : string + + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { +>x : any + } + set ["computedname"](y: string) { +>y : string + } + + set foo(a: string) { } +>foo : string +>a : string + + static set bar(b: number) { } +>bar : number +>b : number + + static set ["computedname"](b: string) { } +>b : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js new file mode 100644 index 00000000000..d82750f276f --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js @@ -0,0 +1,37 @@ +//// [emitClassDeclarationWithLiteralPropertyNameInES6.ts] +class B { + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} + +//// [emitClassDeclarationWithLiteralPropertyNameInES6.js] +class B { + constructor() { + this["hello"] = 10; + this[0b110] = "world"; + this[0o23534] = "WORLD"; + this[20] = "twenty"; + } + "foo"() { + } + 0b1110() { + } + 11() { + } + interface() { + } +} +B["hi"] = 10000; +B[22] = "twenty-two"; +B[0b101] = "binary"; +B[0o3235] = "octal"; diff --git a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types new file mode 100644 index 00000000000..65ba8f7d2b9 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts === +class B { +>B : B + + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } +>interface : () => void + + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js new file mode 100644 index 00000000000..20f58b4274e --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js @@ -0,0 +1,58 @@ +//// [emitClassDeclarationWithMethodInES6.ts] +class D { + _bar: string; + foo() { } + ["computedName"]() { } + ["computedName"](a: string) { } + ["computedName"](a: string): number { return 1; } + bar(): string { + return this._bar; + } + baz(a: any, x: string): string { + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } + static ["computedname"](a: string): boolean { return true; } + static staticMethod() { + var x = 1 + 2; + return x + } + static foo(a: string) { } + static bar(a: string): number { return 1; } +} + +//// [emitClassDeclarationWithMethodInES6.js] +class D { + foo() { + } + ["computedName"]() { + } + ["computedName"](a) { + } + ["computedName"](a) { + return 1; + } + bar() { + return this._bar; + } + baz(a, x) { + return "HELLO"; + } + static ["computedname"]() { + } + static ["computedname"](a) { + } + static ["computedname"](a) { + return true; + } + static staticMethod() { + var x = 1 + 2; + return x; + } + static foo(a) { + } + static bar(a) { + return 1; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types new file mode 100644 index 00000000000..f26a9f87e6d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts === +class D { +>D : D + + _bar: string; +>_bar : string + + foo() { } +>foo : () => void + + ["computedName"]() { } + ["computedName"](a: string) { } +>a : string + + ["computedName"](a: string): number { return 1; } +>a : string + + bar(): string { +>bar : () => string + + return this._bar; +>this._bar : string +>this : D +>_bar : string + } + baz(a: any, x: string): string { +>baz : (a: any, x: string) => string +>a : any +>x : string + + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } +>a : string + + static ["computedname"](a: string): boolean { return true; } +>a : string + + static staticMethod() { +>staticMethod : () => number + + var x = 1 + 2; +>x : number +>1 + 2 : number + + return x +>x : number + } + static foo(a: string) { } +>foo : (a: string) => void +>a : string + + static bar(a: string): number { return 1; } +>bar : (a: string) => number +>a : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js new file mode 100644 index 00000000000..03fb45b806e --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js @@ -0,0 +1,51 @@ +//// [emitClassDeclarationWithPropertyAssignmentInES6.ts] +class C { + x: string = "Hello world"; +} + +class D { + x: string = "Hello world"; + y: number; + constructor() { + this.y = 10; + } +} + +class E extends D{ + z: boolean = true; +} + +class F extends D{ + z: boolean = true; + j: string; + constructor() { + super(); + this.j = "HI"; + } +} + +//// [emitClassDeclarationWithPropertyAssignmentInES6.js] +class C { + constructor() { + this.x = "Hello world"; + } +} +class D { + constructor() { + this.x = "Hello world"; + this.y = 10; + } +} +class E extends D { + constructor(...args) { + super(...args); + this.z = true; + } +} +class F extends D { + constructor() { + super(); + this.z = true; + this.j = "HI"; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types new file mode 100644 index 00000000000..5e7ebbc167c --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts === +class C { +>C : C + + x: string = "Hello world"; +>x : string +} + +class D { +>D : D + + x: string = "Hello world"; +>x : string + + y: number; +>y : number + + constructor() { + this.y = 10; +>this.y = 10 : number +>this.y : number +>this : D +>y : number + } +} + +class E extends D{ +>E : E +>D : D + + z: boolean = true; +>z : boolean +} + +class F extends D{ +>F : F +>D : D + + z: boolean = true; +>z : boolean + + j: string; +>j : string + + constructor() { + super(); +>super() : void +>super : typeof D + + this.j = "HI"; +>this.j = "HI" : string +>this.j : string +>this : F +>j : string + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js new file mode 100644 index 00000000000..8e0bf3de06b --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js @@ -0,0 +1,21 @@ +//// [emitClassDeclarationWithStaticPropertyAssignmentInES6.ts] +class C { + static z: string = "Foo"; +} + +class D { + x = 20000; + static b = true; +} + + +//// [emitClassDeclarationWithStaticPropertyAssignmentInES6.js] +class C { +} +C.z = "Foo"; +class D { + constructor() { + this.x = 20000; + } +} +D.b = true; diff --git a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types new file mode 100644 index 00000000000..6003b85b590 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts === +class C { +>C : C + + static z: string = "Foo"; +>z : string +} + +class D { +>D : D + + x = 20000; +>x : number + + static b = true; +>b : boolean +} + diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js new file mode 100644 index 00000000000..14f74682c00 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js @@ -0,0 +1,38 @@ +//// [emitClassDeclarationWithThisKeywordInES6.ts] +class B { + x = 10; + constructor() { + this.x = 10; + } + static log(a: number) { } + foo() { + B.log(this.x); + } + + get X() { + return this.x; + } + + set bX(y: number) { + this.x = y; + } +} + +//// [emitClassDeclarationWithThisKeywordInES6.js] +class B { + constructor() { + this.x = 10; + this.x = 10; + } + static log(a) { + } + foo() { + B.log(this.x); + } + get X() { + return this.x; + } + set bX(y) { + this.x = y; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types new file mode 100644 index 00000000000..bb0f7e99939 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts === +class B { +>B : B + + x = 10; +>x : number + + constructor() { + this.x = 10; +>this.x = 10 : number +>this.x : number +>this : B +>x : number + } + static log(a: number) { } +>log : (a: number) => void +>a : number + + foo() { +>foo : () => void + + B.log(this.x); +>B.log(this.x) : void +>B.log : (a: number) => void +>B : typeof B +>log : (a: number) => void +>this.x : number +>this : B +>x : number + } + + get X() { +>X : number + + return this.x; +>this.x : number +>this : B +>x : number + } + + set bX(y: number) { +>bX : number +>y : number + + this.x = y; +>this.x = y : number +>this.x : number +>this : B +>x : number +>y : number + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js new file mode 100644 index 00000000000..8dc5b6cddaa --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js @@ -0,0 +1,39 @@ +//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts] +class B { + x: T; + B: T; + + constructor(a: any) + constructor(a: any,b: T) + constructor(a: T) { this.B = a;} + + foo(a: T) + foo(a: any) + foo(b: string) + foo(): T { + return this.x; + } + + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} + +//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.js] +class B { + constructor(a) { + this.B = a; + } + foo() { + return this.x; + } + get BB() { + return this.B; + } + set BBWith(c) { + this.B = c; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types new file mode 100644 index 00000000000..ba515168a5d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types @@ -0,0 +1,75 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts === +class B { +>B : B +>T : T + + x: T; +>x : T +>T : T + + B: T; +>B : T +>T : T + + constructor(a: any) +>a : any + + constructor(a: any,b: T) +>a : any +>b : T +>T : T + + constructor(a: T) { this.B = a;} +>a : T +>T : T +>this.B = a : T +>this.B : T +>this : B +>B : T +>a : T + + foo(a: T) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>a : T +>T : T + + foo(a: any) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>a : any + + foo(b: string) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>b : string + + foo(): T { +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>T : T + + return this.x; +>this.x : T +>this : B +>x : T + } + + get BB(): T { +>BB : T +>T : T + + return this.B; +>this.B : T +>this : B +>B : T + } + set BBWith(c: T) { +>BBWith : T +>c : T +>T : T + + this.B = c; +>this.B = c : T +>this.B : T +>this : B +>B : T +>c : T + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js new file mode 100644 index 00000000000..4e2872b4f06 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js @@ -0,0 +1,31 @@ +//// [emitClassDeclarationWithTypeArgumentInES6.ts] +class B { + x: T; + B: T; + constructor(a: T) { this.B = a;} + foo(): T { + return this.x; + } + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} + +//// [emitClassDeclarationWithTypeArgumentInES6.js] +class B { + constructor(a) { + this.B = a; + } + foo() { + return this.x; + } + get BB() { + return this.B; + } + set BBWith(c) { + this.B = c; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types new file mode 100644 index 00000000000..8081d044e35 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts === +class B { +>B : B +>T : T + + x: T; +>x : T +>T : T + + B: T; +>B : T +>T : T + + constructor(a: T) { this.B = a;} +>a : T +>T : T +>this.B = a : T +>this.B : T +>this : B +>B : T +>a : T + + foo(): T { +>foo : () => T +>T : T + + return this.x; +>this.x : T +>this : B +>x : T + } + get BB(): T { +>BB : T +>T : T + + return this.B; +>this.B : T +>this : B +>B : T + } + set BBWith(c: T) { +>BBWith : T +>c : T +>T : T + + this.B = c; +>this.B = c : T +>this.B : T +>this : B +>B : T +>c : T + } +} diff --git a/tests/baselines/reference/emitDefaultParametersMethodES6.js b/tests/baselines/reference/emitDefaultParametersMethodES6.js index bf96e00e375..3981ddcba3c 100644 --- a/tests/baselines/reference/emitDefaultParametersMethodES6.js +++ b/tests/baselines/reference/emitDefaultParametersMethodES6.js @@ -17,26 +17,23 @@ class E { } //// [emitDefaultParametersMethodES6.js] -var C = (function () { - function C(t, z, x, y = "hello") { +class C { + constructor(t, z, x, y = "hello") { } - C.prototype.foo = function (x, t = false) { - }; - C.prototype.foo1 = function (x, t = false, ...rest) { - }; - C.prototype.bar = function (t = false) { - }; - C.prototype.boo = function (t = false, ...rest) { - }; - return C; -})(); -var D = (function () { - function D(y = "hello") { + foo(x, t = false) { } - return D; -})(); -var E = (function () { - function E(y = "hello", ...rest) { + foo1(x, t = false, ...rest) { } - return E; -})(); + bar(t = false) { + } + boo(t = false, ...rest) { + } +} +class D { + constructor(y = "hello") { + } +} +class E { + constructor(y = "hello", ...rest) { + } +} diff --git a/tests/baselines/reference/emitRestParametersMethodES6.js b/tests/baselines/reference/emitRestParametersMethodES6.js index d0a0e2a120c..fba6ed01e67 100644 --- a/tests/baselines/reference/emitRestParametersMethodES6.js +++ b/tests/baselines/reference/emitRestParametersMethodES6.js @@ -15,21 +15,19 @@ class D { //// [emitRestParametersMethodES6.js] -var C = (function () { - function C(name, ...rest) { +class C { + constructor(name, ...rest) { } - C.prototype.bar = function (...rest) { - }; - C.prototype.foo = function (x, ...rest) { - }; - return C; -})(); -var D = (function () { - function D(...rest) { + bar(...rest) { } - D.prototype.bar = function (...rest) { - }; - D.prototype.foo = function (x, ...rest) { - }; - return D; -})(); + foo(x, ...rest) { + } +} +class D { + constructor(...rest) { + } + bar(...rest) { + } + foo(x, ...rest) { + } +} diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index 383da7d419f..de47b0b95af 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -49,20 +49,20 @@ var RegisteredUser = (function (_super) { RegisteredUser.prototype.f = function () { (function () { function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } }); }; RegisteredUser.prototype.g = function () { function inner() { (function () { - super.sayHello.call(this); + _super.sayHello.call(this); }); } }; RegisteredUser.prototype.h = function () { function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } }; return RegisteredUser; diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index 17cd2c265ed..4ddcca530f1 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -140,27 +140,27 @@ var __extends = this.__extends || function (d, b) { //super property access in instance member accessor(get and set) of class with no base type var NoBase = (function () { function NoBase() { - this.m = super.prototype; - this.n = super.hasOwnProperty.call(this, ''); - var a = super.prototype; - var b = super.hasOwnProperty.call(this, ''); + this.m = _super.prototype; + this.n = _super.hasOwnProperty.call(this, ''); + var a = _super.prototype; + var b = _super.hasOwnProperty.call(this, ''); } NoBase.prototype.fn = function () { - var a = super.prototype; - var b = super.hasOwnProperty.call(this, ''); + var a = _super.prototype; + var b = _super.hasOwnProperty.call(this, ''); }; //super static property access in static member function of class with no base type //super static property access in static member accessor(get and set) of class with no base type NoBase.static1 = function () { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); }; Object.defineProperty(NoBase, "static2", { get: function () { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); return ''; }, set: function (n) { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); }, enumerable: true, configurable: true @@ -210,11 +210,11 @@ var SomeDerived1 = (function (_super) { }); SomeDerived1.prototype.fn2 = function () { function inner() { - super.publicFunc.call(this); + _super.publicFunc.call(this); } var x = { test: function () { - return super.publicFunc.call(this); + return _super.publicFunc.call(this); } }; }; @@ -278,6 +278,6 @@ var SomeDerived3 = (function (_super) { })(SomeBase); // In object literal var obj = { - n: super.wat, - p: super.foo.call(this) + n: _super.wat, + p: _super.foo.call(this) }; diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js new file mode 100644 index 00000000000..3ac92c5d9ea --- /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 declare 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..8c07ff12599 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -0,0 +1,52 @@ +//// [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 declare class { + method(): void; +} + + +//// [DtsFileErrors] + + +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(1,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(1,8): error TS2304: Cannot find name 'declare'. +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(1,16): error TS1005: ';' expected. +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(2,5): error TS2304: Cannot find name 'method'. +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(2,13): error TS1005: ';' expected. +tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/compiler/es5ExportDefaultClassDeclaration2.d.ts (6 errors) ==== + export declare class { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~ +!!! error TS1005: ';' expected. + method(): void; + ~~~~~~ +!!! error TS2304: Cannot find name 'method'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1109: Expression expected. + } + \ No newline at end of file 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..f0c3da6657b --- /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 (1 + 2); 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..01576743581 --- /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 declare 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..6a99726655f --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -0,0 +1,26 @@ +//// [es5ExportDefaultFunctionDeclaration2.ts] + +export default function () { } + + +//// [es5ExportDefaultFunctionDeclaration2.js] +function () { +} +module.exports = _default; + + +//// [es5ExportDefaultFunctionDeclaration2.d.ts] +export declare function (): void; + + +//// [DtsFileErrors] + + +tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.d.ts(1,25): error TS1003: Identifier expected. + + +==== tests/cases/compiler/es5ExportDefaultFunctionDeclaration2.d.ts (1 errors) ==== + export declare function (): void; + ~ +!!! error TS1003: Identifier expected. + \ No newline at end of file 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-amd.js b/tests/baselines/reference/es6-amd.js index 0cce3af0446..74f3037303e 100644 --- a/tests/baselines/reference/es6-amd.js +++ b/tests/baselines/reference/es6-amd.js @@ -14,14 +14,13 @@ class A } //// [es6-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-amd.js.map //// [es6-amd.d.ts] diff --git a/tests/baselines/reference/es6-amd.js.map b/tests/baselines/reference/es6-amd.js.map index c9866d87884..fe234f8424b 100644 --- a/tests/baselines/reference/es6-amd.js.map +++ b/tests/baselines/reference/es6-amd.js.map @@ -1,2 +1,2 @@ //// [es6-amd.js.map] -{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.sourcemap.txt b/tests/baselines/reference/es6-amd.sourcemap.txt index 2b271099401..1ab547073c6 100644 --- a/tests/baselines/reference/es6-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-amd.ts emittedFile:tests/cases/compiler/es6-amd.js sourceFile:es6-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ 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-declaration-amd.js b/tests/baselines/reference/es6-declaration-amd.js index 471f96b223d..aeba23e0b6e 100644 --- a/tests/baselines/reference/es6-declaration-amd.js +++ b/tests/baselines/reference/es6-declaration-amd.js @@ -14,14 +14,13 @@ class A } //// [es6-declaration-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-declaration-amd.js.map //// [es6-declaration-amd.d.ts] diff --git a/tests/baselines/reference/es6-declaration-amd.js.map b/tests/baselines/reference/es6-declaration-amd.js.map index 03f79f6c667..ca1899e03f5 100644 --- a/tests/baselines/reference/es6-declaration-amd.js.map +++ b/tests/baselines/reference/es6-declaration-amd.js.map @@ -1,2 +1,2 @@ //// [es6-declaration-amd.js.map] -{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt index 198a68633b1..9061bc1ed7c 100644 --- a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-declaration-amd.ts emittedFile:tests/cases/compiler/es6-declaration-amd.js sourceFile:es6-declaration-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-declaration-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-declaration-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-declaration-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-declaration-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ 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/es6-sourcemap-amd.js b/tests/baselines/reference/es6-sourcemap-amd.js index 805e56cf830..106726c0f2c 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js +++ b/tests/baselines/reference/es6-sourcemap-amd.js @@ -14,12 +14,11 @@ class A } //// [es6-sourcemap-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.js.map b/tests/baselines/reference/es6-sourcemap-amd.js.map index ef22eb4638c..779c13b1296 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js.map +++ b/tests/baselines/reference/es6-sourcemap-amd.js.map @@ -1,2 +1,2 @@ //// [es6-sourcemap-amd.js.map] -{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt index bcfc33d0405..179dd79ba17 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-sourcemap-amd.ts emittedFile:tests/cases/compiler/es6-sourcemap-amd.js sourceFile:es6-sourcemap-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-sourcemap-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-sourcemap-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-sourcemap-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAll.js b/tests/baselines/reference/es6ExportAll.js new file mode 100644 index 00000000000..4c223545e8a --- /dev/null +++ b/tests/baselines/reference/es6ExportAll.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/es6ExportAll.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export * from "server"; + +//// [server.js] +export class c { +} +var m; +(function (m) { + m.x = 10; +})(m || (m = {})); +export { m }; +export var x = 10; +//// [client.js] +export * from "server"; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] diff --git a/tests/baselines/reference/es6ExportAll.types b/tests/baselines/reference/es6ExportAll.types new file mode 100644 index 00000000000..99e8fde9d40 --- /dev/null +++ b/tests/baselines/reference/es6ExportAll.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export * from "server"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js new file mode 100644 index 00000000000..9fd8c1c4b33 --- /dev/null +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/es6ExportAllInEs5.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export * from "server"; + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +exports.c = c; +var m; +(function (m) { + m.x = 10; +})(m = exports.m || (exports.m = {})); +exports.x = 10; +//// [client.js] +var _server = require("server"); +for (var _a in _server) if (!exports.hasOwnProperty(_a)) exports[_a] = _server[_a]; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] diff --git a/tests/baselines/reference/es6ExportAllInEs5.types b/tests/baselines/reference/es6ExportAllInEs5.types new file mode 100644 index 00000000000..99e8fde9d40 --- /dev/null +++ b/tests/baselines/reference/es6ExportAllInEs5.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/server.ts === + +export class c { +>c : c +} +export interface i { +>i : i +} +export module m { +>m : typeof m + + export var x = 10; +>x : number +} +export var x = 10; +>x : number + +export module uninstantiated { +>uninstantiated : unknown +} + +=== tests/cases/compiler/client.ts === +export * from "server"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt new file mode 100644 index 00000000000..1db7d04e05e --- /dev/null +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ==== + + var a = 10; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment.js b/tests/baselines/reference/es6ExportAssignment.js new file mode 100644 index 00000000000..113e28108b1 --- /dev/null +++ b/tests/baselines/reference/es6ExportAssignment.js @@ -0,0 +1,8 @@ +//// [es6ExportAssignment.ts] + +var a = 10; +export = a; + +//// [es6ExportAssignment.js] +var a = 10; +export default a; diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js new file mode 100644 index 00000000000..9fd7a71554d --- /dev/null +++ b/tests/baselines/reference/es6ExportClause.js @@ -0,0 +1,34 @@ +//// [es6ExportClause.ts] + +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; + +//// [es6ExportClause.js] +class c { +} +var m; +(function (m) { + m.x = 10; +})(m || (m = {})); +var x = 10; +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; + + +//// [es6ExportClause.d.ts] 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/es6ExportClauseWithoutModuleSpecifier.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js new file mode 100644 index 00000000000..29cdc655397 --- /dev/null +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts] //// + +//// [server.ts] + +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +//// [client.ts] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; + +//// [server.js] +export class c { +} +var m; +(function (m) { + m.x = 10; +})(m || (m = {})); +export { m }; +export var x = 10; +//// [client.js] +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; + + +//// [server.d.ts] +export declare class c { +} +export interface i { +} +export declare module m { + var x: number; +} +export declare var x: number; +export declare module uninstantiated { +} +//// [client.d.ts] 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..f2682f0a188 --- /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 declare 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..a975d4322f5 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultClassDeclaration2.js @@ -0,0 +1,48 @@ +//// [es6ExportDefaultClassDeclaration2.ts] + +export default class { + method() { } +} + + +//// [es6ExportDefaultClassDeclaration2.js] +export default class { + method() { + } +} + + +//// [es6ExportDefaultClassDeclaration2.d.ts] +export declare class { + method(): void; +} + + +//// [DtsFileErrors] + + +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(1,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(1,8): error TS2304: Cannot find name 'declare'. +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(1,16): error TS1005: ';' expected. +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(2,5): error TS2304: Cannot find name 'method'. +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(2,13): error TS1005: ';' expected. +tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/compiler/es6ExportDefaultClassDeclaration2.d.ts (6 errors) ==== + export declare class { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~ +!!! error TS1005: ';' expected. + method(): void; + ~~~~~~ +!!! error TS2304: Cannot find name 'method'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1109: Expression expected. + } + \ No newline at end of file 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..e0d91043766 --- /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 (1 + 2); 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..fafc5a114f5 --- /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 declare 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..2071e56c539 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.js @@ -0,0 +1,25 @@ +//// [es6ExportDefaultFunctionDeclaration2.ts] + +export default function () { } + + +//// [es6ExportDefaultFunctionDeclaration2.js] +export default function () { +} + + +//// [es6ExportDefaultFunctionDeclaration2.d.ts] +export declare function (): void; + + +//// [DtsFileErrors] + + +tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.d.ts(1,25): error TS1003: Identifier expected. + + +==== tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.d.ts (1 errors) ==== + export declare function (): void; + ~ +!!! error TS1003: Identifier expected. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types new file mode 100644 index 00000000000..3cb2fc9b1cd --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultFunctionDeclaration2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts === + +No type information for this code.export default function () { } +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportDefaultIdentifier.js b/tests/baselines/reference/es6ExportDefaultIdentifier.js new file mode 100644 index 00000000000..5785220dfee --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultIdentifier.js @@ -0,0 +1,16 @@ +//// [es6ExportDefaultIdentifier.ts] + +export function f() { } + +export default f; + + +//// [es6ExportDefaultIdentifier.js] +export function f() { +} +export default f; + + +//// [es6ExportDefaultIdentifier.d.ts] +export declare function f(): void; +export default f; diff --git a/tests/baselines/reference/es6ExportDefaultIdentifier.types b/tests/baselines/reference/es6ExportDefaultIdentifier.types new file mode 100644 index 00000000000..81dc168efd0 --- /dev/null +++ b/tests/baselines/reference/es6ExportDefaultIdentifier.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/es6ExportDefaultIdentifier.ts === + +export function f() { } +>f : () => void + +export default f; +>f : () => void + diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt new file mode 100644 index 00000000000..cc4206e2a5f --- /dev/null +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/es6ExportEquals.ts (1 errors) ==== + + export function f() { } + + export = f; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportEquals.js b/tests/baselines/reference/es6ExportEquals.js new file mode 100644 index 00000000000..d51f8740da0 --- /dev/null +++ b/tests/baselines/reference/es6ExportEquals.js @@ -0,0 +1,16 @@ +//// [es6ExportEquals.ts] + +export function f() { } + +export = f; + + +//// [es6ExportEquals.js] +export function f() { +} +export default f; + + +//// [es6ExportEquals.d.ts] +export declare function f(): void; +export = f; diff --git a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt index 85390ecce4b..c07a84bb810 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBinding.errors.txt @@ -8,4 +8,5 @@ tests/cases/compiler/es6ImportDefaultBinding_1.ts(1,8): error TS1192: External m ==== tests/cases/compiler/es6ImportDefaultBinding_1.ts (1 errors) ==== import defaultBinding from "es6ImportDefaultBinding_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment. \ No newline at end of file +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBinding.js b/tests/baselines/reference/es6ImportDefaultBinding.js index d8d1fa8111d..c7a320b76aa 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBinding.js @@ -5,8 +5,14 @@ export var a = 10; //// [es6ImportDefaultBinding_1.ts] -import defaultBinding from "es6ImportDefaultBinding_0"; +import defaultBinding from "es6ImportDefaultBinding_0"; + //// [es6ImportDefaultBinding_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportDefaultBinding_1.js] + + +//// [es6ImportDefaultBinding_0.d.ts] +export declare var a: number; +//// [es6ImportDefaultBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js new file mode 100644 index 00000000000..34b39cda4b7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingAmd.ts] //// + +//// [es6ImportDefaultBindingAmd_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingAmd_1.ts] +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used + + +//// [es6ImportDefaultBindingAmd_0.js] +define(["require", "exports"], function (require, exports) { + var a = 10; + return a; +}); +//// [es6ImportDefaultBindingAmd_1.js] +define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, defaultBinding) { + var x = defaultBinding; +}); + + +//// [es6ImportDefaultBindingAmd_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingAmd_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.types b/tests/baselines/reference/es6ImportDefaultBindingAmd.types new file mode 100644 index 00000000000..9b067ef27a4 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es6ImportDefaultBindingAmd_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBindingAmd_1.ts === +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +>defaultBinding : number + +var x = defaultBinding; +>x : number +>defaultBinding : number + +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used +>defaultBinding2 : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingDts.errors.txt new file mode 100644 index 00000000000..fc1e1a1925c --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/client.ts(2,12): error TS4025: Exported variable 'x' has or is using private name 'defaultBinding'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + class c { } + export = c; + +==== tests/cases/compiler/client.ts (1 errors) ==== + import defaultBinding from "server"; + export var x = new defaultBinding(); + ~ +!!! error TS4025: Exported variable 'x' has or is using private name 'defaultBinding'. + import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js new file mode 100644 index 00000000000..ad58abd8125 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingDts.ts] //// + +//// [server.ts] + +class c { } +export = c; + +//// [client.ts] +import defaultBinding from "server"; +export var x = new defaultBinding(); +import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used + + +//// [server.js] +var c = (function () { + function c() { + } + return c; +})(); +module.exports = c; +//// [client.js] +var defaultBinding = require("server"); +exports.x = new defaultBinding(); + + +//// [server.d.ts] +declare class c { +} +export = c; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index bd8714cb86f..c755b8207e7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -48,4 +48,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(6,8): e ~~~~~~~~~~~~~~ !!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment. ~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'defaultBinding'. \ No newline at end of file +!!! error TS2300: Duplicate identifier 'defaultBinding'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index a7402bfeb6a..d7196f86eaa 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -12,10 +12,18 @@ import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImpor import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; + //// [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] + + +//// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +//// [es6ImportDefaultBindingFollowedWithNamedImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt new file mode 100644 index 00000000000..a780f7cec30 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt @@ -0,0 +1,42 @@ +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,30): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,27): error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. + + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (1 errors) ==== + + var a = 10; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_1.ts (6 errors) ==== + import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + var x1: number = defaultBinding1; + import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding2; + import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding3; + import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. + var x1: number = defaultBinding4; + import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. + var x1: number = defaultBinding5; + import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. + var x1: number = defaultBinding6; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js new file mode 100644 index 00000000000..3c8a4080ba7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.ts] +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding6; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.js] +var a = 10; +export default a; +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.js] +import defaultBinding1 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding1; +import defaultBinding2 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding2; +import defaultBinding3 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding3; +import defaultBinding4 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding4; +import defaultBinding5 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding5; +import defaultBinding6 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1 = defaultBinding6; + + +//// [es6ImportDefaultBindingFollowedWithNamedImport1_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamedImport1_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt new file mode 100644 index 00000000000..91d51d5f7ef --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -0,0 +1,61 @@ +tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(2,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(3,12): error TS4025: Exported variable 'x1' has or is using private name 'a'. +tests/cases/compiler/client.ts(4,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(5,12): error TS4025: Exported variable 'x2' has or is using private name 'b'. +tests/cases/compiler/client.ts(6,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(7,12): error TS4025: Exported variable 'x4' has or is using private name 'x'. +tests/cases/compiler/client.ts(8,12): error TS4025: Exported variable 'x5' has or is using private name 'y'. +tests/cases/compiler/client.ts(9,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(10,12): error TS4025: Exported variable 'x3' has or is using private name 'z'. +tests/cases/compiler/client.ts(11,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(12,12): error TS4025: Exported variable 'x6' has or is using private name 'm'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + export class a { } + export class x { } + export class m { } + export class a11 { } + export class a12 { } + export class x11 { } + +==== tests/cases/compiler/client.ts (12 errors) ==== + import defaultBinding1, { } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + import defaultBinding2, { a } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x1 = new a(); + ~~ +!!! error TS4025: Exported variable 'x1' has or is using private name 'a'. + import defaultBinding3, { a11 as b } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x2 = new b(); + ~~ +!!! error TS4025: Exported variable 'x2' has or is using private name 'b'. + import defaultBinding4, { x, a12 as y } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x4 = new x(); + ~~ +!!! error TS4025: Exported variable 'x4' has or is using private name 'x'. + export var x5 = new y(); + ~~ +!!! error TS4025: Exported variable 'x5' has or is using private name 'y'. + import defaultBinding5, { x11 as z, } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x3 = new z(); + ~~ +!!! error TS4025: Exported variable 'x3' has or is using private name 'z'. + import defaultBinding6, { m, } from "server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x6 = new m(); + ~~ +!!! error TS4025: Exported variable 'x6' has or is using private name 'm'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js new file mode 100644 index 00000000000..a6b2c9a1670 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts] //// + +//// [server.ts] + +export class a { } +export class x { } +export class m { } +export class a11 { } +export class a12 { } +export class x11 { } + +//// [client.ts] +import defaultBinding1, { } from "server"; +import defaultBinding2, { a } from "server"; +export var x1 = new a(); +import defaultBinding3, { a11 as b } from "server"; +export var x2 = new b(); +import defaultBinding4, { x, a12 as y } from "server"; +export var x4 = new x(); +export var x5 = new y(); +import defaultBinding5, { x11 as z, } from "server"; +export var x3 = new z(); +import defaultBinding6, { m, } from "server"; +export var x6 = new m(); + + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +exports.a = a; +var x = (function () { + function x() { + } + return x; +})(); +exports.x = x; +var m = (function () { + function m() { + } + return m; +})(); +exports.m = m; +var a11 = (function () { + function a11() { + } + return a11; +})(); +exports.a11 = a11; +var a12 = (function () { + function a12() { + } + return a12; +})(); +exports.a12 = a12; +var x11 = (function () { + function x11() { + } + return x11; +})(); +exports.x11 = x11; +//// [client.js] +var _server_1 = require("server"); +exports.x1 = new _server_1.a(); +var _server_2 = require("server"); +exports.x2 = new _server_2.a11(); +var _server_3 = require("server"); +exports.x4 = new _server_3.x(); +exports.x5 = new _server_3.a12(); +var _server_4 = require("server"); +exports.x3 = new _server_4.x11(); +var _server_5 = require("server"); +exports.x6 = new _server_5.m(); + + +//// [server.d.ts] +export declare class a { +} +export declare class x { +} +export declare class m { +} +export declare class a11 { +} +export declare class a12 { +} +export declare class x11 { +} diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt index 98371eb9198..851a5189a54 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt @@ -8,4 +8,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1, ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; ~~~~~~~~~~~~~~ -!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment. \ No newline at end of file +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment. + var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js index 5ec91279306..2b24fda0755 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js @@ -5,8 +5,16 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] +import * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x = nameSpaceBinding.a; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts] +export declare var a: number; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt new file mode 100644 index 00000000000..2a0f3ad5485 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (1 errors) ==== + + var a = 10; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. + +==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (0 errors) ==== + import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; + var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js new file mode 100644 index 00000000000..927ed3243e7 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = defaultBinding; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] +var a = 10; +export default a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] +import defaultBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x = defaultBinding; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js new file mode 100644 index 00000000000..00166b1bc41 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts] //// + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = defaultBinding; + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] +var a = 10; +module.exports = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] +var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var x = defaultBinding; + + +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.d.ts] +declare var a: number; +export = a; +//// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types new file mode 100644 index 00000000000..dfbc8c0be07 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +>defaultBinding : number +>nameSpaceBinding : typeof nameSpaceBinding + +var x: number = defaultBinding; +>x : number +>defaultBinding : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt new file mode 100644 index 00000000000..b82fb1155e9 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/client.ts(1,8): error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. +tests/cases/compiler/client.ts(2,12): error TS4025: Exported variable 'x' has or is using private name 'nameSpaceBinding.a'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + export class a { } + +==== tests/cases/compiler/client.ts (2 errors) ==== + import defaultBinding, * as nameSpaceBinding from "server"; + ~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/server"' has no default export or export assignment. + export var x = new nameSpaceBinding.a(); + ~ +!!! error TS4025: Exported variable 'x' has or is using private name 'nameSpaceBinding.a'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js new file mode 100644 index 00000000000..3068fb6d39d --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts] //// + +//// [server.ts] + +export class a { } + +//// [client.ts] +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.a(); + +//// [server.js] +var a = (function () { + function a() { + } + return a; +})(); +exports.a = a; +//// [client.js] +var nameSpaceBinding = require("server"); +exports.x = new nameSpaceBinding.a(); + + +//// [server.d.ts] +export declare class a { +} diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.errors.txt new file mode 100644 index 00000000000..3b09108bbfc --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/client.ts(2,12): error TS4025: Exported variable 'x' has or is using private name 'defaultBinding'. + + +==== tests/cases/compiler/server.ts (0 errors) ==== + + class a { } + export = a; + +==== tests/cases/compiler/client.ts (1 errors) ==== + import defaultBinding, * as nameSpaceBinding from "server"; + export var x = new defaultBinding(); + ~ +!!! error TS4025: Exported variable 'x' has or is using private name 'defaultBinding'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js new file mode 100644 index 00000000000..708cffca29d --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts] //// + +//// [server.ts] + +class a { } +export = a; + +//// [client.ts] +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new defaultBinding(); + +//// [server.js] +define(["require", "exports"], function (require, exports) { + var a = (function () { + function a() { + } + return a; + })(); + return a; +}); +//// [client.js] +define(["require", "exports", "server"], function (require, exports, defaultBinding) { + exports.x = new defaultBinding(); +}); + + +//// [server.d.ts] +declare class a { +} +export = a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt new file mode 100644 index 00000000000..d6aacf0ba40 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(5,8): error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(7,8): error TS2300: Duplicate identifier 'defaultBinding3'. +tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(8,8): error TS2300: Duplicate identifier 'defaultBinding3'. + + +==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts (3 errors) ==== + import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; + interface defaultBinding { // This is ok + } + var x = defaultBinding; + import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + ~~~~~~~~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' + var defaultBinding2 = "hello world"; + import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + ~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'defaultBinding3'. + import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + ~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'defaultBinding3'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js new file mode 100644 index 00000000000..628faec6c27 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts] //// + +//// [es6ImportDefaultBindingMergeErrors_0.ts] + +var a = 10; +export = a; + +//// [es6ImportDefaultBindingMergeErrors_1.ts] +import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +interface defaultBinding { // This is ok +} +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +var defaultBinding2 = "hello world"; +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + + +//// [es6ImportDefaultBindingMergeErrors_0.js] +var a = 10; +module.exports = a; +//// [es6ImportDefaultBindingMergeErrors_1.js] +var defaultBinding = require("es6ImportDefaultBindingMergeErrors_0"); +var x = defaultBinding; +var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt new file mode 100644 index 00000000000..a6aaf9f5508 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export or export assignment. + + +==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== + import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export or export assignment. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js new file mode 100644 index 00000000000..f824dbf71d5 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts] //// + +//// [es6ImportDefaultBindingNoDefaultProperty_0.ts] + +export var a = 10; + +//// [es6ImportDefaultBindingNoDefaultProperty_1.ts] +import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; + + +//// [es6ImportDefaultBindingNoDefaultProperty_0.js] +exports.a = 10; +//// [es6ImportDefaultBindingNoDefaultProperty_1.js] diff --git a/tests/baselines/reference/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.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index c6daa3b1222..4f03e9a0ae2 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -5,8 +5,14 @@ export var a = 10; //// [es6ImportNameSpaceImport_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; + //// [es6ImportNameSpaceImport_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportNameSpaceImport_1.js] + + +//// [es6ImportNameSpaceImport_0.d.ts] +export declare var a: number; +//// [es6ImportNameSpaceImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt new file mode 100644 index 00000000000..98a68870833 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(4,13): error TS2300: Duplicate identifier 'nameSpaceBinding1'. +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(5,13): error TS2300: Duplicate identifier 'nameSpaceBinding1'. +tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(7,8): error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' + + +==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_0.ts (0 errors) ==== + + export var a = 10; + +==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts (3 errors) ==== + import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; + interface nameSpaceBinding { } // this should be ok + + import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. + import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. + + import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' + var nameSpaceBinding3 = 10; + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js new file mode 100644 index 00000000000..3c8461fba2b --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts] //// + +//// [es6ImportNameSpaceImportMergeErrors_0.ts] + +export var a = 10; + +//// [es6ImportNameSpaceImportMergeErrors_1.ts] +import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +interface nameSpaceBinding { } // this should be ok + +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + +import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +var nameSpaceBinding3 = 10; + + +//// [es6ImportNameSpaceImportMergeErrors_0.js] +exports.a = 10; +//// [es6ImportNameSpaceImportMergeErrors_1.js] +var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js new file mode 100644 index 00000000000..3d6dab17785 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts] //// + +//// [es6ImportNameSpaceImportNoNamedExports_0.ts] + +var a = 10; +export = a; + +//// [es6ImportNameSpaceImportNoNamedExports_1.ts] +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error + +//// [es6ImportNameSpaceImportNoNamedExports_0.js] +var a = 10; +module.exports = a; +//// [es6ImportNameSpaceImportNoNamedExports_1.js] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types new file mode 100644 index 00000000000..3ba19cef9b4 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_0.ts === + +var a = 10; +>a : number + +export = a; +>a : number + +=== tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +>nameSpaceBinding : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index c52499ef994..7993af7fb07 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -16,12 +16,22 @@ import { x, a as y } from "es6ImportNamedImport_0"; import { x as z, } from "es6ImportNamedImport_0"; import { m, } from "es6ImportNamedImport_0"; import { a1, x1 } from "es6ImportNamedImport_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; + //// [es6ImportNamedImport_0.js] -exports.a = 10; -exports.x = exports.a; -exports.m = exports.a; -exports.a1 = 10; -exports.x1 = 10; +export var a = 10; +export var x = a; +export var m = a; +export var a1 = 10; +export var x1 = 10; //// [es6ImportNamedImport_1.js] + + +//// [es6ImportNamedImport_0.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +export declare var a1: number; +export declare var x1: number; +//// [es6ImportNamedImport_1.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js new file mode 100644 index 00000000000..cd2d5ef6922 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts] //// + +//// [es6ImportNamedImportInExportAssignment_0.ts] + +export var a = 10; + +//// [es6ImportNamedImportInExportAssignment_1.ts] +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export = a; + +//// [es6ImportNamedImportInExportAssignment_0.js] +exports.a = 10; +//// [es6ImportNamedImportInExportAssignment_1.js] +var _es6ImportNamedImportInExportAssignment_0 = require("es6ImportNamedImportInExportAssignment_0"); +module.exports = _es6ImportNamedImportInExportAssignment_0.a; + + +//// [es6ImportNamedImportInExportAssignment_0.d.ts] +export declare var a: number; +//// [es6ImportNamedImportInExportAssignment_1.d.ts] +export = a; + + +//// [DtsFileErrors] + + +tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.d.ts(1,10): error TS2304: Cannot find name 'a'. + + +==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.d.ts (0 errors) ==== + export declare var a: number; + +==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.d.ts (1 errors) ==== + export = a; + ~ +!!! error TS2304: Cannot find name 'a'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types new file mode 100644 index 00000000000..cd72f35c8bf --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types @@ -0,0 +1,12 @@ +=== 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/es6ImportNamedImportInIndirectExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.errors.txt new file mode 100644 index 00000000000..e896a1a88a1 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts(2,12): error TS4000: Import declaration 'x' is using private name 'a'. + + +==== tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_0.ts (0 errors) ==== + + export module a { + export class c { + } + } + +==== tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts (1 errors) ==== + import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; + import x = a; + ~ +!!! error TS4000: Import declaration 'x' is using private name 'a'. + export = x; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js new file mode 100644 index 00000000000..332be6074ad --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts] //// + +//// [es6ImportNamedImportInIndirectExportAssignment_0.ts] + +export module a { + export class c { + } +} + +//// [es6ImportNamedImportInIndirectExportAssignment_1.ts] +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import x = a; +export = x; + +//// [es6ImportNamedImportInIndirectExportAssignment_0.js] +var a; +(function (a) { + var c = (function () { + function c() { + } + return c; + })(); + a.c = c; +})(a = exports.a || (exports.a = {})); +//// [es6ImportNamedImportInIndirectExportAssignment_1.js] +var _es6ImportNamedImportInIndirectExportAssignment_0 = require("es6ImportNamedImportInIndirectExportAssignment_0"); +var x = _es6ImportNamedImportInIndirectExportAssignment_0.a; +module.exports = x; + + +//// [es6ImportNamedImportInIndirectExportAssignment_0.d.ts] +export declare module a { + class c { + } +} diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt new file mode 100644 index 00000000000..b9461b6caca --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(5,10): error TS2440: Import declaration conflicts with local declaration of 'x' +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(7,10): error TS2440: Import declaration conflicts with local declaration of 'x44' +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(9,10): error TS2300: Duplicate identifier 'z'. +tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(10,16): error TS2300: Duplicate identifier 'z'. + + +==== tests/cases/compiler/es6ImportNamedImportMergeErrors_0.ts (0 errors) ==== + + export var a = 10; + export var x = a; + export var z = a; + export var z1 = a; + +==== tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts (4 errors) ==== + import { a } from "es6ImportNamedImportMergeErrors_0"; + interface a { } // shouldnt be error + import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; + interface x1 { } // shouldnt be error + import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2440: Import declaration conflicts with local declaration of 'x' + var x = 10; + import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'x44' + var x44 = 10; + import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2300: Duplicate identifier 'z'. + import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + ~ +!!! error TS2300: Duplicate identifier 'z'. + \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js new file mode 100644 index 00000000000..fad411f557d --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es6ImportNamedImportMergeErrors.ts] //// + +//// [es6ImportNamedImportMergeErrors_0.ts] + +export var a = 10; +export var x = a; +export var z = a; +export var z1 = a; + +//// [es6ImportNamedImportMergeErrors_1.ts] +import { a } from "es6ImportNamedImportMergeErrors_0"; +interface a { } // shouldnt be error +import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +interface x1 { } // shouldnt be error +import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x = 10; +import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x44 = 10; +import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + + +//// [es6ImportNamedImportMergeErrors_0.js] +exports.a = 10; +exports.x = exports.a; +exports.z = exports.a; +exports.z1 = exports.a; +//// [es6ImportNamedImportMergeErrors_1.js] +var x = 10; +var x44 = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt new file mode 100644 index 00000000000..57a77410cb2 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/es6ImportNamedImport_1.ts(1,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. +tests/cases/compiler/es6ImportNamedImport_1.ts(2,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. + + +==== tests/cases/compiler/es6ImportNamedImportNoExportMember_0.ts (0 errors) ==== + + export var a = 10; + export var x = a; + +==== tests/cases/compiler/es6ImportNamedImport_1.ts (2 errors) ==== + import { a1 } from "es6ImportNamedImportNoExportMember_0"; + ~~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. + import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + ~~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js new file mode 100644 index 00000000000..da473fa42a3 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/es6ImportNamedImportNoExportMember.ts] //// + +//// [es6ImportNamedImportNoExportMember_0.ts] + +export var a = 10; +export var x = a; + +//// [es6ImportNamedImport_1.ts] +import { a1 } from "es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + +//// [es6ImportNamedImportNoExportMember_0.js] +exports.a = 10; +exports.x = exports.a; +//// [es6ImportNamedImport_1.js] diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt new file mode 100644 index 00000000000..a5abd986ee8 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(1,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. +tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. + + +==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_0.ts (0 errors) ==== + + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts (2 errors) ==== + import { a } from "es6ImportNamedImportNoNamedExports_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. + import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + ~ +!!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js new file mode 100644 index 00000000000..524860827e6 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts] //// + +//// [es6ImportNamedImportNoNamedExports_0.ts] + +var a = 10; +export = a; + +//// [es6ImportNamedImportNoNamedExports_1.ts] +import { a } from "es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + +//// [es6ImportNamedImportNoNamedExports_0.js] +var a = 10; +module.exports = a; +//// [es6ImportNamedImportNoNamedExports_1.js] diff --git a/tests/baselines/reference/es6ImportNamedImportParsingError.js b/tests/baselines/reference/es6ImportNamedImportParsingError.js index f9d8e90f707..81f141b3dd8 100644 --- a/tests/baselines/reference/es6ImportNamedImportParsingError.js +++ b/tests/baselines/reference/es6ImportNamedImportParsingError.js @@ -13,16 +13,16 @@ import , { a } from "es6ImportNamedImportParsingError_0"; import { a }, from "es6ImportNamedImportParsingError_0"; //// [es6ImportNamedImportParsingError_0.js] -exports.a = 10; -exports.x = exports.a; -exports.m = exports.a; +export var a = 10; +export var x = a; +export var m = a; //// [es6ImportNamedImportParsingError_1.js] from; "es6ImportNamedImportParsingError_0"; { - _module_1.a; + a; } from; "es6ImportNamedImportParsingError_0"; -var _module_1 = require(); +import { a } from , from; "es6ImportNamedImportParsingError_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.js b/tests/baselines/reference/es6ImportWithoutFromClause.js index 43d21885c27..9666409b924 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.js +++ b/tests/baselines/reference/es6ImportWithoutFromClause.js @@ -5,9 +5,15 @@ export var a = 10; //// [es6ImportWithoutFromClause_1.ts] -import "es6ImportWithoutFromClause_0"; +import "es6ImportWithoutFromClause_0"; + //// [es6ImportWithoutFromClause_0.js] -exports.a = 10; +export var a = 10; //// [es6ImportWithoutFromClause_1.js] -require("es6ImportWithoutFromClause_0"); +import "es6ImportWithoutFromClause_0"; + + +//// [es6ImportWithoutFromClause_0.d.ts] +export declare var a: number; +//// [es6ImportWithoutFromClause_1.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.types b/tests/baselines/reference/es6ImportWithoutFromClause.types index 1cd7df9962e..3cc5067891a 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.types +++ b/tests/baselines/reference/es6ImportWithoutFromClause.types @@ -5,4 +5,5 @@ export var a = 10; === tests/cases/compiler/es6ImportWithoutFromClause_1.ts === import "es6ImportWithoutFromClause_0"; +No type information for this code. No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js new file mode 100644 index 00000000000..e63dd4bb53a --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts] //// + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.ts] + +export interface i { +} + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.ts] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.js] +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.js] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; + + +//// [es6ImportWithoutFromClauseNonInstantiatedModule_0.d.ts] +export interface i { +} +//// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts] diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types new file mode 100644 index 00000000000..2be3f67f1e9 --- /dev/null +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_0.ts === + +export interface i { +>i : i +} + +=== tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule_1.ts === +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/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/exportDefaultTypeAnnoation.errors.txt b/tests/baselines/reference/exportDefaultTypeAnnoation.errors.txt new file mode 100644 index 00000000000..71ff4261ffe --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/exportDefaultTypeAnnoation.ts(2,18): error TS1201: A type annotation on an export statement is only allowed in an ambient external module declaration. + + +==== tests/cases/compiler/exportDefaultTypeAnnoation.ts (1 errors) ==== + + export default : number; + ~~~~~~ +!!! error TS1201: A type annotation on an export statement is only allowed in an ambient external module declaration. \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation.js b/tests/baselines/reference/exportDefaultTypeAnnoation.js new file mode 100644 index 00000000000..8adf31a5f18 --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation.js @@ -0,0 +1,6 @@ +//// [exportDefaultTypeAnnoation.ts] + +export default : number; + +//// [exportDefaultTypeAnnoation.js] +module.exports = ; diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation2.js b/tests/baselines/reference/exportDefaultTypeAnnoation2.js new file mode 100644 index 00000000000..2c918954702 --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation2.js @@ -0,0 +1,7 @@ +//// [exportDefaultTypeAnnoation2.ts] + +declare module "mod" { + export default : number; +} + +//// [exportDefaultTypeAnnoation2.js] diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation2.types b/tests/baselines/reference/exportDefaultTypeAnnoation2.types new file mode 100644 index 00000000000..53ca78586cc --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation2.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/exportDefaultTypeAnnoation2.ts === + +No type information for this code.declare module "mod" { +No type information for this code. export default : number; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation3.errors.txt b/tests/baselines/reference/exportDefaultTypeAnnoation3.errors.txt new file mode 100644 index 00000000000..326713e059e --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation3.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/reference1.ts(2,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/reference2.ts(2,5): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/mod.d.ts (0 errors) ==== + + declare module "mod" { + export default : number; + } + +==== tests/cases/compiler/reference1.ts (1 errors) ==== + import d from "mod"; + var s: string = d; // Error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + +==== tests/cases/compiler/reference2.ts (1 errors) ==== + import { default as d } from "mod"; + var s: string = d; // Error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultTypeAnnoation3.js b/tests/baselines/reference/exportDefaultTypeAnnoation3.js new file mode 100644 index 00000000000..069c8385e77 --- /dev/null +++ b/tests/baselines/reference/exportDefaultTypeAnnoation3.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/exportDefaultTypeAnnoation3.ts] //// + +//// [mod.d.ts] + +declare module "mod" { + export default : number; +} + +//// [reference1.ts] +import d from "mod"; +var s: string = d; // Error + +//// [reference2.ts] +import { default as d } from "mod"; +var s: string = d; // Error + +//// [reference1.js] +var d = require("mod"); +var s = d; // Error +//// [reference2.js] +var _mod = require("mod"); +var s = _mod.default; // Error diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js index 65ac7119fb6..958e621c8aa 100644 --- a/tests/baselines/reference/for-of14.js +++ b/tests/baselines/reference/for-of14.js @@ -12,11 +12,8 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail because the iterator is not iterable -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return ""; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js index 74e34c2b2ae..2b4846ec8be 100644 --- a/tests/baselines/reference/for-of15.js +++ b/tests/baselines/reference/for-of15.js @@ -15,14 +15,11 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return ""; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js index 526dc277be7..1cdf72c26ac 100644 --- a/tests/baselines/reference/for-of16.js +++ b/tests/baselines/reference/for-of16.js @@ -12,11 +12,8 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of17.js b/tests/baselines/reference/for-of17.js index 268ead7ee18..3fb4fac91d6 100644 --- a/tests/baselines/reference/for-of17.js +++ b/tests/baselines/reference/for-of17.js @@ -18,17 +18,14 @@ class NumberIterator { var v; for (v of new NumberIterator) { } // Should succeed -var NumberIterator = (function () { - function NumberIterator() { - } - NumberIterator.prototype.next = function () { +class NumberIterator { + next() { return { value: 0, done: false }; - }; - NumberIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return NumberIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js index 3be876409dc..ae3a9e130f0 100644 --- a/tests/baselines/reference/for-of18.js +++ b/tests/baselines/reference/for-of18.js @@ -18,17 +18,14 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should succeed -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { value: "", done: false }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of19.js b/tests/baselines/reference/for-of19.js index eefb9339f18..d0f95caa1e2 100644 --- a/tests/baselines/reference/for-of19.js +++ b/tests/baselines/reference/for-of19.js @@ -20,22 +20,16 @@ class FooIterator { for (var v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of20.js b/tests/baselines/reference/for-of20.js index 39b1081954b..c098abd2f73 100644 --- a/tests/baselines/reference/for-of20.js +++ b/tests/baselines/reference/for-of20.js @@ -20,22 +20,16 @@ class FooIterator { for (let v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of21.js b/tests/baselines/reference/for-of21.js index 5deaad3c2d8..27da28e3b4f 100644 --- a/tests/baselines/reference/for-of21.js +++ b/tests/baselines/reference/for-of21.js @@ -20,22 +20,16 @@ class FooIterator { for (const v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of22.js b/tests/baselines/reference/for-of22.js index d38accb6cd8..886e8dba7c3 100644 --- a/tests/baselines/reference/for-of22.js +++ b/tests/baselines/reference/for-of22.js @@ -21,22 +21,16 @@ class FooIterator { v; for (var v of new FooIterator) { } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of23.js b/tests/baselines/reference/for-of23.js index 87bb1fd428d..f5649128c11 100644 --- a/tests/baselines/reference/for-of23.js +++ b/tests/baselines/reference/for-of23.js @@ -20,22 +20,16 @@ class FooIterator { for (const v of new FooIterator) { const v = 0; // new scope } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js index 86c175f861e..2c85a4dc2fd 100644 --- a/tests/baselines/reference/for-of25.js +++ b/tests/baselines/reference/for-of25.js @@ -12,11 +12,8 @@ class StringIterator { var x; for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return x; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js index edb6b4c38b2..e048caf1006 100644 --- a/tests/baselines/reference/for-of26.js +++ b/tests/baselines/reference/for-of26.js @@ -15,14 +15,11 @@ class StringIterator { var x; for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return x; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js index 379b95c5b09..8b44ca03ef4 100644 --- a/tests/baselines/reference/for-of27.js +++ b/tests/baselines/reference/for-of27.js @@ -8,8 +8,5 @@ class StringIterator { //// [for-of27.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - return StringIterator; -})(); +class StringIterator { +} diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js index 79b1590e12f..69c8ccab727 100644 --- a/tests/baselines/reference/for-of28.js +++ b/tests/baselines/reference/for-of28.js @@ -11,11 +11,8 @@ class StringIterator { //// [for-of28.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js index 759c7823e63..0ed6caaf81e 100644 --- a/tests/baselines/reference/for-of30.js +++ b/tests/baselines/reference/for-of30.js @@ -19,18 +19,17 @@ class StringIterator { //// [for-of30.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { +class StringIterator { + constructor() { this.return = 0; } - StringIterator.prototype.next = function () { + next() { return { done: false, value: "" }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js index 6773c8a3452..d38c1fa017d 100644 --- a/tests/baselines/reference/for-of31.js +++ b/tests/baselines/reference/for-of31.js @@ -17,17 +17,14 @@ class StringIterator { //// [for-of31.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { // no done property value: "" }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js index f3a75eec137..66097f777c8 100644 --- a/tests/baselines/reference/for-of33.js +++ b/tests/baselines/reference/for-of33.js @@ -10,11 +10,8 @@ class StringIterator { //// [for-of33.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return v; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js index 521b4f3c2a4..568a9f73535 100644 --- a/tests/baselines/reference/for-of34.js +++ b/tests/baselines/reference/for-of34.js @@ -14,14 +14,11 @@ class StringIterator { //// [for-of34.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return v; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js index cb6dc0e532f..a157d5e2e8e 100644 --- a/tests/baselines/reference/for-of35.js +++ b/tests/baselines/reference/for-of35.js @@ -17,17 +17,14 @@ class StringIterator { //// [for-of35.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { done: true, value: v }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.js b/tests/baselines/reference/initializePropertiesWithRenamedLet.js new file mode 100644 index 00000000000..902a23f5886 --- /dev/null +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.js @@ -0,0 +1,46 @@ +//// [initializePropertiesWithRenamedLet.ts] + +var x0; +if (true) { + let x0; + var obj1 = { x0: x0 }; + var obj2 = { x0 }; +} + +var x, y, z; +if (true) { + let { x: x } = { x: 0 }; + let { y } = { y: 0 }; + let z; + ({ z: z } = { z: 0 }); + ({ z } = { z: 0 }); +} + +//// [initializePropertiesWithRenamedLet.js] +var x0; +if (true) { + var _x0; + var obj1 = { + x0: _x0 + }; + var obj2 = { + x0: _x0 + }; +} +var x, y, z; +if (true) { + var _x = ({ + x: 0 + }).x; + var _y = ({ + y: 0 + }).y; + var _z; + (_a = { + z: 0 + }, _z = _a.z, _a); + (_b = { + z: 0 + }, _z = _b.z, _b); +} +var _a, _b; diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.types b/tests/baselines/reference/initializePropertiesWithRenamedLet.types new file mode 100644 index 00000000000..77f16756fdb --- /dev/null +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/initializePropertiesWithRenamedLet.ts === + +var x0; +>x0 : any + +if (true) { + let x0; +>x0 : any + + var obj1 = { x0: x0 }; +>obj1 : { x0: any; } +>{ x0: x0 } : { x0: any; } +>x0 : any +>x0 : any + + var obj2 = { x0 }; +>obj2 : { x0: any; } +>{ x0 } : { x0: any; } +>x0 : any +} + +var x, y, z; +>x : any +>y : any +>z : any + +if (true) { + let { x: x } = { x: 0 }; +>x : unknown +>x : number +>{ x: 0 } : { x: number; } +>x : number + + let { y } = { y: 0 }; +>y : number +>{ y: 0 } : { y: number; } +>y : number + + let z; +>z : any + + ({ z: z } = { z: 0 }); +>({ z: z } = { z: 0 }) : { z: number; } +>{ z: z } = { z: 0 } : { z: number; } +>{ z: z } : { z: any; } +>z : any +>z : any +>{ z: 0 } : { z: number; } +>z : number + + ({ z } = { z: 0 }); +>({ z } = { z: 0 }) : { z: number; } +>{ z } = { z: 0 } : { z: number; } +>{ z } : { z: any; } +>z : any +>{ z: 0 } : { z: number; } +>z : number +} diff --git a/tests/baselines/reference/letDeclarations-scopes.js b/tests/baselines/reference/letDeclarations-scopes.js index fc721807994..d0489820d0b 100644 --- a/tests/baselines/reference/letDeclarations-scopes.js +++ b/tests/baselines/reference/letDeclarations-scopes.js @@ -259,30 +259,25 @@ var m; lable: let l2 = 0; })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { let l = 0; n = l; } - C.prototype.method = function () { + method() { let l = 0; n = l; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - let l = 0; - n = l; - return n; - }, - set: function (value) { - let l = 0; - n = l; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + let l = 0; + n = l; + return n; + } + set v(value) { + let l = 0; + n = l; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/letDeclarations-validContexts.js b/tests/baselines/reference/letDeclarations-validContexts.js index f6d404135f6..b11a1922383 100644 --- a/tests/baselines/reference/letDeclarations-validContexts.js +++ b/tests/baselines/reference/letDeclarations-validContexts.js @@ -221,26 +221,21 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { let l24 = 0; } - C.prototype.method = function () { + method() { let l25 = 0; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - let l26 = 0; - return l26; - }, - set: function (value) { - let l27 = value; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + let l26 = 0; + return l26; + } + set v(value) { + let l27 = value; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt new file mode 100644 index 00000000000..d109b048085 --- /dev/null +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(4,16): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1100: Invalid use of 'eval' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type 'string' is not assignable to type 'IArguments'. + Property 'callee' is missing in type 'String'. + + +==== tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts (4 errors) ==== + class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + private bar(eval:any) { + ~~~~ +!!! error TS1100: Invalid use of 'eval' in strict mode. + arguments = "hello"; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + ~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'IArguments'. +!!! error TS2322: Property 'callee' is missing in type 'String'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js new file mode 100644 index 00000000000..2a8d75dde60 --- /dev/null +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js @@ -0,0 +1,23 @@ +//// [parseClassDeclarationInStrictModeByDefaultInES6.ts] +class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + private bar(eval:any) { + arguments = "hello"; + } +} + +//// [parseClassDeclarationInStrictModeByDefaultInES6.js] +class C { + constructor() { + this.interface = 10; + } + implements() { + } + foo(arguments) { + } + bar(eval) { + arguments = "hello"; + } +} diff --git a/tests/baselines/reference/parserComputedPropertyName10.js b/tests/baselines/reference/parserComputedPropertyName10.js index c00d3292f7e..eba480ba810 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.js +++ b/tests/baselines/reference/parserComputedPropertyName10.js @@ -4,9 +4,8 @@ class C { } //// [parserComputedPropertyName10.js] -var C = (function () { - function C() { +class C { + constructor() { this[e] = 1; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName11.js b/tests/baselines/reference/parserComputedPropertyName11.js index 1b9575184f2..dc63d6385d8 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.js +++ b/tests/baselines/reference/parserComputedPropertyName11.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName11.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName12.js b/tests/baselines/reference/parserComputedPropertyName12.js index 96e62b626e7..71cf1d352f4 100644 --- a/tests/baselines/reference/parserComputedPropertyName12.js +++ b/tests/baselines/reference/parserComputedPropertyName12.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName12.js] -var C = (function () { - function C() { +class C { + [e]() { } - C.prototype[e] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName24.js b/tests/baselines/reference/parserComputedPropertyName24.js index 0b9467fb26d..8fc0a5be3a5 100644 --- a/tests/baselines/reference/parserComputedPropertyName24.js +++ b/tests/baselines/reference/parserComputedPropertyName24.js @@ -4,14 +4,7 @@ class C { } //// [parserComputedPropertyName24.js] -var C = (function () { - function C() { +class C { + set [e](v) { } - Object.defineProperty(C.prototype, e, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName25.js b/tests/baselines/reference/parserComputedPropertyName25.js index a00cec2e6dd..47670fe14b8 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.js +++ b/tests/baselines/reference/parserComputedPropertyName25.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName25.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2] = 1; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName27.js b/tests/baselines/reference/parserComputedPropertyName27.js index 03b156af840..f872e95e7e6 100644 --- a/tests/baselines/reference/parserComputedPropertyName27.js +++ b/tests/baselines/reference/parserComputedPropertyName27.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName27.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2]; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName28.js b/tests/baselines/reference/parserComputedPropertyName28.js index 60fb25dfa20..998f60db914 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.js +++ b/tests/baselines/reference/parserComputedPropertyName28.js @@ -5,9 +5,8 @@ class C { } //// [parserComputedPropertyName28.js] -var C = (function () { - function C() { +class C { + constructor() { this[e] = 0; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName29.js b/tests/baselines/reference/parserComputedPropertyName29.js index 05ced020aff..a100cbf1791 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.js +++ b/tests/baselines/reference/parserComputedPropertyName29.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName29.js] -var C = (function () { - function C() { +class C { + constructor() { // yes ASI this[e] = id++; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName31.js b/tests/baselines/reference/parserComputedPropertyName31.js index 2a07155a2f0..cee09fb0ab7 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.js +++ b/tests/baselines/reference/parserComputedPropertyName31.js @@ -6,8 +6,5 @@ class C { } //// [parserComputedPropertyName31.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName33.js b/tests/baselines/reference/parserComputedPropertyName33.js index 1cc06c06780..64239bc1284 100644 --- a/tests/baselines/reference/parserComputedPropertyName33.js +++ b/tests/baselines/reference/parserComputedPropertyName33.js @@ -6,12 +6,11 @@ class C { } //// [parserComputedPropertyName33.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2](); } - return C; -})(); +} { } diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt index 07e937b3b42..8c647be13c9 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,12 +1,15 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (3 errors) ==== class C { [public ]: string; - ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. ~~~~~~ -!!! error TS2304: Cannot find name 'public'. +!!! error TS1109: Expression expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.js b/tests/baselines/reference/parserComputedPropertyName36.js index 264a3512075..fd6f376ef2b 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.js +++ b/tests/baselines/reference/parserComputedPropertyName36.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName36.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName38.errors.txt b/tests/baselines/reference/parserComputedPropertyName38.errors.txt index 4322abf44ed..28daf322748 100644 --- a/tests/baselines/reference/parserComputedPropertyName38.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName38.errors.txt @@ -1,9 +1,21 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS2304: Cannot find name 'public'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,16): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(3,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (5 errors) ==== class C { [public]() { } ~~~~~~ -!!! error TS2304: Cannot find name 'public'. - } \ No newline at end of file +!!! error TS1109: Expression expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1005: '=>' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName38.js b/tests/baselines/reference/parserComputedPropertyName38.js index 487ff4078fd..e5c9512ad2d 100644 --- a/tests/baselines/reference/parserComputedPropertyName38.js +++ b/tests/baselines/reference/parserComputedPropertyName38.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName38.js] -var C = (function () { - function C() { - } - C.prototype[public] = function () { - }; - return C; -})(); +class C { +} +(() => { +}); diff --git a/tests/baselines/reference/parserComputedPropertyName39.js b/tests/baselines/reference/parserComputedPropertyName39.js index c37312f0034..cee81ccc3d0 100644 --- a/tests/baselines/reference/parserComputedPropertyName39.js +++ b/tests/baselines/reference/parserComputedPropertyName39.js @@ -6,10 +6,7 @@ class C { //// [parserComputedPropertyName39.js] "use strict"; -var C = (function () { - function C() { - } - return C; -})(); +class C { +} (() => { }); diff --git a/tests/baselines/reference/parserComputedPropertyName40.js b/tests/baselines/reference/parserComputedPropertyName40.js index 5f6381360fc..417e37067d1 100644 --- a/tests/baselines/reference/parserComputedPropertyName40.js +++ b/tests/baselines/reference/parserComputedPropertyName40.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName40.js] -var C = (function () { - function C() { +class C { + [a ? "" : ""]() { } - C.prototype[a ? "" : ""] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName7.js b/tests/baselines/reference/parserComputedPropertyName7.js index 70ed8b7b073..aa18db09bc6 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.js +++ b/tests/baselines/reference/parserComputedPropertyName7.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName7.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName8.js b/tests/baselines/reference/parserComputedPropertyName8.js index 4b79c459663..bab7c3198bd 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.js +++ b/tests/baselines/reference/parserComputedPropertyName8.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName8.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName9.js b/tests/baselines/reference/parserComputedPropertyName9.js index 4b62cc0ecd9..3ba028a4a1c 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.js +++ b/tests/baselines/reference/parserComputedPropertyName9.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName9.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSuperExpression1.js b/tests/baselines/reference/parserSuperExpression1.js index d0d7f4dcd52..0d312f79104 100644 --- a/tests/baselines/reference/parserSuperExpression1.js +++ b/tests/baselines/reference/parserSuperExpression1.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression2.js b/tests/baselines/reference/parserSuperExpression2.js index 8d0c6cf3698..7a77c28ef52 100644 --- a/tests/baselines/reference/parserSuperExpression2.js +++ b/tests/baselines/reference/parserSuperExpression2.js @@ -10,7 +10,7 @@ var C = (function () { function C() { } C.prototype.M = function () { - super..call(this, 0); + _super..call(this, 0); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression4.js b/tests/baselines/reference/parserSuperExpression4.js index a36981416df..46ffc65f57c 100644 --- a/tests/baselines/reference/parserSuperExpression4.js +++ b/tests/baselines/reference/parserSuperExpression4.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - super.foo = 1; + _super.foo = 1; }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - super.foo = 1; + _super.foo = 1; }; return C; })(); diff --git a/tests/baselines/reference/parserSymbolIndexer2.js b/tests/baselines/reference/parserSymbolIndexer2.js index 563614e1c8c..4bfe400de53 100644 --- a/tests/baselines/reference/parserSymbolIndexer2.js +++ b/tests/baselines/reference/parserSymbolIndexer2.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolIndexer2.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolIndexer3.js b/tests/baselines/reference/parserSymbolIndexer3.js index 917945193ae..36247ea2a13 100644 --- a/tests/baselines/reference/parserSymbolIndexer3.js +++ b/tests/baselines/reference/parserSymbolIndexer3.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolIndexer3.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolProperty5.js b/tests/baselines/reference/parserSymbolProperty5.js index 922e1fb0323..a8b1d564fa8 100644 --- a/tests/baselines/reference/parserSymbolProperty5.js +++ b/tests/baselines/reference/parserSymbolProperty5.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolProperty5.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolProperty6.js b/tests/baselines/reference/parserSymbolProperty6.js index cbc06cd2951..d2aa55fe085 100644 --- a/tests/baselines/reference/parserSymbolProperty6.js +++ b/tests/baselines/reference/parserSymbolProperty6.js @@ -4,9 +4,8 @@ class C { } //// [parserSymbolProperty6.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.toStringTag] = ""; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserSymbolProperty7.js b/tests/baselines/reference/parserSymbolProperty7.js index 9d34b9e3bce..a3061ee1b58 100644 --- a/tests/baselines/reference/parserSymbolProperty7.js +++ b/tests/baselines/reference/parserSymbolProperty7.js @@ -4,10 +4,7 @@ class C { } //// [parserSymbolProperty7.js] -var C = (function () { - function C() { +class C { + [Symbol.toStringTag]() { } - C.prototype[Symbol.toStringTag] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js index 76c4a7ac3a6..594ec1ca18e 100644 --- a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js +++ b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js @@ -16,16 +16,16 @@ if (true) { if (true) { var x = 0; // Error var _a = ({ - _x: 0 + x: 0 }).x, x = _a === void 0 ? 0 : _a; // Error var _b = ({ - _x: 0 + x: 0 }).x, x = _b === void 0 ? 0 : _b; // Error var x = ({ - _x: 0 + x: 0 }).x; // Error var x = ({ - _x: 0 + x: 0 }).x; // Error } } diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index 5c3102cd877..453eb820ddb 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -80,7 +80,7 @@ var Base2 = (function () { function Base2() { } Base2.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return Base2; })(); diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index acc5b4072f5..ab982aa8fdf 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -166,7 +166,7 @@ var Base4; function Sub4E() { } Sub4E.prototype.x = function () { - return super.x.call(this); + return _super.x.call(this); }; return Sub4E; })(); diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index cd3d9c63e41..259afb1af0f 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -64,6 +64,6 @@ var Q = (function (_super) { _super.x.call(this); // error _super.y.call(this); }; - Q.yy = super.; // error for static initializer accessing super + Q.yy = _super.; // error for static initializer accessing super return Q; })(P); diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index 2dc2db1a3d4..2b1a5082617 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -60,14 +60,14 @@ var __extends = this.__extends || function (d, b) { }; function foo() { // super in a non class context - var x = super.; + var x = _super.; var y = function () { - return super.; + return _super.; }; var z = function () { return function () { return function () { - return super.; + return _super.; }; }; }; @@ -88,18 +88,18 @@ var RegisteredUser = (function (_super) { this.name = "Frank"; // super call in an inner function in a constructor function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } // super call in a lambda in an inner function in a constructor function inner2() { var x = function () { - return super.sayHello.call(this); + return _super.sayHello.call(this); }; } // super call in a lambda in a function expression in a constructor (function () { return function () { - return super.; + return _super.; }; })(); } @@ -109,13 +109,13 @@ var RegisteredUser = (function (_super) { // super call in a lambda in an inner function in a method function inner() { var x = function () { - return super.sayHello.call(this); + return _super.sayHello.call(this); }; } // super call in a lambda in a function expression in a constructor (function () { return function () { - return super.; + return _super.; }; })(); }; diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js index 48ae609cdc6..c4ced2a9dcc 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -39,13 +39,13 @@ var ObjectLiteral; var ThisInObjectLiteral = { _foo: '1', get foo() { - return super._foo; + return _super._foo; }, set foo(value) { - super._foo = value; + _super._foo = value; }, test: function () { - return super._foo; + return _super._foo; } }; })(ObjectLiteral || (ObjectLiteral = {})); @@ -65,7 +65,7 @@ var SuperObjectTest = (function (_super) { SuperObjectTest.prototype.testing = function () { var test = { get F() { - return super.test.call(this); + return _super.test.call(this); } }; }; diff --git a/tests/baselines/reference/symbolDeclarationEmit1.js b/tests/baselines/reference/symbolDeclarationEmit1.js index 16d208db5eb..7c3b39b9d86 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.js +++ b/tests/baselines/reference/symbolDeclarationEmit1.js @@ -4,11 +4,8 @@ class C { } //// [symbolDeclarationEmit1.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} //// [symbolDeclarationEmit1.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit11.js b/tests/baselines/reference/symbolDeclarationEmit11.js index c9c819eefa2..599f7393f4b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.js +++ b/tests/baselines/reference/symbolDeclarationEmit11.js @@ -7,23 +7,16 @@ class C { } //// [symbolDeclarationEmit11.js] -var C = (function () { - function C() { +class C { + static [Symbol.toPrimitive]() { } - C[Symbol.toPrimitive] = function () { - }; - Object.defineProperty(C, Symbol.isRegExp, { - get: function () { - return ""; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - C[Symbol.iterator] = 0; - return C; -})(); + static get [Symbol.isRegExp]() { + return ""; + } + static set [Symbol.isRegExp](x) { + } +} +C[Symbol.iterator] = 0; //// [symbolDeclarationEmit11.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit12.js b/tests/baselines/reference/symbolDeclarationEmit12.js index 49ff8b35976..ab930b41580 100644 --- a/tests/baselines/reference/symbolDeclarationEmit12.js +++ b/tests/baselines/reference/symbolDeclarationEmit12.js @@ -15,24 +15,17 @@ module M { //// [symbolDeclarationEmit12.js] var M; (function (M) { - var C = (function () { - function C() { + class C { + [Symbol.toPrimitive](x) { } - C.prototype[Symbol.toPrimitive] = function (x) { - }; - C.prototype[Symbol.isConcatSpreadable] = function () { + [Symbol.isConcatSpreadable]() { return undefined; - }; - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return undefined; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; - })(); + } + get [Symbol.isRegExp]() { + return undefined; + } + set [Symbol.isRegExp](x) { + } + } M.C = C; })(M || (M = {})); diff --git a/tests/baselines/reference/symbolDeclarationEmit13.js b/tests/baselines/reference/symbolDeclarationEmit13.js index 51b6edcece5..f48a918a6f2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.js +++ b/tests/baselines/reference/symbolDeclarationEmit13.js @@ -5,24 +5,13 @@ class C { } //// [symbolDeclarationEmit13.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toStringTag, { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [Symbol.toStringTag](x) { + } +} //// [symbolDeclarationEmit13.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit14.js b/tests/baselines/reference/symbolDeclarationEmit14.js index d81bc329927..6197ffa2b4f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.js +++ b/tests/baselines/reference/symbolDeclarationEmit14.js @@ -5,25 +5,14 @@ class C { } //// [symbolDeclarationEmit14.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toStringTag, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.toStringTag]() { + return ""; + } +} //// [symbolDeclarationEmit14.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit2.js b/tests/baselines/reference/symbolDeclarationEmit2.js index 2112f9e7748..5558bebc64e 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.js +++ b/tests/baselines/reference/symbolDeclarationEmit2.js @@ -4,12 +4,11 @@ class C { } //// [symbolDeclarationEmit2.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.isRegExp] = ""; } - return C; -})(); +} //// [symbolDeclarationEmit2.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit3.js b/tests/baselines/reference/symbolDeclarationEmit3.js index 6d06c09bd69..6f513b053c7 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.js +++ b/tests/baselines/reference/symbolDeclarationEmit3.js @@ -6,13 +6,10 @@ class C { } //// [symbolDeclarationEmit3.js] -var C = (function () { - function C() { +class C { + [Symbol.isRegExp](x) { } - C.prototype[Symbol.isRegExp] = function (x) { - }; - return C; -})(); +} //// [symbolDeclarationEmit3.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit4.js b/tests/baselines/reference/symbolDeclarationEmit4.js index cd3fc53a5bb..14f50a03ee7 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.js +++ b/tests/baselines/reference/symbolDeclarationEmit4.js @@ -5,20 +5,13 @@ class C { } //// [symbolDeclarationEmit4.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [Symbol.isRegExp](x) { + } +} //// [symbolDeclarationEmit4.d.ts] diff --git a/tests/baselines/reference/symbolProperty10.js b/tests/baselines/reference/symbolProperty10.js index 5b4e44f11ab..74bcf886461 100644 --- a/tests/baselines/reference/symbolProperty10.js +++ b/tests/baselines/reference/symbolProperty10.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty10.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty11.js b/tests/baselines/reference/symbolProperty11.js index 83a380c79e7..97fa4fc992f 100644 --- a/tests/baselines/reference/symbolProperty11.js +++ b/tests/baselines/reference/symbolProperty11.js @@ -9,11 +9,8 @@ i = new C; var c: C = i; //// [symbolProperty11.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty12.js b/tests/baselines/reference/symbolProperty12.js index 9f63f86bc18..474ec4a0ffa 100644 --- a/tests/baselines/reference/symbolProperty12.js +++ b/tests/baselines/reference/symbolProperty12.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty12.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty13.js b/tests/baselines/reference/symbolProperty13.js index 1cf24a49c7e..d7620d01159 100644 --- a/tests/baselines/reference/symbolProperty13.js +++ b/tests/baselines/reference/symbolProperty13.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty13.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty14.js b/tests/baselines/reference/symbolProperty14.js index 0283cb01b79..716bc68b430 100644 --- a/tests/baselines/reference/symbolProperty14.js +++ b/tests/baselines/reference/symbolProperty14.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty14.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty15.js b/tests/baselines/reference/symbolProperty15.js index 0c198037093..dec61964252 100644 --- a/tests/baselines/reference/symbolProperty15.js +++ b/tests/baselines/reference/symbolProperty15.js @@ -15,11 +15,8 @@ var i: I; bar(i); //// [symbolProperty15.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty16.js b/tests/baselines/reference/symbolProperty16.js index 1a1f3f857af..1382d913104 100644 --- a/tests/baselines/reference/symbolProperty16.js +++ b/tests/baselines/reference/symbolProperty16.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty16.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty23.js b/tests/baselines/reference/symbolProperty23.js index b3291ad34e8..3210f6dfed7 100644 --- a/tests/baselines/reference/symbolProperty23.js +++ b/tests/baselines/reference/symbolProperty23.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty23.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toPrimitive] = function () { +class C { + [Symbol.toPrimitive]() { return true; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty24.js b/tests/baselines/reference/symbolProperty24.js index b5d059dd29f..3d582d80254 100644 --- a/tests/baselines/reference/symbolProperty24.js +++ b/tests/baselines/reference/symbolProperty24.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty24.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toPrimitive] = function () { +class C { + [Symbol.toPrimitive]() { return ""; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty25.js b/tests/baselines/reference/symbolProperty25.js index c932da1e3eb..33c398a6c0e 100644 --- a/tests/baselines/reference/symbolProperty25.js +++ b/tests/baselines/reference/symbolProperty25.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty25.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toStringTag] = function () { +class C { + [Symbol.toStringTag]() { return ""; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty26.js b/tests/baselines/reference/symbolProperty26.js index 9e98027603d..837ef5837b0 100644 --- a/tests/baselines/reference/symbolProperty26.js +++ b/tests/baselines/reference/symbolProperty26.js @@ -12,27 +12,13 @@ class C2 extends C1 { } //// [symbolProperty26.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return ""; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype[Symbol.toStringTag] = function () { +} +class C2 extends C1 { + [Symbol.toStringTag]() { return ""; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/symbolProperty27.js b/tests/baselines/reference/symbolProperty27.js index f19d05233cb..d4eb6fcafa7 100644 --- a/tests/baselines/reference/symbolProperty27.js +++ b/tests/baselines/reference/symbolProperty27.js @@ -12,27 +12,13 @@ class C2 extends C1 { } //// [symbolProperty27.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return {}; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype[Symbol.toStringTag] = function () { +} +class C2 extends C1 { + [Symbol.toStringTag]() { return ""; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/symbolProperty28.js b/tests/baselines/reference/symbolProperty28.js index 57c826cb7ab..ed53a88f957 100644 --- a/tests/baselines/reference/symbolProperty28.js +++ b/tests/baselines/reference/symbolProperty28.js @@ -11,28 +11,14 @@ var c: C2; var obj = c[Symbol.toStringTag]().x; //// [symbolProperty28.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} var c; var obj = c[Symbol.toStringTag]().x; diff --git a/tests/baselines/reference/symbolProperty29.js b/tests/baselines/reference/symbolProperty29.js index da6afdc6420..759a7754826 100644 --- a/tests/baselines/reference/symbolProperty29.js +++ b/tests/baselines/reference/symbolProperty29.js @@ -7,13 +7,10 @@ class C1 { } //// [symbolProperty29.js] -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty30.js b/tests/baselines/reference/symbolProperty30.js index af151e0efd5..263fdc1041b 100644 --- a/tests/baselines/reference/symbolProperty30.js +++ b/tests/baselines/reference/symbolProperty30.js @@ -7,13 +7,10 @@ class C1 { } //// [symbolProperty30.js] -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty31.js b/tests/baselines/reference/symbolProperty31.js index e8388225dd7..a9db50061b3 100644 --- a/tests/baselines/reference/symbolProperty31.js +++ b/tests/baselines/reference/symbolProperty31.js @@ -9,26 +9,12 @@ class C2 extends C1 { } //// [symbolProperty31.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} diff --git a/tests/baselines/reference/symbolProperty32.js b/tests/baselines/reference/symbolProperty32.js index b544c60da7e..52db43bb9de 100644 --- a/tests/baselines/reference/symbolProperty32.js +++ b/tests/baselines/reference/symbolProperty32.js @@ -9,26 +9,12 @@ class C2 extends C1 { } //// [symbolProperty32.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} diff --git a/tests/baselines/reference/symbolProperty33.js b/tests/baselines/reference/symbolProperty33.js index 082c0fe7e65..8a0e3f691b5 100644 --- a/tests/baselines/reference/symbolProperty33.js +++ b/tests/baselines/reference/symbolProperty33.js @@ -9,26 +9,12 @@ class C2 { } //// [symbolProperty33.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function (_super) { - __extends(C1, _super); - function C1() { - _super.apply(this, arguments); - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 extends C2 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(C2); -var C2 = (function () { - function C2() { } - return C2; -})(); +} +class C2 { +} diff --git a/tests/baselines/reference/symbolProperty34.js b/tests/baselines/reference/symbolProperty34.js index de7d722227b..b8bcd54487f 100644 --- a/tests/baselines/reference/symbolProperty34.js +++ b/tests/baselines/reference/symbolProperty34.js @@ -9,26 +9,12 @@ class C2 { } //// [symbolProperty34.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function (_super) { - __extends(C1, _super); - function C1() { - _super.apply(this, arguments); - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 extends C2 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(C2); -var C2 = (function () { - function C2() { } - return C2; -})(); +} +class C2 { +} diff --git a/tests/baselines/reference/symbolProperty39.js b/tests/baselines/reference/symbolProperty39.js index 18551d20c0b..6454d4a983f 100644 --- a/tests/baselines/reference/symbolProperty39.js +++ b/tests/baselines/reference/symbolProperty39.js @@ -11,14 +11,11 @@ class C { } //// [symbolProperty39.js] -var C = (function () { - function C() { +class C { + [Symbol.iterator](x) { + return undefined; } - C.prototype[Symbol.iterator] = function (x) { + [Symbol.iterator](x) { return undefined; - }; - C.prototype[Symbol.iterator] = function (x) { - return undefined; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty40.js b/tests/baselines/reference/symbolProperty40.js index 15d8c5c6fba..cf5a3c4396d 100644 --- a/tests/baselines/reference/symbolProperty40.js +++ b/tests/baselines/reference/symbolProperty40.js @@ -13,14 +13,11 @@ c[Symbol.iterator](0); //// [symbolProperty40.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} var c = new C; c[Symbol.iterator](""); c[Symbol.iterator](0); diff --git a/tests/baselines/reference/symbolProperty41.js b/tests/baselines/reference/symbolProperty41.js index d26b2c7682a..fd9d58082b6 100644 --- a/tests/baselines/reference/symbolProperty41.js +++ b/tests/baselines/reference/symbolProperty41.js @@ -13,14 +13,11 @@ c[Symbol.iterator]("hello"); //// [symbolProperty41.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} var c = new C; c[Symbol.iterator](""); c[Symbol.iterator]("hello"); diff --git a/tests/baselines/reference/symbolProperty42.js b/tests/baselines/reference/symbolProperty42.js index 1990f54066c..082e862f0fc 100644 --- a/tests/baselines/reference/symbolProperty42.js +++ b/tests/baselines/reference/symbolProperty42.js @@ -8,11 +8,8 @@ class C { } //// [symbolProperty42.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty43.js b/tests/baselines/reference/symbolProperty43.js index fcb1fd3f8e5..fdeb52ca893 100644 --- a/tests/baselines/reference/symbolProperty43.js +++ b/tests/baselines/reference/symbolProperty43.js @@ -5,8 +5,5 @@ class C { } //// [symbolProperty43.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/symbolProperty44.js b/tests/baselines/reference/symbolProperty44.js index d4824e79318..1f4aaf73b3c 100644 --- a/tests/baselines/reference/symbolProperty44.js +++ b/tests/baselines/reference/symbolProperty44.js @@ -9,15 +9,11 @@ class C { } //// [symbolProperty44.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.hasInstance]() { + return ""; + } +} diff --git a/tests/baselines/reference/symbolProperty45.js b/tests/baselines/reference/symbolProperty45.js index d056aba9f56..97b1252b825 100644 --- a/tests/baselines/reference/symbolProperty45.js +++ b/tests/baselines/reference/symbolProperty45.js @@ -9,22 +9,11 @@ class C { } //// [symbolProperty45.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toPrimitive, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.toPrimitive]() { + return ""; + } +} diff --git a/tests/baselines/reference/symbolProperty46.js b/tests/baselines/reference/symbolProperty46.js index 255fbac0809..1d4a373f03c 100644 --- a/tests/baselines/reference/symbolProperty46.js +++ b/tests/baselines/reference/symbolProperty46.js @@ -12,20 +12,13 @@ class C { (new C)[Symbol.hasInstance] = ""; //// [symbolProperty46.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - // Should take a string - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + // Should take a string + set [Symbol.hasInstance](x) { + } +} (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = ""; diff --git a/tests/baselines/reference/symbolProperty47.js b/tests/baselines/reference/symbolProperty47.js index 92429c720c1..7c6886f280b 100644 --- a/tests/baselines/reference/symbolProperty47.js +++ b/tests/baselines/reference/symbolProperty47.js @@ -12,20 +12,13 @@ class C { (new C)[Symbol.hasInstance] = ""; //// [symbolProperty47.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - // Should take a string - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + // Should take a string + set [Symbol.hasInstance](x) { + } +} (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = ""; diff --git a/tests/baselines/reference/symbolProperty48.js b/tests/baselines/reference/symbolProperty48.js index b0dc2b46dba..283c3d0d2c5 100644 --- a/tests/baselines/reference/symbolProperty48.js +++ b/tests/baselines/reference/symbolProperty48.js @@ -11,11 +11,8 @@ module M { var M; (function (M) { var Symbol; - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty49.js b/tests/baselines/reference/symbolProperty49.js index ea6e6f2c523..027b76f76d1 100644 --- a/tests/baselines/reference/symbolProperty49.js +++ b/tests/baselines/reference/symbolProperty49.js @@ -11,11 +11,8 @@ module M { var M; (function (M) { M.Symbol; - var C = (function () { - function C() { + class C { + [M.Symbol.iterator]() { } - C.prototype[M.Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty50.js b/tests/baselines/reference/symbolProperty50.js index 0a668e95509..30c911e8fab 100644 --- a/tests/baselines/reference/symbolProperty50.js +++ b/tests/baselines/reference/symbolProperty50.js @@ -10,11 +10,8 @@ module M { //// [symbolProperty50.js] var M; (function (M) { - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty51.js b/tests/baselines/reference/symbolProperty51.js index b3b9902fcd6..a9a79098424 100644 --- a/tests/baselines/reference/symbolProperty51.js +++ b/tests/baselines/reference/symbolProperty51.js @@ -10,11 +10,8 @@ module M { //// [symbolProperty51.js] var M; (function (M) { - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty6.js b/tests/baselines/reference/symbolProperty6.js index 114999dc873..311baf2c187 100644 --- a/tests/baselines/reference/symbolProperty6.js +++ b/tests/baselines/reference/symbolProperty6.js @@ -9,18 +9,13 @@ class C { } //// [symbolProperty6.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.iterator] = 0; } - C.prototype[Symbol.isRegExp] = function () { - }; - Object.defineProperty(C.prototype, Symbol.toStringTag, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + [Symbol.isRegExp]() { + } + get [Symbol.toStringTag]() { + return 0; + } +} diff --git a/tests/baselines/reference/symbolProperty7.js b/tests/baselines/reference/symbolProperty7.js index 42d19616ce3..b833eecff32 100644 --- a/tests/baselines/reference/symbolProperty7.js +++ b/tests/baselines/reference/symbolProperty7.js @@ -9,18 +9,13 @@ class C { } //// [symbolProperty7.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol()] = 0; } - C.prototype[Symbol()] = function () { - }; - Object.defineProperty(C.prototype, Symbol(), { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + [Symbol()]() { + } + get [Symbol()]() { + return 0; + } +} diff --git a/tests/baselines/reference/symbolProperty9.js b/tests/baselines/reference/symbolProperty9.js index f97a1d44a21..e6c8f7299a9 100644 --- a/tests/baselines/reference/symbolProperty9.js +++ b/tests/baselines/reference/symbolProperty9.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty9.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js index 22ce6831f00..95ab43743ae 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js @@ -11,11 +11,8 @@ f({}, 10, 10); f `abcdef${ 1234 }${ 5678 }ghijkl`; //// [templateStringsArrayTypeRedefinedInES6Mode.js] -var TemplateStringsArray = (function () { - function TemplateStringsArray() { - } - return TemplateStringsArray; -})(); +class TemplateStringsArray { +} function f(x, y, z) { } f({}, 10, 10); 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/es6ExportAll.ts b/tests/cases/compiler/es6ExportAll.ts new file mode 100644 index 00000000000..ed2b47c23c4 --- /dev/null +++ b/tests/cases/compiler/es6ExportAll.ts @@ -0,0 +1,17 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export * from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportAllInEs5.ts b/tests/cases/compiler/es6ExportAllInEs5.ts new file mode 100644 index 00000000000..ed754e5cacb --- /dev/null +++ b/tests/cases/compiler/es6ExportAllInEs5.ts @@ -0,0 +1,18 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export * from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportAssignment.ts b/tests/cases/compiler/es6ExportAssignment.ts new file mode 100644 index 00000000000..f1f2cce9923 --- /dev/null +++ b/tests/cases/compiler/es6ExportAssignment.ts @@ -0,0 +1,4 @@ +// @target: es6 + +var a = 10; +export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClause.ts b/tests/cases/compiler/es6ExportClause.ts new file mode 100644 index 00000000000..a16e2c9e7aa --- /dev/null +++ b/tests/cases/compiler/es6ExportClause.ts @@ -0,0 +1,19 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +class c { +} +interface i { +} +module m { + export var x = 10; +} +var x = 10; +module uninstantiated { +} +export { c }; +export { c as c2 }; +export { i, m as instantiatedModule }; +export { uninstantiated }; +export { x }; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts new file mode 100644 index 00000000000..22a6cef4203 --- /dev/null +++ b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifier.ts @@ -0,0 +1,21 @@ +// @target: es6 +// @declaration: true + +// @filename: server.ts +export class c { +} +export interface i { +} +export module m { + export var x = 10; +} +export var x = 10; +export module uninstantiated { +} + +// @filename: client.ts +export { c } from "server"; +export { c as c2 } from "server"; +export { i, m as instantiatedModule } from "server"; +export { uninstantiated } from "server"; +export { x } from "server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts b/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts new file mode 100644 index 00000000000..3d731753ee4 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultClassDeclaration.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export default class C { + method() { } +} diff --git a/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts b/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts new file mode 100644 index 00000000000..7092d15ef52 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultClassDeclaration2.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export default class { + method() { } +} diff --git a/tests/cases/compiler/es6ExportDefaultExpression.ts b/tests/cases/compiler/es6ExportDefaultExpression.ts new file mode 100644 index 00000000000..ef476210541 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultExpression.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default (1 + 2); diff --git a/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts new file mode 100644 index 00000000000..19984bde2a6 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default function f() { } diff --git a/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts new file mode 100644 index 00000000000..022fbd81233 --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultFunctionDeclaration2.ts @@ -0,0 +1,4 @@ +// @target: es6 +// @declaration: true + +export default function () { } diff --git a/tests/cases/compiler/es6ExportDefaultIdentifier.ts b/tests/cases/compiler/es6ExportDefaultIdentifier.ts new file mode 100644 index 00000000000..1590677d4ce --- /dev/null +++ b/tests/cases/compiler/es6ExportDefaultIdentifier.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export function f() { } + +export default f; diff --git a/tests/cases/compiler/es6ExportEquals.ts b/tests/cases/compiler/es6ExportEquals.ts new file mode 100644 index 00000000000..5dfc98b4c93 --- /dev/null +++ b/tests/cases/compiler/es6ExportEquals.ts @@ -0,0 +1,6 @@ +// @target: es6 +// @declaration: true + +export function f() { } + +export = f; diff --git a/tests/cases/compiler/es6ImportDefaultBinding.ts b/tests/cases/compiler/es6ImportDefaultBinding.ts index dc5b4ab98d6..9e779e8664d 100644 --- a/tests/cases/compiler/es6ImportDefaultBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBinding.ts @@ -1,8 +1,8 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBinding_0.ts export var a = 10; // @filename: es6ImportDefaultBinding_1.ts -import defaultBinding from "es6ImportDefaultBinding_0"; \ No newline at end of file +import defaultBinding from "es6ImportDefaultBinding_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingAmd.ts b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts new file mode 100644 index 00000000000..85e06b8c99d --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingAmd.ts @@ -0,0 +1,11 @@ +// @module: amd +// @declaration: true + +// @filename: es6ImportDefaultBindingAmd_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingAmd_1.ts +import defaultBinding from "es6ImportDefaultBindingAmd_0"; +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingDts.ts new file mode 100644 index 00000000000..4700782b78e --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingDts.ts @@ -0,0 +1,11 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +class c { } +export = c; + +// @filename: client.ts +import defaultBinding from "server"; +export var x = new defaultBinding(); +import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts index 96b277d6640..20f0f122e99 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts @@ -1,5 +1,5 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamedImport_0.ts export var a = 10; @@ -12,4 +12,4 @@ import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImpor import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; \ No newline at end of file +import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts new file mode 100644 index 00000000000..c1ac752426e --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts @@ -0,0 +1,20 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamedImport1_1.ts +import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding1; +import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding2; +import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding3; +import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding4; +import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding5; +import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +var x1: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts new file mode 100644 index 00000000000..a84dab94033 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts @@ -0,0 +1,24 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class a { } +export class x { } +export class m { } +export class a11 { } +export class a12 { } +export class x11 { } + +// @filename: client.ts +import defaultBinding1, { } from "server"; +import defaultBinding2, { a } from "server"; +export var x1 = new a(); +import defaultBinding3, { a11 as b } from "server"; +export var x2 = new b(); +import defaultBinding4, { x, a12 as y } from "server"; +export var x4 = new x(); +export var x5 = new y(); +import defaultBinding5, { x11 as z, } from "server"; +export var x3 = new z(); +import defaultBinding6, { m, } from "server"; +export var x6 = new m(); diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts index 3d029e28738..3e2cdd34092 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts @@ -1,8 +1,9 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; \ No newline at end of file +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts new file mode 100644 index 00000000000..81113b776b4 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts @@ -0,0 +1,10 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts new file mode 100644 index 00000000000..db076b87c9a --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts +import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts new file mode 100644 index 00000000000..732f7ef7ba0 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @declaration: true + +// @filename: server.ts +export class a { } + +// @filename: client.ts +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts new file mode 100644 index 00000000000..1f026af8f34 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.ts @@ -0,0 +1,10 @@ +// @module: amd +// @declaration: true + +// @filename: server.ts +class a { } +export = a; + +// @filename: client.ts +import defaultBinding, * as nameSpaceBinding from "server"; +export var x = new defaultBinding(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts new file mode 100644 index 00000000000..cd1bad83716 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -0,0 +1,15 @@ +// @module: commonjs + +// @filename: es6ImportDefaultBindingMergeErrors_0.ts +var a = 10; +export = a; + +// @filename: es6ImportDefaultBindingMergeErrors_1.ts +import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +interface defaultBinding { // This is ok +} +var x = defaultBinding; +import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +var defaultBinding2 = "hello world"; +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error diff --git a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts new file mode 100644 index 00000000000..5ab1c743721 --- /dev/null +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts @@ -0,0 +1,7 @@ +// @module: commonjs + +// @filename: es6ImportDefaultBindingNoDefaultProperty_0.ts +export var a = 10; + +// @filename: es6ImportDefaultBindingNoDefaultProperty_1.ts +import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; diff --git a/tests/cases/compiler/es6ImportEqualsDeclaration.ts b/tests/cases/compiler/es6ImportEqualsDeclaration.ts new file mode 100644 index 00000000000..7df85a31d75 --- /dev/null +++ b/tests/cases/compiler/es6ImportEqualsDeclaration.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// @filename: server.ts +var a = 10; +export = a; + +// @filename: client.ts +import a = require("server"); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImport.ts b/tests/cases/compiler/es6ImportNameSpaceImport.ts index 9937606c41f..58ef52daf53 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImport.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImport.ts @@ -1,8 +1,8 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportNameSpaceImport_0.ts export var a = 10; // @filename: es6ImportNameSpaceImport_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; \ No newline at end of file +import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts new file mode 100644 index 00000000000..d4b69e8bcf4 --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts @@ -0,0 +1,15 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNameSpaceImportMergeErrors_0.ts +export var a = 10; + +// @filename: es6ImportNameSpaceImportMergeErrors_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +interface nameSpaceBinding { } // this should be ok + +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + +import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +var nameSpaceBinding3 = 10; diff --git a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts new file mode 100644 index 00000000000..7d3bdcec94c --- /dev/null +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNameSpaceImportNoNamedExports_0.ts +var a = 10; +export = a; + +// @filename: es6ImportNameSpaceImportNoNamedExports_1.ts +import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImport.ts b/tests/cases/compiler/es6ImportNamedImport.ts index ed34434bd29..df5de478975 100644 --- a/tests/cases/compiler/es6ImportNamedImport.ts +++ b/tests/cases/compiler/es6ImportNamedImport.ts @@ -1,5 +1,5 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportNamedImport_0.ts export var a = 10; @@ -16,4 +16,4 @@ import { x, a as y } from "es6ImportNamedImport_0"; import { x as z, } from "es6ImportNamedImport_0"; import { m, } from "es6ImportNamedImport_0"; import { a1, x1 } from "es6ImportNamedImport_0"; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; \ No newline at end of file +import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; 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 b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts new file mode 100644 index 00000000000..a2739175770 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @declaration: true + +// @filename: es6ImportNamedImportInExportAssignment_0.ts +export var a = 10; + +// @filename: es6ImportNamedImportInExportAssignment_1.ts +import { a } from "es6ImportNamedImportInExportAssignment_0"; +export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts new file mode 100644 index 00000000000..16d11d4e19f --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @declaration: true + +// @filename: es6ImportNamedImportInIndirectExportAssignment_0.ts +export module a { + export class c { + } +} + +// @filename: es6ImportNamedImportInIndirectExportAssignment_1.ts +import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import x = a; +export = x; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts new file mode 100644 index 00000000000..54e30be1e23 --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts @@ -0,0 +1,19 @@ +// @module: commonjs + +// @filename: es6ImportNamedImportMergeErrors_0.ts +export var a = 10; +export var x = a; +export var z = a; +export var z1 = a; + +// @filename: es6ImportNamedImportMergeErrors_1.ts +import { a } from "es6ImportNamedImportMergeErrors_0"; +interface a { } // shouldnt be error +import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +interface x1 { } // shouldnt be error +import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x = 10; +import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +var x44 = 10; +import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error diff --git a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts new file mode 100644 index 00000000000..bd507308d8d --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts @@ -0,0 +1,9 @@ +// @module: commonjs + +// @filename: es6ImportNamedImportNoExportMember_0.ts +export var a = 10; +export var x = a; + +// @filename: es6ImportNamedImport_1.ts +import { a1 } from "es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts new file mode 100644 index 00000000000..9dd243ff36d --- /dev/null +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts @@ -0,0 +1,10 @@ +// @target: es5 +// @module: commonjs + +// @filename: es6ImportNamedImportNoNamedExports_0.ts +var a = 10; +export = a; + +// @filename: es6ImportNamedImportNoNamedExports_1.ts +import { a } from "es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportParsingError.ts b/tests/cases/compiler/es6ImportNamedImportParsingError.ts index a836acc1140..26bd9b69153 100644 --- a/tests/cases/compiler/es6ImportNamedImportParsingError.ts +++ b/tests/cases/compiler/es6ImportNamedImportParsingError.ts @@ -1,5 +1,4 @@ // @target: es6 -// @module: commonjs // @filename: es6ImportNamedImportParsingError_0.ts export var a = 10; diff --git a/tests/cases/compiler/es6ImportParseErrors.ts b/tests/cases/compiler/es6ImportParseErrors.ts index 2cc21dad746..9eb3ccba82a 100644 --- a/tests/cases/compiler/es6ImportParseErrors.ts +++ b/tests/cases/compiler/es6ImportParseErrors.ts @@ -1,4 +1,3 @@ // @target: es6 -// @module: commonjs import 10; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportWithoutFromClause.ts b/tests/cases/compiler/es6ImportWithoutFromClause.ts index 70a15a9bc54..0a38cda093c 100644 --- a/tests/cases/compiler/es6ImportWithoutFromClause.ts +++ b/tests/cases/compiler/es6ImportWithoutFromClause.ts @@ -1,8 +1,8 @@ // @target: es6 -// @module: commonjs +// @declaration: true // @filename: es6ImportWithoutFromClause_0.ts export var a = 10; // @filename: es6ImportWithoutFromClause_1.ts -import "es6ImportWithoutFromClause_0"; \ No newline at end of file +import "es6ImportWithoutFromClause_0"; diff --git a/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts new file mode 100644 index 00000000000..22b250435c8 --- /dev/null +++ b/tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts @@ -0,0 +1,9 @@ +// @target: es6 +// @declaration: true + +// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_0.ts +export interface i { +} + +// @filename: es6ImportWithoutFromClauseNonInstantiatedModule_1.ts +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; \ No newline at end of file diff --git a/tests/cases/compiler/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/exportDefaultTypeAnnoation.ts b/tests/cases/compiler/exportDefaultTypeAnnoation.ts new file mode 100644 index 00000000000..d7fd24d5be3 --- /dev/null +++ b/tests/cases/compiler/exportDefaultTypeAnnoation.ts @@ -0,0 +1,4 @@ +// @target: es5 +// @module: commonjs + +export default : number; \ No newline at end of file diff --git a/tests/cases/compiler/exportDefaultTypeAnnoation2.ts b/tests/cases/compiler/exportDefaultTypeAnnoation2.ts new file mode 100644 index 00000000000..ddb317bd8fc --- /dev/null +++ b/tests/cases/compiler/exportDefaultTypeAnnoation2.ts @@ -0,0 +1,6 @@ +// @target: es5 +// @module: commonjs + +declare module "mod" { + export default : number; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportDefaultTypeAnnoation3.ts b/tests/cases/compiler/exportDefaultTypeAnnoation3.ts new file mode 100644 index 00000000000..88a45de2d32 --- /dev/null +++ b/tests/cases/compiler/exportDefaultTypeAnnoation3.ts @@ -0,0 +1,15 @@ +// @target: es5 +// @module: commonjs + +// @fileName: mod.d.ts +declare module "mod" { + export default : number; +} + +// @fileName: reference1.ts +import d from "mod"; +var s: string = d; // Error + +// @fileName: reference2.ts +import { default as d } from "mod"; +var s: string = d; // Error \ No newline at end of file diff --git a/tests/cases/compiler/initializePropertiesWithRenamedLet.ts b/tests/cases/compiler/initializePropertiesWithRenamedLet.ts new file mode 100644 index 00000000000..b30ce609775 --- /dev/null +++ b/tests/cases/compiler/initializePropertiesWithRenamedLet.ts @@ -0,0 +1,17 @@ +// @target: es5 + +var x0; +if (true) { + let x0; + var obj1 = { x0: x0 }; + var obj2 = { x0 }; +} + +var x, y, z; +if (true) { + let { x: x } = { x: 0 }; + let { y } = { y: 0 }; + let z; + ({ z: z } = { z: 0 }); + ({ z } = { z: 0 }); +} \ 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/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts new file mode 100644 index 00000000000..776d0b45847 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts @@ -0,0 +1,11 @@ +// @target: es6 +class C { + constructor(y: any) + constructor(x: number) { + } +} + +class D { + constructor(y: any) + constructor(x: number, z="hello") {} +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts new file mode 100644 index 00000000000..e6c71b06740 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts @@ -0,0 +1,24 @@ +// @target: es6 +class A { + y: number; + constructor(x: number) { + } + foo(a: any); + foo() { } +} + +class B { + y: number; + x: string = "hello"; + _bar: string; + + constructor(x: number, z = "hello", ...args) { + this.y = 10; + } + baz(...args): string; + baz(z: string, v: number): string { + return this._bar; + } +} + + diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts new file mode 100644 index 00000000000..c27723e3391 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts @@ -0,0 +1,11 @@ +// @target: es6 +class B { + constructor(a: T) { } +} +class C extends B { } +class D extends B { + constructor(a: any) + constructor(b: number) { + super(b); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts new file mode 100644 index 00000000000..9b79d1b003b --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts @@ -0,0 +1,23 @@ +// @target: es6 +class B { + baz(a: string, y = 10) { } +} +class C extends B { + foo() { } + baz(a: string, y:number) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + + foo() { + super.foo(); + } + + baz() { + super.baz("hello", 10); + } +} diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts new file mode 100644 index 00000000000..70c0b35763e --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts @@ -0,0 +1,28 @@ +// @target:es6 +class C { + _name: string; + get name(): string { + return this._name; + } + static get name2(): string { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { + } + set ["computedname"](y: string) { + } + + set foo(a: string) { } + static set bar(b: number) { } + static set ["computedname"](b: string) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts new file mode 100644 index 00000000000..87114db7739 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts @@ -0,0 +1,15 @@ +// @target: es6 +class B { + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts new file mode 100644 index 00000000000..c5d95bc6cb1 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts @@ -0,0 +1,23 @@ +// @target:es6 +class D { + _bar: string; + foo() { } + ["computedName"]() { } + ["computedName"](a: string) { } + ["computedName"](a: string): number { return 1; } + bar(): string { + return this._bar; + } + baz(a: any, x: string): string { + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } + static ["computedname"](a: string): boolean { return true; } + static staticMethod() { + var x = 1 + 2; + return x + } + static foo(a: string) { } + static bar(a: string): number { return 1; } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts new file mode 100644 index 00000000000..dd97cfc85f3 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts @@ -0,0 +1,25 @@ +// @target:es6 +class C { + x: string = "Hello world"; +} + +class D { + x: string = "Hello world"; + y: number; + constructor() { + this.y = 10; + } +} + +class E extends D{ + z: boolean = true; +} + +class F extends D{ + z: boolean = true; + j: string; + constructor() { + super(); + this.j = "HI"; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts new file mode 100644 index 00000000000..7ed36bb22a2 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts @@ -0,0 +1,9 @@ +// @target:es6 +class C { + static z: string = "Foo"; +} + +class D { + x = 20000; + static b = true; +} diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts new file mode 100644 index 00000000000..4356fcce2ab --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts @@ -0,0 +1,19 @@ +// @target: es6 +class B { + x = 10; + constructor() { + this.x = 10; + } + static log(a: number) { } + foo() { + B.log(this.x); + } + + get X() { + return this.x; + } + + set bX(y: number) { + this.x = y; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts new file mode 100644 index 00000000000..945b2101012 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts @@ -0,0 +1,23 @@ +// @target: es6 +class B { + x: T; + B: T; + + constructor(a: any) + constructor(a: any,b: T) + constructor(a: T) { this.B = a;} + + foo(a: T) + foo(a: any) + foo(b: string) + foo(): T { + return this.x; + } + + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts new file mode 100644 index 00000000000..078356f6f15 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts @@ -0,0 +1,15 @@ +// @target: es6 +class B { + x: T; + B: T; + constructor(a: T) { this.B = a;} + foo(): T { + return this.x; + } + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts b/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts new file mode 100644 index 00000000000..b2517d89657 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts @@ -0,0 +1,9 @@ +// @target: es6 +class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + private bar(eval:any) { + arguments = "hello"; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts index ff94b6c9617..ac9ffd50fd6 100644 --- a/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts @@ -5,7 +5,5 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts index 4b0d794b1a7..3b2f66fe588 100644 --- a/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ]() { } diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts new file mode 100644 index 00000000000..4cd9047581f --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts @@ -0,0 +1,11 @@ +// @target: es6 +class C { + static staticProp = 10; + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x: string) { + var y = x; + } + [C.staticProp]() { } +} \ No newline at end of file diff --git a/tests/cases/fourslash/formattingChangeSettings.ts b/tests/cases/fourslash/formattingChangeSettings.ts new file mode 100644 index 00000000000..190de4c3e92 --- /dev/null +++ b/tests/cases/fourslash/formattingChangeSettings.ts @@ -0,0 +1,24 @@ +/// + +////module M { +/////*1*/var x=1; +////} + +var originalOptions = format.copyFormatOptions(); + +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs(" var x = 1;"); + +var copy = format.copyFormatOptions(); +copy.TabSize = 2; +copy.IndentSize = 2; + +format.setFormatOptions(copy); +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs(" var x = 1;"); + +format.setFormatOptions(originalOptions); \ No newline at end of file diff --git a/tests/cases/fourslash/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 diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index e785f1cdf00..422675e9e0a 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -686,7 +686,6 @@ module m3 { }\ }); it('Surrounding function declarations with block',() => { - debugger; var source = "declare function F1() { } export function F2() { } declare export function F3() { }" var oldText = ScriptSnapshot.fromString(source); @@ -719,6 +718,15 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + it('Moving methods from object literal to class in strict mode', () => { + var source = "\"use strict\"; var v = { public A() { } public B() { } public C() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); }); @@ -728,6 +736,15 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "class".length, "interface"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + it('Moving index signatures from class to interface in strict mode', () => { + var source = "\"use strict\"; class C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "class".length, "interface"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); @@ -737,6 +754,16 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "interface".length, "class"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + + it('Moving index signatures from interface to class in strict mode', () => { + var source = "\"use strict\"; interface C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "interface".length, "class"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); @@ -755,6 +782,16 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + + it('Moving accessors from object literal to class in strict mode', () => { + var source = "\"use strict\"; var v = { public get A() { } public get B() { } public get C() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); });