diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68d88854849..3a712b5619a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,11 +36,13 @@ Your pull request should: The library sources are in: [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib) -To build the library files, run +Library files in `built/local/` are updated by running ```Shell -jake lib +jake ``` +The files in `lib/` are used to bootstrap compilation and usually do not need to be updated. + #### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator diff --git a/Jakefile.js b/Jakefile.js index 398b897097d..beb16d2886f 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -544,7 +544,8 @@ compileFile(word2mdJs, // The generated spec.md; built for the 'generate-spec' task file(specMd, [word2mdJs, specWord], function () { var specWordFullPath = path.resolve(specWord); - var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd; + var specMDFullPath = path.resolve(specMd); + var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + '"' + specMDFullPath + '"'; console.log(cmd); child_process.exec(cmd, function () { complete(); diff --git a/doc/TypeScript Language Specification (Change Markup).docx b/doc/TypeScript Language Specification (Change Markup).docx index 893f2e7ed22..24e7d1b623a 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).docx and b/doc/TypeScript Language Specification (Change Markup).docx differ diff --git a/doc/TypeScript Language Specification.docx b/doc/TypeScript Language Specification.docx index 4aaa3bf92fe..4eb94908b57 100644 Binary files a/doc/TypeScript Language Specification.docx and b/doc/TypeScript Language Specification.docx differ diff --git a/doc/spec.md b/doc/spec.md index fe2147be477..a7947b19926 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -1323,7 +1323,7 @@ x = "hello"; // Ok x = 42; // Ok x = test; // Error, boolean not assignable x = test ? 5 : "five"; // Ok -x = test ? 0 : false; // Error, number | boolean not asssignable +x = test ? 0 : false; // Error, number | boolean not assignable ``` it is possible to assign 'x' a value of type `string`, `number`, or the union type `string | number`, but not any other type. To access a value in 'x', a type guard can be used to first narrow the type of 'x' to either `string` or `number`: diff --git a/lib/README.md b/lib/README.md index b2837989505..583ddf91156 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,4 +1,4 @@ # Read this! These files are not meant to be edited by hand. -If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. \ No newline at end of file +If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. Running `jake LKG` will then appropriately update the files in this directory. diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3296824123a..45f4e43e424 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -51,6 +51,7 @@ namespace ts { const emitResolver = createResolver(); const undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); + undefinedSymbol.declarations = []; const argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); const checker: TypeChecker = { @@ -234,6 +235,10 @@ namespace ts { ResolvedReturnType } + const builtinGlobals: SymbolTable = { + [undefinedSymbol.name]: undefinedSymbol + }; + initializeTypeChecker(); return checker; @@ -360,6 +365,24 @@ namespace ts { } } + function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { + for (const id in source) { + if (hasProperty(source, id)) { + if (hasProperty(target, id)) { + // Error on redeclarations + forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + } + else { + target[id] = source[id]; + } + } + } + + function addDeclarationDiagnostic(id: string, message: DiagnosticMessage) { + return (declaration: Declaration) => diagnostics.add(createDiagnosticForNode(declaration, message, id)); + } + } + function getSymbolLinks(symbol: Symbol): SymbolLinks { if (symbol.flags & SymbolFlags.Transient) return symbol; const id = getSymbolId(symbol); @@ -379,6 +402,14 @@ namespace ts { return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } + /** Is this type one of the apparent types created from the primitive types. */ + function isPrimitiveApparentType(type: Type): boolean { + return type === globalStringType || + type === globalNumberType || + type === globalBooleanType || + type === globalESSymbolType; + } + function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { if (meaning && hasProperty(symbols, name)) { const symbol = symbols[name]; @@ -1095,39 +1126,81 @@ namespace ts { return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } - function extendExportSymbols(target: SymbolTable, source: SymbolTable) { + interface ExportCollisionTracker { + specifierText: string; + exportsWithDuplicate: ExportDeclaration[]; + } + + /** + * Extends one symbol table with another while collecting information on name collisions for error message generation into the `lookupTable` argument + * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables + */ + function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { for (const id in source) { if (id !== "default" && !hasProperty(target, id)) { target[id] = source[id]; + if (lookupTable && exportNode) { + lookupTable[id] = { + specifierText: getTextOfNode(exportNode.moduleSpecifier) + } as ExportCollisionTracker; + } + } + else if (lookupTable && exportNode && id !== "default" && hasProperty(target, id) && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { + if (!lookupTable[id].exportsWithDuplicate) { + lookupTable[id].exportsWithDuplicate = [exportNode]; + } + else { + lookupTable[id].exportsWithDuplicate.push(exportNode); + } } } } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { - let result: SymbolTable; const visitedSymbols: Symbol[] = []; - visit(moduleSymbol); - return result || moduleSymbol.exports; + return visit(moduleSymbol) || moduleSymbol.exports; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. - function visit(symbol: Symbol) { - if (symbol && symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol)) { - visitedSymbols.push(symbol); - if (symbol !== moduleSymbol) { - if (!result) { - result = cloneSymbolTable(moduleSymbol.exports); - } - extendExportSymbols(result, symbol.exports); - } - // All export * declarations are collected in an __export symbol by the binder - const exportStars = symbol.exports["__export"]; - if (exportStars) { - for (const node of exportStars.declarations) { - visit(resolveExternalModuleName(node, (node).moduleSpecifier)); - } - } + function visit(symbol: Symbol): SymbolTable { + if (!(symbol && symbol.flags & SymbolFlags.HasExports && !contains(visitedSymbols, symbol))) { + return; } + visitedSymbols.push(symbol); + const symbols = cloneSymbolTable(symbol.exports); + // All export * declarations are collected in an __export symbol by the binder + const exportStars = symbol.exports["__export"]; + if (exportStars) { + const nestedSymbols: SymbolTable = {}; + const lookupTable: Map = {}; + for (const node of exportStars.declarations) { + const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier); + const exportedSymbols = visit(resolvedModule); + extendExportSymbols( + nestedSymbols, + exportedSymbols, + lookupTable, + node as ExportDeclaration + ); + } + for (const id in lookupTable) { + const { exportsWithDuplicate } = lookupTable[id]; + // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || hasProperty(symbols, id)) { + continue; + } + for (const node of exportsWithDuplicate) { + diagnostics.add(createDiagnosticForNode( + node, + Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, + lookupTable[id].specifierText, + id + )); + } + } + extendExportSymbols(symbols, nestedSymbols); + } + return symbols; } } @@ -1521,9 +1594,9 @@ namespace ts { return result; } - function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { + function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string { const writer = getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind); const result = writer.string(); releaseStringWriter(writer); @@ -1881,7 +1954,7 @@ namespace ts { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, symbolStack); + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -1893,7 +1966,7 @@ namespace ts { } writeKeyword(writer, SyntaxKind.NewKeyword); writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, symbolStack); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -1907,15 +1980,12 @@ namespace ts { writer.writeLine(); writer.increaseIndent(); for (const signature of resolved.callSignatures) { - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } for (const signature of resolved.constructSignatures) { - writeKeyword(writer, SyntaxKind.NewKeyword); - writeSpace(writer); - - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, SignatureKind.Construct, symbolStack); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } @@ -1956,7 +2026,7 @@ namespace ts { if (p.flags & SymbolFlags.Optional) { writePunctuation(writer, SyntaxKind.QuestionToken); } - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } @@ -2078,7 +2148,12 @@ namespace ts { buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } - function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, symbolStack?: Symbol[]) { + if (kind === SignatureKind.Construct) { + writeKeyword(writer, SyntaxKind.NewKeyword); + writeSpace(writer); + } + if (signature.target && (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature)) { // Instantiated signature, write type arguments instead // This is achieved by passing in the mapper separately @@ -2952,10 +3027,6 @@ namespace ts { return type.resolvedBaseConstructorType; } - function hasClassBaseType(type: InterfaceType): boolean { - return !!forEach(getBaseTypes(type), t => !!(t.symbol.flags & SymbolFlags.Class)); - } - function getBaseTypes(type: InterfaceType): ObjectType[] { const isClass = type.symbol.flags & SymbolFlags.Class; const isInterface = type.symbol.flags & SymbolFlags.Interface; @@ -3388,11 +3459,11 @@ namespace ts { } function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { - if (!hasClassBaseType(classType)) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; - } const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); + if (baseSignatures.length === 0) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; + } const baseTypeNode = getBaseTypeNodeOfClass(classType); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); const typeArgCount = typeArguments ? typeArguments.length : 0; @@ -3610,7 +3681,7 @@ namespace ts { return type; } - // Return properties of an object type or an empty array for other types + /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type: Type): Symbol[] { if (type.flags & TypeFlags.ObjectType) { return resolveStructuredTypeMembers(type).properties; @@ -3618,8 +3689,8 @@ namespace ts { return emptyArray; } - // If the given type is an object type and that type has a property by the given name, - // return the symbol for that property.Otherwise return undefined. + /** If the given type is an object type and that type has a property by the given name, + * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); @@ -5155,9 +5226,6 @@ namespace ts { } return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); } - if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { - return typeParameterIdenticalTo(source, target); - } if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { if (result = eachTypeRelatedToSomeType(source, target)) { @@ -5288,17 +5356,6 @@ namespace ts { return result; } - function typeParameterIdenticalTo(source: TypeParameter, target: TypeParameter): Ternary { - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return Ternary.True; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return Ternary.False; - } - return isIdenticalTo(source.constraint, target.constraint); - } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -5524,20 +5581,26 @@ namespace ts { outer: for (const t of targetSignatures) { if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) { - let localErrors = reportErrors; - const checkedAbstractAssignability = false; + // Only elaborate errors from the first failure + let shouldElaborateErrors = reportErrors; for (const s of sourceSignatures) { if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) { - const related = signatureRelatedTo(s, t, localErrors); + const related = signatureRelatedTo(s, t, shouldElaborateErrors); if (related) { result &= related; errorInfo = saveErrorInfo; continue outer; } - // Only report errors from the first failure - localErrors = false; + shouldElaborateErrors = false; } } + // don't elaborate the primitive apparent types (like Number) + // because the actual primitives will have already been reported. + if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1, + typeToString(source), + signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); + } return Ternary.False; } } @@ -5820,26 +5883,19 @@ namespace ts { if (!(isMatchingSignature(source, target, partialMatch))) { return Ternary.False; } - let result = Ternary.True; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return Ternary.False; - } - for (let i = 0, len = source.typeParameters.length; i < len; ++i) { - const related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return Ternary.False; - } - result &= related; - } - } - else if (source.typeParameters || target.typeParameters) { + // Check that the two signatures have the same number of type parameters. We might consider + // also checking that any type parameter constraints match, but that would require instantiating + // the constraints with a common set of type arguments to get relatable entities in places where + // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, + // particularly as we're comparing erased versions of the signatures below. + if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { return Ternary.False; } // Spec 1.0 Section 3.8.3 & 3.8.4: // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); + let result = Ternary.True; const targetLen = target.parameters.length; for (let i = 0; i < targetLen; i++) { const s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); @@ -6150,14 +6206,25 @@ namespace ts { function inferFromTypes(source: Type, target: Type) { if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { - // Source and target are both unions or both intersections. To improve the quality of - // inferences we first reduce the types by removing constituents that are identically - // matched by a constituent in the other type. For example, when inferring from - // 'string | string[]' to 'string | T', we reduce the types to 'string[]' and 'T'. - const reducedSource = reduceUnionOrIntersectionType(source, target); - const reducedTarget = reduceUnionOrIntersectionType(target, source); - source = reducedSource; - target = reducedTarget; + // Source and target are both unions or both intersections. First, find each + // target constituent type that has an identically matching source constituent + // type, and for each such target constituent type infer from the type to itself. + // When inferring from a type to itself we effectively find all type parameter + // occurrences within that type and infer themselves as their type arguments. + let matchingTypes: Type[]; + for (const t of (target).types) { + if (typeIdenticalToSomeType(t, (source).types)) { + (matchingTypes || (matchingTypes = [])).push(t); + inferFromTypes(t, t); + } + } + // Next, to improve the quality of inferences, reduce the source and target types by + // removing the identically matched constituents. For example, when inferring from + // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. + if (matchingTypes) { + source = removeTypesFromUnionOrIntersection(source, matchingTypes); + target = removeTypesFromUnionOrIntersection(target, matchingTypes); + } } if (target.flags & TypeFlags.TypeParameter) { // If target is a type parameter, make an inference, unless the source type contains @@ -6246,9 +6313,12 @@ namespace ts { } else { source = getApparentType(source); - if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) || - (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (source.flags & TypeFlags.ObjectType && ( + target.flags & TypeFlags.Reference && (target).typeArguments || + target.flags & TypeFlags.Tuple || + target.flags & TypeFlags.Anonymous && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) { + // If source is an object type, and target is a type reference with type arguments, a tuple type, + // the type of a method, or a type literal, infer from members if (isInProcess(source, target)) { return; } @@ -6311,9 +6381,9 @@ namespace ts { } } - function typeIdenticalToSomeType(source: Type, target: UnionOrIntersectionType): boolean { - for (const t of target.types) { - if (isTypeIdenticalTo(source, t)) { + function typeIdenticalToSomeType(type: Type, types: Type[]): boolean { + for (const t of types) { + if (isTypeIdenticalTo(t, type)) { return true; } } @@ -6321,29 +6391,17 @@ namespace ts { } /** - * Return the reduced form of the source type. This type is computed by by removing all source - * constituents that have an identical match in the target type. + * Return a new union or intersection type computed by removing a given set of types + * from a given union or intersection type. */ - function reduceUnionOrIntersectionType(source: UnionOrIntersectionType, target: UnionOrIntersectionType) { - let sourceTypes = source.types; - let sourceIndex = 0; - let modified = false; - while (sourceIndex < sourceTypes.length) { - if (typeIdenticalToSomeType(sourceTypes[sourceIndex], target)) { - if (!modified) { - sourceTypes = sourceTypes.slice(0); - modified = true; - } - sourceTypes.splice(sourceIndex, 1); - } - else { - sourceIndex++; + function removeTypesFromUnionOrIntersection(type: UnionOrIntersectionType, typesToRemove: Type[]) { + const reducedTypes: Type[] = []; + for (const t of type.types) { + if (!typeIdenticalToSomeType(t, typesToRemove)) { + reducedTypes.push(t); } } - if (modified) { - return source.flags & TypeFlags.Union ? getUnionType(sourceTypes, /*noSubtypeReduction*/ true) : getIntersectionType(sourceTypes); - } - return source; + return type.flags & TypeFlags.Union ? getUnionType(reducedTypes, /*noSubtypeReduction*/ true) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context: InferenceContext, index: number): Type[] { @@ -14248,8 +14306,29 @@ namespace ts { const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } + // Checks for export * conflicts + const exports = getExportsOfModule(moduleSymbol); + for (const id in exports) { + if (id === "__export") { + continue; + } + const { declarations, flags } = exports[id]; + // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces) + if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && declarations.length > 1) { + const exportedDeclarations: Declaration[] = filter(declarations, isNotOverload); + if (exportedDeclarations.length > 1) { + for (const declaration of exportedDeclarations) { + diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Cannot_redeclare_exported_variable_0, id)); + } + } + } + } links.exportsChecked = true; } + + function isNotOverload(declaration: Declaration): boolean { + return declaration.kind !== SyntaxKind.FunctionDeclaration || !!(declaration as FunctionDeclaration).body; + } } function checkTypePredicate(node: TypePredicateNode) { @@ -15060,6 +15139,35 @@ namespace ts { return getReferencedValueSymbol(node) === argumentsSymbol; } + function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean { + let moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression); + if (!moduleSymbol) { + // module not found - be conservative + return true; + } + + const hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined; + // if module has export assignment then 'resolveExternalModuleSymbol' will return resolved symbol for export assignment + // otherwise it will return moduleSymbol itself + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); + + const symbolLinks = getSymbolLinks(moduleSymbol); + if (symbolLinks.exportsSomeValue === undefined) { + // for export assignments - check if resolved symbol for RHS is itself a value + // otherwise - check if at least one export is value + symbolLinks.exportsSomeValue = hasExportAssignment + ? !!(moduleSymbol.flags & SymbolFlags.Value) + : forEachValue(getExportsOfModule(moduleSymbol), isValue); + } + + return symbolLinks.exportsSomeValue; + + function isValue(s: Symbol): boolean { + s = resolveSymbol(s); + return s && !!(s.flags & SymbolFlags.Value); + } + } + // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration { @@ -15365,6 +15473,7 @@ namespace ts { getReferencedValueDeclaration, getTypeReferenceSerializationKind, isOptionalParameter, + moduleExportsSomeValue, isArgumentsLocalBinding, getExternalModuleFileFromDeclaration }; @@ -15392,10 +15501,12 @@ namespace ts { } }); + // Setup global builtins + addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); + getSymbolLinks(undefinedSymbol).type = undefinedType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1); @@ -15533,6 +15644,11 @@ namespace ts { let flags = 0; for (const modifier of node.modifiers) { switch (modifier.kind) { + case SyntaxKind.ConstKeyword: + if (node.kind !== SyntaxKind.EnumDeclaration && node.parent.kind === SyntaxKind.ClassDeclaration) { + return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword)); + } + break; case SyntaxKind.PublicKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PrivateKeyword: @@ -16005,6 +16121,13 @@ namespace ts { return grammarErrorOnNode((prop).equalsToken, Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } + // Modifiers are never allowed on properties except for 'async' on a method declaration + forEach(prop.modifiers, mod => { + if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) { + grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod)); + } + }); + // ECMA-262 11.1.5 Object Initialiser // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -16089,13 +16212,27 @@ namespace ts { if (forInOrOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { - if (variableList.declarations.length > 1) { + const declarations = variableList.declarations; + + // declarations.length can be zero if there is an error in variable declaration in for-of or for-in + // See http://www.ecma-international.org/ecma-262/6.0/#sec-for-in-and-for-of-statements for details + // For example: + // var let = 10; + // for (let of [1,2,3]) {} // this is invalid ES6 syntax + // for (let in [1,2,3]) {} // this is invalid ES6 syntax + // We will then want to skip on grammar checking on variableList declaration + if (!declarations.length) { + return false; + } + + if (declarations.length > 1) { const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ? Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } - const firstDeclaration = variableList.declarations[0]; + const firstDeclaration = declarations[0]; + if (firstDeclaration.initializer) { const diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ? Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer @@ -16294,7 +16431,7 @@ namespace ts { } } - const checkLetConstNames = languageVersion >= ScriptTarget.ES6 && (isLet(node) || isConst(node)); + const checkLetConstNames = (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -16308,7 +16445,7 @@ namespace ts { function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean { if (name.kind === SyntaxKind.Identifier) { - if ((name).text === "let") { + if ((name).originalKeywordKind === SyntaxKind.LetKeyword) { return grammarErrorOnNode(name, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0ca8a93d071..959363f148a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -435,7 +435,7 @@ "category": "Error", "code": 1147 }, - "Cannot compile modules unless the '--module' flag is provided.": { + "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": { "category": "Error", "code": 1148 }, @@ -791,7 +791,10 @@ "category": "Error", "code": 1247 }, - + "A class member cannot have the '{0}' keyword.": { + "category": "Error", + "code": 1248 + }, "'with' statements are not allowed in an async function block.": { "category": "Error", "code": 1300 @@ -844,6 +847,10 @@ "category": "Error", "code": 2307 }, + "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.": { + "category": "Error", + "code": 2308 + }, "An export assignment cannot be used in a module with other exported elements.": { "category": "Error", "code": 2309 @@ -900,6 +907,10 @@ "category": "Error", "code": 2322 }, + "Cannot redeclare exported variable '{0}'.": { + "category": "Error", + "code": 2323 + }, "Property '{0}' is missing in type '{1}'.": { "category": "Error", "code": 2324 @@ -1180,6 +1191,10 @@ "category": "Error", "code": 2396 }, + "Declaration name conflicts with built-in global identifier '{0}'.": { + "category": "Error", + "code": 2397 + }, "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { "category": "Error", "code": 2399 @@ -1740,6 +1755,10 @@ "category": "Error", "code": 2657 }, + "Type '{0}' provides no match for the signature '{1}'": { + "category": "Error", + "code": 2658 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 380be73b482..a73d7374b59 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -499,7 +499,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; let exportSpecifiers: Map; let exportEquals: ExportAssignment; - let hasExportStars: boolean; + let hasExportStarsToExportValues: boolean; let detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[]; @@ -574,7 +574,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; - hasExportStars = undefined; + hasExportStarsToExportValues = undefined; detachedCommentsInfo = undefined; sourceMapData = undefined; isEs6Module = false; @@ -1453,6 +1453,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.IfStatement: + case SyntaxKind.JsxClosingElement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSpreadAttribute: @@ -3628,12 +3629,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // only allow export default at a source file level if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) { if (!isEs6Module) { - if (languageVersion === ScriptTarget.ES5) { + if (languageVersion !== ScriptTarget.ES3) { // default value of configurable, enumerable, writable are `false`. write("Object.defineProperty(exports, \"__esModule\", { value: true });"); writeLine(); } - else if (languageVersion === ScriptTarget.ES3) { + else { write("exports.__esModule = true;"); writeLine(); } @@ -5171,35 +5172,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (!(node.flags & NodeFlags.Export)) { return; } - // If this is an exported class, but not on the top level (i.e. on an internal - // module), export it - if (node.flags & NodeFlags.Default) { - // if this is a top level default export of decorated class, write the export after the declaration. - writeLine(); - if (thisNodeIsDecorated && modulekind === ModuleKind.ES6) { - write("export default "); - emitDeclarationName(node); - write(";"); - } - else if (modulekind === ModuleKind.System) { - write(`${exportFunctionForFile}("default", `); - emitDeclarationName(node); - write(");"); - } - else if (modulekind !== ModuleKind.ES6) { - write(`exports.default = `); - emitDeclarationName(node); - write(";"); - } + if (modulekind !== ModuleKind.ES6) { + emitExportMemberAssignment(node as ClassDeclaration); } - else if (node.parent.kind !== SyntaxKind.SourceFile || (modulekind !== ModuleKind.ES6 && !(node.flags & NodeFlags.Default))) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emitDeclarationName(node); - emitEnd(node); - write(";"); + else { + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (node.flags & NodeFlags.Default) { + // if this is a top level default export of decorated class, write the export after the declaration. + if (thisNodeIsDecorated) { + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + else if (node.parent.kind !== SyntaxKind.SourceFile) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } } } @@ -5800,9 +5796,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted - if (!(node.flags & NodeFlags.Export) || isES6ExportedDeclaration(node)) { + + const isES6ExportedEnum = isES6ExportedDeclaration(node); + if (!(node.flags & NodeFlags.Export) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.EnumDeclaration))) { emitStart(node); - if (isES6ExportedDeclaration(node)) { + if (isES6ExportedEnum) { write("export "); } write("var "); @@ -5899,6 +5897,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return languageVersion === ScriptTarget.ES6 && !!(resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalModuleMergesWithClass); } + function isFirstDeclarationOfKind(node: Declaration, declarations: Declaration[], kind: SyntaxKind) { + return !forEach(declarations, declaration => declaration.kind === kind && declaration.pos < node.pos); + } + function emitModuleDeclaration(node: ModuleDeclaration) { // Emit only if this module is non-ambient. const shouldEmit = shouldEmitModuleDeclaration(node); @@ -5910,15 +5912,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi const emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { - emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); + const isES6ExportedNamespace = isES6ExportedDeclaration(node); + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, SyntaxKind.ModuleDeclaration)) { + emitStart(node); + if (isES6ExportedNamespace) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); } - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); } emitStart(node); @@ -6226,15 +6231,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { // export * from "foo" - writeLine(); - write("__export("); - if (modulekind !== ModuleKind.AMD) { - emitRequire(getExternalModuleName(node)); + if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + writeLine(); + write("__export("); + if (modulekind !== ModuleKind.AMD) { + emitRequire(getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); } - else { - write(generatedName); - } - write(");"); } emitEnd(node); } @@ -6322,7 +6329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi externalImports = []; exportSpecifiers = {}; exportEquals = undefined; - hasExportStars = false; + hasExportStarsToExportValues = false; for (const node of sourceFile.statements) { switch (node.kind) { case SyntaxKind.ImportDeclaration: @@ -6345,8 +6352,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if ((node).moduleSpecifier) { if (!(node).exportClause) { // export * from "mod" - externalImports.push(node); - hasExportStars = true; + if (resolver.moduleExportsSomeValue((node).moduleSpecifier)) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } } else if (resolver.isValueAliasDeclaration(node)) { // export { x, y } from "mod" where at least one export is a value symbol @@ -6372,7 +6381,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportStarHelper() { - if (hasExportStars) { + if (hasExportStarsToExportValues) { writeLine(); write("function __export(m) {"); increaseIndent(); @@ -6450,7 +6459,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // should always win over entries with similar names that were added via star exports // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. - if (!hasExportStars) { + if (!hasExportStarsToExportValues) { // local names set is needed only in presence of star exports return undefined; } @@ -6875,6 +6884,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } else { + // collectExternalModuleInfo prefilters star exports to keep only ones that export values + // this means that check 'resolver.moduleExportsSomeValue' is redundant and can be omitted here writeLine(); // export * from 'foo' // emit as: @@ -7143,7 +7154,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; - hasExportStars = false; + hasExportStarsToExportValues = false; const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); @@ -7367,7 +7378,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; - hasExportStars = false; + hasExportStarsToExportValues = false; emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7819,6 +7830,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi const shebang = getShebang(currentText); if (shebang) { write(shebang); + writeLine(); } } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8b735ad0aa3..62d98337102 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1134,6 +1134,14 @@ namespace ts { return token === t && tryParse(nextTokenCanFollowModifier); } + function nextTokenIsOnSameLineAndCanFollowModifier() { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } + return canFollowModifier(); + } + function nextTokenCanFollowModifier() { if (token === SyntaxKind.ConstKeyword) { // 'const' is only a modifier if followed by 'enum'. @@ -1154,11 +1162,7 @@ namespace ts { return canFollowModifier(); } - nextToken(); - if (scanner.hasPrecedingLineBreak()) { - return false; - } - return canFollowModifier(); + return nextTokenIsOnSameLineAndCanFollowModifier(); } function parseAnyContextualModifier(): boolean { @@ -3646,7 +3650,7 @@ namespace ts { parseExpected(SyntaxKind.OpenBraceToken); if (token !== SyntaxKind.CloseBraceToken) { - node.expression = parseExpression(); + node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { parseExpected(SyntaxKind.CloseBraceToken); @@ -3988,6 +3992,7 @@ namespace ts { } else { const propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); + propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(SyntaxKind.ColonToken); @@ -4934,15 +4939,31 @@ namespace ts { return decorators; } - function parseModifiers(): ModifiersArray { + /* + * There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member. + * In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect + * and turns it into a standalone declaration), then it is better to parse it and report an error later. + * + * In such situations, 'permitInvalidConstAsModifier' should be set to true. + */ + function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray { let flags = 0; let modifiers: ModifiersArray; while (true) { const modifierStart = scanner.getStartPos(); const modifierKind = token; - if (!parseAnyContextualModifier()) { - break; + if (token === SyntaxKind.ConstKeyword && permitInvalidConstAsModifier) { + // We need to ensure that any subsequent modifiers appear on the same line + // so that when 'const' is a standalone declaration, we don't issue an error. + if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { + break; + } + } + else { + if (!parseAnyContextualModifier()) { + break; + } } if (!modifiers) { @@ -4987,7 +5008,7 @@ namespace ts { const fullStart = getNodePos(); const decorators = parseDecorators(); - const modifiers = parseModifiers(); + const modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); if (accessor) { @@ -5321,16 +5342,17 @@ namespace ts { } function parseModuleSpecifier(): Expression { - // We allow arbitrary expressions here, even though the grammar only allows string - // literals. We check to ensure that it is only a string literal later in the grammar - // walker. - const 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. - if (result.kind === SyntaxKind.StringLiteral) { + if (token === SyntaxKind.StringLiteral) { + const result = parseLiteralNode(); internIdentifier((result).text); + return result; + } + else { + // We allow arbitrary expressions here, even though the grammar only allows string + // literals. We check to ensure that it is only a string literal later in the grammar + // check pass. + return parseExpression(); } - return result; } function parseNamespaceImport(): NamespaceImport { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6139dda0013..da6f7ab0ee7 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -99,7 +99,7 @@ namespace ts { jsonContent = { typings: undefined }; } - if (jsonContent.typings) { + if (typeof jsonContent.typings === "string") { const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host); if (result) { return result; @@ -661,19 +661,17 @@ namespace ts { } function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { - // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a - // JavaScript file. - if (isSourceFileJavaScript(sourceFile)) { - return getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken); - } - return runWithCancellationToken(() => { const typeChecker = getDiagnosticsProducingTypeChecker(); Debug.assert(!!sourceFile.bindDiagnostics); const bindDiagnostics = sourceFile.bindDiagnostics; - const checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report the normal typescript semantic errors. + // Instead, we just report errors for using TypeScript-only constructs from within a + // JavaScript file. + const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? + getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + typeChecker.getDiagnostics(sourceFile, cancellationToken); const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); @@ -1079,6 +1077,8 @@ namespace ts { const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { + // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, + // this check is ok. Otherwise this would be never true for javascript file if (!isExternalModule(importedFile)) { const start = getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); @@ -1234,7 +1234,7 @@ namespace ts { else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); } // Cannot specify module gen target of es6 when below es6 diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3a90ca42fa1..cd7580119b5 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -47,6 +47,21 @@ namespace ts { constructor(o: any); } + declare var ChakraHost: { + args: string[]; + currentDirectory: string; + executingFile: string; + echo(s: string): void; + quit(exitCode?: number): void; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(path: string): void; + resolvePath(path: string): string; + readFile(path: string): string; + writeFile(path: string, contents: string): void; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; + }; + export var sys: System = (function () { function getWScriptSystem(): System { @@ -194,6 +209,7 @@ namespace ts { } }; } + function getNodeSystem(): System { const _fs = require("fs"); const _path = require("path"); @@ -281,7 +297,7 @@ namespace ts { // REVIEW: for now this implementation uses polling. // The advantage of polling is that it works reliably // on all os and with network mounted files. - // For 90 referenced files, the average time to detect + // For 90 referenced files, the average time to detect // changes is 2*msInterval (by default 5 seconds). // The overhead of this is .04 percent (1/2500) with // average pause of < 1 millisecond (and max @@ -406,7 +422,7 @@ namespace ts { }; }, watchDirectory: (path, callback, recursive) => { - // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows + // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) return _fs.watch( path, @@ -454,6 +470,37 @@ namespace ts { } }; } + + function getChakraSystem(): System { + + return { + newLine: "\r\n", + args: ChakraHost.args, + useCaseSensitiveFileNames: false, + write: ChakraHost.echo, + readFile(path: string, encoding?: string) { + // encoding is automatically handled by the implementation in ChakraHost + return ChakraHost.readFile(path); + }, + writeFile(path: string, data: string, writeByteOrderMark?: boolean) { + // If a BOM is required, emit one + if (writeByteOrderMark) { + data = "\uFEFF" + data; + } + + ChakraHost.writeFile(path, data); + }, + resolvePath: ChakraHost.resolvePath, + fileExists: ChakraHost.fileExists, + directoryExists: ChakraHost.directoryExists, + createDirectory: ChakraHost.createDirectory, + getExecutingFilePath: () => ChakraHost.executingFile, + getCurrentDirectory: () => ChakraHost.currentDirectory, + readDirectory: ChakraHost.readDirectory, + exit: ChakraHost.quit, + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } @@ -462,8 +509,13 @@ namespace ts { // process.browser check excludes webpack and browserify return getNodeSystem(); } + else if (typeof ChakraHost !== "undefined") { + return getChakraSystem(); + } else { return undefined; // Unsupported host } })(); } + + diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9358ec24333..7b795846190 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1761,7 +1761,7 @@ namespace ts { export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; @@ -1906,6 +1906,7 @@ namespace ts { getReferencedValueDeclaration(reference: Identifier): Declaration; getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; isOptionalParameter(node: ParameterDeclaration): boolean; + moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile; } @@ -2024,6 +2025,7 @@ namespace ts { exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol + exportsSomeValue?: boolean; // true if module exports some value (not just types) } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 863fbcb23ef..d56b7a92935 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2404,7 +2404,7 @@ namespace ts { * Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph * as the fallback implementation does not check for circular references by default. */ - export const stringify: (value: any) => string = JSON && JSON.stringify + export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify ? JSON.stringify : stringifyFallback; diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 5984505c4cf..0dff2cedc39 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -6923,7 +6923,7 @@ interface IDBDatabase extends EventTarget { onerror: (ev: Event) => any; version: string; close(): void; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -6948,10 +6948,11 @@ declare var IDBFactory: { } interface IDBIndex { - keyPath: string; + keyPath: string | string[]; name: string; objectStore: IDBObjectStore; unique: boolean; + multiEntry: boolean; count(key?: any): IDBRequest; get(key: any): IDBRequest; getKey(key: any): IDBRequest; @@ -6988,7 +6989,7 @@ interface IDBObjectStore { add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; delete(key: any): IDBRequest; deleteIndex(indexName: string): void; get(key: any): IDBRequest; @@ -12575,6 +12576,16 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface IDBObjectStoreParameters { + keyPath?: string | string[]; + autoIncrement?: boolean; +} + +interface IDBIndexParameters { + unique?: boolean; + multiEntry?: boolean; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12610,6 +12621,15 @@ interface ProgressEventInit extends EventInit { total?: number; } +interface HTMLTemplateElement extends HTMLElement { + content: DocumentFragment; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index e2b26747516..531dbf9e5ea 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -1224,7 +1224,7 @@ declare namespace Reflect { function isExtensible(target: any): boolean; function ownKeys(target: any): Array; function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; } @@ -1272,7 +1272,16 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: Iterable>): Promise; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: Iterable>): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 8001511a98b..a1d87f79787 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -311,7 +311,7 @@ interface IDBDatabase extends EventTarget { onerror: (ev: Event) => any; version: string; close(): void; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -336,10 +336,11 @@ declare var IDBFactory: { } interface IDBIndex { - keyPath: string; + keyPath: string | string[]; name: string; objectStore: IDBObjectStore; unique: boolean; + multiEntry: boolean; count(key?: any): IDBRequest; get(key: any): IDBRequest; getKey(key: any): IDBRequest; @@ -376,7 +377,7 @@ interface IDBObjectStore { add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; delete(key: any): IDBRequest; deleteIndex(indexName: string): void; get(key: any): IDBRequest; @@ -892,6 +893,16 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface IDBObjectStoreParameters { + keyPath?: string | string[]; + autoIncrement?: boolean; +} + +interface IDBIndexParameters { + unique?: boolean; + multiEntry?: boolean; +} + interface BlobPropertyBag { type?: string; endings?: string; diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 651105e9d5c..55adb7b7233 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -31,8 +31,8 @@ namespace ts.formatting { * the first token in line so it should be indented */ interface DynamicIndentation { - getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number; - getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number; + getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind, container: Node): number; + getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number, container: Node): number; /** * Indentation for open and close tokens of the node if it is block or another node that needs special indentation * ... { @@ -54,7 +54,7 @@ namespace ts.formatting { * so bar inherits indentation from foo and bar.delta will be 4 * */ - getDelta(): number; + getDelta(child: TextRangeWithKind): number; /** * Formatter calls this function when rule adds or deletes new lines from the text * so indentation scope can adjust values of indentation and delta. @@ -282,19 +282,19 @@ namespace ts.formatting { */ function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number { let previousLine = Constants.Unknown; - let childKind = SyntaxKind.Unknown; + let child: Node; while (n) { let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; if (previousLine !== Constants.Unknown && line !== previousLine) { break; } - if (SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + if (SmartIndenter.shouldIndentChildNode(n, child)) { return options.IndentSize; } previousLine = line; - childKind = n.kind; + child = n; n = n.parent; } return 0; @@ -386,34 +386,7 @@ namespace ts.formatting { effectiveParentStartLine: number): Indentation { let indentation = inheritedIndentation; - if (indentation === Constants.Unknown) { - if (isSomeBlock(node.kind)) { - // blocks should be indented in - // - other blocks - // - source file - // - switch\default clauses - if (isSomeBlock(parent.kind) || - parent.kind === SyntaxKind.SourceFile || - parent.kind === SyntaxKind.CaseClause || - parent.kind === SyntaxKind.DefaultClause) { - - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - else { - indentation = parentDynamicIndentation.getIndentation(); - } - } - else { - if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - } - } - - var delta = SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown) ? options.IndentSize : 0; + var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0; if (effectiveParentStartLine === startLine) { // if node is located on the same line with the parent @@ -422,8 +395,17 @@ namespace ts.formatting { indentation = startLine === lastIndentedLine ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); + delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta(node) + delta); } + else if (indentation === Constants.Unknown) { + if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node); + } + } + return { indentation, delta @@ -455,7 +437,7 @@ namespace ts.formatting { function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation { return { - getIndentationForComment: (kind, tokenIndentation) => { + getIndentationForComment: (kind, tokenIndentation, container) => { switch (kind) { // preceding comment to the token that closes the indentation scope inherits the indentation from the scope // .. { @@ -464,11 +446,11 @@ namespace ts.formatting { case SyntaxKind.CloseBraceToken: case SyntaxKind.CloseBracketToken: case SyntaxKind.CloseParenToken: - return indentation + delta; + return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation; }, - getIndentationForToken: (line, kind) => { + getIndentationForToken: (line, kind, container) => { if (nodeStartLine !== line && node.decorators) { if (kind === getFirstNonDecoratorTokenOfNode(node)) { // if this token is the first token following the list of decorators, we do not need to indent @@ -489,13 +471,13 @@ namespace ts.formatting { return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + delta : indentation; + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; } }, getIndentation: () => indentation, - getDelta: () => delta, + getDelta: child => getEffectiveDelta(delta, child), recomputeIndentation: lineAdded => { - if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { + if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent, node)) { if (lineAdded) { indentation += options.IndentSize; } @@ -503,14 +485,19 @@ namespace ts.formatting { indentation -= options.IndentSize; } - if (SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown)) { + if (SmartIndenter.shouldIndentChildNode(node)) { delta = options.IndentSize; } else { delta = 0; } } - }, + } + } + + function getEffectiveDelta(delta: number, child: TextRangeWithKind) { + // Delta value should be zero when the node explicitly prevents indentation of the child node + return SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0; } } @@ -610,7 +597,7 @@ namespace ts.formatting { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules let tokenInfo = formattingScanner.readTokenInfo(child); Debug.assert(tokenInfo.token.end === child.end); - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } @@ -679,7 +666,7 @@ namespace ts.formatting { } } - function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation): void { + function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation, container?: Node): void { Debug.assert(rangeContainsRange(parent, currentTokenInfo.token)); let lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); @@ -720,11 +707,11 @@ namespace ts.formatting { if (indentToken) { let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : Constants.Unknown; if (currentTokenInfo.leadingTrivia) { - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); let indentNextTokenOrTrivia = true; for (let triviaItem of currentTokenInfo.leadingTrivia) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 12efb774dd3..de4761f57d2 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -123,6 +123,7 @@ namespace ts.formatting { public SpaceAfterModuleName: Rule; // Lambda expressions + public SpaceBeforeArrow: Rule; public SpaceAfterArrow: Rule; // Optional parameters and let args @@ -254,7 +255,7 @@ namespace ts.formatting { // No space before and after indexer this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext ), RuleAction.Delete)); + this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments; @@ -342,6 +343,7 @@ namespace ts.formatting { this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space)); // Lambda expressions + this.SpaceBeforeArrow = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsGreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Optional parameters and let args @@ -379,8 +381,7 @@ namespace ts.formatting { this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // These rules are higher in priority than user-configurable rules. - this.HighPriorityCommonRules = - [ + this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, this.NoSpaceAfterQuestionMark, @@ -411,7 +412,7 @@ namespace ts.formatting { this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, - this.SpaceAfterArrow, + this.SpaceBeforeArrow, this.SpaceAfterArrow, this.NoSpaceAfterEllipsis, this.NoSpaceAfterOptionalParameters, this.NoSpaceBetweenEmptyInterfaceBraceBrackets, @@ -427,8 +428,7 @@ namespace ts.formatting { ]; // These rules are lower in priority than user-configurable rules. - this.LowPriorityCommonRules = - [ + this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, @@ -732,7 +732,7 @@ namespace ts.formatting { } static IsStartOfVariableDeclarationList(context: FormattingContext): boolean { - return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList && + return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index de1d1b19cf2..067118fd7a8 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -68,7 +68,7 @@ namespace ts.formatting { let indentationDelta: number; while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : SyntaxKind.Unknown)) { + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { @@ -153,7 +153,7 @@ namespace ts.formatting { } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line - if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } @@ -461,16 +461,15 @@ namespace ts.formatting { case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: + case SyntaxKind.NamedImports: return true; } return false; } - - export function shouldIndentChildNode(parent: SyntaxKind, child: SyntaxKind): boolean { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { + + export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) { + let childKind = child ? child.kind : SyntaxKind.Unknown; + switch (parent.kind) { case SyntaxKind.DoStatement: case SyntaxKind.WhileStatement: case SyntaxKind.ForInStatement: @@ -484,10 +483,17 @@ namespace ts.formatting { case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - return child !== SyntaxKind.Block; - default: - return false; + return childKind !== SyntaxKind.Block; } + // No explicit rule for given nodes so the result will follow the default value argument + return indentByDefault; + } + + /* + Function returns true when the parent node should indent the given child by an explicit rule + */ + export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean { + return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false); } } } diff --git a/src/services/services.ts b/src/services/services.ts index 4e0a0265b91..a9dda549ead 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3751,7 +3751,8 @@ namespace ts { // Ignore omitted expressions for missing members if (m.kind !== SyntaxKind.PropertyAssignment && m.kind !== SyntaxKind.ShorthandPropertyAssignment && - m.kind !== SyntaxKind.BindingElement) { + m.kind !== SyntaxKind.BindingElement && + m.kind !== SyntaxKind.MethodDeclaration) { continue; } diff --git a/tests/baselines/reference/ClassDeclaration26.errors.txt b/tests/baselines/reference/ClassDeclaration26.errors.txt new file mode 100644 index 00000000000..5e2d570b801 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration26.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/ClassDeclaration26.ts(2,22): error TS1005: ';' expected. +tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: '=' expected. +tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected. +tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/compiler/ClassDeclaration26.ts (5 errors) ==== + class C { + public const var export foo = 10; + ~~~~~~ +!!! error TS1005: ';' expected. + + var constructor() { } + ~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: '=>' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ClassDeclaration26.js b/tests/baselines/reference/ClassDeclaration26.js new file mode 100644 index 00000000000..b0879502119 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration26.js @@ -0,0 +1,15 @@ +//// [ClassDeclaration26.ts] +class C { + public const var export foo = 10; + + var constructor() { } +} + +//// [ClassDeclaration26.js] +var C = (function () { + function C() { + this.foo = 10; + } + return C; +})(); +var constructor = function () { }; diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.errors.txt b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.errors.txt new file mode 100644 index 00000000000..d07f07e2096 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts(2,3): error TS1248: A class member cannot have the 'const' keyword. + + +==== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts (1 errors) ==== + class AtomicNumbers { + static const H = 1; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1248: A class member cannot have the 'const' keyword. + } \ No newline at end of file diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js new file mode 100644 index 00000000000..b8c4dbdf433 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js @@ -0,0 +1,12 @@ +//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts] +class AtomicNumbers { + static const H = 1; +} + +//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration.js] +var AtomicNumbers = (function () { + function AtomicNumbers() { + } + AtomicNumbers.H = 1; + return AtomicNumbers; +})(); diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.js b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.js new file mode 100644 index 00000000000..bd1f1e0c674 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.js @@ -0,0 +1,13 @@ +//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts] +class C { + const + x = 10; +} + +//// [ClassDeclarationWithInvalidConstOnPropertyDeclaration2.js] +var C = (function () { + function C() { + this.x = 10; + } + return C; +})(); diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.symbols b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.symbols new file mode 100644 index 00000000000..ce0ab000017 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts === +class C { +>C : Symbol(C, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 0, 0)) + + const +>const : Symbol(const, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 0, 9)) + + x = 10; +>x : Symbol(x, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts, 1, 9)) +} diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types new file mode 100644 index 00000000000..47139729995 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts === +class C { +>C : C + + const +>const : any + + x = 10; +>x : number +>10 : number +} diff --git a/tests/baselines/reference/ExportAssignment7.errors.txt b/tests/baselines/reference/ExportAssignment7.errors.txt index 83651e10b8e..fe461785c63 100644 --- a/tests/baselines/reference/ExportAssignment7.errors.txt +++ b/tests/baselines/reference/ExportAssignment7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/ExportAssignment7.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. tests/cases/compiler/ExportAssignment7.ts(4,10): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/compiler/ExportAssignment7.ts(4,10): error TS2304: Cannot find name ==== tests/cases/compiler/ExportAssignment7.ts (3 errors) ==== export class C { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } export = B; diff --git a/tests/baselines/reference/ExportAssignment8.errors.txt b/tests/baselines/reference/ExportAssignment8.errors.txt index d1a285cfe51..22e32c9c7d0 100644 --- a/tests/baselines/reference/ExportAssignment8.errors.txt +++ b/tests/baselines/reference/ExportAssignment8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/ExportAssignment8.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. tests/cases/compiler/ExportAssignment8.ts(1,10): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/compiler/ExportAssignment8.ts(1,10): error TS2304: Cannot find name ==== tests/cases/compiler/ExportAssignment8.ts (3 errors) ==== export = B; ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. ~ diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.errors.txt b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.errors.txt index fefdcd8f6f5..e46805a6a2f 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.errors.txt +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(3,24): error TS2304: Cannot find name 'Point'. tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,36): error TS2304: Cannot find name 'Point'. tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error TS2304: Cannot find name 'Point'. @@ -7,7 +7,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error ==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (1 errors) ==== export module A { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export interface Point { x: number; y: number; diff --git a/tests/baselines/reference/ambientDeclarationsExternal.errors.txt b/tests/baselines/reference/ambientDeclarationsExternal.errors.txt index d05dfe813fd..2a9b1fe4879 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.errors.txt +++ b/tests/baselines/reference/ambientDeclarationsExternal.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/ambient/consumer.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/ambient/consumer.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/ambient/consumer.ts (1 errors) ==== /// import imp1 = require('equ'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. // Ambient external module members are always exported with or without export keyword when module lacks export assignment diff --git a/tests/baselines/reference/anonymousDefaultExportsAmd.js b/tests/baselines/reference/anonymousDefaultExportsAmd.js index 67931fd6cc8..bb5cd587a83 100644 --- a/tests/baselines/reference/anonymousDefaultExportsAmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsAmd.js @@ -11,11 +11,13 @@ define(["require", "exports"], function (require, exports) { "use strict"; class default_1 { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; function default_1() { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js index 513b75c27bd..754ffdb7c9b 100644 --- a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js +++ b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js @@ -10,8 +10,10 @@ export default function() {} "use strict"; class default_1 { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; //// [b.js] "use strict"; function default_1() { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/anonymousDefaultExportsUmd.js b/tests/baselines/reference/anonymousDefaultExportsUmd.js index bdaf8dc6aa8..203b234dfa0 100644 --- a/tests/baselines/reference/anonymousDefaultExportsUmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsUmd.js @@ -18,6 +18,7 @@ export default function() {} "use strict"; class default_1 { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); //// [b.js] @@ -31,5 +32,6 @@ export default function() {} })(function (require, exports) { "use strict"; function default_1() { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures.errors.txt index 9c0c0d6a8fd..8e285d414e5 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures.errors.txt @@ -1,11 +1,19 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(28,1): error TS2322: Type 'S2' is not assignable to type 'T'. + Type 'S2' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(29,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(30,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'. + Type '(x: string) => number' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(31,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'. + Type '(x: string) => string' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(32,1): error TS2322: Type 'S2' is not assignable to type 'new (x: number) => void'. + Type 'S2' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(33,1): error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(34,1): error TS2322: Type '(x: string) => number' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => number' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts(35,1): error TS2322: Type '(x: string) => string' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => string' provides no match for the signature 'new (x: number): void' ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts (8 errors) ==== @@ -39,25 +47,33 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme t = s2; ~ !!! error TS2322: Type 'S2' is not assignable to type 'T'. +!!! error TS2322: Type 'S2' provides no match for the signature 'new (x: number): void' t = a3; ~ !!! error TS2322: Type '(x: string) => void' is not assignable to type 'T'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' t = (x: string) => 1; ~ !!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'. +!!! error TS2322: Type '(x: string) => number' provides no match for the signature 'new (x: number): void' t = function (x: string) { return ''; } ~ !!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'. +!!! error TS2322: Type '(x: string) => string' provides no match for the signature 'new (x: number): void' a = s2; ~ !!! error TS2322: Type 'S2' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type 'S2' provides no match for the signature 'new (x: number): void' a = a3; ~ !!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' a = (x: string) => 1; ~ !!! error TS2322: Type '(x: string) => number' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => number' provides no match for the signature 'new (x: number): void' a = function (x: string) { return ''; } ~ !!! error TS2322: Type '(x: string) => string' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => string' provides no match for the signature 'new (x: number): void' \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt index 5e8fc6dd3a4..eacf758d935 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt @@ -9,9 +9,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(34,1): error TS2322: Type 'S2' is not assignable to type 'T'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(35,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(36,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'. Property 'f' is missing in type '(x: string) => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(37,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'. @@ -19,9 +21,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(38,1): error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(39,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f: new (x: number) => void; }'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. + Type '(x: string) => void' provides no match for the signature 'new (x: number): void' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(40,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'. Property 'f' is missing in type '(x: string) => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(41,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f: new (x: number) => void; }'. @@ -79,11 +83,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'S2' is not assignable to type 'T'. !!! error TS2322: Types of property 'f' are incompatible. !!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' t = a3; ~ !!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'. !!! error TS2322: Types of property 'f' are incompatible. !!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' t = (x: string) => 1; ~ !!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'. @@ -97,11 +103,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'. !!! error TS2322: Types of property 'f' are incompatible. !!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' a = a3; ~ !!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f: new (x: number) => void; }'. !!! error TS2322: Types of property 'f' are incompatible. !!! error TS2322: Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. +!!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void' a = (x: string) => 1; ~ !!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 804e31600e1..6cd40f6c8c1 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -11,12 +11,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new (x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'. Types of parameters 'x' and 'x' are incompatible. Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'. + Type '(a: any) => any' provides no match for the signature 'new (a: number): number' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new (x: (a: T) => T) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new (x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }'. Types of parameters 'x' and 'x' are incompatible. Type '(a: any) => any' is not assignable to type '{ new (a: T): T; new (a: T): T; }'. + Type '(a: any) => any' provides no match for the signature 'new (a: T): T' tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }' is not assignable to type 'new (x: (a: T) => T) => any[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ new (a: T): T; new (a: T): T; }' is not assignable to type '(a: any) => any'. @@ -116,6 +118,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'. +!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new (a: number): number' b16 = a16; // error ~~~ !!! error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new (x: (a: T) => T) => T[]'. @@ -128,6 +131,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new (a: T): T; new (a: T): T; }'. +!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new (a: T): T' b17 = a17; // error ~~~ !!! error TS2322: Type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }' is not assignable to type 'new (x: (a: T) => T) => any[]'. diff --git a/tests/baselines/reference/assignmentCompatability24.errors.txt b/tests/baselines/reference/assignmentCompatability24.errors.txt index 0f4a535d413..e49f0803b04 100644 --- a/tests/baselines/reference/assignmentCompatability24.errors.txt +++ b/tests/baselines/reference/assignmentCompatability24.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/assignmentCompatability24.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. + Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tstring): Tstring' ==== tests/cases/compiler/assignmentCompatability24.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability24.ts(9,1): error TS2322: Type 'inte } __test2__.__val__obj = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. \ No newline at end of file +!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. +!!! error TS2322: Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tstring): Tstring' \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability33.errors.txt b/tests/baselines/reference/assignmentCompatability33.errors.txt index e2352625280..386b3c5e292 100644 --- a/tests/baselines/reference/assignmentCompatability33.errors.txt +++ b/tests/baselines/reference/assignmentCompatability33.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/assignmentCompatability33.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. + Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tstring): Tstring' ==== tests/cases/compiler/assignmentCompatability33.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability33.ts(9,1): error TS2322: Type 'inte } __test2__.__val__obj = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. \ No newline at end of file +!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tstring) => Tstring'. +!!! error TS2322: Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tstring): Tstring' \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability34.errors.txt b/tests/baselines/reference/assignmentCompatability34.errors.txt index 2dd9cba6470..fa91456b286 100644 --- a/tests/baselines/reference/assignmentCompatability34.errors.txt +++ b/tests/baselines/reference/assignmentCompatability34.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/assignmentCompatability34.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tnumber) => Tnumber'. + Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tnumber): Tnumber' ==== tests/cases/compiler/assignmentCompatability34.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability34.ts(9,1): error TS2322: Type 'inte } __test2__.__val__obj = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tnumber) => Tnumber'. \ No newline at end of file +!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '(a: Tnumber) => Tnumber'. +!!! error TS2322: Type 'interfaceWithPublicAndOptional' provides no match for the signature '(a: Tnumber): Tnumber' \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability37.errors.txt b/tests/baselines/reference/assignmentCompatability37.errors.txt index 452b72fe8ff..194e216f1ee 100644 --- a/tests/baselines/reference/assignmentCompatability37.errors.txt +++ b/tests/baselines/reference/assignmentCompatability37.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/assignmentCompatability37.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tnumber) => any'. + Type 'interfaceWithPublicAndOptional' provides no match for the signature 'new (param: Tnumber): any' ==== tests/cases/compiler/assignmentCompatability37.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability37.ts(9,1): error TS2322: Type 'inte } __test2__.__val__aa = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tnumber) => any'. \ No newline at end of file +!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tnumber) => any'. +!!! error TS2322: Type 'interfaceWithPublicAndOptional' provides no match for the signature 'new (param: Tnumber): any' \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability38.errors.txt b/tests/baselines/reference/assignmentCompatability38.errors.txt index 5f7918374c1..c15e5e31230 100644 --- a/tests/baselines/reference/assignmentCompatability38.errors.txt +++ b/tests/baselines/reference/assignmentCompatability38.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/assignmentCompatability38.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tstring) => any'. + Type 'interfaceWithPublicAndOptional' provides no match for the signature 'new (param: Tstring): any' ==== tests/cases/compiler/assignmentCompatability38.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/assignmentCompatability38.ts(9,1): error TS2322: Type 'inte } __test2__.__val__aa = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tstring) => any'. \ No newline at end of file +!!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'new (param: Tstring) => any'. +!!! error TS2322: Type 'interfaceWithPublicAndOptional' provides no match for the signature 'new (param: Tstring): any' \ No newline at end of file diff --git a/tests/baselines/reference/callConstructAssignment.errors.txt b/tests/baselines/reference/callConstructAssignment.errors.txt index 42949cf585d..fc36e472151 100644 --- a/tests/baselines/reference/callConstructAssignment.errors.txt +++ b/tests/baselines/reference/callConstructAssignment.errors.txt @@ -1,5 +1,7 @@ tests/cases/compiler/callConstructAssignment.ts(7,1): error TS2322: Type 'new () => any' is not assignable to type '() => void'. + Type 'new () => any' provides no match for the signature '(): void' tests/cases/compiler/callConstructAssignment.ts(8,1): error TS2322: Type '() => void' is not assignable to type 'new () => any'. + Type '() => void' provides no match for the signature 'new (): any' ==== tests/cases/compiler/callConstructAssignment.ts (2 errors) ==== @@ -12,6 +14,8 @@ tests/cases/compiler/callConstructAssignment.ts(8,1): error TS2322: Type '() => foo = bar; // error ~~~ !!! error TS2322: Type 'new () => any' is not assignable to type '() => void'. +!!! error TS2322: Type 'new () => any' provides no match for the signature '(): void' bar = foo; // error ~~~ -!!! error TS2322: Type '() => void' is not assignable to type 'new () => any'. \ No newline at end of file +!!! error TS2322: Type '() => void' is not assignable to type 'new () => any'. +!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any' \ No newline at end of file diff --git a/tests/baselines/reference/circularReference.errors.txt b/tests/baselines/reference/circularReference.errors.txt index 5e0a6208a1e..9954944ff1f 100644 --- a/tests/baselines/reference/circularReference.errors.txt +++ b/tests/baselines/reference/circularReference.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/externalModules/foo1.ts(9,12): error TS2339: Property 'x' does not exist on type 'C1'. tests/cases/conformance/externalModules/foo2.ts(8,12): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/externalModules/foo2.ts(13,8): error TS2339: Property 'x' does not exist on type 'C1'. @@ -29,7 +29,7 @@ tests/cases/conformance/externalModules/foo2.ts(13,8): error TS2339: Property 'x ==== tests/cases/conformance/externalModules/foo1.ts (2 errors) ==== import foo2 = require('./foo2'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export module M1 { export class C1 { m1: foo2.M1.C1; diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt index b200404eaf0..eec5ac4bc0d 100644 --- a/tests/baselines/reference/classAbstractManyKeywords.errors.txt +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. @@ -7,7 +7,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== export default abstract class A {} ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~ !!! error TS1005: ';' expected. export abstract class B {} diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.errors.txt b/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.errors.txt index 47adb957141..b016952a3aa 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.errors.txt +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(4,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(4,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(8,21): error TS2301: Initializer of instance member variable 'messageHandler' cannot reference identifier 'field1' declared in the constructor. @@ -11,7 +11,7 @@ tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(8,21): error T }; export class Test1 { ~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. constructor(private field1: string) { } messageHandler = () => { diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.errors.txt b/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.errors.txt index 9d1a2dd3418..73fa862e82b 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.errors.txt +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts(8,21): error TS2304: Cannot find name 'field1'. ==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_0.ts (1 errors) ==== export var field1: string; ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/compiler/classMemberInitializerWithLamdaScoping3_1.ts (1 errors) ==== declare var console: { diff --git a/tests/baselines/reference/constructorAsType.errors.txt b/tests/baselines/reference/constructorAsType.errors.txt index b0d30295cde..7865a5ecac5 100644 --- a/tests/baselines/reference/constructorAsType.errors.txt +++ b/tests/baselines/reference/constructorAsType.errors.txt @@ -1,10 +1,12 @@ tests/cases/compiler/constructorAsType.ts(1,5): error TS2322: Type '() => { name: string; }' is not assignable to type 'new () => { name: string; }'. + Type '() => { name: string; }' provides no match for the signature 'new (): { name: string; }' ==== tests/cases/compiler/constructorAsType.ts (1 errors) ==== var Person:new () => {name: string;} = function () {return {name:"joe"};}; ~~~~~~ !!! error TS2322: Type '() => { name: string; }' is not assignable to type 'new () => { name: string; }'. +!!! error TS2322: Type '() => { name: string; }' provides no match for the signature 'new (): { name: string; }' var Person2:{new() : {name:string;};}; diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js index 05323aa247d..dbbe72ba52c 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js @@ -28,6 +28,7 @@ define(["require", "exports"], function (require, exports) { Foo = __decorate([ decorator ], Foo); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -45,5 +46,6 @@ define(["require", "exports"], function (require, exports) { default_1 = __decorate([ decorator ], default_1); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js index 32e053789ce..ab518d73cb9 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js @@ -27,6 +27,7 @@ let Foo = class { Foo = __decorate([ decorator ], Foo); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; //// [b.js] "use strict"; @@ -42,4 +43,5 @@ let default_1 = class { default_1 = __decorate([ decorator ], default_1); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js index d65bc33575b..f8cb770f1d2 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js @@ -35,6 +35,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, Foo = __decorate([ decorator ], Foo); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -59,5 +60,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, default_1 = __decorate([ decorator ], default_1); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/defaultExportsGetExportedAmd.js b/tests/baselines/reference/defaultExportsGetExportedAmd.js index fd9927250cb..fc0385254c0 100644 --- a/tests/baselines/reference/defaultExportsGetExportedAmd.js +++ b/tests/baselines/reference/defaultExportsGetExportedAmd.js @@ -12,11 +12,13 @@ define(["require", "exports"], function (require, exports) { "use strict"; class Foo { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; function foo() { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; }); diff --git a/tests/baselines/reference/defaultExportsGetExportedCommonjs.js b/tests/baselines/reference/defaultExportsGetExportedCommonjs.js index 8b97cff5d38..1290404099d 100644 --- a/tests/baselines/reference/defaultExportsGetExportedCommonjs.js +++ b/tests/baselines/reference/defaultExportsGetExportedCommonjs.js @@ -11,8 +11,10 @@ export default function foo() {} "use strict"; class Foo { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; //// [b.js] "use strict"; function foo() { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; diff --git a/tests/baselines/reference/defaultExportsGetExportedUmd.js b/tests/baselines/reference/defaultExportsGetExportedUmd.js index 2d442e42061..754c5b00ac8 100644 --- a/tests/baselines/reference/defaultExportsGetExportedUmd.js +++ b/tests/baselines/reference/defaultExportsGetExportedUmd.js @@ -19,6 +19,7 @@ export default function foo() {} "use strict"; class Foo { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -32,5 +33,6 @@ export default function foo() {} })(function (require, exports) { "use strict"; function foo() { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; }); diff --git a/tests/baselines/reference/duplicateExportAssignments.errors.txt b/tests/baselines/reference/duplicateExportAssignments.errors.txt index 47a97f9d8af..a76513133b9 100644 --- a/tests/baselines/reference/duplicateExportAssignments.errors.txt +++ b/tests/baselines/reference/duplicateExportAssignments.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(3,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(3,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/externalModules/foo1.ts(3,1): error TS2300: Duplicate identifier 'export='. tests/cases/conformance/externalModules/foo1.ts(4,1): error TS2300: Duplicate identifier 'export='. tests/cases/conformance/externalModules/foo2.ts(3,1): error TS2300: Duplicate identifier 'export='. @@ -17,7 +17,7 @@ tests/cases/conformance/externalModules/foo5.ts(6,1): error TS2300: Duplicate id var y = 20; export = x; ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'export='. export = y; diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index bd6d535d88e..0a49c71e29b 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected. tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected. tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'. -tests/cases/compiler/duplicateLocalVariable1.ts(12,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/duplicateLocalVariable1.ts(12,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. @@ -25,7 +25,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequen export class TestCase { ~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { } } diff --git a/tests/baselines/reference/enumExportMergingES6.js b/tests/baselines/reference/enumExportMergingES6.js new file mode 100644 index 00000000000..7a5ea5f2718 --- /dev/null +++ b/tests/baselines/reference/enumExportMergingES6.js @@ -0,0 +1,23 @@ +//// [enumExportMergingES6.ts] +export enum Animals { + Cat = 1 +} +export enum Animals { + Dog = 2 +} +export enum Animals { + CatDog = Cat | Dog +} + + +//// [enumExportMergingES6.js] +export var Animals; +(function (Animals) { + Animals[Animals["Cat"] = 1] = "Cat"; +})(Animals || (Animals = {})); +(function (Animals) { + Animals[Animals["Dog"] = 2] = "Dog"; +})(Animals || (Animals = {})); +(function (Animals) { + Animals[Animals["CatDog"] = 3] = "CatDog"; +})(Animals || (Animals = {})); diff --git a/tests/baselines/reference/enumExportMergingES6.symbols b/tests/baselines/reference/enumExportMergingES6.symbols new file mode 100644 index 00000000000..66fc31c5e18 --- /dev/null +++ b/tests/baselines/reference/enumExportMergingES6.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/enums/enumExportMergingES6.ts === +export enum Animals { +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) + + Cat = 1 +>Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21)) +} +export enum Animals { +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) + + Dog = 2 +>Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21)) +} +export enum Animals { +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) + + CatDog = Cat | Dog +>CatDog : Symbol(Animals.CatDog, Decl(enumExportMergingES6.ts, 6, 21)) +>Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21)) +>Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21)) +} + diff --git a/tests/baselines/reference/enumExportMergingES6.types b/tests/baselines/reference/enumExportMergingES6.types new file mode 100644 index 00000000000..da2fc22cb8a --- /dev/null +++ b/tests/baselines/reference/enumExportMergingES6.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/enums/enumExportMergingES6.ts === +export enum Animals { +>Animals : Animals + + Cat = 1 +>Cat : Animals +>1 : number +} +export enum Animals { +>Animals : Animals + + Dog = 2 +>Dog : Animals +>2 : number +} +export enum Animals { +>Animals : Animals + + CatDog = Cat | Dog +>CatDog : Animals +>Cat | Dog : number +>Cat : Animals +>Dog : Animals +} + diff --git a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt index faf27a85206..90f10087194 100644 --- a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt +++ b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts (1 errors) ==== export class A ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. { constructor () { diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 3d9c1c95fcd..1ad4222d222 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -290,7 +290,6 @@ exports.a8 = function_module_2.a; var class_module_2 = require("class-module"); exports.a0 = class_module_2.a; // export-star -__export(require("interface")); __export(require("variable")); __export(require("interface-variable")); __export(require("module")); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 51fc7bf6897..d7dfe29208d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -27,6 +27,7 @@ var x1: number = m; exports.a = 10; exports.x = exports.a; exports.m = exports.a; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] "use strict"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt index 76c424a74d4..97c66a17960 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt @@ -1,15 +1,21 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(2,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(3,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(3,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(4,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(5,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(5,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(6,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(7,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(7,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. tests/cases/compiler/client.ts(7,37): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. +tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(9,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. +tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. +tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'x1'. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -17,23 +23,29 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil var a = 10; export default a; -==== tests/cases/compiler/client.ts (12 errors) ==== +==== tests/cases/compiler/client.ts (18 errors) ==== export import defaultBinding1, { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = defaultBinding1; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding2, { a } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding2; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding3, { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding3; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding4, { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. @@ -42,16 +54,22 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding4; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding5, { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. export var x1: number = defaultBinding5; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding6, { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. export var x1: number = defaultBinding6; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt index 83f91787b87..859fe59b47f 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt @@ -1,9 +1,15 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(5,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(7,12): error TS2323: Cannot redeclare exported variable 'x1'. +tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'x1'. tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'x1'. ==== tests/cases/compiler/server.ts (0 errors) ==== @@ -13,7 +19,7 @@ tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot export var m = a; export default {}; -==== tests/cases/compiler/client.ts (6 errors) ==== +==== tests/cases/compiler/client.ts (12 errors) ==== export import defaultBinding1, { } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. @@ -21,21 +27,33 @@ tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = a; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding3, { a as b } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = b; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding4, { x, a as y } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = x; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export var x1: number = y; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding5, { x as z, } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = z; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. export import defaultBinding6, { m, } from "server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = m; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt index a5a4301683e..3b2d6b0cbd0 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt @@ -1,11 +1,21 @@ tests/cases/compiler/client.ts(1,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(2,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(3,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(4,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(5,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(6,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(7,12): error TS2323: Cannot redeclare exported variable 'xxxx'. +tests/cases/compiler/client.ts(8,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(9,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(10,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(11,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(12,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(13,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(14,12): error TS2323: Cannot redeclare exported variable 'xxxx'. +tests/cases/compiler/client.ts(15,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(16,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/compiler/client.ts(17,12): error TS2323: Cannot redeclare exported variable 'xxxx'. +tests/cases/compiler/client.ts(18,12): error TS2323: Cannot redeclare exported variable 'xxxx'. tests/cases/compiler/client.ts(19,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(21,1): error TS1191: An import declaration cannot have modifiers. tests/cases/compiler/client.ts(25,1): error TS1191: An import declaration cannot have modifiers. @@ -23,7 +33,7 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot export var z2 = 10; export var aaaa = 10; -==== tests/cases/compiler/client.ts (12 errors) ==== +==== tests/cases/compiler/client.ts (22 errors) ==== export import { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. @@ -31,33 +41,53 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = b; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = x; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export var xxxx = y; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = z; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = m; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { a1, x1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a1; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export var xxxx = x1; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { a1 as a11, x1 as x11 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a11; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export var xxxx = x11; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'xxxx'. export import { z1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. diff --git a/tests/baselines/reference/es6ModuleInternalNamedImports2.js b/tests/baselines/reference/es6ModuleInternalNamedImports2.js index 9dee8153e56..98226a1e52b 100644 --- a/tests/baselines/reference/es6ModuleInternalNamedImports2.js +++ b/tests/baselines/reference/es6ModuleInternalNamedImports2.js @@ -58,7 +58,6 @@ export var M; // alias M.M_A = M_M; })(M || (M = {})); -export var M; (function (M) { // Reexports export { M_V as v }; diff --git a/tests/baselines/reference/exportAssignDottedName.errors.txt b/tests/baselines/reference/exportAssignDottedName.errors.txt index 39a0a2577ee..3ed4f3c888f 100644 --- a/tests/baselines/reference/exportAssignDottedName.errors.txt +++ b/tests/baselines/reference/exportAssignDottedName.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ==== @@ -8,7 +8,7 @@ tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot comp ==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ==== export function x(){ ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. return true; } \ No newline at end of file diff --git a/tests/baselines/reference/exportAssignImportedIdentifier.errors.txt b/tests/baselines/reference/exportAssignImportedIdentifier.errors.txt index 753bc567619..167c0baca3d 100644 --- a/tests/baselines/reference/exportAssignImportedIdentifier.errors.txt +++ b/tests/baselines/reference/exportAssignImportedIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo3.ts (0 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/externalModules/foo1.ts(1,17): error TS1148: Cannot comp ==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ==== export function x(){ ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. return true; } diff --git a/tests/baselines/reference/exportAssignNonIdentifier.errors.txt b/tests/baselines/reference/exportAssignNonIdentifier.errors.txt index c3d58c9b36f..9e8bfa8d747 100644 --- a/tests/baselines/reference/exportAssignNonIdentifier.errors.txt +++ b/tests/baselines/reference/exportAssignNonIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/externalModules/foo6.ts(1,14): error TS1109: Expression expected. @@ -6,7 +6,7 @@ tests/cases/conformance/externalModules/foo6.ts(1,14): error TS1109: Expression var x = 10; export = typeof x; // Ok ~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ==== export = "sausages"; // Ok diff --git a/tests/baselines/reference/exportAssignTypes.errors.txt b/tests/baselines/reference/exportAssignTypes.errors.txt index ba5538777c5..9d39f48fec8 100644 --- a/tests/baselines/reference/exportAssignTypes.errors.txt +++ b/tests/baselines/reference/exportAssignTypes.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/expString.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/expString.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/consumer.ts (0 errors) ==== @@ -27,7 +27,7 @@ tests/cases/conformance/externalModules/expString.ts(2,1): error TS1148: Cannot var x = "test"; export = x; ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/expNumber.ts (0 errors) ==== var x = 42; diff --git a/tests/baselines/reference/exportDeclarationInInternalModule.js b/tests/baselines/reference/exportDeclarationInInternalModule.js index 4a1ee9b739f..39c8123a1e7 100644 --- a/tests/baselines/reference/exportDeclarationInInternalModule.js +++ b/tests/baselines/reference/exportDeclarationInInternalModule.js @@ -53,7 +53,7 @@ var Bbb; return SomeType; })(); Bbb.SomeType = SomeType; - __export(require()); // this line causes the nullref + // this line causes the nullref })(Bbb || (Bbb = {})); var a; diff --git a/tests/baselines/reference/exportDeclaredModule.errors.txt b/tests/baselines/reference/exportDeclaredModule.errors.txt index 47ee543e0c0..c235d4c448f 100644 --- a/tests/baselines/reference/exportDeclaredModule.errors.txt +++ b/tests/baselines/reference/exportDeclaredModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(6,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(6,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ==== @@ -12,5 +12,5 @@ tests/cases/conformance/externalModules/foo1.ts(6,1): error TS1148: Cannot compi } export = M1; ~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. \ No newline at end of file diff --git a/tests/baselines/reference/exportNonVisibleType.errors.txt b/tests/baselines/reference/exportNonVisibleType.errors.txt index 04c174b4994..bc4dac4ca58 100644 --- a/tests/baselines/reference/exportNonVisibleType.errors.txt +++ b/tests/baselines/reference/exportNonVisibleType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo1.ts(7,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/foo1.ts(7,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo1.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/externalModules/foo1.ts(7,1): error TS1148: Cannot compi var x: I1 = {a: "test", b: 42}; export = x; // Should fail, I1 not exported. ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/foo2.ts (0 errors) ==== diff --git a/tests/baselines/reference/exportStar-amd.errors.txt b/tests/baselines/reference/exportStar-amd.errors.txt index adab0516103..edd5c0d51bd 100644 --- a/tests/baselines/reference/exportStar-amd.errors.txt +++ b/tests/baselines/reference/exportStar-amd.errors.txt @@ -1,4 +1,6 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export. +tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. +tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. ==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ==== @@ -16,10 +18,14 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/c var z = "z"; export { x, y, z }; -==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ==== +==== tests/cases/conformance/es6/modules/t4.ts (2 errors) ==== export * from "./t1"; export * from "./t2"; export * from "./t3"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. ==== tests/cases/conformance/es6/modules/main.ts (1 errors) ==== import hello, { x, y, z, foo } from "./t4"; diff --git a/tests/baselines/reference/exportStar.errors.txt b/tests/baselines/reference/exportStar.errors.txt index adab0516103..edd5c0d51bd 100644 --- a/tests/baselines/reference/exportStar.errors.txt +++ b/tests/baselines/reference/exportStar.errors.txt @@ -1,4 +1,6 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export. +tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. +tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. ==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ==== @@ -16,10 +18,14 @@ tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/c var z = "z"; export { x, y, z }; -==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ==== +==== tests/cases/conformance/es6/modules/t4.ts (2 errors) ==== export * from "./t1"; export * from "./t2"; export * from "./t3"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. ==== tests/cases/conformance/es6/modules/main.ts (1 errors) ==== import hello, { x, y, z, foo } from "./t4"; diff --git a/tests/baselines/reference/exportStarForValues.js b/tests/baselines/reference/exportStarForValues.js new file mode 100644 index 00000000000..dd432ecc1d3 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/exportStarForValues.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +var x; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x; +}); diff --git a/tests/baselines/reference/exportStarForValues.symbols b/tests/baselines/reference/exportStarForValues.symbols new file mode 100644 index 00000000000..6694afecdc6 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x; +>x : Symbol(x, Decl(file2.ts, 1, 3)) + diff --git a/tests/baselines/reference/exportStarForValues.types b/tests/baselines/reference/exportStarForValues.types new file mode 100644 index 00000000000..b326a7e7ff6 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x; +>x : any + diff --git a/tests/baselines/reference/exportStarForValues10.js b/tests/baselines/reference/exportStarForValues10.js new file mode 100644 index 00000000000..dca5dad9b7a --- /dev/null +++ b/tests/baselines/reference/exportStarForValues10.js @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/exportStarForValues10.ts] //// + +//// [file0.ts] + +export var v = 1; + +//// [file1.ts] +export interface Foo { x } + +//// [file2.ts] +export * from "file0"; +export * from "file1"; +var x = 1; + +//// [file0.js] +System.register([], function(exports_1) { + "use strict"; + var v; + return { + setters:[], + execute: function() { + exports_1("v", v = 1); + } + } +}); +//// [file1.js] +System.register([], function(exports_1) { + "use strict"; + return { + setters:[], + execute: function() { + } + } +}); +//// [file2.js] +System.register(["file0"], function(exports_1) { + "use strict"; + var x; + function exportStar_1(m) { + var exports = {}; + for(var n in m) { + if (n !== "default") exports[n] = m[n]; + } + exports_1(exports); + } + return { + setters:[ + function (file0_1_1) { + exportStar_1(file0_1_1); + }], + execute: function() { + x = 1; + } + } +}); diff --git a/tests/baselines/reference/exportStarForValues10.symbols b/tests/baselines/reference/exportStarForValues10.symbols new file mode 100644 index 00000000000..2de35864d27 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues10.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file0.ts === + +export var v = 1; +>v : Symbol(v, Decl(file0.ts, 1, 10)) + +=== tests/cases/compiler/file1.ts === +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 0, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file0"; +export * from "file1"; +var x = 1; +>x : Symbol(x, Decl(file2.ts, 2, 3)) + diff --git a/tests/baselines/reference/exportStarForValues10.types b/tests/baselines/reference/exportStarForValues10.types new file mode 100644 index 00000000000..370f02318c1 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues10.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/file0.ts === + +export var v = 1; +>v : number +>1 : number + +=== tests/cases/compiler/file1.ts === +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file0"; +export * from "file1"; +var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues2.js b/tests/baselines/reference/exportStarForValues2.js new file mode 100644 index 00000000000..e45d5bdd3ba --- /dev/null +++ b/tests/baselines/reference/exportStarForValues2.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/exportStarForValues2.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +var x = 1; + +//// [file3.ts] +export * from "file2" +var x = 1; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); +//// [file3.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues2.symbols b/tests/baselines/reference/exportStarForValues2.symbols new file mode 100644 index 00000000000..0fa739f5431 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x = 1; +>x : Symbol(x, Decl(file2.ts, 1, 3)) + +=== tests/cases/compiler/file3.ts === +export * from "file2" +var x = 1; +>x : Symbol(x, Decl(file3.ts, 1, 3)) + diff --git a/tests/baselines/reference/exportStarForValues2.types b/tests/baselines/reference/exportStarForValues2.types new file mode 100644 index 00000000000..f1de53bd7cf --- /dev/null +++ b/tests/baselines/reference/exportStarForValues2.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export * from "file2" +var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues3.js b/tests/baselines/reference/exportStarForValues3.js new file mode 100644 index 00000000000..9efe5ccf8e5 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues3.js @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/exportStarForValues3.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export interface A { x } +export * from "file1" +var x = 1; + +//// [file3.ts] +export interface B { x } +export * from "file1" +var x = 1; + +//// [file4.ts] +export interface C { x } +export * from "file2" +export * from "file3" +var x = 1; + +//// [file5.ts] +export * from "file4" +var x = 1; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); +//// [file3.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); +//// [file4.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); +//// [file5.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues3.symbols b/tests/baselines/reference/exportStarForValues3.symbols new file mode 100644 index 00000000000..a79aeb36588 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues3.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>x : Symbol(x, Decl(file2.ts, 0, 20)) + +export * from "file1" +var x = 1; +>x : Symbol(x, Decl(file2.ts, 2, 3)) + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : Symbol(B, Decl(file3.ts, 0, 0)) +>x : Symbol(x, Decl(file3.ts, 0, 20)) + +export * from "file1" +var x = 1; +>x : Symbol(x, Decl(file3.ts, 2, 3)) + +=== tests/cases/compiler/file4.ts === +export interface C { x } +>C : Symbol(C, Decl(file4.ts, 0, 0)) +>x : Symbol(x, Decl(file4.ts, 0, 20)) + +export * from "file2" +export * from "file3" +var x = 1; +>x : Symbol(x, Decl(file4.ts, 3, 3)) + +=== tests/cases/compiler/file5.ts === +export * from "file4" +var x = 1; +>x : Symbol(x, Decl(file5.ts, 1, 3)) + diff --git a/tests/baselines/reference/exportStarForValues3.types b/tests/baselines/reference/exportStarForValues3.types new file mode 100644 index 00000000000..d2ee5ebb1d4 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues3.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : A +>x : any + +export * from "file1" +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : B +>x : any + +export * from "file1" +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file4.ts === +export interface C { x } +>C : C +>x : any + +export * from "file2" +export * from "file3" +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file5.ts === +export * from "file4" +var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues4.js b/tests/baselines/reference/exportStarForValues4.js new file mode 100644 index 00000000000..34b13bb00f3 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues4.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/exportStarForValues4.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export interface A { x } +export * from "file1" +export * from "file3" +var x = 1; + +//// [file3.ts] +export interface B { x } +export * from "file2" +var x = 1; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file3.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues4.symbols b/tests/baselines/reference/exportStarForValues4.symbols new file mode 100644 index 00000000000..465d6ed3237 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues4.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>x : Symbol(x, Decl(file2.ts, 0, 20)) + +export * from "file1" +export * from "file3" +var x = 1; +>x : Symbol(x, Decl(file2.ts, 3, 3)) + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : Symbol(B, Decl(file3.ts, 0, 0)) +>x : Symbol(x, Decl(file3.ts, 0, 20)) + +export * from "file2" +var x = 1; +>x : Symbol(x, Decl(file3.ts, 2, 3)) + diff --git a/tests/baselines/reference/exportStarForValues4.types b/tests/baselines/reference/exportStarForValues4.types new file mode 100644 index 00000000000..b381f9461e8 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues4.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : A +>x : any + +export * from "file1" +export * from "file3" +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : B +>x : any + +export * from "file2" +var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues5.js b/tests/baselines/reference/exportStarForValues5.js new file mode 100644 index 00000000000..dc4d4c8b68e --- /dev/null +++ b/tests/baselines/reference/exportStarForValues5.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/exportStarForValues5.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +export var x; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); diff --git a/tests/baselines/reference/exportStarForValues5.symbols b/tests/baselines/reference/exportStarForValues5.symbols new file mode 100644 index 00000000000..a2950afa73f --- /dev/null +++ b/tests/baselines/reference/exportStarForValues5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x; +>x : Symbol(x, Decl(file2.ts, 1, 10)) + diff --git a/tests/baselines/reference/exportStarForValues5.types b/tests/baselines/reference/exportStarForValues5.types new file mode 100644 index 00000000000..9edfc88289a --- /dev/null +++ b/tests/baselines/reference/exportStarForValues5.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x; +>x : any + diff --git a/tests/baselines/reference/exportStarForValues6.js b/tests/baselines/reference/exportStarForValues6.js new file mode 100644 index 00000000000..69357d87ee0 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues6.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/exportStarForValues6.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +export var x = 1; + +//// [file1.js] +System.register([], function(exports_1) { + "use strict"; + return { + setters:[], + execute: function() { + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + "use strict"; + var x; + return { + setters:[], + execute: function() { + exports_1("x", x = 1); + } + } +}); diff --git a/tests/baselines/reference/exportStarForValues6.symbols b/tests/baselines/reference/exportStarForValues6.symbols new file mode 100644 index 00000000000..c57baf301dd --- /dev/null +++ b/tests/baselines/reference/exportStarForValues6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x = 1; +>x : Symbol(x, Decl(file2.ts, 1, 10)) + diff --git a/tests/baselines/reference/exportStarForValues6.types b/tests/baselines/reference/exportStarForValues6.types new file mode 100644 index 00000000000..4fe38a45d02 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues6.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js new file mode 100644 index 00000000000..39a152fdc89 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues7.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/exportStarForValues7.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +export var x = 1; + +//// [file3.ts] +export * from "file2" +export var x = 1; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + exports.x = 1; +}); +//// [file3.js] +define(["require", "exports", "file2"], function (require, exports, file2_1) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(file2_1); + exports.x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues7.symbols b/tests/baselines/reference/exportStarForValues7.symbols new file mode 100644 index 00000000000..b59f2890047 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues7.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x = 1; +>x : Symbol(x, Decl(file2.ts, 1, 10)) + +=== tests/cases/compiler/file3.ts === +export * from "file2" +export var x = 1; +>x : Symbol(x, Decl(file3.ts, 1, 10)) + diff --git a/tests/baselines/reference/exportStarForValues7.types b/tests/baselines/reference/exportStarForValues7.types new file mode 100644 index 00000000000..d37661320d6 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues7.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +export var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export * from "file2" +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js new file mode 100644 index 00000000000..f8e7678a40c --- /dev/null +++ b/tests/baselines/reference/exportStarForValues8.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/exportStarForValues8.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export interface A { x } +export * from "file1" +export var x = 1; + +//// [file3.ts] +export interface B { x } +export * from "file1" +export var x = 1; + +//// [file4.ts] +export interface C { x } +export * from "file2" +export * from "file3" +export var x = 1; + +//// [file5.ts] +export * from "file4" +export var x = 1; + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + exports.x = 1; +}); +//// [file3.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + exports.x = 1; +}); +//// [file4.js] +define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(file2_1); + __export(file3_1); + exports.x = 1; +}); +//// [file5.js] +define(["require", "exports", "file4"], function (require, exports, file4_1) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(file4_1); + exports.x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues8.symbols b/tests/baselines/reference/exportStarForValues8.symbols new file mode 100644 index 00000000000..be958ecabe8 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues8.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>x : Symbol(x, Decl(file2.ts, 0, 20)) + +export * from "file1" +export var x = 1; +>x : Symbol(x, Decl(file2.ts, 2, 10)) + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : Symbol(B, Decl(file3.ts, 0, 0)) +>x : Symbol(x, Decl(file3.ts, 0, 20)) + +export * from "file1" +export var x = 1; +>x : Symbol(x, Decl(file3.ts, 2, 10)) + +=== tests/cases/compiler/file4.ts === +export interface C { x } +>C : Symbol(C, Decl(file4.ts, 0, 0)) +>x : Symbol(x, Decl(file4.ts, 0, 20)) + +export * from "file2" +export * from "file3" +export var x = 1; +>x : Symbol(x, Decl(file4.ts, 3, 10)) + +=== tests/cases/compiler/file5.ts === +export * from "file4" +export var x = 1; +>x : Symbol(x, Decl(file5.ts, 1, 10)) + diff --git a/tests/baselines/reference/exportStarForValues8.types b/tests/baselines/reference/exportStarForValues8.types new file mode 100644 index 00000000000..9cc1484eecb --- /dev/null +++ b/tests/baselines/reference/exportStarForValues8.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : A +>x : any + +export * from "file1" +export var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : B +>x : any + +export * from "file1" +export var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file4.ts === +export interface C { x } +>C : C +>x : any + +export * from "file2" +export * from "file3" +export var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file5.ts === +export * from "file4" +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js new file mode 100644 index 00000000000..e057e4d4027 --- /dev/null +++ b/tests/baselines/reference/exportStarForValues9.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/exportStarForValues9.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export interface A { x } +export * from "file1" +export * from "file3" +export var x = 1; + +//// [file3.ts] +export interface B { x } +export * from "file2" +export var x = 1; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [file3.js] +define(["require", "exports", "file2"], function (require, exports, file2_1) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(file2_1); + exports.x = 1; +}); +//// [file2.js] +define(["require", "exports", "file3"], function (require, exports, file3_1) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(file3_1); + exports.x = 1; +}); diff --git a/tests/baselines/reference/exportStarForValues9.symbols b/tests/baselines/reference/exportStarForValues9.symbols new file mode 100644 index 00000000000..0684c9e7b7c --- /dev/null +++ b/tests/baselines/reference/exportStarForValues9.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>x : Symbol(x, Decl(file2.ts, 0, 20)) + +export * from "file1" +export * from "file3" +export var x = 1; +>x : Symbol(x, Decl(file2.ts, 3, 10)) + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : Symbol(B, Decl(file3.ts, 0, 0)) +>x : Symbol(x, Decl(file3.ts, 0, 20)) + +export * from "file2" +export var x = 1; +>x : Symbol(x, Decl(file3.ts, 2, 10)) + diff --git a/tests/baselines/reference/exportStarForValues9.types b/tests/baselines/reference/exportStarForValues9.types new file mode 100644 index 00000000000..3cf250ec50b --- /dev/null +++ b/tests/baselines/reference/exportStarForValues9.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export interface A { x } +>A : A +>x : any + +export * from "file1" +export * from "file3" +export var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/file3.ts === +export interface B { x } +>B : B +>x : any + +export * from "file2" +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportStarForValuesInSystem.js b/tests/baselines/reference/exportStarForValuesInSystem.js new file mode 100644 index 00000000000..a33465f7e2e --- /dev/null +++ b/tests/baselines/reference/exportStarForValuesInSystem.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/exportStarForValuesInSystem.ts] //// + +//// [file1.ts] + +export interface Foo { x } + +//// [file2.ts] +export * from "file1" +var x = 1; + +//// [file1.js] +System.register([], function(exports_1) { + "use strict"; + return { + setters:[], + execute: function() { + } + } +}); +//// [file2.js] +System.register([], function(exports_1) { + "use strict"; + var x; + return { + setters:[], + execute: function() { + x = 1; + } + } +}); diff --git a/tests/baselines/reference/exportStarForValuesInSystem.symbols b/tests/baselines/reference/exportStarForValuesInSystem.symbols new file mode 100644 index 00000000000..c9ef9830c60 --- /dev/null +++ b/tests/baselines/reference/exportStarForValuesInSystem.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) +>x : Symbol(x, Decl(file1.ts, 1, 22)) + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x = 1; +>x : Symbol(x, Decl(file2.ts, 1, 3)) + diff --git a/tests/baselines/reference/exportStarForValuesInSystem.types b/tests/baselines/reference/exportStarForValuesInSystem.types new file mode 100644 index 00000000000..36d07741e10 --- /dev/null +++ b/tests/baselines/reference/exportStarForValuesInSystem.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === + +export interface Foo { x } +>Foo : Foo +>x : any + +=== tests/cases/compiler/file2.ts === +export * from "file1" +var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index 3d3278b4462..39c6583e935 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -41,6 +41,7 @@ export { a, b, c, d, e1, e2, f1, f2 }; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.js b/tests/baselines/reference/extendConstructSignatureInInterface.js new file mode 100644 index 00000000000..c440872a566 --- /dev/null +++ b/tests/baselines/reference/extendConstructSignatureInInterface.js @@ -0,0 +1,27 @@ +//// [extendConstructSignatureInInterface.ts] +interface C { + new(x: number): C; +} + +var CStatic: C; +class E extends CStatic { +} + +var e: E = new E(1); + + +//// [extendConstructSignatureInInterface.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var CStatic; +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + return E; +})(CStatic); +var e = new E(1); diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.symbols b/tests/baselines/reference/extendConstructSignatureInInterface.symbols new file mode 100644 index 00000000000..df966bc9fcc --- /dev/null +++ b/tests/baselines/reference/extendConstructSignatureInInterface.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/extendConstructSignatureInInterface.ts === +interface C { +>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0)) + + new(x: number): C; +>x : Symbol(x, Decl(extendConstructSignatureInInterface.ts, 1, 8)) +>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0)) +} + +var CStatic: C; +>CStatic : Symbol(CStatic, Decl(extendConstructSignatureInInterface.ts, 4, 3)) +>C : Symbol(C, Decl(extendConstructSignatureInInterface.ts, 0, 0)) + +class E extends CStatic { +>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15)) +>CStatic : Symbol(CStatic, Decl(extendConstructSignatureInInterface.ts, 4, 3)) +} + +var e: E = new E(1); +>e : Symbol(e, Decl(extendConstructSignatureInInterface.ts, 8, 3)) +>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15)) +>E : Symbol(E, Decl(extendConstructSignatureInInterface.ts, 4, 15)) + diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.types b/tests/baselines/reference/extendConstructSignatureInInterface.types new file mode 100644 index 00000000000..363107b2e54 --- /dev/null +++ b/tests/baselines/reference/extendConstructSignatureInInterface.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/extendConstructSignatureInInterface.ts === +interface C { +>C : C + + new(x: number): C; +>x : number +>C : C +} + +var CStatic: C; +>CStatic : C +>C : C + +class E extends CStatic { +>E : E +>CStatic : C +} + +var e: E = new E(1); +>e : E +>E : E +>new E(1) : E +>E : typeof E +>1 : number + diff --git a/tests/baselines/reference/externalModuleWithoutCompilerFlag1.errors.txt b/tests/baselines/reference/externalModuleWithoutCompilerFlag1.errors.txt index 64874c767ee..e2ffd4ec372 100644 --- a/tests/baselines/reference/externalModuleWithoutCompilerFlag1.errors.txt +++ b/tests/baselines/reference/externalModuleWithoutCompilerFlag1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts(3,17): error TS1148: // Not on line 0 because we want to verify the error is placed in the appropriate location. export module M { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } \ No newline at end of file diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index 871368da9fe..4f78636d08c 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -3,15 +3,21 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(23,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'. + Type 'Function' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(24,15): error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'. Types of parameters 'x' and 'x' are incompatible. Type 'string[]' is not assignable to type 'string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(25,15): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'. + Type 'typeof C' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(26,15): error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'. + Type 'new (x: string) => string' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(28,16): error TS2345: Argument of type '(x: U, y: V) => U' is not assignable to parameter of type '(x: string) => string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(29,16): error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'. + Type 'typeof C2' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(30,16): error TS2345: Argument of type 'new (x: T) => T' is not assignable to parameter of type '(x: string) => string'. + Type 'new (x: T) => T' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(34,16): error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'. + Type 'F2' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(36,38): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'. Type '() => void' is not assignable to type '(x: string) => string'. @@ -51,6 +57,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain var r = foo2(new Function()); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'Function' provides no match for the signature '(x: string): string' var r2 = foo2((x: string[]) => x); ~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'. @@ -59,9 +66,11 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain var r6 = foo2(C); ~ !!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'typeof C' provides no match for the signature '(x: string): string' var r7 = foo2(b); ~ !!! error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'new (x: string) => string' provides no match for the signature '(x: string): string' var r8 = foo2((x: U) => x); // no error expected var r11 = foo2((x: U, y: V) => x); ~~~~~~~~~~~~~~~~~~~~~~~ @@ -69,15 +78,18 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain var r13 = foo2(C2); ~~ !!! error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'typeof C2' provides no match for the signature '(x: string): string' var r14 = foo2(b2); ~~ !!! error TS2345: Argument of type 'new (x: T) => T' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'new (x: T) => T' provides no match for the signature '(x: string): string' interface F2 extends Function { foo: string; } var f2: F2; var r16 = foo2(f2); ~~ !!! error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'. +!!! error TS2345: Type 'F2' provides no match for the signature '(x: string): string' function fff(x: T, y: U) { ~~~~~~~~~~~ diff --git a/tests/baselines/reference/generatorTypeCheck31.errors.txt b/tests/baselines/reference/generatorTypeCheck31.errors.txt index a0336b464a4..3f54edacb2a 100644 --- a/tests/baselines/reference/generatorTypeCheck31.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck31.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'. + Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>' ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts (1 errors) ==== @@ -10,4 +11,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): erro } () ~~~~~~~~ !!! error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'. +!!! error TS2322: Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>' } \ No newline at end of file diff --git a/tests/baselines/reference/genericArrayExtenstions.errors.txt b/tests/baselines/reference/genericArrayExtenstions.errors.txt index f3035497910..7b332366fed 100644 --- a/tests/baselines/reference/genericArrayExtenstions.errors.txt +++ b/tests/baselines/reference/genericArrayExtenstions.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericArrayExtenstions.ts(1,22): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/genericArrayExtenstions.ts(1,22): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/genericArrayExtenstions.ts(1,22): error TS2420: Class 'ObservableArray' incorrectly implements interface 'T[]'. Property 'length' is missing in type 'ObservableArray'. @@ -6,7 +6,7 @@ tests/cases/compiler/genericArrayExtenstions.ts(1,22): error TS2420: Class 'Obse ==== tests/cases/compiler/genericArrayExtenstions.ts (2 errors) ==== export declare class ObservableArray implements Array { // MS.Entertainment.ObservableArray ~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~~~~~ !!! error TS2420: Class 'ObservableArray' incorrectly implements interface 'T[]'. !!! error TS2420: Property 'length' is missing in type 'ObservableArray'. diff --git a/tests/baselines/reference/genericSignatureIdentity.js b/tests/baselines/reference/genericSignatureIdentity.js new file mode 100644 index 00000000000..9a51a61edbd --- /dev/null +++ b/tests/baselines/reference/genericSignatureIdentity.js @@ -0,0 +1,32 @@ +//// [genericSignatureIdentity.ts] +// This test is here to remind us of our current limits of type identity checking. +// Ideally all of the below declarations would be considered different (and thus errors) +// but they aren't because we erase type parameters to type any and don't check that +// constraints are identical. + +var x: { + (x: T): T; +}; + +var x: { + (x: T): T; +}; + +var x: { + (x: T): T; +}; + +var x: { + (x: any): any; +}; + + +//// [genericSignatureIdentity.js] +// This test is here to remind us of our current limits of type identity checking. +// Ideally all of the below declarations would be considered different (and thus errors) +// but they aren't because we erase type parameters to type any and don't check that +// constraints are identical. +var x; +var x; +var x; +var x; diff --git a/tests/baselines/reference/genericSignatureIdentity.symbols b/tests/baselines/reference/genericSignatureIdentity.symbols new file mode 100644 index 00000000000..afd12ec266a --- /dev/null +++ b/tests/baselines/reference/genericSignatureIdentity.symbols @@ -0,0 +1,49 @@ +=== tests/cases/compiler/genericSignatureIdentity.ts === +// This test is here to remind us of our current limits of type identity checking. +// Ideally all of the below declarations would be considered different (and thus errors) +// but they aren't because we erase type parameters to type any and don't check that +// constraints are identical. + +var x: { +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3)) + + (x: T): T; +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5)) +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 6, 21)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 6, 5)) + +}; + +var x: { +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3)) + + (x: T): T; +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5)) +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 10, 23)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 10, 5)) + +}; + +var x: { +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3)) + + (x: T): T; +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5)) +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 14, 8)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5)) +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 14, 5)) + +}; + +var x: { +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 5, 3), Decl(genericSignatureIdentity.ts, 9, 3), Decl(genericSignatureIdentity.ts, 13, 3), Decl(genericSignatureIdentity.ts, 17, 3)) + + (x: any): any; +>T : Symbol(T, Decl(genericSignatureIdentity.ts, 18, 5)) +>x : Symbol(x, Decl(genericSignatureIdentity.ts, 18, 8)) + +}; + diff --git a/tests/baselines/reference/genericSignatureIdentity.types b/tests/baselines/reference/genericSignatureIdentity.types new file mode 100644 index 00000000000..9385718a361 --- /dev/null +++ b/tests/baselines/reference/genericSignatureIdentity.types @@ -0,0 +1,49 @@ +=== tests/cases/compiler/genericSignatureIdentity.ts === +// This test is here to remind us of our current limits of type identity checking. +// Ideally all of the below declarations would be considered different (and thus errors) +// but they aren't because we erase type parameters to type any and don't check that +// constraints are identical. + +var x: { +>x : (x: T) => T + + (x: T): T; +>T : T +>Date : Date +>x : T +>T : T +>T : T + +}; + +var x: { +>x : (x: T) => T + + (x: T): T; +>T : T +>x : T +>T : T +>T : T + +}; + +var x: { +>x : (x: T) => T + + (x: T): T; +>T : T +>x : T +>T : T +>T : T + +}; + +var x: { +>x : (x: T) => T + + (x: any): any; +>T : T +>x : any + +}; + diff --git a/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.errors.txt b/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.errors.txt index d12854648e5..56d1549f853 100644 --- a/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.errors.txt +++ b/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule_file0.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule_file0.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule_file1.ts (0 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule_file0.ts( ==== tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule_file0.ts (1 errors) ==== export module m { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export function foo() { } } \ No newline at end of file diff --git a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt index 74f532d0c1e..34cfe02305f 100644 --- a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt +++ b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,20): error TS2307: Cannot find module 'externalModule'. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): error TS2307: Cannot find module 'externalModule'. @@ -7,7 +7,7 @@ tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): er ==== tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts (4 errors) ==== import b = require("externalModule"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'externalModule'. declare module "m1" { diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt index 13991aea7f7..9e3d012aeb6 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt +++ b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importDeclWithDeclareModifier.ts(5,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/importDeclWithDeclareModifier.ts(5,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/importDeclWithDeclareModifier.ts(5,9): error TS1029: 'export' modifier must precede 'declare' modifier. tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2305: Module 'x' has no exported member 'c'. @@ -10,7 +10,7 @@ tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2305: Modul } declare export import a = x.c; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~ !!! error TS1029: 'export' modifier must precede 'declare' modifier. ~ diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index e48d1b1dc73..3d805a65822 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -14,17 +14,24 @@ tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(106,21): error TS2304: Cannot find name 'i1'. tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'. + Type '{}' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(113,5): error TS2322: Type 'Object' is not assignable to type 'i2'. + Type 'Object' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(114,17): error TS2350: Only a void function can be called with the 'new' keyword. tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not assignable to type 'i2'. + Type 'Base' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'. tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(120,22): error TS2304: Cannot find name 'i2'. tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'. + Type '{}' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(127,5): error TS2322: Type 'Object' is not assignable to type 'i3'. + Type 'Object' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(129,5): error TS2322: Type 'Base' is not assignable to type 'i3'. + Type 'Base' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is not assignable to type 'i3'. + Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'. tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'. @@ -50,9 +57,12 @@ tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(162,22): error TS2304: Cannot find name 'i5'. tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'. + Type '{}' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(169,5): error TS2322: Type 'Object' is not assignable to type 'i6'. + Type 'Object' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(170,17): error TS2350: Only a void function can be called with the 'new' keyword. tests/cases/compiler/intTypeCheck.ts(171,5): error TS2322: Type 'Base' is not assignable to type 'i6'. + Type 'Base' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is not assignable to type 'i6'. Type 'void' is not assignable to type 'number'. tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'. @@ -60,9 +70,13 @@ tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(176,22): error TS2304: Cannot find name 'i6'. tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'. + Type '{}' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(183,5): error TS2322: Type 'Object' is not assignable to type 'i7'. + Type 'Object' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(185,17): error TS2352: Neither type 'Base' nor type 'i7' is assignable to the other. + Type 'Base' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is not assignable to type 'i7'. + Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'. tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'. @@ -216,15 +230,18 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj12: i2 = {}; ~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'i2'. +!!! error TS2322: Type '{}' provides no match for the signature '(): any' var obj13: i2 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i2'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): any' var obj14: i2 = new obj11; ~~~~~~~~~ !!! error TS2350: Only a void function can be called with the 'new' keyword. var obj15: i2 = new Base; ~~~~~ !!! error TS2322: Type 'Base' is not assignable to type 'i2'. +!!! error TS2322: Type 'Base' provides no match for the signature '(): any' var obj16: i2 = null; var obj17: i2 = function ():any { return 0; }; //var obj18: i2 = function foo() { }; @@ -246,17 +263,21 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj23: i3 = {}; ~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'i3'. +!!! error TS2322: Type '{}' provides no match for the signature 'new (): any' var obj24: i3 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i3'. +!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any' var obj25: i3 = new obj22; var obj26: i3 = new Base; ~~~~~ !!! error TS2322: Type 'Base' is not assignable to type 'i3'. +!!! error TS2322: Type 'Base' provides no match for the signature 'new (): any' var obj27: i3 = null; var obj28: i3 = function () { }; ~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'i3'. +!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any' //var obj29: i3 = function foo() { }; var obj30: i3 = anyVar; var obj31: i3 = new anyVar; @@ -338,15 +359,18 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj56: i6 = {}; ~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'i6'. +!!! error TS2322: Type '{}' provides no match for the signature '(): any' var obj57: i6 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i6'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): any' var obj58: i6 = new obj55; ~~~~~~~~~ !!! error TS2350: Only a void function can be called with the 'new' keyword. var obj59: i6 = new Base; ~~~~~ !!! error TS2322: Type 'Base' is not assignable to type 'i6'. +!!! error TS2322: Type 'Base' provides no match for the signature '(): any' var obj60: i6 = null; var obj61: i6 = function () { }; ~~~~~ @@ -371,17 +395,21 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj67: i7 = {}; ~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'i7'. +!!! error TS2322: Type '{}' provides no match for the signature 'new (): any' var obj68: i7 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i7'. +!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any' var obj69: i7 = new obj66; var obj70: i7 = new Base; ~~~~~~~~~~~~ !!! error TS2352: Neither type 'Base' nor type 'i7' is assignable to the other. +!!! error TS2352: Type 'Base' provides no match for the signature 'new (): any' var obj71: i7 = null; var obj72: i7 = function () { }; ~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'i7'. +!!! error TS2322: Type '() => void' provides no match for the signature 'new (): any' //var obj73: i7 = function foo() { }; var obj74: i7 = anyVar; var obj75: i7 = new anyVar; diff --git a/tests/baselines/reference/interfaceImplementation1.errors.txt b/tests/baselines/reference/interfaceImplementation1.errors.txt index 45b011c6929..e5e1a212a06 100644 --- a/tests/baselines/reference/interfaceImplementation1.errors.txt +++ b/tests/baselines/reference/interfaceImplementation1.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2420: Class 'C1' tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2420: Class 'C1' incorrectly implements interface 'I2'. Property 'iFn' is private in type 'C1' but not in type 'I2'. tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2322: Type '() => C2' is not assignable to type 'I4'. + Type '() => C2' provides no match for the signature 'new (): I3' ==== tests/cases/compiler/interfaceImplementation1.ts (3 errors) ==== @@ -48,6 +49,7 @@ tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2322: Type '() = var a:I4 = function(){ ~ !!! error TS2322: Type '() => C2' is not assignable to type 'I4'. +!!! error TS2322: Type '() => C2' provides no match for the signature 'new (): I3' return new C2(); } new a(); diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt new file mode 100644 index 00000000000..c31b03bae4c --- /dev/null +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: '=' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(7,1): error TS1005: ';' expected. + + +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (3 errors) ==== + // This should be an error + // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + + var let = 10; + for (let of [1,2,3]) {} + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: ',' expected. + + for (let in [1,2,3]) {} + ~~~ +!!! error TS1005: ';' expected. + + + \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js new file mode 100644 index 00000000000..729cb246a85 --- /dev/null +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js @@ -0,0 +1,18 @@ +//// [invalidLetInForOfAndForIn_ES5.ts] +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + +var let = 10; +for (let of [1,2,3]) {} + +for (let in [1,2,3]) {} + + + + +//// [invalidLetInForOfAndForIn_ES5.js] +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements +var let = 10; +for (let of = [1, 2, 3], { }; ; ) + for ( in [1, 2, 3]) { } diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt new file mode 100644 index 00000000000..c126e8b7443 --- /dev/null +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: '=' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(7,1): error TS1005: ';' expected. + + +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (3 errors) ==== + // This should be an error + // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + + var let = 10; + for (let of [1,2,3]) {} + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: ',' expected. + + for (let in [1,2,3]) {} + ~~~ +!!! error TS1005: ';' expected. + + + \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js new file mode 100644 index 00000000000..93258d6b225 --- /dev/null +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js @@ -0,0 +1,18 @@ +//// [invalidLetInForOfAndForIn_ES6.ts] +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + +var let = 10; +for (let of [1,2,3]) {} + +for (let in [1,2,3]) {} + + + + +//// [invalidLetInForOfAndForIn_ES6.js] +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements +var let = 10; +for (let of = [1, 2, 3], { }; ; ) + for ( in [1, 2, 3]) { } diff --git a/tests/baselines/reference/jsFileCompilationBindDuplicateIdentifier.errors.txt b/tests/baselines/reference/jsFileCompilationBindDuplicateIdentifier.errors.txt new file mode 100644 index 00000000000..2816eaee8b4 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationBindDuplicateIdentifier.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/a.js(1,5): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/a.js(2,7): error TS2300: Duplicate identifier 'a'. + + +==== tests/cases/compiler/a.js (2 errors) ==== + var a = 10; + ~ +!!! error TS2300: Duplicate identifier 'a'. + class a { + ~ +!!! error TS2300: Duplicate identifier 'a'. + } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt new file mode 100644 index 00000000000..eeae7053333 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/a.js(1,5): error TS2451: Cannot redeclare block-scoped variable 'C'. +tests/cases/compiler/a.js(2,5): error TS2451: Cannot redeclare block-scoped variable 'C'. +tests/cases/compiler/a.js(6,5): error TS7027: Unreachable code detected. +tests/cases/compiler/a.js(11,9): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/a.js (4 errors) ==== + let C = "sss"; + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'C'. + let C = 0; // Error: Cannot redeclare block-scoped variable 'C'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'C'. + + function f() { + return; + return; // Error: Unreachable code detected. + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + + function b() { + "use strict"; + var arguments = 0; // Error: Invalid use of 'arguments' in strict mode. + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationBindErrors.symbols b/tests/baselines/reference/jsFileCompilationBindErrors.symbols deleted file mode 100644 index 6ad06da1df6..00000000000 --- a/tests/baselines/reference/jsFileCompilationBindErrors.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/a.js === -let C = "sss"; ->C : Symbol(C, Decl(a.js, 0, 3)) - -let C = 0; // Error: Cannot redeclare block-scoped variable 'C'. ->C : Symbol(C, Decl(a.js, 1, 3)) - -function f() { ->f : Symbol(f, Decl(a.js, 1, 10)) - - return; - return; // Error: Unreachable code detected. -} - -function b() { ->b : Symbol(b, Decl(a.js, 6, 1)) - - "use strict"; - var arguments = 0; // Error: Invalid use of 'arguments' in strict mode. ->arguments : Symbol(arguments, Decl(a.js, 10, 7)) -} diff --git a/tests/baselines/reference/jsFileCompilationBindErrors.types b/tests/baselines/reference/jsFileCompilationBindErrors.types deleted file mode 100644 index 113bcd08bc9..00000000000 --- a/tests/baselines/reference/jsFileCompilationBindErrors.types +++ /dev/null @@ -1,26 +0,0 @@ -=== tests/cases/compiler/a.js === -let C = "sss"; ->C : string ->"sss" : string - -let C = 0; // Error: Cannot redeclare block-scoped variable 'C'. ->C : number ->0 : number - -function f() { ->f : () => void - - return; - return; // Error: Unreachable code detected. -} - -function b() { ->b : () => void - - "use strict"; ->"use strict" : string - - var arguments = 0; // Error: Invalid use of 'arguments' in strict mode. ->arguments : number ->0 : number -} diff --git a/tests/baselines/reference/jsFileCompilationBindMultipleDefaultExports.errors.txt b/tests/baselines/reference/jsFileCompilationBindMultipleDefaultExports.errors.txt new file mode 100644 index 00000000000..733f66922ab --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationBindMultipleDefaultExports.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/a.js(1,22): error TS2528: A module cannot have multiple default exports. +tests/cases/compiler/a.js(3,1): error TS2528: A module cannot have multiple default exports. +tests/cases/compiler/a.js(3,1): error TS8003: 'export=' can only be used in a .ts file. +tests/cases/compiler/a.js(3,16): error TS1109: Expression expected. + + +==== tests/cases/compiler/a.js (4 errors) ==== + export default class a { + ~ +!!! error TS2528: A module cannot have multiple default exports. + } + export default var a = 10; + ~~~~~~~~~~~~~~ +!!! error TS2528: A module cannot have multiple default exports. + ~~~~~~~~~~~~~~ +!!! error TS8003: 'export=' can only be used in a .ts file. + ~~~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt new file mode 100644 index 00000000000..a883e66e607 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt @@ -0,0 +1,31 @@ +tests/cases/compiler/a.js(3,9): error TS7029: Fallthrough case in switch. +tests/cases/compiler/a.js(16,5): error TS7027: Unreachable code detected. +tests/cases/compiler/a.js(19,1): error TS7028: Unused label. + + +==== tests/cases/compiler/a.js (3 errors) ==== + function foo(a, b) { + switch (a) { + case 10: + ~~~~ +!!! error TS7029: Fallthrough case in switch. + if (b) { + return b; + } + case 20: + return a; + } + } + + function bar() { + return x; + function bar2() { + } + var x = 10; // error + ~~~ +!!! error TS7027: Unreachable code detected. + } + + label1: var x2 = 10; + ~~~~~~ +!!! error TS7028: Unused label. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt new file mode 100644 index 00000000000..65dffb5a08e --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt @@ -0,0 +1,81 @@ +tests/cases/compiler/a.js(3,5): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/a.js(5,5): error TS1117: An object literal cannot have multiple properties with the same name in strict mode. +tests/cases/compiler/a.js(5,5): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/a.js(7,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode +tests/cases/compiler/a.js(8,8): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/compiler/a.js(10,10): error TS1100: Invalid use of 'eval' in strict mode. +tests/cases/compiler/a.js(12,10): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/compiler/a.js(15,1): error TS1101: 'with' statements are not allowed in strict mode. +tests/cases/compiler/b.js(3,7): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode. +tests/cases/compiler/b.js(6,13): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode. +tests/cases/compiler/c.js(1,12): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. +tests/cases/compiler/c.js(2,5): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. +tests/cases/compiler/d.js(2,9): error TS1121: Octal literals are not allowed in strict mode. +tests/cases/compiler/d.js(2,11): error TS1005: ',' expected. + + +==== tests/cases/compiler/a.js (8 errors) ==== + "use strict"; + var a = { + a: "hello", // error + ~ +!!! error TS2300: Duplicate identifier 'a'. + b: 10, + a: 10 // error + ~ +!!! error TS1117: An object literal cannot have multiple properties with the same name in strict mode. + ~ +!!! error TS2300: Duplicate identifier 'a'. + }; + var let = 10; // error + ~~~ +!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode + delete a; // error + ~ +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + try { + } catch (eval) { // error + ~~~~ +!!! error TS1100: Invalid use of 'eval' in strict mode. + } + function arguments() { // error + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } + + with (a) { + ~~~~ +!!! error TS1101: 'with' statements are not allowed in strict mode. + b = 10; + } + +==== tests/cases/compiler/b.js (2 errors) ==== + // this is not in strict mode but class definitions are always in strict mode + class c { + a(eval) { //error + ~~~~ +!!! error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode. + } + method() { + var let = 10; // error + ~~~ +!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode. + } + } + +==== tests/cases/compiler/c.js (2 errors) ==== + export var let = 10; // external modules are automatically in strict mode + ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + var eval = function () { + ~~~~ +!!! error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. + }; + +==== tests/cases/compiler/d.js (2 errors) ==== + "use strict"; + var x = 009; // error + ~~ +!!! error TS1121: Octal literals are not allowed in strict mode. + ~ +!!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationExportAssignmentSyntax.errors.txt b/tests/baselines/reference/jsFileCompilationExportAssignmentSyntax.errors.txt index f537941c55c..7e67c6325e0 100644 --- a/tests/baselines/reference/jsFileCompilationExportAssignmentSyntax.errors.txt +++ b/tests/baselines/reference/jsFileCompilationExportAssignmentSyntax.errors.txt @@ -1,9 +1,12 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. +tests/cases/compiler/a.js(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/a.js(1,1): error TS8003: 'export=' can only be used in a .ts file. !!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -==== tests/cases/compiler/a.js (1 errors) ==== +==== tests/cases/compiler/a.js (2 errors) ==== export = b; ~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. + ~~~~~~~~~~~ !!! error TS8003: 'export=' can only be used in a .ts file. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt b/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt new file mode 100644 index 00000000000..58111c777f1 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/moduleA/a.js(2,17): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/b.ts' is not a module. Please contact the package author to update the package definition. + + +==== tests/cases/compiler/moduleA/a.js (1 errors) ==== + + import {a} from "b"; + ~~~ +!!! error TS2656: Exported external package typings file 'b.ts' is not a module. Please contact the package author to update the package definition. + a++; + import {c} from "c"; + c++; + +==== tests/cases/compiler/node_modules/b.ts (0 errors) ==== + var a = 10; + +==== tests/cases/compiler/node_modules/c.js (0 errors) ==== + exports.a = 10; + c = 10; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError1.errors.txt b/tests/baselines/reference/jsxParsingError1.errors.txt new file mode 100644 index 00000000000..e769947dfa6 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/jsx/file.tsx(12,36): error TS1005: '}' expected. +tests/cases/conformance/jsx/file.tsx(12,44): error TS1003: Identifier expected. +tests/cases/conformance/jsx/file.tsx(12,46): error TS1161: Unterminated regular expression literal. + + +==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + + // This should be a parse error + const class1 = "foo"; + const class2 = "bar"; + const elem =
; + ~ +!!! error TS1005: '}' expected. + ~ +!!! error TS1003: Identifier expected. + +!!! error TS1161: Unterminated regular expression literal. + \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError1.js b/tests/baselines/reference/jsxParsingError1.js new file mode 100644 index 00000000000..14b60afdde8 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError1.js @@ -0,0 +1,21 @@ +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// This should be a parse error +const class1 = "foo"; +const class2 = "bar"; +const elem =
; + + +//// [file.jsx] +// This should be a parse error +var class1 = "foo"; +var class2 = "bar"; +var elem =
; +/>;; diff --git a/tests/baselines/reference/letAsIdentifier2.js b/tests/baselines/reference/letAsIdentifier2.js new file mode 100644 index 00000000000..62c8461bfc8 --- /dev/null +++ b/tests/baselines/reference/letAsIdentifier2.js @@ -0,0 +1,6 @@ +//// [letAsIdentifier2.ts] + +function let() {} + +//// [letAsIdentifier2.js] +function let() { } diff --git a/tests/baselines/reference/letAsIdentifier2.symbols b/tests/baselines/reference/letAsIdentifier2.symbols new file mode 100644 index 00000000000..211aae05316 --- /dev/null +++ b/tests/baselines/reference/letAsIdentifier2.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/letAsIdentifier2.ts === + +function let() {} +>let : Symbol(let, Decl(letAsIdentifier2.ts, 0, 0)) + diff --git a/tests/baselines/reference/letAsIdentifier2.types b/tests/baselines/reference/letAsIdentifier2.types new file mode 100644 index 00000000000..dc1416fdae9 --- /dev/null +++ b/tests/baselines/reference/letAsIdentifier2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/letAsIdentifier2.ts === + +function let() {} +>let : () => void + diff --git a/tests/baselines/reference/letInConstDeclarations_ES5.errors.txt b/tests/baselines/reference/letInConstDeclarations_ES5.errors.txt new file mode 100644 index 00000000000..8b694c35dbb --- /dev/null +++ b/tests/baselines/reference/letInConstDeclarations_ES5.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/letInConstDeclarations_ES5.ts(3,15): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInConstDeclarations_ES5.ts(6,19): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInConstDeclarations_ES5.ts (2 errors) ==== + + // All use of let in const declaration should be an error + const x = 50, let = 5; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + const x = 10, let = 20; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/letInConstDeclarations_ES5.js b/tests/baselines/reference/letInConstDeclarations_ES5.js new file mode 100644 index 00000000000..f76d49765f0 --- /dev/null +++ b/tests/baselines/reference/letInConstDeclarations_ES5.js @@ -0,0 +1,15 @@ +//// [letInConstDeclarations_ES5.ts] + +// All use of let in const declaration should be an error +const x = 50, let = 5; + +{ + const x = 10, let = 20; +} + +//// [letInConstDeclarations_ES5.js] +// All use of let in const declaration should be an error +var x = 50, let = 5; +{ + var x_1 = 10, let_1 = 20; +} diff --git a/tests/baselines/reference/letInConstDeclarations_ES6.errors.txt b/tests/baselines/reference/letInConstDeclarations_ES6.errors.txt new file mode 100644 index 00000000000..d29f78be014 --- /dev/null +++ b/tests/baselines/reference/letInConstDeclarations_ES6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/letInConstDeclarations_ES6.ts(3,15): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInConstDeclarations_ES6.ts(6,19): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInConstDeclarations_ES6.ts (2 errors) ==== + + // All use of let in const declaration should be an error + const x = 50, let = 5; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + const x = 10, let = 20; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/letInConstDeclarations_ES6.js b/tests/baselines/reference/letInConstDeclarations_ES6.js new file mode 100644 index 00000000000..f209ef1dede --- /dev/null +++ b/tests/baselines/reference/letInConstDeclarations_ES6.js @@ -0,0 +1,15 @@ +//// [letInConstDeclarations_ES6.ts] + +// All use of let in const declaration should be an error +const x = 50, let = 5; + +{ + const x = 10, let = 20; +} + +//// [letInConstDeclarations_ES6.js] +// All use of let in const declaration should be an error +const x = 50, let = 5; +{ + const x = 10, let = 20; +} diff --git a/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.errors.txt b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.errors.txt new file mode 100644 index 00000000000..e335a9652f4 --- /dev/null +++ b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(3,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(5,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(7,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(9,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(12,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(14,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(16,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts(18,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts (8 errors) ==== + + // Should be an error + for (let let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (let let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + for (let let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (let let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } + + \ No newline at end of file diff --git a/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.js b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.js new file mode 100644 index 00000000000..4c467176492 --- /dev/null +++ b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES5.js @@ -0,0 +1,43 @@ +//// [letInLetConstDeclOfForOfAndForIn_ES5.ts] + +// Should be an error +for (let let of [1,2,3]) {} + +for (const let of [1,2,3]) {} + +for (let let in [1,2,3]) {} + +for (const let in [1,2,3]) {} + +{ + for (let let of [1,2,3]) {} + + for (const let of [1,2,3]) {} + + for (let let in [1,2,3]) {} + + for (const let in [1,2,3]) {} +} + + + +//// [letInLetConstDeclOfForOfAndForIn_ES5.js] +// Should be an error +for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) { + var let = _a[_i]; +} +for (var _b = 0, _c = [1, 2, 3]; _b < _c.length; _b++) { + var let = _c[_b]; +} +for (var let in [1, 2, 3]) { } +for (var let in [1, 2, 3]) { } +{ + for (var _d = 0, _e = [1, 2, 3]; _d < _e.length; _d++) { + var let = _e[_d]; + } + for (var _f = 0, _g = [1, 2, 3]; _f < _g.length; _f++) { + var let = _g[_f]; + } + for (var let in [1, 2, 3]) { } + for (var let in [1, 2, 3]) { } +} diff --git a/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.errors.txt b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.errors.txt new file mode 100644 index 00000000000..1a5af892b74 --- /dev/null +++ b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(3,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(5,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(7,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(9,12): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(12,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(14,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(16,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts(18,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts (8 errors) ==== + + // Should be an error + for (let let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (let let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + for (let let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let of [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (let let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + for (const let in [1,2,3]) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } + + \ No newline at end of file diff --git a/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.js b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.js new file mode 100644 index 00000000000..583dc936871 --- /dev/null +++ b/tests/baselines/reference/letInLetConstDeclOfForOfAndForIn_ES6.js @@ -0,0 +1,35 @@ +//// [letInLetConstDeclOfForOfAndForIn_ES6.ts] + +// Should be an error +for (let let of [1,2,3]) {} + +for (const let of [1,2,3]) {} + +for (let let in [1,2,3]) {} + +for (const let in [1,2,3]) {} + +{ + for (let let of [1,2,3]) {} + + for (const let of [1,2,3]) {} + + for (let let in [1,2,3]) {} + + for (const let in [1,2,3]) {} +} + + + +//// [letInLetConstDeclOfForOfAndForIn_ES6.js] +// Should be an error +for (let let of [1, 2, 3]) { } +for (const let of [1, 2, 3]) { } +for (let let in [1, 2, 3]) { } +for (const let in [1, 2, 3]) { } +{ + for (let let of [1, 2, 3]) { } + for (const let of [1, 2, 3]) { } + for (let let in [1, 2, 3]) { } + for (const let in [1, 2, 3]) { } +} diff --git a/tests/baselines/reference/letInLetDeclarations_ES5.errors.txt b/tests/baselines/reference/letInLetDeclarations_ES5.errors.txt new file mode 100644 index 00000000000..73f824dd7de --- /dev/null +++ b/tests/baselines/reference/letInLetDeclarations_ES5.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/letInLetDeclarations_ES5.ts(3,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetDeclarations_ES5.ts(6,17): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInLetDeclarations_ES5.ts (2 errors) ==== + + // All use of let in const declaration should be an error + let x = 50, let = 5; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + let x = 10, let = 20; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/letInLetDeclarations_ES5.js b/tests/baselines/reference/letInLetDeclarations_ES5.js new file mode 100644 index 00000000000..0b7f02150a4 --- /dev/null +++ b/tests/baselines/reference/letInLetDeclarations_ES5.js @@ -0,0 +1,15 @@ +//// [letInLetDeclarations_ES5.ts] + +// All use of let in const declaration should be an error +let x = 50, let = 5; + +{ + let x = 10, let = 20; +} + +//// [letInLetDeclarations_ES5.js] +// All use of let in const declaration should be an error +var x = 50, let = 5; +{ + var x_1 = 10, let_1 = 20; +} diff --git a/tests/baselines/reference/letInLetDeclarations_ES6.errors.txt b/tests/baselines/reference/letInLetDeclarations_ES6.errors.txt new file mode 100644 index 00000000000..0fe1aa882e9 --- /dev/null +++ b/tests/baselines/reference/letInLetDeclarations_ES6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/letInLetDeclarations_ES6.ts(3,13): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/compiler/letInLetDeclarations_ES6.ts(6,17): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/compiler/letInLetDeclarations_ES6.ts (2 errors) ==== + + // All use of let in const declaration should be an error + let x = 50, let = 5; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + { + let x = 10, let = 20; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + } \ No newline at end of file diff --git a/tests/baselines/reference/letInLetDeclarations_ES6.js b/tests/baselines/reference/letInLetDeclarations_ES6.js new file mode 100644 index 00000000000..7c4385cd4d9 --- /dev/null +++ b/tests/baselines/reference/letInLetDeclarations_ES6.js @@ -0,0 +1,15 @@ +//// [letInLetDeclarations_ES6.ts] + +// All use of let in const declaration should be an error +let x = 50, let = 5; + +{ + let x = 10, let = 20; +} + +//// [letInLetDeclarations_ES6.js] +// All use of let in const declaration should be an error +let x = 50, let = 5; +{ + let x = 10, let = 20; +} diff --git a/tests/baselines/reference/letInLetOrConstDeclarations.errors.txt b/tests/baselines/reference/letInLetOrConstDeclarations.errors.txt deleted file mode 100644 index fbcee276583..00000000000 --- a/tests/baselines/reference/letInLetOrConstDeclarations.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/compiler/letInLetOrConstDeclarations.ts(2,9): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. -tests/cases/compiler/letInLetOrConstDeclarations.ts(3,14): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. -tests/cases/compiler/letInLetOrConstDeclarations.ts(6,11): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. - - -==== tests/cases/compiler/letInLetOrConstDeclarations.ts (3 errors) ==== - { - let let = 1; // should error - ~~~ -!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. - for (let let in []) { } // should error - ~~~ -!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. - } - { - const let = 1; // should error - ~~~ -!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. - } - { - function let() { // should be ok - } - } \ No newline at end of file diff --git a/tests/baselines/reference/letInLetOrConstDeclarations.js b/tests/baselines/reference/letInLetOrConstDeclarations.js deleted file mode 100644 index ee23abc4e4f..00000000000 --- a/tests/baselines/reference/letInLetOrConstDeclarations.js +++ /dev/null @@ -1,25 +0,0 @@ -//// [letInLetOrConstDeclarations.ts] -{ - let let = 1; // should error - for (let let in []) { } // should error -} -{ - const let = 1; // should error -} -{ - function let() { // should be ok - } -} - -//// [letInLetOrConstDeclarations.js] -{ - let let = 1; // should error - for (let let in []) { } // should error -} -{ - const let = 1; // should error -} -{ - function let() { - } -} diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES5.js b/tests/baselines/reference/letInVarDeclOfForIn_ES5.js new file mode 100644 index 00000000000..2cef7610199 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES5.js @@ -0,0 +1,16 @@ +//// [letInVarDeclOfForIn_ES5.ts] + +// should not be an error +for (var let in [1,2,3]) {} + +{ + for (var let in [1,2,3]) {} +} + + +//// [letInVarDeclOfForIn_ES5.js] +// should not be an error +for (var let in [1, 2, 3]) { } +{ + for (var let in [1, 2, 3]) { } +} diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES5.symbols b/tests/baselines/reference/letInVarDeclOfForIn_ES5.symbols new file mode 100644 index 00000000000..cbfd0f58086 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/letInVarDeclOfForIn_ES5.ts === + +// should not be an error +for (var let in [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForIn_ES5.ts, 2, 8), Decl(letInVarDeclOfForIn_ES5.ts, 5, 9)) + +{ + for (var let in [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForIn_ES5.ts, 2, 8), Decl(letInVarDeclOfForIn_ES5.ts, 5, 9)) +} + diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES5.types b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types new file mode 100644 index 00000000000..ac1ca3f27c9 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/letInVarDeclOfForIn_ES5.ts === + +// should not be an error +for (var let in [1,2,3]) {} +>let : any +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +{ + for (var let in [1,2,3]) {} +>let : any +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number +} + diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES6.js b/tests/baselines/reference/letInVarDeclOfForIn_ES6.js new file mode 100644 index 00000000000..1cf6850f588 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES6.js @@ -0,0 +1,16 @@ +//// [letInVarDeclOfForIn_ES6.ts] + +// should not be an error +for (var let in [1,2,3]) {} + +{ + for (var let in [1,2,3]) {} +} + + +//// [letInVarDeclOfForIn_ES6.js] +// should not be an error +for (var let in [1, 2, 3]) { } +{ + for (var let in [1, 2, 3]) { } +} diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES6.symbols b/tests/baselines/reference/letInVarDeclOfForIn_ES6.symbols new file mode 100644 index 00000000000..3b3e68e3040 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/letInVarDeclOfForIn_ES6.ts === + +// should not be an error +for (var let in [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForIn_ES6.ts, 2, 8), Decl(letInVarDeclOfForIn_ES6.ts, 5, 9)) + +{ + for (var let in [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForIn_ES6.ts, 2, 8), Decl(letInVarDeclOfForIn_ES6.ts, 5, 9)) +} + diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES6.types b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types new file mode 100644 index 00000000000..3c508bd8e2b --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/letInVarDeclOfForIn_ES6.ts === + +// should not be an error +for (var let in [1,2,3]) {} +>let : any +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +{ + for (var let in [1,2,3]) {} +>let : any +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number +} + diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES5.js b/tests/baselines/reference/letInVarDeclOfForOf_ES5.js new file mode 100644 index 00000000000..cdc374fbea0 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES5.js @@ -0,0 +1,20 @@ +//// [letInVarDeclOfForOf_ES5.ts] + +// should not be an error +for (var let of [1,2,3]) {} + +{ + for (var let of [1,2,3]) {} +} + + +//// [letInVarDeclOfForOf_ES5.js] +// should not be an error +for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) { + var let = _a[_i]; +} +{ + for (var _b = 0, _c = [1, 2, 3]; _b < _c.length; _b++) { + var let = _c[_b]; + } +} diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES5.symbols b/tests/baselines/reference/letInVarDeclOfForOf_ES5.symbols new file mode 100644 index 00000000000..f5411cfca2d --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/letInVarDeclOfForOf_ES5.ts === + +// should not be an error +for (var let of [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForOf_ES5.ts, 2, 8), Decl(letInVarDeclOfForOf_ES5.ts, 5, 9)) + +{ + for (var let of [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForOf_ES5.ts, 2, 8), Decl(letInVarDeclOfForOf_ES5.ts, 5, 9)) +} + diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES5.types b/tests/baselines/reference/letInVarDeclOfForOf_ES5.types new file mode 100644 index 00000000000..a1000df8bed --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES5.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/letInVarDeclOfForOf_ES5.ts === + +// should not be an error +for (var let of [1,2,3]) {} +>let : number +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +{ + for (var let of [1,2,3]) {} +>let : number +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number +} + diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES6.js b/tests/baselines/reference/letInVarDeclOfForOf_ES6.js new file mode 100644 index 00000000000..fca365c4b0d --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES6.js @@ -0,0 +1,16 @@ +//// [letInVarDeclOfForOf_ES6.ts] + +// should not be an error +for (var let of [1,2,3]) {} + +{ + for (var let of [1,2,3]) {} +} + + +//// [letInVarDeclOfForOf_ES6.js] +// should not be an error +for (var let of [1, 2, 3]) { } +{ + for (var let of [1, 2, 3]) { } +} diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES6.symbols b/tests/baselines/reference/letInVarDeclOfForOf_ES6.symbols new file mode 100644 index 00000000000..d4c14eff0b0 --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/letInVarDeclOfForOf_ES6.ts === + +// should not be an error +for (var let of [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForOf_ES6.ts, 2, 8), Decl(letInVarDeclOfForOf_ES6.ts, 5, 9)) + +{ + for (var let of [1,2,3]) {} +>let : Symbol(let, Decl(letInVarDeclOfForOf_ES6.ts, 2, 8), Decl(letInVarDeclOfForOf_ES6.ts, 5, 9)) +} + diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES6.types b/tests/baselines/reference/letInVarDeclOfForOf_ES6.types new file mode 100644 index 00000000000..1515895feda --- /dev/null +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES6.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/letInVarDeclOfForOf_ES6.ts === + +// should not be an error +for (var let of [1,2,3]) {} +>let : number +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number + +{ + for (var let of [1,2,3]) {} +>let : number +>[1,2,3] : number[] +>1 : number +>2 : number +>3 : number +} + diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen.errors.txt b/tests/baselines/reference/mergedModuleDeclarationCodeGen.errors.txt index d9b7fa55d71..a39c1c4d91a 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen.errors.txt +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/mergedModuleDeclarationCodeGen.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/mergedModuleDeclarationCodeGen.ts(1,15): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/compiler/mergedModuleDeclarationCodeGen.ts (1 errors) ==== export module X { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export module Y { class A { constructor(Y: any) { diff --git a/tests/baselines/reference/missingSemicolonInModuleSpecifier.js b/tests/baselines/reference/missingSemicolonInModuleSpecifier.js new file mode 100644 index 00000000000..069849ffb83 --- /dev/null +++ b/tests/baselines/reference/missingSemicolonInModuleSpecifier.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/missingSemicolonInModuleSpecifier.ts] //// + +//// [a.ts] + +export const x = 1; + +//// [b.ts] +import {x} from "./a" +(function() { return 1; }()) + +//// [a.js] +"use strict"; +exports.x = 1; +//// [b.js] +"use strict"; +(function () { return 1; }()); diff --git a/tests/baselines/reference/missingSemicolonInModuleSpecifier.symbols b/tests/baselines/reference/missingSemicolonInModuleSpecifier.symbols new file mode 100644 index 00000000000..695779002ac --- /dev/null +++ b/tests/baselines/reference/missingSemicolonInModuleSpecifier.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/a.ts === + +export const x = 1; +>x : Symbol(x, Decl(a.ts, 1, 12)) + +=== tests/cases/compiler/b.ts === +import {x} from "./a" +>x : Symbol(x, Decl(b.ts, 0, 8)) + +(function() { return 1; }()) diff --git a/tests/baselines/reference/missingSemicolonInModuleSpecifier.types b/tests/baselines/reference/missingSemicolonInModuleSpecifier.types new file mode 100644 index 00000000000..b68c68b62e0 --- /dev/null +++ b/tests/baselines/reference/missingSemicolonInModuleSpecifier.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/a.ts === + +export const x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/b.ts === +import {x} from "./a" +>x : number + +(function() { return 1; }()) +>(function() { return 1; }()) : number +>function() { return 1; }() : number +>function() { return 1; } : () => number +>1 : number + diff --git a/tests/baselines/reference/modifiersInObjectLiterals.errors.txt b/tests/baselines/reference/modifiersInObjectLiterals.errors.txt new file mode 100644 index 00000000000..25382123390 --- /dev/null +++ b/tests/baselines/reference/modifiersInObjectLiterals.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/modifiersInObjectLiterals.ts(2,2): error TS1042: 'public' modifier cannot be used here. +tests/cases/compiler/modifiersInObjectLiterals.ts(3,2): error TS1042: 'private' modifier cannot be used here. +tests/cases/compiler/modifiersInObjectLiterals.ts(4,2): error TS1042: 'protected' modifier cannot be used here. +tests/cases/compiler/modifiersInObjectLiterals.ts(5,2): error TS1042: 'abstract' modifier cannot be used here. + + +==== tests/cases/compiler/modifiersInObjectLiterals.ts (4 errors) ==== + let data = { + public foo: 'hey', + ~~~~~~ +!!! error TS1042: 'public' modifier cannot be used here. + private bar: 'nay', + ~~~~~~~ +!!! error TS1042: 'private' modifier cannot be used here. + protected baz: 'oh my', + ~~~~~~~~~ +!!! error TS1042: 'protected' modifier cannot be used here. + abstract noWay: 'yes' + ~~~~~~~~ +!!! error TS1042: 'abstract' modifier cannot be used here. + }; + + data.foo + data.bar + data.baz + data.noWay + \ No newline at end of file diff --git a/tests/baselines/reference/modifiersInObjectLiterals.js b/tests/baselines/reference/modifiersInObjectLiterals.js new file mode 100644 index 00000000000..0a59b13c21e --- /dev/null +++ b/tests/baselines/reference/modifiersInObjectLiterals.js @@ -0,0 +1,19 @@ +//// [modifiersInObjectLiterals.ts] +let data = { + public foo: 'hey', + private bar: 'nay', + protected baz: 'oh my', + abstract noWay: 'yes' +}; + +data.foo + data.bar + data.baz + data.noWay + + +//// [modifiersInObjectLiterals.js] +var data = { + foo: 'hey', + bar: 'nay', + baz: 'oh my', + noWay: 'yes' +}; +data.foo + data.bar + data.baz + data.noWay; diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt b/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt new file mode 100644 index 00000000000..22bd6641a83 --- /dev/null +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt @@ -0,0 +1,55 @@ +tests/cases/compiler/moduleDuplicateIdentifiers.ts(1,12): error TS2323: Cannot redeclare exported variable 'Foo'. +tests/cases/compiler/moduleDuplicateIdentifiers.ts(2,12): error TS2323: Cannot redeclare exported variable 'Foo'. +tests/cases/compiler/moduleDuplicateIdentifiers.ts(20,14): error TS2300: Duplicate identifier 'Kettle'. +tests/cases/compiler/moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplicate identifier 'Kettle'. + + +==== tests/cases/compiler/moduleDuplicateIdentifiers.ts (4 errors) ==== + export var Foo = 2; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'Foo'. + export var Foo = 42; // Should error + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'Foo'. + + export interface Bar { + _brand1: any; + } + + export interface Bar { // Shouldn't error + _brand2: any; + } + + export namespace FooBar { + export var member1 = 2; + } + + export namespace FooBar { // Shouldn't error + export var member2 = 42; + } + + export class Kettle { + ~~~~~~ +!!! error TS2300: Duplicate identifier 'Kettle'. + member1 = 2; + } + + export class Kettle { // Should error + ~~~~~~ +!!! error TS2300: Duplicate identifier 'Kettle'. + member2 = 42; + } + + export var Pot = 2; + Pot = 42; // Shouldn't error + + export enum Utensils { + Spoon, + Fork, + Knife + } + + export enum Utensils { // Shouldn't error + Spork = 3 + } + \ No newline at end of file diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.js b/tests/baselines/reference/moduleDuplicateIdentifiers.js new file mode 100644 index 00000000000..842d1587911 --- /dev/null +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.js @@ -0,0 +1,80 @@ +//// [moduleDuplicateIdentifiers.ts] +export var Foo = 2; +export var Foo = 42; // Should error + +export interface Bar { + _brand1: any; +} + +export interface Bar { // Shouldn't error + _brand2: any; +} + +export namespace FooBar { + export var member1 = 2; +} + +export namespace FooBar { // Shouldn't error + export var member2 = 42; +} + +export class Kettle { + member1 = 2; +} + +export class Kettle { // Should error + member2 = 42; +} + +export var Pot = 2; +Pot = 42; // Shouldn't error + +export enum Utensils { + Spoon, + Fork, + Knife +} + +export enum Utensils { // Shouldn't error + Spork = 3 +} + + +//// [moduleDuplicateIdentifiers.js] +"use strict"; +exports.Foo = 2; +exports.Foo = 42; // Should error +var FooBar; +(function (FooBar) { + FooBar.member1 = 2; +})(FooBar = exports.FooBar || (exports.FooBar = {})); +var FooBar; +(function (FooBar) { + FooBar.member2 = 42; +})(FooBar = exports.FooBar || (exports.FooBar = {})); +var Kettle = (function () { + function Kettle() { + this.member1 = 2; + } + return Kettle; +})(); +exports.Kettle = Kettle; +var Kettle = (function () { + function Kettle() { + this.member2 = 42; + } + return Kettle; +})(); +exports.Kettle = Kettle; +exports.Pot = 2; +exports.Pot = 42; // Shouldn't error +(function (Utensils) { + Utensils[Utensils["Spoon"] = 0] = "Spoon"; + Utensils[Utensils["Fork"] = 1] = "Fork"; + Utensils[Utensils["Knife"] = 2] = "Knife"; +})(exports.Utensils || (exports.Utensils = {})); +var Utensils = exports.Utensils; +(function (Utensils) { + Utensils[Utensils["Spork"] = 3] = "Spork"; +})(exports.Utensils || (exports.Utensils = {})); +var Utensils = exports.Utensils; diff --git a/tests/baselines/reference/moduleElementsInWrongContext.js b/tests/baselines/reference/moduleElementsInWrongContext.js index 635da02bdf2..df4935f9e19 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext.js +++ b/tests/baselines/reference/moduleElementsInWrongContext.js @@ -34,7 +34,6 @@ { var v; function foo() { } - __export(require("ambient")); exports["default"] = v; var C = (function () { function C() { diff --git a/tests/baselines/reference/moduleElementsInWrongContext2.js b/tests/baselines/reference/moduleElementsInWrongContext2.js index fdf1222e549..b923bc7861e 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext2.js +++ b/tests/baselines/reference/moduleElementsInWrongContext2.js @@ -34,7 +34,6 @@ function blah () { function blah() { var v; function foo() { } - __export(require("ambient")); exports["default"] = v; var C = (function () { function C() { diff --git a/tests/baselines/reference/moduleElementsInWrongContext3.js b/tests/baselines/reference/moduleElementsInWrongContext3.js index d464d9d31b1..2fa0b60dce4 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext3.js +++ b/tests/baselines/reference/moduleElementsInWrongContext3.js @@ -37,7 +37,6 @@ var P; { var v; function foo() { } - __export(require("ambient")); P["default"] = v; var C = (function () { function C() { diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js new file mode 100644 index 00000000000..4061a32b49f --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts] //// + +//// [a.ts] +export * from "./b"; +export * from "./c"; + +//// [b.ts] +export * from "./c"; + +//// [c.ts] +export var foo = 42; + +//// [c.js] +"use strict"; +exports.foo = 42; +//// [b.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(require("./c")); +//// [a.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(require("./b")); +__export(require("./c")); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.symbols b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.symbols new file mode 100644 index 00000000000..2f8bba9b6ab --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/a.ts === +export * from "./b"; +No type information for this code.export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/b.ts === +export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/c.ts === +export var foo = 42; +>foo : Symbol(foo, Decl(c.ts, 0, 10)) + diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types new file mode 100644 index 00000000000..57be71c802b --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/a.ts === +export * from "./b"; +No type information for this code.export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/b.ts === +export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/c.ts === +export var foo = 42; +>foo : number +>42 : number + diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js new file mode 100644 index 00000000000..99a09af149a --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/moduleSameValueDuplicateExportedBindings2.ts] //// + +//// [a.ts] +export * from "./b"; +export * from "./c"; + +//// [b.ts] +export {Animals} from "./c"; + +//// [c.ts] +export enum Animals { + Cat, + Dog +}; + +//// [c.js] +"use strict"; +(function (Animals) { + Animals[Animals["Cat"] = 0] = "Cat"; + Animals[Animals["Dog"] = 1] = "Dog"; +})(exports.Animals || (exports.Animals = {})); +var Animals = exports.Animals; +; +//// [b.js] +"use strict"; +var c_1 = require("./c"); +exports.Animals = c_1.Animals; +//// [a.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(require("./b")); +__export(require("./c")); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.symbols b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.symbols new file mode 100644 index 00000000000..390fd1b0bed --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/a.ts === +export * from "./b"; +No type information for this code.export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/b.ts === +export {Animals} from "./c"; +>Animals : Symbol(Animals, Decl(b.ts, 0, 8)) + +=== tests/cases/compiler/c.ts === +export enum Animals { +>Animals : Symbol(Animals, Decl(c.ts, 0, 0)) + + Cat, +>Cat : Symbol(Animals.Cat, Decl(c.ts, 0, 21)) + + Dog +>Dog : Symbol(Animals.Dog, Decl(c.ts, 1, 5)) + +}; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types new file mode 100644 index 00000000000..600b0d946c6 --- /dev/null +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/a.ts === +export * from "./b"; +No type information for this code.export * from "./c"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/b.ts === +export {Animals} from "./c"; +>Animals : typeof Animals + +=== tests/cases/compiler/c.ts === +export enum Animals { +>Animals : Animals + + Cat, +>Cat : Animals + + Dog +>Dog : Animals + +}; diff --git a/tests/baselines/reference/moduleScoping.errors.txt b/tests/baselines/reference/moduleScoping.errors.txt index 21471bc93a5..961715f2e71 100644 --- a/tests/baselines/reference/moduleScoping.errors.txt +++ b/tests/baselines/reference/moduleScoping.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/file3.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/file3.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/file1.ts (0 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/externalModules/file3.ts(1,1): error TS1148: Cannot comp ==== tests/cases/conformance/externalModules/file3.ts (1 errors) ==== export var v3 = true; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. var v2 = [1,2,3]; // Module scope. Should not appear in global scope ==== tests/cases/conformance/externalModules/file4.ts (0 errors) ==== diff --git a/tests/baselines/reference/multipleDefaultExports02.errors.txt b/tests/baselines/reference/multipleDefaultExports02.errors.txt index 235f8f7c3e3..3f27db47c94 100644 --- a/tests/baselines/reference/multipleDefaultExports02.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports02.errors.txt @@ -1,17 +1,23 @@ +tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2323: Cannot redeclare exported variable 'default'. tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2323: Cannot redeclare exported variable 'default'. tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate function implementation. -==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== +==== tests/cases/conformance/es6/modules/m1.ts (4 errors) ==== export default function foo() { ~~~ +!!! error TS2323: Cannot redeclare exported variable 'default'. + ~~~ !!! error TS2393: Duplicate function implementation. } export default function bar() { ~~~ +!!! error TS2323: Cannot redeclare exported variable 'default'. + ~~~ !!! error TS2393: Duplicate function implementation. } diff --git a/tests/baselines/reference/multipleDefaultExports04.errors.txt b/tests/baselines/reference/multipleDefaultExports04.errors.txt index e67659f6b9f..bf137e3cc17 100644 --- a/tests/baselines/reference/multipleDefaultExports04.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports04.errors.txt @@ -1,15 +1,21 @@ +tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(2,25): error TS2323: Cannot redeclare exported variable 'default'. tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(2,25): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(5,25): error TS2323: Cannot redeclare exported variable 'default'. tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(5,25): error TS2393: Duplicate function implementation. -==== tests/cases/conformance/es6/modules/multipleDefaultExports04.ts (2 errors) ==== +==== tests/cases/conformance/es6/modules/multipleDefaultExports04.ts (4 errors) ==== export default function f() { ~ +!!! error TS2323: Cannot redeclare exported variable 'default'. + ~ !!! error TS2393: Duplicate function implementation. } export default function f() { ~ +!!! error TS2323: Cannot redeclare exported variable 'default'. + ~ !!! error TS2393: Duplicate function implementation. } \ No newline at end of file diff --git a/tests/baselines/reference/nonMergedOverloads.errors.txt b/tests/baselines/reference/nonMergedOverloads.errors.txt index 9a38ebdc3b3..f5fb58247da 100644 --- a/tests/baselines/reference/nonMergedOverloads.errors.txt +++ b/tests/baselines/reference/nonMergedOverloads.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/nonMergedOverloads.ts(1,5): error TS2300: Duplicate identifier 'f'. -tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/nonMergedOverloads.ts(4,17): error TS2300: Duplicate identifier 'f'. @@ -11,7 +11,7 @@ tests/cases/compiler/nonMergedOverloads.ts(4,17): error TS2300: Duplicate identi export function f(); ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~ !!! error TS2300: Duplicate identifier 'f'. export function f() { diff --git a/tests/baselines/reference/objectLiteralMemberWithModifiers1.errors.txt b/tests/baselines/reference/objectLiteralMemberWithModifiers1.errors.txt index 9e739194f54..182eab1b4cf 100644 --- a/tests/baselines/reference/objectLiteralMemberWithModifiers1.errors.txt +++ b/tests/baselines/reference/objectLiteralMemberWithModifiers1.errors.txt @@ -1,7 +1,10 @@ +tests/cases/compiler/objectLiteralMemberWithModifiers1.ts(1,11): error TS1042: 'public' modifier cannot be used here. tests/cases/compiler/objectLiteralMemberWithModifiers1.ts(1,11): error TS1184: Modifiers cannot appear here. -==== tests/cases/compiler/objectLiteralMemberWithModifiers1.ts (1 errors) ==== +==== tests/cases/compiler/objectLiteralMemberWithModifiers1.ts (2 errors) ==== var v = { public foo() { } } ~~~~~~ +!!! error TS1042: 'public' modifier cannot be used here. + ~~~~~~ !!! error TS1184: Modifiers cannot appear here. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt b/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt index be2bea5e241..0d1822339b6 100644 --- a/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt +++ b/tests/baselines/reference/objectLiteralMemberWithModifiers2.errors.txt @@ -1,9 +1,12 @@ +tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,11): error TS1042: 'public' modifier cannot be used here. tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,22): error TS2378: A 'get' accessor must return a value. -==== tests/cases/compiler/objectLiteralMemberWithModifiers2.ts (2 errors) ==== +==== tests/cases/compiler/objectLiteralMemberWithModifiers2.ts (3 errors) ==== var v = { public get foo() { } } + ~~~~~~ +!!! error TS1042: 'public' modifier cannot be used here. ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ diff --git a/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt b/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt index 30b40f431a7..e296f2113fb 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt +++ b/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts(8,1): error TS2322: Type 'Object' is not assignable to type 'I'. + Type 'Object' provides no match for the signature '(): void' tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts(14,1): error TS2322: Type 'Object' is not assignable to type '() => void'. + Type 'Object' provides no match for the signature '(): void' ==== tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfFunctionAssignmentCompat.ts (2 errors) ==== @@ -13,6 +15,7 @@ tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOf i = f; ~ !!! error TS2322: Type 'Object' is not assignable to type 'I'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): void' var a: { (): void @@ -20,4 +23,5 @@ tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOf f = a; a = f; ~ -!!! error TS2322: Type 'Object' is not assignable to type '() => void'. \ No newline at end of file +!!! error TS2322: Type 'Object' is not assignable to type '() => void'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): void' \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt b/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt index 0faba936715..227ccc99603 100644 --- a/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt +++ b/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts(8,1): error TS2322: Type 'Object' is not assignable to type 'I'. + Type 'Object' provides no match for the signature 'new (): any' tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts(14,1): error TS2322: Type 'Object' is not assignable to type 'new () => any'. + Type 'Object' provides no match for the signature 'new (): any' ==== tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMembersOfFunctionAssignmentCompat.ts (2 errors) ==== @@ -13,6 +15,7 @@ tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMemb i = f; ~ !!! error TS2322: Type 'Object' is not assignable to type 'I'. +!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any' var a: { new(): any @@ -20,4 +23,5 @@ tests/cases/conformance/types/members/objectTypeWithConstructSignatureHidingMemb f = a; a = f; ~ -!!! error TS2322: Type 'Object' is not assignable to type 'new () => any'. \ No newline at end of file +!!! error TS2322: Type 'Object' is not assignable to type 'new () => any'. +!!! error TS2322: Type 'Object' provides no match for the signature 'new (): any' \ No newline at end of file diff --git a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js index 66d280839d4..5b99f76a5b9 100644 --- a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js +++ b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js @@ -14,12 +14,14 @@ export default function foo() { new Foo(); } define("b", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; function foo() { new a_1.default(); } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; }); define("a", ["require", "exports", "b"], function (require, exports, b_1) { "use strict"; class Foo { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; b_1.default(); }); diff --git a/tests/baselines/reference/overloadOnConstInheritance2.errors.txt b/tests/baselines/reference/overloadOnConstInheritance2.errors.txt index 4870106f474..4b502f145a6 100644 --- a/tests/baselines/reference/overloadOnConstInheritance2.errors.txt +++ b/tests/baselines/reference/overloadOnConstInheritance2.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/overloadOnConstInheritance2.ts(5,11): error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. Types of property 'addEventListener' are incompatible. Type '(x: "bar") => string' is not assignable to type '{ (x: string): any; (x: "foo"): string; }'. + Type '(x: "bar") => string' provides no match for the signature '(x: string): any' tests/cases/compiler/overloadOnConstInheritance2.ts(6,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. @@ -14,6 +15,7 @@ tests/cases/compiler/overloadOnConstInheritance2.ts(6,5): error TS2382: Speciali !!! error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. !!! error TS2430: Types of property 'addEventListener' are incompatible. !!! error TS2430: Type '(x: "bar") => string' is not assignable to type '{ (x: string): any; (x: "foo"): string; }'. +!!! error TS2430: Type '(x: "bar") => string' provides no match for the signature '(x: string): any' addEventListener(x: 'bar'): string; // shouldn't need to redeclare the string overload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature. diff --git a/tests/baselines/reference/overloadOnConstInheritance3.errors.txt b/tests/baselines/reference/overloadOnConstInheritance3.errors.txt index b338f9795d7..6d9f9b00692 100644 --- a/tests/baselines/reference/overloadOnConstInheritance3.errors.txt +++ b/tests/baselines/reference/overloadOnConstInheritance3.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/overloadOnConstInheritance3.ts(4,11): error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. Types of property 'addEventListener' are incompatible. Type '{ (x: "bar"): string; (x: "foo"): string; }' is not assignable to type '(x: string) => any'. + Type '{ (x: "bar"): string; (x: "foo"): string; }' provides no match for the signature '(x: string): any' tests/cases/compiler/overloadOnConstInheritance3.ts(6,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/compiler/overloadOnConstInheritance3.ts(7,5): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. @@ -14,6 +15,7 @@ tests/cases/compiler/overloadOnConstInheritance3.ts(7,5): error TS2382: Speciali !!! error TS2430: Interface 'Deriver' incorrectly extends interface 'Base'. !!! error TS2430: Types of property 'addEventListener' are incompatible. !!! error TS2430: Type '{ (x: "bar"): string; (x: "foo"): string; }' is not assignable to type '(x: string) => any'. +!!! error TS2430: Type '{ (x: "bar"): string; (x: "foo"): string; }' provides no match for the signature '(x: string): any' // shouldn't need to redeclare the string overload addEventListener(x: 'bar'): string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/parseTypes.errors.txt b/tests/baselines/reference/parseTypes.errors.txt index baa5aaff738..cf8b0d79115 100644 --- a/tests/baselines/reference/parseTypes.errors.txt +++ b/tests/baselines/reference/parseTypes.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/parseTypes.ts(10,1): error TS2322: Type '(s: string) => voi tests/cases/compiler/parseTypes.ts(11,1): error TS2322: Type '(s: string) => void' is not assignable to type '{ [x: number]: number; }'. Index signature is missing in type '(s: string) => void'. tests/cases/compiler/parseTypes.ts(12,1): error TS2322: Type '(s: string) => void' is not assignable to type 'new () => number'. + Type '(s: string) => void' provides no match for the signature 'new (): number' ==== tests/cases/compiler/parseTypes.ts (4 errors) ==== @@ -27,4 +28,5 @@ tests/cases/compiler/parseTypes.ts(12,1): error TS2322: Type '(s: string) => voi z=g; ~ !!! error TS2322: Type '(s: string) => void' is not assignable to type 'new () => number'. +!!! error TS2322: Type '(s: string) => void' provides no match for the signature 'new (): number' \ No newline at end of file diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 97527418337..85c450ef39f 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,28): error TS2304: Cannot find name 'DisplayPosition'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,45): error TS1137: Expression or comma expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1005: ';' expected. @@ -38,7 +38,7 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T ==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (35 errors) ==== export class Game { ~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. private position = new DisplayPosition([), 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 0], NoMove, 0); ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'DisplayPosition'. diff --git a/tests/baselines/reference/parser509546.errors.txt b/tests/baselines/reference/parser509546.errors.txt index 6b98dc2aa30..65e524cb0e7 100644 --- a/tests/baselines/reference/parser509546.errors.txt +++ b/tests/baselines/reference/parser509546.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546.ts (1 errors) ==== export class Logger { ~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. public } \ No newline at end of file diff --git a/tests/baselines/reference/parser509546_1.errors.txt b/tests/baselines/reference/parser509546_1.errors.txt index 5987aadff24..1098adc1463 100644 --- a/tests/baselines/reference/parser509546_1.errors.txt +++ b/tests/baselines/reference/parser509546_1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_1.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_1.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_1.ts (1 errors) ==== export class Logger { ~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. public } \ No newline at end of file diff --git a/tests/baselines/reference/parser509546_2.errors.txt b/tests/baselines/reference/parser509546_2.errors.txt index 617fec94321..ad551887dda 100644 --- a/tests/baselines/reference/parser509546_2.errors.txt +++ b/tests/baselines/reference/parser509546_2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_2.ts(3,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_2.ts(3,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_2.ts(3,1 export class Logger { ~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. public } \ No newline at end of file diff --git a/tests/baselines/reference/parser618973.errors.txt b/tests/baselines/reference/parser618973.errors.txt index 95e08726661..b76aa15c858 100644 --- a/tests/baselines/reference/parser618973.errors.txt +++ b/tests/baselines/reference/parser618973.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,8): error TS1030: 'export' modifier already seen. -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts (2 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21) ~~~~~~ !!! error TS1030: 'export' modifier already seen. ~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. public Bar() { } } \ No newline at end of file diff --git a/tests/baselines/reference/parserAccessors10.errors.txt b/tests/baselines/reference/parserAccessors10.errors.txt index d6a2b99eaca..b309b5e3947 100644 --- a/tests/baselines/reference/parserAccessors10.errors.txt +++ b/tests/baselines/reference/parserAccessors10.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,3): error TS1042: 'public' modifier cannot be used here. tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,14): error TS2378: A 'get' accessor must return a value. -==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts (2 errors) ==== var v = { public get foo() { } + ~~~~~~ +!!! error TS1042: 'public' modifier cannot be used here. ~~~ !!! error TS2378: A 'get' accessor must return a value. }; \ No newline at end of file diff --git a/tests/baselines/reference/parserArgumentList1.errors.txt b/tests/baselines/reference/parserArgumentList1.errors.txt index 36d1a0fad37..01575cec0c4 100644 --- a/tests/baselines/reference/parserArgumentList1.errors.txt +++ b/tests/baselines/reference/parserArgumentList1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts(1,35): error TS2304: Cannot find name 'HTMLElement'. tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts(2,42): error TS2304: Cannot find name '_classNameRegexp'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts(2,42): error T ==== tests/cases/conformance/parser/ecmascript5/parserArgumentList1.ts (3 errors) ==== export function removeClass (node:HTMLElement, className:string) { ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~ !!! error TS2304: Cannot find name 'HTMLElement'. node.className = node.className.replace(_classNameRegexp(className), function (everything, leftDelimiter, name, rightDelimiter) { diff --git a/tests/baselines/reference/parserAutomaticSemicolonInsertion1.errors.txt b/tests/baselines/reference/parserAutomaticSemicolonInsertion1.errors.txt index ee17b6f82aa..9ffdc614ab1 100644 --- a/tests/baselines/reference/parserAutomaticSemicolonInsertion1.errors.txt +++ b/tests/baselines/reference/parserAutomaticSemicolonInsertion1.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/parser/ecmascript5/AutomaticSemicolonInsertion/parserAutomaticSemicolonInsertion1.ts(8,1): error TS2322: Type 'Object' is not assignable to type 'I'. + Type 'Object' provides no match for the signature '(): void' tests/cases/conformance/parser/ecmascript5/AutomaticSemicolonInsertion/parserAutomaticSemicolonInsertion1.ts(14,1): error TS2322: Type 'Object' is not assignable to type '() => void'. + Type 'Object' provides no match for the signature '(): void' ==== tests/cases/conformance/parser/ecmascript5/AutomaticSemicolonInsertion/parserAutomaticSemicolonInsertion1.ts (2 errors) ==== @@ -13,6 +15,7 @@ tests/cases/conformance/parser/ecmascript5/AutomaticSemicolonInsertion/parserAut i = o; ~ !!! error TS2322: Type 'Object' is not assignable to type 'I'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): void' var a: { (): void @@ -21,4 +24,5 @@ tests/cases/conformance/parser/ecmascript5/AutomaticSemicolonInsertion/parserAut a = o; ~ !!! error TS2322: Type 'Object' is not assignable to type '() => void'. +!!! error TS2322: Type 'Object' provides no match for the signature '(): void' \ No newline at end of file diff --git a/tests/baselines/reference/parserClass1.errors.txt b/tests/baselines/reference/parserClass1.errors.txt index da4fc8d870d..03ec87f66a6 100644 --- a/tests/baselines/reference/parserClass1.errors.txt +++ b/tests/baselines/reference/parserClass1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass1.ts(1,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass1.ts(1,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass1.ts(1,40): error TS2304: Cannot find name 'ILogger'. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass1.ts (2 errors) ==== export class NullLogger implements ILogger { ~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~ !!! error TS2304: Cannot find name 'ILogger'. public information(): boolean { return false; } diff --git a/tests/baselines/reference/parserClass2.errors.txt b/tests/baselines/reference/parserClass2.errors.txt index 39476805e1d..ee67b262fe5 100644 --- a/tests/baselines/reference/parserClass2.errors.txt +++ b/tests/baselines/reference/parserClass2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(3,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(3,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(3,43): error TS2304: Cannot find name 'ILogger'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(4,37): error TS2304: Cannot find name 'ILogger'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(5,18): error TS2339: Property '_information' does not exist on type 'LoggerAdapter'. @@ -9,7 +9,7 @@ tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClass2.ts(5,1 export class LoggerAdapter implements ILogger { ~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~ !!! error TS2304: Cannot find name 'ILogger'. constructor (public logger: ILogger) { diff --git a/tests/baselines/reference/parserEnum1.errors.txt b/tests/baselines/reference/parserEnum1.errors.txt index ca89c5fc104..dd8cd23fe2c 100644 --- a/tests/baselines/reference/parserEnum1.errors.txt +++ b/tests/baselines/reference/parserEnum1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum1.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum1.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum1.ts(3,17) export enum SignatureFlags { ~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. None = 0, IsIndexer = 1, IsStringIndexer = 1 << 1, diff --git a/tests/baselines/reference/parserEnum2.errors.txt b/tests/baselines/reference/parserEnum2.errors.txt index f8a841fd9ba..242b624ad88 100644 --- a/tests/baselines/reference/parserEnum2.errors.txt +++ b/tests/baselines/reference/parserEnum2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum2.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum2.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum2.ts(3,17) export enum SignatureFlags { ~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. None = 0, IsIndexer = 1, IsStringIndexer = 1 << 1, diff --git a/tests/baselines/reference/parserEnum3.errors.txt b/tests/baselines/reference/parserEnum3.errors.txt index 463f338159a..e0b3691dbde 100644 --- a/tests/baselines/reference/parserEnum3.errors.txt +++ b/tests/baselines/reference/parserEnum3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum3.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum3.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum3.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum3.ts(3,17) export enum SignatureFlags { ~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } \ No newline at end of file diff --git a/tests/baselines/reference/parserEnum4.errors.txt b/tests/baselines/reference/parserEnum4.errors.txt index 9f2cd1d1862..9329b484c92 100644 --- a/tests/baselines/reference/parserEnum4.errors.txt +++ b/tests/baselines/reference/parserEnum4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum4.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum4.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum4.ts(4,9): error TS1132: Enum member expected. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum4.ts(4,9): export enum SignatureFlags { ~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. , ~ !!! error TS1132: Enum member expected. diff --git a/tests/baselines/reference/parserExportAssignment1.errors.txt b/tests/baselines/reference/parserExportAssignment1.errors.txt index cd153319f1a..cb989f655ce 100644 --- a/tests/baselines/reference/parserExportAssignment1.errors.txt +++ b/tests/baselines/reference/parserExportAssignment1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment1.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment1.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment1.ts(1,10): error TS2304: Cannot find name 'foo'. ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment1.ts (2 errors) ==== export = foo ~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~ !!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/parserExportAssignment2.errors.txt b/tests/baselines/reference/parserExportAssignment2.errors.txt index 60eb0c1f43e..7e7fcbd950f 100644 --- a/tests/baselines/reference/parserExportAssignment2.errors.txt +++ b/tests/baselines/reference/parserExportAssignment2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment2.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment2.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment2.ts(1,10): error TS2304: Cannot find name 'foo'. ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment2.ts (2 errors) ==== export = foo; ~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~ !!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/parserExportAssignment3.errors.txt b/tests/baselines/reference/parserExportAssignment3.errors.txt index b1e94a27469..5e2ff747e2d 100644 --- a/tests/baselines/reference/parserExportAssignment3.errors.txt +++ b/tests/baselines/reference/parserExportAssignment3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment3.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment3.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment3.ts(1,9): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment3.ts (2 errors) ==== export = ~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserExportAssignment4.errors.txt b/tests/baselines/reference/parserExportAssignment4.errors.txt index 93e311bdb23..10830b9b977 100644 --- a/tests/baselines/reference/parserExportAssignment4.errors.txt +++ b/tests/baselines/reference/parserExportAssignment4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment4.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment4.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment4.ts(1,10): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment4.ts (2 errors) ==== export = ; ~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserExportAssignment7.errors.txt b/tests/baselines/reference/parserExportAssignment7.errors.txt index 7e54f2a4bce..c4ecd785484 100644 --- a/tests/baselines/reference/parserExportAssignment7.errors.txt +++ b/tests/baselines/reference/parserExportAssignment7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment7.ts(1,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment7.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment7.ts(4,10): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignm ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment7.ts (3 errors) ==== export class C { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } export = B; diff --git a/tests/baselines/reference/parserExportAssignment8.errors.txt b/tests/baselines/reference/parserExportAssignment8.errors.txt index 71b37c99db7..39ccc32e495 100644 --- a/tests/baselines/reference/parserExportAssignment8.errors.txt +++ b/tests/baselines/reference/parserExportAssignment8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment8.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment8.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment8.ts(1,10): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignm ==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment8.ts (3 errors) ==== export = B; ~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. ~ diff --git a/tests/baselines/reference/parserInterfaceDeclaration6.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration6.errors.txt index ab6985c5ab1..6820ecdd48c 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration6.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts(1,8): error TS1030: 'export' modifier already seen. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts(1,25): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts(1,25): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterface ~~~~~~ !!! error TS1030: 'export' modifier already seen. ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration7.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration7.errors.txt index 344a5d9deb8..ecd59ae29e8 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration7.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration7.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration7.ts(1,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration7.ts(1,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration7.ts (1 errors) ==== export interface I { ~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. } \ No newline at end of file diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock1.errors.txt b/tests/baselines/reference/parserModifierOnStatementInBlock1.errors.txt index 973920e3584..c73c52ddd35 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock1.errors.txt +++ b/tests/baselines/reference/parserModifierOnStatementInBlock1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock1.ts(2,4): error TS1184: Modifiers cannot appear here. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock1.ts (2 errors) ==== export function foo() { ~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export var x = this; ~~~~~~ !!! error TS1184: Modifiers cannot appear here. diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock3.errors.txt b/tests/baselines/reference/parserModifierOnStatementInBlock3.errors.txt index 7a3fb004225..a480a0c4330 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock3.errors.txt +++ b/tests/baselines/reference/parserModifierOnStatementInBlock3.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock3.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock3.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock3.ts(2,4): error TS1184: Modifiers cannot appear here. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock3.ts (2 errors) ==== export function foo() { ~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export function bar() { ~~~~~~ !!! error TS1184: Modifiers cannot appear here. diff --git a/tests/baselines/reference/parserModule1.errors.txt b/tests/baselines/reference/parserModule1.errors.txt index 3a145493dd9..dc5c9c2dd35 100644 --- a/tests/baselines/reference/parserModule1.errors.txt +++ b/tests/baselines/reference/parserModule1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModule1.ts(1,19): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModule1.ts(1,19): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModule1.ts (1 errors) ==== export module CompilerDiagnostics { ~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export var debug = false; export interface IDiagnosticWriter { Alert(output: string): void; diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.errors.txt b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.errors.txt new file mode 100644 index 00000000000..52d6c4c0fff --- /dev/null +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.errors.txt @@ -0,0 +1,55 @@ +tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_core.ts(15,12): error TS2323: Cannot redeclare exported variable 'publicUse_im_public_mi_public'. +tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_core.ts(17,12): error TS2323: Cannot redeclare exported variable 'publicUse_im_public_mi_public'. + + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_core.ts (2 errors) ==== + /// + /// + // Privacy errors - importing private elements + export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); + export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); + export import im_public_mi_public = require("m"); + export import im_public_mu_public = require("m2"); + + // Usage of privacy error imports + var privateUse_im_public_mi_private = new im_public_mi_private.c_public(); + export var publicUse_im_public_mi_private = new im_public_mi_private.c_public(); + var privateUse_im_public_mu_private = new im_public_mu_private.c_public(); + export var publicUse_im_public_mu_private = new im_public_mu_private.c_public(); + var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); + export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'publicUse_im_public_mi_public'. + var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); + export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'publicUse_im_public_mi_public'. + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require.ts (0 errors) ==== + // Public elements + export class c_public { + foo: string; + } + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts (0 errors) ==== + export class c_public { + bar: string; + } + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts (0 errors) ==== + // private elements + // Export - Error ambient modules allowed only in global + declare module 'm' { + export class c_private { + baz: string; + } + } + + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require3.ts (0 errors) ==== + declare module 'm2' { + export class c_private { + bing: string; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols deleted file mode 100644 index 2dcddbbfa06..00000000000 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_core.ts === -/// -/// -// Privacy errors - importing private elements -export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); ->im_public_mi_private : Symbol(im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 0, 0)) - -export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) - -export import im_public_mi_public = require("m"); ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) - -export import im_public_mu_public = require("m2"); ->im_public_mu_public : Symbol(im_public_mu_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 5, 49)) - -// Usage of privacy error imports -var privateUse_im_public_mi_private = new im_public_mi_private.c_public(); ->privateUse_im_public_mi_private : Symbol(privateUse_im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 9, 3)) ->im_public_mi_private.c_public : Symbol(im_public_mi_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 0, 0)) ->im_public_mi_private : Symbol(im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 0, 0)) ->c_public : Symbol(im_public_mi_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 0, 0)) - -export var publicUse_im_public_mi_private = new im_public_mi_private.c_public(); ->publicUse_im_public_mi_private : Symbol(publicUse_im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 10, 10)) ->im_public_mi_private.c_public : Symbol(im_public_mi_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 0, 0)) ->im_public_mi_private : Symbol(im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 0, 0)) ->c_public : Symbol(im_public_mi_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 0, 0)) - -var privateUse_im_public_mu_private = new im_public_mu_private.c_public(); ->privateUse_im_public_mu_private : Symbol(privateUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 11, 3)) ->im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) ->c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) - -export var publicUse_im_public_mu_private = new im_public_mu_private.c_public(); ->publicUse_im_public_mu_private : Symbol(publicUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 12, 10)) ->im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) ->c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) - -var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); ->privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) ->im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) ->c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) - -export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); ->publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) ->im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) ->c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) - -var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); ->privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) ->im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) ->c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) - -export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); ->publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) ->im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) ->c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require.ts === -// Public elements -export class c_public { ->c_public : Symbol(c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 0, 0)) - - foo: string; ->foo : Symbol(foo, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require.ts, 1, 23)) -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts === -export class c_public { ->c_public : Symbol(c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) - - bar: string; ->bar : Symbol(bar, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 23)) -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts === -// private elements -// Export - Error ambient modules allowed only in global -declare module 'm' { - export class c_private { ->c_private : Symbol(c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) - - baz: string; ->baz : Symbol(baz, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 3, 28)) - } -} - - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require3.ts === -declare module 'm2' { - export class c_private { ->c_private : Symbol(c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require3.ts, 0, 21)) - - bing: string; ->bing : Symbol(bing, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require3.ts, 1, 28)) - } -} - diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types deleted file mode 100644 index 5c082bef5de..00000000000 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types +++ /dev/null @@ -1,113 +0,0 @@ -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_core.ts === -/// -/// -// Privacy errors - importing private elements -export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); ->im_public_mi_private : typeof im_public_mi_private - -export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); ->im_public_mu_private : typeof im_public_mu_private - -export import im_public_mi_public = require("m"); ->im_public_mi_public : typeof im_public_mi_public - -export import im_public_mu_public = require("m2"); ->im_public_mu_public : typeof im_public_mu_public - -// Usage of privacy error imports -var privateUse_im_public_mi_private = new im_public_mi_private.c_public(); ->privateUse_im_public_mi_private : im_public_mi_private.c_public ->new im_public_mi_private.c_public() : im_public_mi_private.c_public ->im_public_mi_private.c_public : typeof im_public_mi_private.c_public ->im_public_mi_private : typeof im_public_mi_private ->c_public : typeof im_public_mi_private.c_public - -export var publicUse_im_public_mi_private = new im_public_mi_private.c_public(); ->publicUse_im_public_mi_private : im_public_mi_private.c_public ->new im_public_mi_private.c_public() : im_public_mi_private.c_public ->im_public_mi_private.c_public : typeof im_public_mi_private.c_public ->im_public_mi_private : typeof im_public_mi_private ->c_public : typeof im_public_mi_private.c_public - -var privateUse_im_public_mu_private = new im_public_mu_private.c_public(); ->privateUse_im_public_mu_private : im_public_mu_private.c_public ->new im_public_mu_private.c_public() : im_public_mu_private.c_public ->im_public_mu_private.c_public : typeof im_public_mu_private.c_public ->im_public_mu_private : typeof im_public_mu_private ->c_public : typeof im_public_mu_private.c_public - -export var publicUse_im_public_mu_private = new im_public_mu_private.c_public(); ->publicUse_im_public_mu_private : im_public_mu_private.c_public ->new im_public_mu_private.c_public() : im_public_mu_private.c_public ->im_public_mu_private.c_public : typeof im_public_mu_private.c_public ->im_public_mu_private : typeof im_public_mu_private ->c_public : typeof im_public_mu_private.c_public - -var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); ->privateUse_im_public_mi_public : im_public_mi_public.c_private ->new im_public_mi_public.c_private() : im_public_mi_public.c_private ->im_public_mi_public.c_private : typeof im_public_mi_public.c_private ->im_public_mi_public : typeof im_public_mi_public ->c_private : typeof im_public_mi_public.c_private - -export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); ->publicUse_im_public_mi_public : im_public_mi_public.c_private ->new im_public_mi_public.c_private() : im_public_mi_public.c_private ->im_public_mi_public.c_private : typeof im_public_mi_public.c_private ->im_public_mi_public : typeof im_public_mi_public ->c_private : typeof im_public_mi_public.c_private - -var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); ->privateUse_im_public_mi_public : im_public_mi_public.c_private ->new im_public_mi_public.c_private() : im_public_mi_public.c_private ->im_public_mi_public.c_private : typeof im_public_mi_public.c_private ->im_public_mi_public : typeof im_public_mi_public ->c_private : typeof im_public_mi_public.c_private - -export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); ->publicUse_im_public_mi_public : im_public_mi_public.c_private ->new im_public_mi_public.c_private() : im_public_mi_public.c_private ->im_public_mi_public.c_private : typeof im_public_mi_public.c_private ->im_public_mi_public : typeof im_public_mi_public ->c_private : typeof im_public_mi_public.c_private - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require.ts === -// Public elements -export class c_public { ->c_public : c_public - - foo: string; ->foo : string -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts === -export class c_public { ->c_public : c_public - - bar: string; ->bar : string -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts === -// private elements -// Export - Error ambient modules allowed only in global -declare module 'm' { - export class c_private { ->c_private : c_private - - baz: string; ->baz : string - } -} - - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require3.ts === -declare module 'm2' { - export class c_private { ->c_private : c_private - - bing: string; ->bing : string - } -} - diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.errors.txt b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.errors.txt new file mode 100644 index 00000000000..cc81762bce3 --- /dev/null +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.errors.txt @@ -0,0 +1,55 @@ +tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts(15,12): error TS2323: Cannot redeclare exported variable 'publicUse_im_private_mi_public'. +tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts(17,12): error TS2323: Cannot redeclare exported variable 'publicUse_im_private_mi_public'. + + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts (2 errors) ==== + /// + /// + // Privacy errors - importing private elements + import im_private_mi_private = require("m"); + import im_private_mu_private = require("m2"); + import im_private_mi_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require"); + import im_private_mu_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require1"); + + // Usage of privacy error imports + var privateUse_im_private_mi_private = new im_private_mi_private.c_private(); + export var publicUse_im_private_mi_private = new im_private_mi_private.c_private(); + var privateUse_im_private_mu_private = new im_private_mu_private.c_private(); + export var publicUse_im_private_mu_private = new im_private_mu_private.c_private(); + var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); + export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'publicUse_im_private_mi_public'. + var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); + export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'publicUse_im_private_mi_public'. + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts (0 errors) ==== + + // Public elements + export class c_public { + foo: string; + } + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts (0 errors) ==== + export class c_public { + bar: string; + } + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts (0 errors) ==== + // private elements + // Export - Error ambient modules allowed only in global + declare module 'm' { + export class c_private { + baz: string + } + } + +==== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts (0 errors) ==== + declare module 'm2' { + export class c_private { + bing: string; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.symbols b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.symbols deleted file mode 100644 index e366538124f..00000000000 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts === -/// -/// -// Privacy errors - importing private elements -import im_private_mi_private = require("m"); ->im_private_mi_private : Symbol(im_private_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 0, 0)) - -import im_private_mu_private = require("m2"); ->im_private_mu_private : Symbol(im_private_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 3, 44)) - -import im_private_mi_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require"); ->im_private_mi_public : Symbol(im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 4, 45)) - -import im_private_mu_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require1"); ->im_private_mu_public : Symbol(im_private_mu_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 5, 105)) - -// Usage of privacy error imports -var privateUse_im_private_mi_private = new im_private_mi_private.c_private(); ->privateUse_im_private_mi_private : Symbol(privateUse_im_private_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 9, 3)) ->im_private_mi_private.c_private : Symbol(im_private_mi_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 2, 20)) ->im_private_mi_private : Symbol(im_private_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 0, 0)) ->c_private : Symbol(im_private_mi_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 2, 20)) - -export var publicUse_im_private_mi_private = new im_private_mi_private.c_private(); ->publicUse_im_private_mi_private : Symbol(publicUse_im_private_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 10, 10)) ->im_private_mi_private.c_private : Symbol(im_private_mi_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 2, 20)) ->im_private_mi_private : Symbol(im_private_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 0, 0)) ->c_private : Symbol(im_private_mi_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 2, 20)) - -var privateUse_im_private_mu_private = new im_private_mu_private.c_private(); ->privateUse_im_private_mu_private : Symbol(privateUse_im_private_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 11, 3)) ->im_private_mu_private.c_private : Symbol(im_private_mu_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 0, 21)) ->im_private_mu_private : Symbol(im_private_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 3, 44)) ->c_private : Symbol(im_private_mu_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 0, 21)) - -export var publicUse_im_private_mu_private = new im_private_mu_private.c_private(); ->publicUse_im_private_mu_private : Symbol(publicUse_im_private_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 12, 10)) ->im_private_mu_private.c_private : Symbol(im_private_mu_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 0, 21)) ->im_private_mu_private : Symbol(im_private_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 3, 44)) ->c_private : Symbol(im_private_mu_private.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 0, 21)) - -var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); ->privateUse_im_private_mi_public : Symbol(privateUse_im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 15, 3)) ->im_private_mi_public.c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) ->im_private_mi_public : Symbol(im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 4, 45)) ->c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) - -export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); ->publicUse_im_private_mi_public : Symbol(publicUse_im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 16, 10)) ->im_private_mi_public.c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) ->im_private_mi_public : Symbol(im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 4, 45)) ->c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) - -var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); ->privateUse_im_private_mi_public : Symbol(privateUse_im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 15, 3)) ->im_private_mi_public.c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) ->im_private_mi_public : Symbol(im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 4, 45)) ->c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) - -export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); ->publicUse_im_private_mi_public : Symbol(publicUse_im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 16, 10)) ->im_private_mi_public.c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) ->im_private_mi_public : Symbol(im_private_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts, 4, 45)) ->c_public : Symbol(im_private_mi_public.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts === - -// Public elements -export class c_public { ->c_public : Symbol(c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 0, 0)) - - foo: string; ->foo : Symbol(foo, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts, 2, 23)) -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts === -export class c_public { ->c_public : Symbol(c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts, 0, 0)) - - bar: string; ->bar : Symbol(bar, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts, 0, 23)) -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts === -// private elements -// Export - Error ambient modules allowed only in global -declare module 'm' { - export class c_private { ->c_private : Symbol(c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 2, 20)) - - baz: string ->baz : Symbol(baz, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts, 3, 28)) - } -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts === -declare module 'm2' { - export class c_private { ->c_private : Symbol(c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 0, 21)) - - bing: string; ->bing : Symbol(bing, Decl(privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts, 1, 28)) - } -} - diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.types b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.types deleted file mode 100644 index 437d35fb64a..00000000000 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.types +++ /dev/null @@ -1,113 +0,0 @@ -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_core.ts === -/// -/// -// Privacy errors - importing private elements -import im_private_mi_private = require("m"); ->im_private_mi_private : typeof im_private_mi_private - -import im_private_mu_private = require("m2"); ->im_private_mu_private : typeof im_private_mu_private - -import im_private_mi_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require"); ->im_private_mi_public : typeof im_private_mi_public - -import im_private_mu_public = require("privacyTopLevelAmbientExternalModuleImportWithoutExport_require1"); ->im_private_mu_public : typeof im_private_mu_public - -// Usage of privacy error imports -var privateUse_im_private_mi_private = new im_private_mi_private.c_private(); ->privateUse_im_private_mi_private : im_private_mi_private.c_private ->new im_private_mi_private.c_private() : im_private_mi_private.c_private ->im_private_mi_private.c_private : typeof im_private_mi_private.c_private ->im_private_mi_private : typeof im_private_mi_private ->c_private : typeof im_private_mi_private.c_private - -export var publicUse_im_private_mi_private = new im_private_mi_private.c_private(); ->publicUse_im_private_mi_private : im_private_mi_private.c_private ->new im_private_mi_private.c_private() : im_private_mi_private.c_private ->im_private_mi_private.c_private : typeof im_private_mi_private.c_private ->im_private_mi_private : typeof im_private_mi_private ->c_private : typeof im_private_mi_private.c_private - -var privateUse_im_private_mu_private = new im_private_mu_private.c_private(); ->privateUse_im_private_mu_private : im_private_mu_private.c_private ->new im_private_mu_private.c_private() : im_private_mu_private.c_private ->im_private_mu_private.c_private : typeof im_private_mu_private.c_private ->im_private_mu_private : typeof im_private_mu_private ->c_private : typeof im_private_mu_private.c_private - -export var publicUse_im_private_mu_private = new im_private_mu_private.c_private(); ->publicUse_im_private_mu_private : im_private_mu_private.c_private ->new im_private_mu_private.c_private() : im_private_mu_private.c_private ->im_private_mu_private.c_private : typeof im_private_mu_private.c_private ->im_private_mu_private : typeof im_private_mu_private ->c_private : typeof im_private_mu_private.c_private - -var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); ->privateUse_im_private_mi_public : im_private_mi_public.c_public ->new im_private_mi_public.c_public() : im_private_mi_public.c_public ->im_private_mi_public.c_public : typeof im_private_mi_public.c_public ->im_private_mi_public : typeof im_private_mi_public ->c_public : typeof im_private_mi_public.c_public - -export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); ->publicUse_im_private_mi_public : im_private_mi_public.c_public ->new im_private_mi_public.c_public() : im_private_mi_public.c_public ->im_private_mi_public.c_public : typeof im_private_mi_public.c_public ->im_private_mi_public : typeof im_private_mi_public ->c_public : typeof im_private_mi_public.c_public - -var privateUse_im_private_mi_public = new im_private_mi_public.c_public(); ->privateUse_im_private_mi_public : im_private_mi_public.c_public ->new im_private_mi_public.c_public() : im_private_mi_public.c_public ->im_private_mi_public.c_public : typeof im_private_mi_public.c_public ->im_private_mi_public : typeof im_private_mi_public ->c_public : typeof im_private_mi_public.c_public - -export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); ->publicUse_im_private_mi_public : im_private_mi_public.c_public ->new im_private_mi_public.c_public() : im_private_mi_public.c_public ->im_private_mi_public.c_public : typeof im_private_mi_public.c_public ->im_private_mi_public : typeof im_private_mi_public ->c_public : typeof im_private_mi_public.c_public - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require.ts === - -// Public elements -export class c_public { ->c_public : c_public - - foo: string; ->foo : string -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.ts === -export class c_public { ->c_public : c_public - - bar: string; ->bar : string -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require2.ts === -// private elements -// Export - Error ambient modules allowed only in global -declare module 'm' { - export class c_private { ->c_private : c_private - - baz: string ->baz : string - } -} - -=== tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithoutExport_require3.ts === -declare module 'm2' { - export class c_private { ->c_private : c_private - - bing: string; ->bing : string - } -} - diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 47359caf9c2..815d0a44d53 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/propertyAssignment.ts(6,13): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. tests/cases/compiler/propertyAssignment.ts(6,14): error TS2304: Cannot find name 'index'. tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. + Type '{ x: number; }' provides no match for the signature 'new (): any' tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. + Type '{ x: number; }' provides no match for the signature '(): void' ==== tests/cases/compiler/propertyAssignment.ts (4 errors) ==== @@ -25,7 +27,9 @@ tests/cases/compiler/propertyAssignment.ts(16,1): error TS2322: Type '{ x: numbe foo1 = bar1; // should be an error ~~~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. +!!! error TS2322: Type '{ x: number; }' provides no match for the signature 'new (): any' foo2 = bar2; foo3 = bar3; // should be an error ~~~~ -!!! error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. \ No newline at end of file +!!! error TS2322: Type '{ x: number; }' is not assignable to type '() => void'. +!!! error TS2322: Type '{ x: number; }' provides no match for the signature '(): void' \ No newline at end of file diff --git a/tests/baselines/reference/qualify.errors.txt b/tests/baselines/reference/qualify.errors.txt index c7679a0a0f8..f38fc93ccde 100644 --- a/tests/baselines/reference/qualify.errors.txt +++ b/tests/baselines/reference/qualify.errors.txt @@ -7,7 +7,9 @@ tests/cases/compiler/qualify.ts(45,13): error TS2322: Type 'I4' is not assignabl tests/cases/compiler/qualify.ts(46,13): error TS2322: Type 'I4' is not assignable to type 'I3[]'. Property 'length' is missing in type 'I4'. tests/cases/compiler/qualify.ts(47,13): error TS2322: Type 'I4' is not assignable to type '() => I3'. + Type 'I4' provides no match for the signature '(): I3' tests/cases/compiler/qualify.ts(48,13): error TS2322: Type 'I4' is not assignable to type '(k: I3) => void'. + Type 'I4' provides no match for the signature '(k: I3): void' tests/cases/compiler/qualify.ts(49,13): error TS2322: Type 'I4' is not assignable to type '{ k: I3; }'. Property 'k' is missing in type 'I4'. tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable to type 'T.I'. @@ -76,9 +78,11 @@ tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable var v4:()=>K1.I3=v1; ~~ !!! error TS2322: Type 'I4' is not assignable to type '() => I3'. +!!! error TS2322: Type 'I4' provides no match for the signature '(): I3' var v5:(k:K1.I3)=>void=v1; ~~ !!! error TS2322: Type 'I4' is not assignable to type '(k: I3) => void'. +!!! error TS2322: Type 'I4' provides no match for the signature '(k: I3): void' var v6:{k:K1.I3;}=v1; ~~ !!! error TS2322: Type 'I4' is not assignable to type '{ k: I3; }'. diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt b/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt index b8429be5ea0..bd392492899 100644 --- a/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt +++ b/tests/baselines/reference/recursiveBaseConstructorCreation3.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/recursiveBaseConstructorCreation3.ts(6,27): error TS2314: Generic type 'abc' requires 1 type argument(s). -tests/cases/compiler/recursiveBaseConstructorCreation3.ts(10,18): error TS2339: Property 'foo' does not exist on type 'xyz'. +tests/cases/compiler/recursiveBaseConstructorCreation3.ts(9,11): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. ==== tests/cases/compiler/recursiveBaseConstructorCreation3.ts (2 errors) ==== @@ -14,6 +14,6 @@ tests/cases/compiler/recursiveBaseConstructorCreation3.ts(10,18): error TS2339: } var bar = new xyz(); // Error: Invalid 'new' expression. - var r: xyz = bar.foo; - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'xyz'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + var r: xyz = bar.foo; \ No newline at end of file diff --git a/tests/baselines/reference/recursiveUnionTypeInference.js b/tests/baselines/reference/recursiveUnionTypeInference.js new file mode 100644 index 00000000000..580a6bf83e5 --- /dev/null +++ b/tests/baselines/reference/recursiveUnionTypeInference.js @@ -0,0 +1,14 @@ +//// [recursiveUnionTypeInference.ts] +interface Foo { + x: T; +} + +function bar(x: Foo | string): T { + return bar(x); +} + + +//// [recursiveUnionTypeInference.js] +function bar(x) { + return bar(x); +} diff --git a/tests/baselines/reference/recursiveUnionTypeInference.symbols b/tests/baselines/reference/recursiveUnionTypeInference.symbols new file mode 100644 index 00000000000..88233573941 --- /dev/null +++ b/tests/baselines/reference/recursiveUnionTypeInference.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/recursiveUnionTypeInference.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(recursiveUnionTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveUnionTypeInference.ts, 0, 14)) + + x: T; +>x : Symbol(x, Decl(recursiveUnionTypeInference.ts, 0, 18)) +>T : Symbol(T, Decl(recursiveUnionTypeInference.ts, 0, 14)) +} + +function bar(x: Foo | string): T { +>bar : Symbol(bar, Decl(recursiveUnionTypeInference.ts, 2, 1)) +>T : Symbol(T, Decl(recursiveUnionTypeInference.ts, 4, 13)) +>x : Symbol(x, Decl(recursiveUnionTypeInference.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(recursiveUnionTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveUnionTypeInference.ts, 4, 13)) +>T : Symbol(T, Decl(recursiveUnionTypeInference.ts, 4, 13)) + + return bar(x); +>bar : Symbol(bar, Decl(recursiveUnionTypeInference.ts, 2, 1)) +>x : Symbol(x, Decl(recursiveUnionTypeInference.ts, 4, 16)) +} + diff --git a/tests/baselines/reference/recursiveUnionTypeInference.types b/tests/baselines/reference/recursiveUnionTypeInference.types new file mode 100644 index 00000000000..e5d62a051a5 --- /dev/null +++ b/tests/baselines/reference/recursiveUnionTypeInference.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/recursiveUnionTypeInference.ts === +interface Foo { +>Foo : Foo +>T : T + + x: T; +>x : T +>T : T +} + +function bar(x: Foo | string): T { +>bar : (x: Foo | string) => T +>T : T +>x : Foo | string +>Foo : Foo +>T : T +>T : T + + return bar(x); +>bar(x) : T +>bar : (x: Foo | string) => T +>x : Foo | string +} + diff --git a/tests/baselines/reference/relativePathToDeclarationFile.errors.txt b/tests/baselines/reference/relativePathToDeclarationFile.errors.txt index 041dd5c3a8f..0431c3a5bfa 100644 --- a/tests/baselines/reference/relativePathToDeclarationFile.errors.txt +++ b/tests/baselines/reference/relativePathToDeclarationFile.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/test/foo.d.ts(1,23): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/externalModules/test/foo.d.ts(1,23): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/externalModules/test/file1.ts (0 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/externalModules/test/foo.d.ts(1,23): error TS1148: Canno ==== tests/cases/conformance/externalModules/test/foo.d.ts (1 errors) ==== export declare module M2 { ~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export var x: boolean; } diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index d6e2d04073d..fa89df3af7a 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/reservedWords2.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/compiler/reservedWords2.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/compiler/reservedWords2.ts(1,8): error TS1109: Expression expected. tests/cases/compiler/reservedWords2.ts(1,14): error TS1005: '(' expected. tests/cases/compiler/reservedWords2.ts(1,16): error TS2304: Cannot find name 'require'. @@ -35,7 +35,7 @@ tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected. ==== tests/cases/compiler/reservedWords2.ts (32 errors) ==== import while = require("dfdf"); ~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~ !!! error TS1109: Expression expected. ~ diff --git a/tests/baselines/reference/scannerClass2.errors.txt b/tests/baselines/reference/scannerClass2.errors.txt index 74b62602dad..d808f6fdd59 100644 --- a/tests/baselines/reference/scannerClass2.errors.txt +++ b/tests/baselines/reference/scannerClass2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(3,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(3,18): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(3,43): error TS2304: Cannot find name 'ILogger'. tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(4,37): error TS2304: Cannot find name 'ILogger'. tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(5,18): error TS2339: Property '_information' does not exist on type 'LoggerAdapter'. @@ -9,7 +9,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerClass2.ts(5,18): error TS2339 export class LoggerAdapter implements ILogger { ~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ~~~~~~~ !!! error TS2304: Cannot find name 'ILogger'. constructor (public logger: ILogger) { diff --git a/tests/baselines/reference/scannerEnum1.errors.txt b/tests/baselines/reference/scannerEnum1.errors.txt index 64d7508980f..d0bbf16743c 100644 --- a/tests/baselines/reference/scannerEnum1.errors.txt +++ b/tests/baselines/reference/scannerEnum1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/scanner/ecmascript5/scannerEnum1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/scanner/ecmascript5/scannerEnum1.ts(1,17): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/scanner/ecmascript5/scannerEnum1.ts (1 errors) ==== export enum CodeGenTarget { ~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ES3 = 0, ES5 = 1, } \ No newline at end of file diff --git a/tests/baselines/reference/shebangBeforeReferences.js b/tests/baselines/reference/shebangBeforeReferences.js index 6be2707277d..6c3e1420c4a 100644 --- a/tests/baselines/reference/shebangBeforeReferences.js +++ b/tests/baselines/reference/shebangBeforeReferences.js @@ -16,6 +16,7 @@ import {x} from "test"; use(x); //// [f.js] -#!/usr/bin/env node"use strict"; +#!/usr/bin/env node +"use strict"; var test_1 = require("test"); use(test_1.x); diff --git a/tests/baselines/reference/strictModeReservedWord.errors.txt b/tests/baselines/reference/strictModeReservedWord.errors.txt index 6f6a387429d..02ece81a1d9 100644 --- a/tests/baselines/reference/strictModeReservedWord.errors.txt +++ b/tests/baselines/reference/strictModeReservedWord.errors.txt @@ -1,6 +1,8 @@ +tests/cases/compiler/strictModeReservedWord.ts(1,5): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. tests/cases/compiler/strictModeReservedWord.ts(5,9): error TS1212: Identifier expected. 'public' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(6,9): error TS1212: Identifier expected. 'static' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(7,9): error TS1212: Identifier expected. 'let' is a reserved word in strict mode +tests/cases/compiler/strictModeReservedWord.ts(7,9): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. tests/cases/compiler/strictModeReservedWord.ts(8,9): error TS1212: Identifier expected. 'package' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(8,9): error TS2300: Duplicate identifier 'package'. tests/cases/compiler/strictModeReservedWord.ts(9,14): error TS1212: Identifier expected. 'package' is a reserved word in strict mode @@ -41,8 +43,10 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS1212: Identifier e tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. -==== tests/cases/compiler/strictModeReservedWord.ts (41 errors) ==== +==== tests/cases/compiler/strictModeReservedWord.ts (43 errors) ==== let let = 10; + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. function foo() { "use strict" @@ -55,6 +59,8 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok let let = "blah"; ~~~ !!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. var package = "hello" ~~~~~~~ !!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode diff --git a/tests/baselines/reference/targetTypeVoidFunc.errors.txt b/tests/baselines/reference/targetTypeVoidFunc.errors.txt index f9434c1d630..d47f811c2ed 100644 --- a/tests/baselines/reference/targetTypeVoidFunc.errors.txt +++ b/tests/baselines/reference/targetTypeVoidFunc.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/targetTypeVoidFunc.ts(2,12): error TS2322: Type '() => void' is not assignable to type 'new () => number'. + Type '() => void' provides no match for the signature 'new (): number' ==== tests/cases/compiler/targetTypeVoidFunc.ts (1 errors) ==== @@ -6,6 +7,7 @@ tests/cases/compiler/targetTypeVoidFunc.ts(2,12): error TS2322: Type '() => void return function () { return; } ~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'new () => number'. +!!! error TS2322: Type '() => void' provides no match for the signature 'new (): number' }; var x = f1(); diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 2aa474d4cdc..a1afdea661b 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'any' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. ==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (8 errors) ==== @@ -72,4 +72,4 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod export = this; // Should be an error ~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. \ No newline at end of file +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. \ No newline at end of file diff --git a/tests/baselines/reference/tsxPreserveEmit1.js b/tests/baselines/reference/tsxPreserveEmit1.js index 894d0c3d698..7ac6c18ebca 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.js +++ b/tests/baselines/reference/tsxPreserveEmit1.js @@ -22,12 +22,28 @@ import ReactRouter = require('react-router'); import Route = ReactRouter.Route; -var routes = ; +var routes1 = ; + +module M { + export var X: any; +} +module M { + // Should emit 'M.X' in both opening and closing tags + var y = ; +} //// [test.jsx] define(["require", "exports", 'react-router'], function (require, exports, ReactRouter) { "use strict"; var Route = ReactRouter.Route; - var routes = ; + var routes1 = ; + var M; + (function (M) { + })(M || (M = {})); + var M; + (function (M) { + // Should emit 'M.X' in both opening and closing tags + var y = ; + })(M || (M = {})); }); diff --git a/tests/baselines/reference/tsxPreserveEmit1.symbols b/tests/baselines/reference/tsxPreserveEmit1.symbols index 6dcf4d9ac49..53707b86104 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.symbols +++ b/tests/baselines/reference/tsxPreserveEmit1.symbols @@ -11,10 +11,26 @@ import Route = ReactRouter.Route; >ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 4, 1)) >Route : Symbol(ReactRouter.Route, Decl(react.d.ts, 7, 4)) -var routes = ; ->routes : Symbol(routes, Decl(test.tsx, 6, 3)) +var routes1 = ; +>routes1 : Symbol(routes1, Decl(test.tsx, 6, 3)) >Route : Symbol(Route, Decl(test.tsx, 2, 45)) +module M { +>M : Symbol(M, Decl(test.tsx, 6, 24), Decl(test.tsx, 10, 1)) + + export var X: any; +>X : Symbol(X, Decl(test.tsx, 9, 11)) +} +module M { +>M : Symbol(M, Decl(test.tsx, 6, 24), Decl(test.tsx, 10, 1)) + + // Should emit 'M.X' in both opening and closing tags + var y = ; +>y : Symbol(y, Decl(test.tsx, 13, 4)) +>X : Symbol(X, Decl(test.tsx, 9, 11)) +>X : Symbol(X, Decl(test.tsx, 9, 11)) +} + === tests/cases/conformance/jsx/react.d.ts === declare module 'react' { diff --git a/tests/baselines/reference/tsxPreserveEmit1.types b/tests/baselines/reference/tsxPreserveEmit1.types index ea64e2d2e94..26da75b39e4 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.types +++ b/tests/baselines/reference/tsxPreserveEmit1.types @@ -11,11 +11,28 @@ import Route = ReactRouter.Route; >ReactRouter : typeof ReactRouter >Route : any -var routes = ; ->routes : any +var routes1 = ; +>routes1 : any > : any >Route : any +module M { +>M : typeof M + + export var X: any; +>X : any +} +module M { +>M : typeof M + + // Should emit 'M.X' in both opening and closing tags + var y = ; +>y : any +> : any +>X : any +>X : any +} + === tests/cases/conformance/jsx/react.d.ts === declare module 'react' { diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt index 49f3ab6bac4..cced3116b5e 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/jsx/file.tsx(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. tests/cases/conformance/jsx/file.tsx(20,16): error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'. tests/cases/conformance/jsx/file.tsx(26,42): error TS2339: Property 'subtr' does not exist on type 'string'. tests/cases/conformance/jsx/file.tsx(28,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'. @@ -9,7 +9,7 @@ tests/cases/conformance/jsx/file.tsx(36,26): error TS2339: Property 'propertyNot import React = require('react'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. function Greet(x: {name?: string}) { return
Hello, {x}
; diff --git a/tests/baselines/reference/typeofANonExportedType.errors.txt b/tests/baselines/reference/typeofANonExportedType.errors.txt index d07468f62e1..2399938dcfc 100644 --- a/tests/baselines/reference/typeofANonExportedType.errors.txt +++ b/tests/baselines/reference/typeofANonExportedType.errors.txt @@ -1,12 +1,14 @@ -tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(20,12): error TS2323: Cannot redeclare exported variable 'r5'. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(21,12): error TS2323: Cannot redeclare exported variable 'r5'. tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (2 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (4 errors) ==== var x = 1; export var r1: typeof x; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. var y = { foo: '' }; export var r2: typeof y; class C { @@ -25,7 +27,11 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType export var i: I; var i2: I; export var r5: typeof i; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'r5'. export var r5: typeof i2; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'r5'. module M { export var foo = ''; diff --git a/tests/baselines/reference/typeofAnExportedType.errors.txt b/tests/baselines/reference/typeofAnExportedType.errors.txt index cb6d8c68887..9740909bd59 100644 --- a/tests/baselines/reference/typeofAnExportedType.errors.txt +++ b/tests/baselines/reference/typeofAnExportedType.errors.txt @@ -1,11 +1,13 @@ -tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(20,12): error TS2323: Cannot redeclare exported variable 'r5'. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(21,12): error TS2323: Cannot redeclare exported variable 'r5'. tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (2 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (4 errors) ==== export var x = 1; ~~~~~~~~~~~~~~~~~ -!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. export var r1: typeof x; export var y = { foo: '' }; export var r2: typeof y; @@ -25,7 +27,11 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.t export var i: I; var i2: I; export var r5: typeof i; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'r5'. export var r5: typeof i2; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'r5'. export module M { export var foo = ''; diff --git a/tests/baselines/reference/typesWithPrivateConstructor.errors.txt b/tests/baselines/reference/typesWithPrivateConstructor.errors.txt index 2440e51cd39..261038a1f4a 100644 --- a/tests/baselines/reference/typesWithPrivateConstructor.errors.txt +++ b/tests/baselines/reference/typesWithPrivateConstructor.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(4,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(8,5): error TS2322: Type 'Function' is not assignable to type '() => void'. + Type 'Function' provides no match for the signature '(): void' tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(11,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(12,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(15,10): error TS2346: Supplied parameters do not match any signature of call target. @@ -18,6 +19,7 @@ tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(15,10): err var r: () => void = c.constructor; ~ !!! error TS2322: Type 'Function' is not assignable to type '() => void'. +!!! error TS2322: Type 'Function' provides no match for the signature '(): void' class C2 { private constructor(x: number); diff --git a/tests/baselines/reference/typesWithPublicConstructor.errors.txt b/tests/baselines/reference/typesWithPublicConstructor.errors.txt index a3d66c3520a..54bee79dae0 100644 --- a/tests/baselines/reference/typesWithPublicConstructor.errors.txt +++ b/tests/baselines/reference/typesWithPublicConstructor.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/members/typesWithPublicConstructor.ts(8,5): error TS2322: Type 'Function' is not assignable to type '() => void'. + Type 'Function' provides no match for the signature '(): void' tests/cases/conformance/types/members/typesWithPublicConstructor.ts(15,10): error TS2346: Supplied parameters do not match any signature of call target. @@ -13,6 +14,7 @@ tests/cases/conformance/types/members/typesWithPublicConstructor.ts(15,10): erro var r: () => void = c.constructor; ~ !!! error TS2322: Type 'Function' is not assignable to type '() => void'. +!!! error TS2322: Type 'Function' provides no match for the signature '(): void' class C2 { public constructor(x: number); diff --git a/tests/baselines/reference/undefinedTypeAssignment1.errors.txt b/tests/baselines/reference/undefinedTypeAssignment1.errors.txt new file mode 100644 index 00000000000..b8dd74a58a8 --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/undefinedTypeAssignment1.ts(1,1): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + + +==== tests/cases/compiler/undefinedTypeAssignment1.ts (1 errors) ==== + type undefined = string; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + function p(undefined = "wat") { + return undefined; + } + \ No newline at end of file diff --git a/tests/baselines/reference/undefinedTypeAssignment1.js b/tests/baselines/reference/undefinedTypeAssignment1.js new file mode 100644 index 00000000000..1f53c4f6c45 --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment1.js @@ -0,0 +1,12 @@ +//// [undefinedTypeAssignment1.ts] +type undefined = string; +function p(undefined = "wat") { + return undefined; +} + + +//// [undefinedTypeAssignment1.js] +function p(undefined) { + if (undefined === void 0) { undefined = "wat"; } + return undefined; +} diff --git a/tests/baselines/reference/undefinedTypeAssignment2.errors.txt b/tests/baselines/reference/undefinedTypeAssignment2.errors.txt new file mode 100644 index 00000000000..55fdbf0fc1b --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/undefinedTypeAssignment2.ts(1,5): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + + +==== tests/cases/compiler/undefinedTypeAssignment2.ts (1 errors) ==== + var undefined = void 0; + ~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + \ No newline at end of file diff --git a/tests/baselines/reference/undefinedTypeAssignment2.js b/tests/baselines/reference/undefinedTypeAssignment2.js new file mode 100644 index 00000000000..040bc8c800d --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment2.js @@ -0,0 +1,6 @@ +//// [undefinedTypeAssignment2.ts] +var undefined = void 0; + + +//// [undefinedTypeAssignment2.js] +var undefined = void 0; diff --git a/tests/baselines/reference/undefinedTypeAssignment3.errors.txt b/tests/baselines/reference/undefinedTypeAssignment3.errors.txt new file mode 100644 index 00000000000..88df370940f --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment3.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/undefinedTypeAssignment3.ts(1,5): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + + +==== tests/cases/compiler/undefinedTypeAssignment3.ts (1 errors) ==== + var undefined = null; + ~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + \ No newline at end of file diff --git a/tests/baselines/reference/undefinedTypeAssignment3.js b/tests/baselines/reference/undefinedTypeAssignment3.js new file mode 100644 index 00000000000..4015d49e33a --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment3.js @@ -0,0 +1,6 @@ +//// [undefinedTypeAssignment3.ts] +var undefined = null; + + +//// [undefinedTypeAssignment3.js] +var undefined = null; diff --git a/tests/baselines/reference/undefinedTypeAssignment4.errors.txt b/tests/baselines/reference/undefinedTypeAssignment4.errors.txt new file mode 100644 index 00000000000..dab6ea2a880 --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment4.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/undefinedTypeAssignment4.ts(1,7): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. +tests/cases/compiler/undefinedTypeAssignment4.ts(4,11): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. +tests/cases/compiler/undefinedTypeAssignment4.ts(7,11): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + + +==== tests/cases/compiler/undefinedTypeAssignment4.ts (3 errors) ==== + class undefined { + ~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + foo: string; + } + interface undefined { + ~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + member: number; + } + namespace undefined { + ~~~~~~~~~ +!!! error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. + export var x = 42; + } + var x: undefined; + var y: typeof undefined; + \ No newline at end of file diff --git a/tests/baselines/reference/undefinedTypeAssignment4.js b/tests/baselines/reference/undefinedTypeAssignment4.js new file mode 100644 index 00000000000..186afd872c3 --- /dev/null +++ b/tests/baselines/reference/undefinedTypeAssignment4.js @@ -0,0 +1,26 @@ +//// [undefinedTypeAssignment4.ts] +class undefined { + foo: string; +} +interface undefined { + member: number; +} +namespace undefined { + export var x = 42; +} +var x: undefined; +var y: typeof undefined; + + +//// [undefinedTypeAssignment4.js] +var undefined = (function () { + function undefined() { + } + return undefined; +})(); +var undefined; +(function (undefined) { + undefined.x = 42; +})(undefined || (undefined = {})); +var x; +var y; diff --git a/tests/baselines/reference/unionTypeParameterInference.js b/tests/baselines/reference/unionTypeParameterInference.js new file mode 100644 index 00000000000..c96e809cd4d --- /dev/null +++ b/tests/baselines/reference/unionTypeParameterInference.js @@ -0,0 +1,17 @@ +//// [unionTypeParameterInference.ts] +// Regression test for #5861 + +interface Foo { prop: T; } + +declare function lift(value: U | Foo): Foo; + +function unlift(value: U | Foo): U { + return lift(value).prop; +} + + +//// [unionTypeParameterInference.js] +// Regression test for #5861 +function unlift(value) { + return lift(value).prop; +} diff --git a/tests/baselines/reference/unionTypeParameterInference.symbols b/tests/baselines/reference/unionTypeParameterInference.symbols new file mode 100644 index 00000000000..f2dbaac31ff --- /dev/null +++ b/tests/baselines/reference/unionTypeParameterInference.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/unionTypeParameterInference.ts === +// Regression test for #5861 + +interface Foo { prop: T; } +>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) +>T : Symbol(T, Decl(unionTypeParameterInference.ts, 2, 14)) +>prop : Symbol(prop, Decl(unionTypeParameterInference.ts, 2, 18)) +>T : Symbol(T, Decl(unionTypeParameterInference.ts, 2, 14)) + +declare function lift(value: U | Foo): Foo; +>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 2, 29)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 25)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) +>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) +>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) + +function unlift(value: U | Foo): U { +>unlift : Symbol(unlift, Decl(unionTypeParameterInference.ts, 4, 52)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 6, 19)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) +>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) + + return lift(value).prop; +>lift(value).prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 2, 18)) +>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 2, 29)) +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 6, 19)) +>prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 2, 18)) +} + diff --git a/tests/baselines/reference/unionTypeParameterInference.types b/tests/baselines/reference/unionTypeParameterInference.types new file mode 100644 index 00000000000..54eaed90ecc --- /dev/null +++ b/tests/baselines/reference/unionTypeParameterInference.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/unionTypeParameterInference.ts === +// Regression test for #5861 + +interface Foo { prop: T; } +>Foo : Foo +>T : T +>prop : T +>T : T + +declare function lift(value: U | Foo): Foo; +>lift : (value: U | Foo) => Foo +>U : U +>value : U | Foo +>U : U +>Foo : Foo +>U : U +>Foo : Foo +>U : U + +function unlift(value: U | Foo): U { +>unlift : (value: U | Foo) => U +>U : U +>value : U | Foo +>U : U +>Foo : Foo +>U : U +>U : U + + return lift(value).prop; +>lift(value).prop : U +>lift(value) : Foo +>lift : (value: U | Foo) => Foo +>value : U | Foo +>prop : U +} + diff --git a/tests/cases/compiler/ClassDeclaration26.ts b/tests/cases/compiler/ClassDeclaration26.ts new file mode 100644 index 00000000000..0adcbc470e0 --- /dev/null +++ b/tests/cases/compiler/ClassDeclaration26.ts @@ -0,0 +1,5 @@ +class C { + public const var export foo = 10; + + var constructor() { } +} \ No newline at end of file diff --git a/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts b/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts new file mode 100644 index 00000000000..06af5a0fdb5 --- /dev/null +++ b/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts @@ -0,0 +1,3 @@ +class AtomicNumbers { + static const H = 1; +} \ No newline at end of file diff --git a/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts b/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts new file mode 100644 index 00000000000..fe90dded9e3 --- /dev/null +++ b/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.ts @@ -0,0 +1,4 @@ +class C { + const + x = 10; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues.ts b/tests/cases/compiler/exportStarForValues.ts new file mode 100644 index 00000000000..3432548c528 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues.ts @@ -0,0 +1,8 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +var x; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues10.ts b/tests/cases/compiler/exportStarForValues10.ts new file mode 100644 index 00000000000..82cee772b18 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues10.ts @@ -0,0 +1,12 @@ +// @module: system + +// @filename: file0.ts +export var v = 1; + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file0"; +export * from "file1"; +var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues2.ts b/tests/cases/compiler/exportStarForValues2.ts new file mode 100644 index 00000000000..63a880cce0a --- /dev/null +++ b/tests/cases/compiler/exportStarForValues2.ts @@ -0,0 +1,12 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +var x = 1; + +// @filename: file3.ts +export * from "file2" +var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues3.ts b/tests/cases/compiler/exportStarForValues3.ts new file mode 100644 index 00000000000..f0c36db0bda --- /dev/null +++ b/tests/cases/compiler/exportStarForValues3.ts @@ -0,0 +1,24 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export interface A { x } +export * from "file1" +var x = 1; + +// @filename: file3.ts +export interface B { x } +export * from "file1" +var x = 1; + +// @filename: file4.ts +export interface C { x } +export * from "file2" +export * from "file3" +var x = 1; + +// @filename: file5.ts +export * from "file4" +var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues4.ts b/tests/cases/compiler/exportStarForValues4.ts new file mode 100644 index 00000000000..d685ba1c8a3 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues4.ts @@ -0,0 +1,15 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export interface A { x } +export * from "file1" +export * from "file3" +var x = 1; + +// @filename: file3.ts +export interface B { x } +export * from "file2" +var x = 1; diff --git a/tests/cases/compiler/exportStarForValues5.ts b/tests/cases/compiler/exportStarForValues5.ts new file mode 100644 index 00000000000..cb716c72002 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues5.ts @@ -0,0 +1,8 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +export var x; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues6.ts b/tests/cases/compiler/exportStarForValues6.ts new file mode 100644 index 00000000000..a623e31f178 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues6.ts @@ -0,0 +1,8 @@ +// @module: system + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +export var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues7.ts b/tests/cases/compiler/exportStarForValues7.ts new file mode 100644 index 00000000000..c1343a44119 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues7.ts @@ -0,0 +1,12 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +export var x = 1; + +// @filename: file3.ts +export * from "file2" +export var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues8.ts b/tests/cases/compiler/exportStarForValues8.ts new file mode 100644 index 00000000000..0594f8b0877 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues8.ts @@ -0,0 +1,24 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export interface A { x } +export * from "file1" +export var x = 1; + +// @filename: file3.ts +export interface B { x } +export * from "file1" +export var x = 1; + +// @filename: file4.ts +export interface C { x } +export * from "file2" +export * from "file3" +export var x = 1; + +// @filename: file5.ts +export * from "file4" +export var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/exportStarForValues9.ts b/tests/cases/compiler/exportStarForValues9.ts new file mode 100644 index 00000000000..53ffb1b7954 --- /dev/null +++ b/tests/cases/compiler/exportStarForValues9.ts @@ -0,0 +1,15 @@ +// @module: amd + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export interface A { x } +export * from "file1" +export * from "file3" +export var x = 1; + +// @filename: file3.ts +export interface B { x } +export * from "file2" +export var x = 1; diff --git a/tests/cases/compiler/exportStarForValuesInSystem.ts b/tests/cases/compiler/exportStarForValuesInSystem.ts new file mode 100644 index 00000000000..1f60e8dec6f --- /dev/null +++ b/tests/cases/compiler/exportStarForValuesInSystem.ts @@ -0,0 +1,8 @@ +// @module: system + +// @filename: file1.ts +export interface Foo { x } + +// @filename: file2.ts +export * from "file1" +var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/extendConstructSignatureInInterface.ts b/tests/cases/compiler/extendConstructSignatureInInterface.ts new file mode 100644 index 00000000000..a0880de69cd --- /dev/null +++ b/tests/cases/compiler/extendConstructSignatureInInterface.ts @@ -0,0 +1,9 @@ +interface C { + new(x: number): C; +} + +var CStatic: C; +class E extends CStatic { +} + +var e: E = new E(1); diff --git a/tests/cases/compiler/genericSignatureIdentity.ts b/tests/cases/compiler/genericSignatureIdentity.ts new file mode 100644 index 00000000000..c685b8cc573 --- /dev/null +++ b/tests/cases/compiler/genericSignatureIdentity.ts @@ -0,0 +1,20 @@ +// This test is here to remind us of our current limits of type identity checking. +// Ideally all of the below declarations would be considered different (and thus errors) +// but they aren't because we erase type parameters to type any and don't check that +// constraints are identical. + +var x: { + (x: T): T; +}; + +var x: { + (x: T): T; +}; + +var x: { + (x: T): T; +}; + +var x: { + (x: any): any; +}; diff --git a/tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts b/tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts new file mode 100644 index 00000000000..03a01204462 --- /dev/null +++ b/tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts @@ -0,0 +1,10 @@ +// @target: es6 +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + +var let = 10; +for (let of [1,2,3]) {} + +for (let in [1,2,3]) {} + + diff --git a/tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts b/tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts new file mode 100644 index 00000000000..03a01204462 --- /dev/null +++ b/tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts @@ -0,0 +1,10 @@ +// @target: es6 +// This should be an error +// More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements + +var let = 10; +for (let of [1,2,3]) {} + +for (let in [1,2,3]) {} + + diff --git a/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts b/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts new file mode 100644 index 00000000000..3433adc17d5 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts @@ -0,0 +1,6 @@ +// @allowJs: true +// @noEmit: true +// @filename: a.js +var a = 10; +class a { +} \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts b/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts new file mode 100644 index 00000000000..32a9e77fcc7 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts @@ -0,0 +1,7 @@ +// @allowJs: true +// @noEmit: true +// @filename: a.js +// @target: es6 +export default class a { +} +export default var a = 10; \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts new file mode 100644 index 00000000000..b95f85c2139 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts @@ -0,0 +1,23 @@ +// @allowJs: true +// @noEmit: true +// @filename: a.js +// @noFallthroughCasesInSwitch: true +function foo(a, b) { + switch (a) { + case 10: + if (b) { + return b; + } + case 20: + return a; + } +} + +function bar() { + return x; + function bar2() { + } + var x = 10; // error +} + +label1: var x2 = 10; \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts b/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts new file mode 100644 index 00000000000..30b43b1990e --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts @@ -0,0 +1,40 @@ +// @allowJs: true +// @noEmit: true +// @filename: a.js +// @target: es6 +"use strict"; +var a = { + a: "hello", // error + b: 10, + a: 10 // error +}; +var let = 10; // error +delete a; // error +try { +} catch (eval) { // error +} +function arguments() { // error +} + +with (a) { + b = 10; +} + +// @filename: b.js +// this is not in strict mode but class definitions are always in strict mode +class c { + a(eval) { //error + } + method() { + var let = 10; // error + } +} + +// @filename: c.js +export var let = 10; // external modules are automatically in strict mode +var eval = function () { +}; + +//@filename: d.js +"use strict"; +var x = 009; // error \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationExternalPackageError.ts b/tests/cases/compiler/jsFileCompilationExternalPackageError.ts new file mode 100644 index 00000000000..cb9d32adb82 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationExternalPackageError.ts @@ -0,0 +1,16 @@ +// @allowJs: true +// @noEmit: true +// @module: commonjs + +// @filename: moduleA/a.js +import {a} from "b"; +a++; +import {c} from "c"; +c++; + +// @filename: node_modules/b.ts +var a = 10; + +// @filename: node_modules/c.js +exports.a = 10; +c = 10; diff --git a/tests/cases/compiler/letAsIdentifier2.ts b/tests/cases/compiler/letAsIdentifier2.ts new file mode 100644 index 00000000000..7ebbeb0704b --- /dev/null +++ b/tests/cases/compiler/letAsIdentifier2.ts @@ -0,0 +1,3 @@ +// @target: es6 + +function let() {} \ No newline at end of file diff --git a/tests/cases/compiler/letInConstDeclarations_ES5.ts b/tests/cases/compiler/letInConstDeclarations_ES5.ts new file mode 100644 index 00000000000..2898abd1e2a --- /dev/null +++ b/tests/cases/compiler/letInConstDeclarations_ES5.ts @@ -0,0 +1,8 @@ +// @target: es5 + +// All use of let in const declaration should be an error +const x = 50, let = 5; + +{ + const x = 10, let = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/letInConstDeclarations_ES6.ts b/tests/cases/compiler/letInConstDeclarations_ES6.ts new file mode 100644 index 00000000000..aac2a592d11 --- /dev/null +++ b/tests/cases/compiler/letInConstDeclarations_ES6.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// All use of let in const declaration should be an error +const x = 50, let = 5; + +{ + const x = 10, let = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts b/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts new file mode 100644 index 00000000000..7e8b6824329 --- /dev/null +++ b/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES5.ts @@ -0,0 +1,21 @@ +// @target: es5 + +// Should be an error +for (let let of [1,2,3]) {} + +for (const let of [1,2,3]) {} + +for (let let in [1,2,3]) {} + +for (const let in [1,2,3]) {} + +{ + for (let let of [1,2,3]) {} + + for (const let of [1,2,3]) {} + + for (let let in [1,2,3]) {} + + for (const let in [1,2,3]) {} +} + diff --git a/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts b/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts new file mode 100644 index 00000000000..68ba1716199 --- /dev/null +++ b/tests/cases/compiler/letInLetConstDeclOfForOfAndForIn_ES6.ts @@ -0,0 +1,21 @@ +// @target: es6 + +// Should be an error +for (let let of [1,2,3]) {} + +for (const let of [1,2,3]) {} + +for (let let in [1,2,3]) {} + +for (const let in [1,2,3]) {} + +{ + for (let let of [1,2,3]) {} + + for (const let of [1,2,3]) {} + + for (let let in [1,2,3]) {} + + for (const let in [1,2,3]) {} +} + diff --git a/tests/cases/compiler/letInLetDeclarations_ES5.ts b/tests/cases/compiler/letInLetDeclarations_ES5.ts new file mode 100644 index 00000000000..8d4a71b85c8 --- /dev/null +++ b/tests/cases/compiler/letInLetDeclarations_ES5.ts @@ -0,0 +1,8 @@ +// @target: es5 + +// All use of let in const declaration should be an error +let x = 50, let = 5; + +{ + let x = 10, let = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/letInLetDeclarations_ES6.ts b/tests/cases/compiler/letInLetDeclarations_ES6.ts new file mode 100644 index 00000000000..8c4650dd938 --- /dev/null +++ b/tests/cases/compiler/letInLetDeclarations_ES6.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// All use of let in const declaration should be an error +let x = 50, let = 5; + +{ + let x = 10, let = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/letInLetOrConstDeclarations.ts b/tests/cases/compiler/letInLetOrConstDeclarations.ts deleted file mode 100644 index c622759a459..00000000000 --- a/tests/cases/compiler/letInLetOrConstDeclarations.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @target: es6 -{ - let let = 1; // should error - for (let let in []) { } // should error -} -{ - const let = 1; // should error -} -{ - function let() { // should be ok - } -} \ No newline at end of file diff --git a/tests/cases/compiler/letInVarDeclOfForIn_ES5.ts b/tests/cases/compiler/letInVarDeclOfForIn_ES5.ts new file mode 100644 index 00000000000..684dc3b2e9f --- /dev/null +++ b/tests/cases/compiler/letInVarDeclOfForIn_ES5.ts @@ -0,0 +1,8 @@ +// @target: es5 + +// should not be an error +for (var let in [1,2,3]) {} + +{ + for (var let in [1,2,3]) {} +} diff --git a/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts b/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts new file mode 100644 index 00000000000..8d79f41713e --- /dev/null +++ b/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// should not be an error +for (var let in [1,2,3]) {} + +{ + for (var let in [1,2,3]) {} +} diff --git a/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts b/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts new file mode 100644 index 00000000000..2d369aa162e --- /dev/null +++ b/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts @@ -0,0 +1,8 @@ +// @target: es5 + +// should not be an error +for (var let of [1,2,3]) {} + +{ + for (var let of [1,2,3]) {} +} diff --git a/tests/cases/compiler/letInVarDeclOfForOf_ES6.ts b/tests/cases/compiler/letInVarDeclOfForOf_ES6.ts new file mode 100644 index 00000000000..9e343a45f4b --- /dev/null +++ b/tests/cases/compiler/letInVarDeclOfForOf_ES6.ts @@ -0,0 +1,8 @@ +// @target: es6 + +// should not be an error +for (var let of [1,2,3]) {} + +{ + for (var let of [1,2,3]) {} +} diff --git a/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts b/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts new file mode 100644 index 00000000000..c3db4389504 --- /dev/null +++ b/tests/cases/compiler/missingSemicolonInModuleSpecifier.ts @@ -0,0 +1,8 @@ +// @module: commonjs + +// @filename: a.ts +export const x = 1; + +// @filename: b.ts +import {x} from "./a" +(function() { return 1; }()) \ No newline at end of file diff --git a/tests/cases/compiler/modifiersInObjectLiterals.ts b/tests/cases/compiler/modifiersInObjectLiterals.ts new file mode 100644 index 00000000000..58fa64f82e9 --- /dev/null +++ b/tests/cases/compiler/modifiersInObjectLiterals.ts @@ -0,0 +1,8 @@ +let data = { + public foo: 'hey', + private bar: 'nay', + protected baz: 'oh my', + abstract noWay: 'yes' +}; + +data.foo + data.bar + data.baz + data.noWay diff --git a/tests/cases/compiler/moduleDuplicateIdentifiers.ts b/tests/cases/compiler/moduleDuplicateIdentifiers.ts new file mode 100644 index 00000000000..47be2bc5dbb --- /dev/null +++ b/tests/cases/compiler/moduleDuplicateIdentifiers.ts @@ -0,0 +1,40 @@ +// @module: commonjs +export var Foo = 2; +export var Foo = 42; // Should error + +export interface Bar { + _brand1: any; +} + +export interface Bar { // Shouldn't error + _brand2: any; +} + +export namespace FooBar { + export var member1 = 2; +} + +export namespace FooBar { // Shouldn't error + export var member2 = 42; +} + +export class Kettle { + member1 = 2; +} + +export class Kettle { // Should error + member2 = 42; +} + +export var Pot = 2; +Pot = 42; // Shouldn't error + +export enum Utensils { + Spoon, + Fork, + Knife +} + +export enum Utensils { // Shouldn't error + Spork = 3 +} diff --git a/tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts b/tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts new file mode 100644 index 00000000000..d51de9c2e5a --- /dev/null +++ b/tests/cases/compiler/moduleSameValueDuplicateExportedBindings1.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @filename: a.ts +export * from "./b"; +export * from "./c"; + +// @filename: b.ts +export * from "./c"; + +// @filename: c.ts +export var foo = 42; \ No newline at end of file diff --git a/tests/cases/compiler/moduleSameValueDuplicateExportedBindings2.ts b/tests/cases/compiler/moduleSameValueDuplicateExportedBindings2.ts new file mode 100644 index 00000000000..1a30004301a --- /dev/null +++ b/tests/cases/compiler/moduleSameValueDuplicateExportedBindings2.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @filename: a.ts +export * from "./b"; +export * from "./c"; + +// @filename: b.ts +export {Animals} from "./c"; + +// @filename: c.ts +export enum Animals { + Cat, + Dog +}; \ No newline at end of file diff --git a/tests/cases/compiler/recursiveUnionTypeInference.ts b/tests/cases/compiler/recursiveUnionTypeInference.ts new file mode 100644 index 00000000000..4ffc6fcf4a7 --- /dev/null +++ b/tests/cases/compiler/recursiveUnionTypeInference.ts @@ -0,0 +1,7 @@ +interface Foo { + x: T; +} + +function bar(x: Foo | string): T { + return bar(x); +} diff --git a/tests/cases/compiler/undefinedTypeAssignment1.ts b/tests/cases/compiler/undefinedTypeAssignment1.ts new file mode 100644 index 00000000000..7d340daba69 --- /dev/null +++ b/tests/cases/compiler/undefinedTypeAssignment1.ts @@ -0,0 +1,4 @@ +type undefined = string; +function p(undefined = "wat") { + return undefined; +} diff --git a/tests/cases/compiler/undefinedTypeAssignment2.ts b/tests/cases/compiler/undefinedTypeAssignment2.ts new file mode 100644 index 00000000000..3f42068e24e --- /dev/null +++ b/tests/cases/compiler/undefinedTypeAssignment2.ts @@ -0,0 +1 @@ +var undefined = void 0; diff --git a/tests/cases/compiler/undefinedTypeAssignment3.ts b/tests/cases/compiler/undefinedTypeAssignment3.ts new file mode 100644 index 00000000000..8bada4f946c --- /dev/null +++ b/tests/cases/compiler/undefinedTypeAssignment3.ts @@ -0,0 +1 @@ +var undefined = null; diff --git a/tests/cases/compiler/undefinedTypeAssignment4.ts b/tests/cases/compiler/undefinedTypeAssignment4.ts new file mode 100644 index 00000000000..fc0dc155acd --- /dev/null +++ b/tests/cases/compiler/undefinedTypeAssignment4.ts @@ -0,0 +1,11 @@ +class undefined { + foo: string; +} +interface undefined { + member: number; +} +namespace undefined { + export var x = 42; +} +var x: undefined; +var y: typeof undefined; diff --git a/tests/cases/compiler/unionTypeParameterInference.ts b/tests/cases/compiler/unionTypeParameterInference.ts new file mode 100644 index 00000000000..79c4f3cc0e5 --- /dev/null +++ b/tests/cases/compiler/unionTypeParameterInference.ts @@ -0,0 +1,9 @@ +// Regression test for #5861 + +interface Foo { prop: T; } + +declare function lift(value: U | Foo): Foo; + +function unlift(value: U | Foo): U { + return lift(value).prop; +} diff --git a/tests/cases/conformance/enums/enumExportMergingES6.ts b/tests/cases/conformance/enums/enumExportMergingES6.ts new file mode 100644 index 00000000000..0a5185ecdd5 --- /dev/null +++ b/tests/cases/conformance/enums/enumExportMergingES6.ts @@ -0,0 +1,10 @@ +// @target: es6 +export enum Animals { + Cat = 1 +} +export enum Animals { + Dog = 2 +} +export enum Animals { + CatDog = Cat | Dog +} diff --git a/tests/cases/conformance/jsx/jsxParsingError1.tsx b/tests/cases/conformance/jsx/jsxParsingError1.tsx new file mode 100644 index 00000000000..2668f04e885 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxParsingError1.tsx @@ -0,0 +1,14 @@ +//@jsx: preserve + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// This should be a parse error +const class1 = "foo"; +const class2 = "bar"; +const elem =
; diff --git a/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx b/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx index e75a1dbfde2..179a3116b43 100644 --- a/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx +++ b/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx @@ -23,4 +23,12 @@ import ReactRouter = require('react-router'); import Route = ReactRouter.Route; -var routes = ; +var routes1 = ; + +module M { + export var X: any; +} +module M { + // Should emit 'M.X' in both opening and closing tags + var y = ; +} diff --git a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts new file mode 100644 index 00000000000..06a1c24230c --- /dev/null +++ b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts @@ -0,0 +1,21 @@ +/// + +////interface I1 { +//// a(): void; +//// b(): void; +////} +//// +////var imp1: I1 { +//// a() {}, +//// /*0*/ +////} +//// +////var imp2: I1 { +//// a: () => {}, +//// /*1*/ +////} + +goTo.marker("0"); +verify.not.completionListContains("a"); +goTo.marker("1"); +verify.not.completionListContains("a"); diff --git a/tests/cases/fourslash/formattingFatArrowFunctions.ts b/tests/cases/fourslash/formattingFatArrowFunctions.ts index c540c2837e1..d4ce38dbd62 100644 --- a/tests/cases/fourslash/formattingFatArrowFunctions.ts +++ b/tests/cases/fourslash/formattingFatArrowFunctions.ts @@ -4,6 +4,7 @@ //// ( ) => 1 ;/*1*/ //// ( arg ) => 2 ;/*2*/ //// arg => 2 ;/*3*/ +//// arg=>2 ;/*3a*/ //// ( arg = 1 ) => 3 ;/*4*/ //// ( arg ? ) => 4 ;/*5*/ //// ( arg : number ) => 5 ;/*6*/ @@ -118,7 +119,9 @@ verify.currentLineContentIs("() => 1;"); goTo.marker("2"); verify.currentLineContentIs("(arg) => 2;"); goTo.marker("3"); -verify.currentLineContentIs("arg => 2;"); +verify.currentLineContentIs("arg => 2;"); +goTo.marker("3a"); +verify.currentLineContentIs("arg => 2;"); goTo.marker("4"); verify.currentLineContentIs("(arg = 1) => 3;"); goTo.marker("5"); diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics2.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics2.ts index 9ab29b41798..198c39abe42 100644 --- a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics2.ts +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics2.ts @@ -11,5 +11,12 @@ verify.getSemanticDiagnostics(`[ "length": 11, "category": "error", "code": 8003 + }, + { + "message": "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.", + "start": 0, + "length": 11, + "category": "error", + "code": 1148 } ]`); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst04.ts b/tests/cases/fourslash/getOccurrencesConst04.ts index c7f293450d3..2a8ee4c9e2c 100644 --- a/tests/cases/fourslash/getOccurrencesConst04.ts +++ b/tests/cases/fourslash/getOccurrencesConst04.ts @@ -1,12 +1,14 @@ /// ////export const class C { -//// private static c/*1*/onst foo; -//// constructor(public con/*2*/st foo) { +//// private static c/*1*/onst f/*2*/oo; +//// constructor(public con/*3*/st foo) { //// } ////} goTo.marker("1"); -verify.occurrencesAtPositionCount(1); +verify.occurrencesAtPositionCount(0); goTo.marker("2"); +verify.occurrencesAtPositionCount(1); +goTo.marker("3"); verify.occurrencesAtPositionCount(0); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentNamedImport.ts b/tests/cases/fourslash/smartIndentNamedImport.ts new file mode 100644 index 00000000000..37ef80f6316 --- /dev/null +++ b/tests/cases/fourslash/smartIndentNamedImport.ts @@ -0,0 +1,12 @@ +/// + +////import {/*0*/ +//// numbers as bn,/*1*/ +//// list/*2*/ +////} from '@bykov/basics';/*3*/ + +format.document(); +goTo.marker("0"); verify.currentLineContentIs("import {"); +goTo.marker("1"); verify.currentLineContentIs(" numbers as bn,"); +goTo.marker("2"); verify.currentLineContentIs(" list"); +goTo.marker("3"); verify.currentLineContentIs("} from '@bykov/basics';"); \ No newline at end of file diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index c4c17ebb223..5b924650401 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -99,13 +99,34 @@ module ts { assert.equal(resolution.failedLookupLocations.length, supportedTypeScriptExtensions.length); } - it("module name as directory - load from typings", () => { + it("module name as directory - load from 'typings'", () => { testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar"); testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar"); testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar"); testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar"); }); + function testTypingsIgnored(typings: any): void { + let containingFile = { name: "/a/b.ts" }; + let packageJson = { name: "/node_modules/b/package.json", content: JSON.stringify({ "typings": typings }) }; + let moduleFile = { name: "/a/b.d.ts" }; + + let indexPath = "/node_modules/b/index.d.ts"; + let indexFile = { name: indexPath } + + let resolution = nodeModuleNameResolver("b", containingFile.name, {}, createModuleResolutionHost(containingFile, packageJson, moduleFile, indexFile)); + + assert.equal(resolution.resolvedModule.resolvedFileName, indexPath); + } + + it("module name as directory - handle invalid 'typings'", () => { + testTypingsIgnored(["a", "b"]); + testTypingsIgnored({ "a": "b" }); + testTypingsIgnored(true); + testTypingsIgnored(null); + testTypingsIgnored(undefined); + }); + it("module name as directory - load index.d.ts", () => { let containingFile = { name: "/a/b/c.ts" }; let packageJson = { name: "/a/b/foo/package.json", content: JSON.stringify({ main: "/c/d" }) };