diff --git a/package.json b/package.json index f0ba128a91..261cdfa64b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "istanbul": "latest", "mocha-fivemat-progress-reporter": "latest", "tslint": "next", - "typescript": "1.8.0-dev.20160113", + "typescript": "next", "tsd": "latest" }, "scripts": { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3127561fea..5eee3c3172 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -137,6 +137,7 @@ namespace ts { options = opts; inStrictMode = !!file.externalModuleIndicator; classifiableNames = {}; + Symbol = objectAllocator.getSymbolConstructor(); if (!file.locals) { @@ -201,8 +202,8 @@ namespace ts { // unless it is a well known Symbol. function getDeclarationName(node: Declaration): string { if (node.name) { - if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) { - return `"${(node.name).text}"`; + if (isAmbientModule(node)) { + return isGlobalScopeAugmentation(node) ? "__global" : `"${(node.name).text}"`; } if (node.name.kind === SyntaxKind.ComputedPropertyName) { const nameExpression = (node.name).expression; @@ -358,7 +359,12 @@ namespace ts { // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & NodeFlags.ExportContext) { + + // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge + // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation + // and this case is specially handled. Module augmentations should only be merged with original module definition + // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. + if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) { const exportKind = (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | (symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | @@ -871,7 +877,10 @@ namespace ts { function bindModuleDeclaration(node: ModuleDeclaration) { setExportContextFlag(node); - if (node.name.kind === SyntaxKind.StringLiteral) { + if (isAmbientModule(node)) { + if (node.flags & NodeFlags.Export) { + errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); + } declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); } else { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2d1292c51..edc1868401 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -372,6 +372,32 @@ namespace ts { } } + function mergeModuleAugmentation(moduleName: LiteralExpression): void { + const moduleAugmentation = moduleName.parent; + if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { + // this is a combined symbol for multiple augmentations within the same file. + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration + Debug.assert(moduleAugmentation.symbol.declarations.length > 1); + return; + } + + if (isGlobalScopeAugmentation(moduleAugmentation)) { + mergeSymbolTable(globals, moduleAugmentation.symbol.exports); + } + else { + // find a module that about to be augmented + let mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); + if (!mainModule) { + return; + } + // if module symbol has already been merged - it is safe to use it. + // otherwise clone it + mainModule = mainModule.flags & SymbolFlags.Merged ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + } + function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { for (const id in source) { if (hasProperty(source, id)) { @@ -401,22 +427,10 @@ namespace ts { return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } - function getSourceFile(node: Node): SourceFile { - return getAncestor(node, SyntaxKind.SourceFile); - } - function isGlobalSourceFile(node: Node) { 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]; @@ -579,8 +593,7 @@ namespace ts { if (!isExternalOrCommonJsModule(location)) break; case SyntaxKind.ModuleDeclaration: const moduleExports = getSymbolOfNode(location).exports; - if (location.kind === SyntaxKind.SourceFile || - (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { + if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. @@ -736,7 +749,9 @@ namespace ts { if (!result) { if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); + if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); + } } return undefined; } @@ -773,6 +788,43 @@ namespace ts { return result; } + function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean { + if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + return false; + } + + const container = getThisContainer(errorLocation, /* includeArrowFunctions */ true); + let location = container; + while (location) { + if (isClassLike(location.parent)) { + const classSymbol = getSymbolOfNode(location.parent); + if (!classSymbol) { + break; + } + + // Check to see if a static member exists. + const constructorType = getTypeOfSymbol(classSymbol); + if (getPropertyOfType(constructorType, name)) { + error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), symbolToString(classSymbol)); + return true; + } + + // No static member is present. + // Check if we're in an instance method and look for a relevant instance member. + if (location === container && !(location.flags & NodeFlags.Static)) { + const instanceType = (getDeclaredTypeOfSymbol(classSymbol)).thisType; + if (getPropertyOfType(instanceType, name)) { + error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); + return true; + } + } + } + + location = location.parent; + } + return false; + } + function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); // Block-scoped variables cannot be used before their definition @@ -1074,6 +1126,10 @@ namespace ts { } function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol { + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0); + } + + function resolveExternalModuleNameWorker(location: Node, moduleReferenceExpression: Expression, moduleNotFoundError: DiagnosticMessage): Symbol { if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral) { return; } @@ -1092,20 +1148,29 @@ namespace ts { if (!isRelative) { const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); if (symbol) { - return symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(symbol); } } - const resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + const resolvedModule = getResolvedModule(getSourceFileOfNode(location), moduleReferenceLiteral.text); const sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { - return sourceFile.symbol; + // merged symbol is module declaration symbol combined with all augmentations + return getMergedSymbol(sourceFile.symbol); } - error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName); - return; + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName); + } + return undefined; } - error(moduleReferenceLiteral, Diagnostics.Cannot_find_module_0, moduleName); + if (moduleNotFoundError) { + // report errors only if it was requested + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } + return undefined; } // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, @@ -1522,8 +1587,7 @@ namespace ts { } function hasExternalModuleSymbol(declaration: Node) { - return (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).name.kind === SyntaxKind.StringLiteral) || - (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(declaration)); + return isAmbientModule(declaration) || (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult { @@ -1647,6 +1711,12 @@ namespace ts { return undefined; } + function isTopLevelInExternalModuleAugmentation(node: Node): boolean { + return node && node.parent && + node.parent.kind === SyntaxKind.ModuleBlock && + isExternalModuleAugmentation(node.parent.parent); + } + function getSymbolDisplayBuilder(): SymbolDisplayBuilder { function getNameOfSymbol(symbol: Symbol): string { @@ -2229,6 +2299,10 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.ImportEqualsDeclaration: + // external module augmentation is always visible + if (isExternalModuleAugmentation(node)) { + return true; + } const parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(getCombinedNodeFlags(node) & NodeFlags.Export) && @@ -2321,7 +2395,9 @@ namespace ts { const firstIdentifier = getFirstIdentifier(internalModuleReference); const importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, firstIdentifier); - buildVisibleNodeList(importSymbol.declarations); + if (importSymbol) { + buildVisibleNodeList(importSymbol.declarations); + } } }); } @@ -2406,7 +2482,7 @@ namespace ts { // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. - const classType = getDeclaredTypeOfSymbol(prototype.parent); + const classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(classType, map(classType.typeParameters, _ => anyType)) : classType; } @@ -4900,6 +4976,10 @@ namespace ts { return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; } + function compareTypesAssignable(source: Type, target: Type): Ternary { + return checkTypeRelatedTo(source, target, assignableRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False; + } + function isTypeSubtypeOf(source: Type, target: Type): boolean { return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } @@ -4916,16 +4996,27 @@ namespace ts { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } + function isSignatureAssignableTo(source: Signature, + target: Signature, + ignoreReturnTypes: boolean): boolean { + return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; + } + /** * See signatureRelatedTo, compareSignaturesIdentical */ - function isSignatureAssignableTo(source: Signature, target: Signature, ignoreReturnTypes: boolean): boolean { + function compareSignaturesRelated(source: Signature, + target: Signature, + ignoreReturnTypes: boolean, + reportErrors: boolean, + errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void, + compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return true; + return Ternary.True; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return Ternary.False; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -4933,36 +5024,49 @@ namespace ts { source = getErasedSignature(source); target = getErasedSignature(target); + let result = Ternary.True; + const sourceMax = getNumNonRestParameters(source); const targetMax = getNumNonRestParameters(target); const checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); + const sourceParams = source.parameters; + const targetParams = target.parameters; for (let i = 0; i < checkCount; i++) { - const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - const related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t); + const s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source); + const t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target); + const related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors); if (!related) { - return false; + if (reportErrors) { + errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, + sourceParams[i < sourceMax ? i : sourceMax].name, + targetParams[i < targetMax ? i : targetMax].name); + } + return Ternary.False; } + result &= related; } if (!ignoreReturnTypes) { const targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) { - return true; + return result; } const sourceReturnType = getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions if (targetReturnType.flags & TypeFlags.PredicateType && (targetReturnType as PredicateType).predicate.kind === TypePredicateKind.Identifier) { if (!(sourceReturnType.flags & TypeFlags.PredicateType)) { - return false; + if (reportErrors) { + errorReporter(Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); + } + return Ternary.False; } } - return isTypeAssignableTo(sourceReturnType, targetReturnType); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } - return true; + return result; } function isImplementationCompatibleWithOverload(implementation: Signature, overload: Signature): boolean { @@ -5033,24 +5137,14 @@ namespace ts { let expandingFlags: number; let depth = 0; let overflow = false; - let elaborateErrors = false; Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - const result = isRelatedTo(source, target, errorNode !== undefined, headMessage); + const result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } else if (errorInfo) { - // If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution), - // then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened, - // request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context - // where errors were being reported. - if (errorInfo.next === undefined) { - errorInfo = undefined; - elaborateErrors = true; - isRelatedTo(source, target, errorNode !== undefined, headMessage); - } if (containingMessageChain) { errorInfo = concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } @@ -5060,6 +5154,7 @@ namespace ts { return result !== Ternary.False; function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { + Debug.assert(!!errorNode); errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } @@ -5197,14 +5292,14 @@ namespace ts { } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - const apparentType = getApparentType(source); + const apparentSource = getApparentType(source); // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { + if (apparentSource.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { // Report structural errors only if we haven't reported any errors yet - const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { + const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & TypeFlags.Primitive); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } @@ -5269,6 +5364,7 @@ namespace ts { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. + Debug.assert(!!errorNode); errorNode = prop.valueDeclaration; reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); @@ -5371,7 +5467,7 @@ namespace ts { const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; const related = relation[id]; if (related !== undefined) { - if (elaborateErrors && related === RelationComparisonResult.Failed) { + if (reportErrors && related === RelationComparisonResult.Failed) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. relation[id] = RelationComparisonResult.FailedAndReported; @@ -5591,7 +5687,7 @@ namespace ts { } // don't elaborate the primitive apparent types (like Number) // because the actual primitives will have already been reported. - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); @@ -5603,77 +5699,10 @@ namespace ts { } /** - * See signatureAssignableTo, signatureAssignableTo + * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary { - // TODO (drosen): De-duplicate code between related functions. - if (source === target) { - return Ternary.True; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return Ternary.False; - } - let sourceMax = source.parameters.length; - let targetMax = target.parameters.length; - let checkCount: number; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - // 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; - for (let i = 0; i < checkCount; i++) { - const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - const saveErrorInfo = errorInfo; - let related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, /*reportErrors*/ false); - if (!related) { - if (reportErrors) { - reportError(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, - source.parameters[i < sourceMax ? i : sourceMax].name, - target.parameters[i < targetMax ? i : targetMax].name); - } - return Ternary.False; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - - const targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) { - return result; - } - const sourceReturnType = getReturnTypeOfSignature(source); - - // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions - if (targetReturnType.flags & TypeFlags.PredicateType && (targetReturnType as PredicateType).predicate.kind === TypePredicateKind.Identifier) { - if (!(sourceReturnType.flags & TypeFlags.PredicateType)) { - if (reportErrors) { - reportError(Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); - } - return Ternary.False; - } - } - - return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); + return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { @@ -6681,10 +6710,6 @@ namespace ts { if (typeInfo && typeInfo.type === undefinedType) { return type; } - // If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive - if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) { - return typeInfo.type; - } let flags: TypeFlags; if (typeInfo) { flags = typeInfo.flags; @@ -6695,6 +6720,10 @@ namespace ts { } // At this point we can bail if it's not a union if (!(type.flags & TypeFlags.Union)) { + // If we're on the true branch and the type is a subtype, we should return the primitive type + if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) { + return typeInfo.type; + } // If the active non-union type would be removed from a union by this type guard, return an empty union return filterUnion(type) ? type : emptyUnionType; } @@ -8619,7 +8648,7 @@ namespace ts { function checkIndexedAccess(node: ElementAccessExpression): Type { // Grammar checking if (!node.argumentExpression) { - const sourceFile = getSourceFile(node); + const sourceFile = getSourceFileOfNode(node); if (node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node) { const start = skipTrivia(sourceFile.text, node.expression.end); const end = node.end; @@ -11990,7 +12019,7 @@ namespace ts { case SyntaxKind.InterfaceDeclaration: return SymbolFlags.ExportType; case SyntaxKind.ModuleDeclaration: - return (d).name.kind === SyntaxKind.StringLiteral || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated + return isAmbientModule(d) || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated ? SymbolFlags.ExportNamespace | SymbolFlags.ExportValue : SymbolFlags.ExportNamespace; case SyntaxKind.ClassDeclaration: @@ -12438,7 +12467,7 @@ namespace ts { // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. const firstDeclaration = forEach(localSymbol.declarations, // Get first non javascript function declaration - declaration => declaration.kind === node.kind && !isSourceFileJavaScript(getSourceFile(declaration)) ? + declaration => declaration.kind === node.kind && !isSourceFileJavaScript(getSourceFileOfNode(declaration)) ? declaration : undefined); // Only type check the symbol once @@ -14123,7 +14152,13 @@ namespace ts { function checkModuleDeclaration(node: ModuleDeclaration) { if (produceDiagnostics) { // Grammar checking - const isAmbientExternalModule = node.name.kind === SyntaxKind.StringLiteral; + const isGlobalAugmentation = isGlobalScopeAugmentation(node); + const inAmbientContext = isInAmbientContext(node); + if (isGlobalAugmentation && !inAmbientContext) { + error(node.name, Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); + } + + const isAmbientExternalModule = isAmbientModule(node); const contextErrorMessage = isAmbientExternalModule ? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -14133,7 +14168,7 @@ namespace ts { } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) { + if (!inAmbientContext && node.name.kind === SyntaxKind.StringLiteral) { grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -14146,7 +14181,7 @@ namespace ts { // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 - && !isInAmbientContext(node) + && !inAmbientContext && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { const firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { @@ -14167,19 +14202,107 @@ namespace ts { } } - // Checks for ambient external modules. if (isAmbientExternalModule) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + if (isExternalModuleAugmentation(node)) { + // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) + // otherwise we'll be swamped in cascading errors. + // We can detect if augmentation was applied using following rules: + // - augmentation for a global scope is always applied + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged); + if (checkBody) { + // body of ambient external module is always a module block + for (const statement of (node.body).statements) { + checkModuleAugmentationElement(statement, isGlobalAugmentation); + } + } } - if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + else if (isGlobalSourceFile(node.parent)) { + if (isGlobalAugmentation) { + error(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else if (isExternalModuleNameRelative(node.name.text)) { + error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); + } + } + else { + if (isGlobalAugmentation) { + error(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations); + } + else { + // Node is not an augmentation and is not located on the script level. + // This means that this is declaration of ambient module that is located in other module or namespace which is prohibited. + error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); + } } } } checkSourceElement(node.body); } + function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void { + switch (node.kind) { + case SyntaxKind.VariableStatement: + // error each individual name in variable statement instead of marking the entire variable statement + for (const decl of (node).declarationList.declarations) { + checkModuleAugmentationElement(decl, isGlobalAugmentation); + } + break; + case SyntaxKind.ExportAssignment: + case SyntaxKind.ExportDeclaration: + grammarErrorOnFirstToken(node, Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); + break; + case SyntaxKind.ImportEqualsDeclaration: + if ((node).moduleReference.kind !== SyntaxKind.StringLiteral) { + error((node).name, Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + break; + } + // fallthrough + case SyntaxKind.ImportDeclaration: + grammarErrorOnFirstToken(node, Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); + break; + case SyntaxKind.BindingElement: + case SyntaxKind.VariableDeclaration: + const name = (node).name; + if (isBindingPattern(name)) { + for (const el of name.elements) { + // mark individual names in binding pattern + checkModuleAugmentationElement(el, isGlobalAugmentation); + } + break; + } + // fallthrough + case SyntaxKind.ClassDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.TypeAliasDeclaration: + const symbol = getSymbolOfNode(node); + if (symbol) { + // module augmentations cannot introduce new names on the top level scope of the module + // this is done it two steps + // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error + // 2. main check - report error if value declaration of the parent symbol is module augmentation) + let reportError = !(symbol.flags & SymbolFlags.Merged); + if (!reportError) { + if (isGlobalAugmentation) { + // global symbol should not have parent since it is not explicitly exported + reportError = symbol.parent !== undefined; + } + else { + // symbol should not originate in augmentation + reportError = isExternalModuleAugmentation(symbol.parent.valueDeclaration); + } + } + if (reportError) { + error(node, Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); + } + } + break; + } + } + function getFirstIdentifier(node: EntityName | Expression): Identifier { while (true) { if (node.kind === SyntaxKind.QualifiedName) { @@ -14202,7 +14325,7 @@ namespace ts { error(moduleName, Diagnostics.String_literal_expected); return false; } - const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; + const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent); if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { error(moduleName, node.kind === SyntaxKind.ExportDeclaration ? Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : @@ -14210,12 +14333,16 @@ namespace ts { return false; } if (inAmbientExternalModule && isExternalModuleNameRelative((moduleName).text)) { - // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference - // other external modules only through top - level external module names. - // Relative external module names are not permitted. - error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); - return false; + // we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration + // no need to do this again. + if (!isTopLevelInExternalModuleAugmentation(node)) { + // TypeScript 1.0 spec (April 2013): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // other external modules only through top - level external module names. + // Relative external module names are not permitted. + error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name); + return false; + } } return true; } @@ -14321,7 +14448,7 @@ namespace ts { // export { x, y } from "foo" forEach(node.exportClause.elements, checkExportSpecifier); - const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral; + const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent); if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -14365,7 +14492,7 @@ namespace ts { } const container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent; - if (container.kind === SyntaxKind.ModuleDeclaration && (container).name.kind === SyntaxKind.Identifier) { + if (container.kind === SyntaxKind.ModuleDeclaration && !isAmbientModule(container)) { error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -14395,7 +14522,7 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - for (var id in moduleSymbol.exports) { + for (const id in moduleSymbol.exports) { if (id !== "export=") { return true; } @@ -14410,7 +14537,9 @@ namespace ts { const exportEqualsSymbol = moduleSymbol.exports["export="]; if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + if (!isTopLevelInExternalModuleAugmentation(declaration)) { + error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); + } } // Checks for export * conflicts const exports = getExportsOfModule(moduleSymbol); @@ -15470,13 +15599,13 @@ namespace ts { }; } - function getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile { - const specifier = getExternalModuleName(declaration); - const moduleSymbol = getSymbolAtLocation(specifier); - if (!moduleSymbol) { - return undefined; - } - return getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; + function getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile { + const specifier = getExternalModuleName(declaration); + const moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); + if (!moduleSymbol) { + return undefined; + } + return getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile; } function initializeTypeChecker() { @@ -15485,13 +15614,27 @@ namespace ts { bindSourceFile(file, compilerOptions); }); + let augmentations: LiteralExpression[][]; // Initialize global symbol table forEach(host.getSourceFiles(), file => { if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } + if (file.moduleAugmentations) { + (augmentations || (augmentations = [])).push(file.moduleAugmentations); + } }); + if (augmentations) { + // merge module augmentations. + // this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed + for (const list of augmentations) { + for (const augmentation of list) { + mergeModuleAugmentation(augmentation); + } + } + } + // Setup global builtins addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); @@ -16307,7 +16450,7 @@ namespace ts { return true; } else if (node.body === undefined) { - return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, Diagnostics._0_expected, "{"); + return grammarErrorAtPos(getSourceFileOfNode(node), node.end - 1, ";".length, Diagnostics._0_expected, "{"); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4056d9c3e9..cfdcb2b930 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -718,7 +718,8 @@ namespace ts { } // Find the component that differs - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { + let joinStartIndex: number; + for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 75319d0ab5..9a57b4b1a3 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -54,6 +54,7 @@ namespace ts { let writer = createAndSetNewTextWriterWithSymbolWriter(); let enclosingDeclaration: Node; + let resultHasExternalModuleIndicator: boolean; let currentText: string; let currentLineMap: number[]; let currentIdentifiers: Map; @@ -101,6 +102,7 @@ namespace ts { }); } + resultHasExternalModuleIndicator = false; if (!isBundledEmit || !isExternalModule(sourceFile)) { noDeclare = false; emitSourceFile(sourceFile); @@ -139,6 +141,14 @@ namespace ts { allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo); moduleElementDeclarationEmitInfo = []; } + + if (!isBundledEmit && isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) { + // if file was external module with augmentations - this fact should be preserved in .d.ts as well. + // in case if we didn't write any external module specifiers in .d.ts we need to emit something + // that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here. + write("export {};"); + writeLine(); + } }); return { @@ -721,16 +731,25 @@ namespace ts { writer.writeLine(); } - function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration) { + function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration) { + // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). + // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered + // external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' + // so compiler will treat them as external modules. + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration; let moduleSpecifier: Node; if (parent.kind === SyntaxKind.ImportEqualsDeclaration) { const node = parent as ImportEqualsDeclaration; moduleSpecifier = getExternalModuleImportEqualsDeclarationExpression(node); } + else if (parent.kind === SyntaxKind.ModuleDeclaration) { + moduleSpecifier = (parent).name; + } else { const node = parent as (ImportDeclaration | ExportDeclaration); moduleSpecifier = node.moduleSpecifier; } + if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit && (compilerOptions.out || compilerOptions.outFile)) { const moduleName = getExternalModuleNameFromDeclaration(host, resolver, parent); if (moduleName) { @@ -784,13 +803,23 @@ namespace ts { function writeModuleDeclaration(node: ModuleDeclaration) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & NodeFlags.Namespace) { - write("namespace "); + if (isGlobalScopeAugmentation(node)) { + write("global "); } else { - write("module "); + if (node.flags & NodeFlags.Namespace) { + write("namespace "); + } + else { + write("module "); + } + if (isExternalModuleAugmentation(node)) { + emitExternalModuleSpecifier(node); + } + else { + writeTextOfNode(currentText, node.name); + } } - writeTextOfNode(currentText, node.name); while (node.body.kind !== SyntaxKind.ModuleBlock) { node = node.body; write("."); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 760da6058c..8fd40f7b42 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1767,6 +1767,42 @@ "category": "Error", "code": 2661 }, + "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?": { + "category": "Error", + "code": 2662 + }, + "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?": { + "category": "Error", + "code": 2663 + }, + "Invalid module name in augmentation, module '{0}' cannot be found.": { + "category": "Error", + "code": 2664 + }, + "Module augmentation cannot introduce new names in the top level scope.": { + "category": "Error", + "code": 2665 + }, + "Exports and export assignments are not permitted in module augmentations.": { + "category": "Error", + "code": 2666 + }, + "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.": { + "category": "Error", + "code": 2667 + }, + "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.": { + "category": "Error", + "code": 2668 + }, + "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.": { + "category": "Error", + "code": 2669 + }, + "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.": { + "category": "Error", + "code": 2670 + }, "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 1ebbbe74ab..96c655ac90 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1250,7 +1250,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { // One object literal with all the attributes in them write("{"); - for (var i = 0; i < attrs.length; i++) { + for (let i = 0, n = attrs.length; i < n; i++) { if (i > 0) { write(", "); } @@ -1262,7 +1262,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Children if (children) { - for (var i = 0; i < children.length; i++) { + for (let i = 0; i < children.length; i++) { // Don't emit empty expressions if (children[i].kind === SyntaxKind.JsxExpression && !((children[i]).expression)) { continue; @@ -1356,7 +1356,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitJsxElement(node: JsxElement) { emitJsxOpeningOrSelfClosingElement(node.openingElement); - for (var i = 0, n = node.children.length; i < n; i++) { + for (let i = 0, n = node.children.length; i < n; i++) { emit(node.children[i]); } @@ -2886,7 +2886,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - if ((node).initializer.kind === SyntaxKind.VariableDeclarationList) { + const initializer = (node).initializer; + if (initializer && initializer.kind === SyntaxKind.VariableDeclarationList) { loopInitializer = (node).initializer; } break; @@ -5171,7 +5172,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (isClassExpressionWithStaticProperties) { - for (var property of staticProperties) { + for (const property of staticProperties) { write(","); writeLine(); emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true); @@ -5718,7 +5719,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi const parameters = valueDeclaration.parameters; const parameterCount = parameters.length; if (parameterCount > 0) { - for (var i = 0; i < parameterCount; i++) { + for (let i = 0; i < parameterCount; i++) { if (i > 0) { write(", "); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 420d201adc..e391408b41 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4430,6 +4430,9 @@ namespace ts { } continue; + case SyntaxKind.GlobalKeyword: + return nextToken() === SyntaxKind.OpenBraceToken; + case SyntaxKind.ImportKeyword: nextToken(); return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken || @@ -4494,6 +4497,7 @@ namespace ts { case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: case SyntaxKind.TypeKeyword: + case SyntaxKind.GlobalKeyword: // When these don't start a declaration, they're an identifier in an expression statement return true; @@ -4582,6 +4586,7 @@ namespace ts { case SyntaxKind.PublicKeyword: case SyntaxKind.AbstractKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.GlobalKeyword: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -4609,6 +4614,7 @@ namespace ts { return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case SyntaxKind.EnumKeyword: return parseEnumDeclaration(fullStart, decorators, modifiers); + case SyntaxKind.GlobalKeyword: case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -5243,14 +5249,25 @@ namespace ts { const node = createNode(SyntaxKind.ModuleDeclaration, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(/*internName*/ true); + if (token === SyntaxKind.GlobalKeyword) { + // parse 'global' as name of global scope augmentation + node.name = parseIdentifier(); + node.flags |= NodeFlags.GlobalAugmentation; + } + else { + node.name = parseLiteralNode(/*internName*/ true); + } node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ModuleDeclaration { let flags = modifiers ? modifiers.flags : 0; - if (parseOptional(SyntaxKind.NamespaceKeyword)) { + if (token === SyntaxKind.GlobalKeyword) { + // global augmentation + return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + } + else if (parseOptional(SyntaxKind.NamespaceKeyword)) { flags |= NodeFlags.Namespace; } else { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6905e01b1e..398ce27ef4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -361,7 +361,24 @@ namespace ts { const currentDirectory = host.getCurrentDirectory(); const resolveModuleNamesWorker = host.resolveModuleNames ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) - : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); + : ((moduleNames: string[], containingFile: string) => { + const resolvedModuleNames: ResolvedModule[] = []; + // resolveModuleName does not store any results between calls. + // lookup is a local cache to avoid resolving the same module name several times + const lookup: Map = {}; + for (const moduleName of moduleNames) { + let resolvedName: ResolvedModule; + if (hasProperty(lookup, moduleName)) { + resolvedName = lookup[moduleName]; + } + else { + resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule; + lookup[moduleName] = resolvedName; + } + resolvedModuleNames.push(resolvedName); + } + return resolvedModuleNames; + }); const filesByName = createFileMap(); // stores 'filename -> file association' ignoring case @@ -498,15 +515,19 @@ namespace ts { return false; } - // check imports + // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed return false; } + if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + return false; + } if (resolveModuleNamesWorker) { - const moduleNames = map(newSourceFile.imports, name => name.text); + const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; i++) { @@ -895,65 +916,85 @@ namespace ts { return a.text === b.text; } + function getTextOfLiteral(literal: LiteralExpression): string { + return literal.text; + } + function collectExternalModuleReferences(file: SourceFile): void { if (file.imports) { return; } const isJavaScriptFile = isSourceFileJavaScript(file); + const isExternalModuleFile = isExternalModule(file); let imports: LiteralExpression[]; + let moduleAugmentations: LiteralExpression[]; + for (const node of file.statements) { - collect(node, /*allowRelativeModuleNames*/ true, /*collectOnlyRequireCalls*/ false); + collectModuleReferences(node, /*inAmbientModule*/ false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; return; - function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void { - if (!collectOnlyRequireCalls) { - switch (node.kind) { - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.ExportDeclaration: - let moduleNameExpr = getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { - break; - } - if (!(moduleNameExpr).text) { - break; - } - - if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { - (imports || (imports = [])).push(moduleNameExpr); - } + function collectModuleReferences(node: Node, inAmbientModule: boolean): void { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportDeclaration: + let moduleNameExpr = getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) { break; - case SyntaxKind.ModuleDeclaration: - if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 + } + if (!(moduleNameExpr).text) { + break; + } + + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (!inAmbientModule || !isExternalModuleNameRelative((moduleNameExpr).text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case SyntaxKind.ModuleDeclaration: + if (isAmbientModule(node) && (inAmbientModule || node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { + const moduleName = (node).name; + // Ambient module declarations can be interpreted as augmentations for some existing external modules. + // This will happen in two cases: + // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope + // - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name + // immediately nested in top level ambient module declaration . + if (isExternalModuleFile || (inAmbientModule && !isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted - forEachChild((node).body, node => { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - collect(node, /*allowRelativeModuleNames*/ false, collectOnlyRequireCalls); - }); - } - break; - } - } - if (isJavaScriptFile) { - if (isRequireCall(node)) { - (imports || (imports = [])).push((node).arguments[0]); - } - else { - forEachChild(node, node => collect(node, allowRelativeModuleNames, /*collectOnlyRequireCalls*/ true)); - } + // NOTE: body of ambient module is always a module block + for (const statement of ((node).body).statements) { + collectModuleReferences(statement, /*inAmbientModule*/ true); + } + } + } + } + } + + function collectRequireCalls(node: Node): void { + if (isRequireCall(node)) { + (imports || (imports = [])).push((node).arguments[0]); + } + else { + forEachChild(node, collectRequireCalls); } } } @@ -1083,14 +1124,22 @@ namespace ts { function processImportedModules(file: SourceFile, basePath: string) { collectExternalModuleReferences(file); - if (file.imports.length) { + if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; - const moduleNames = map(file.imports, name => name.text); + const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (let i = 0; i < file.imports.length; i++) { + for (let i = 0; i < moduleNames.length; i++) { const resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); - if (resolution && !options.noResolve) { + // add file to program only if: + // - resolution was successfull + // - noResolve is falsy + // - module name come from the list fo imports + const shouldAddFile = resolution && + !options.noResolve && + i < file.imports.length; + + if (shouldAddFile) { 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) { @@ -1168,7 +1217,7 @@ namespace ts { if (sourceFiles) { const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var sourceFile of sourceFiles) { + for (const sourceFile of sourceFiles) { if (!isDeclarationFile(sourceFile)) { const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 8161ea998c..7192ba6b40 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -94,6 +94,7 @@ namespace ts { "protected": SyntaxKind.ProtectedKeyword, "public": SyntaxKind.PublicKeyword, "require": SyntaxKind.RequireKeyword, + "global": SyntaxKind.GlobalKeyword, "return": SyntaxKind.ReturnKeyword, "set": SyntaxKind.SetKeyword, "static": SyntaxKind.StaticKeyword, diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index e6f908d250..bf25d39aa4 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -376,9 +376,11 @@ namespace ts { /** * @param watcherPath is the path from which the watcher is triggered. */ - function fileEventHandler(eventName: string, relativefileName: string, baseDirPath: Path) { + function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: Path) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" - const filePath = relativefileName === undefined ? undefined : toPath(relativefileName, baseDirPath, getCanonicalPath); + const filePath = typeof relativeFileName !== "string" + ? undefined + : toPath(relativeFileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)); if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { for (const fileCallback of fileWatcherCallbacks.get(filePath)) { fileCallback(filePath); @@ -460,7 +462,7 @@ namespace ts { } function getCanonicalPath(path: string): string { - return useCaseSensitiveFileNames ? path.toLowerCase() : path; + return useCaseSensitiveFileNames ? path : path.toLowerCase(); } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a4632bed3b..18dc6602ab 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -170,6 +170,7 @@ namespace ts { SymbolKeyword, TypeKeyword, FromKeyword, + GlobalKeyword, OfKeyword, // LastKeyword and LastToken // Parse tree nodes @@ -389,10 +390,11 @@ namespace ts { ContainsThis = 1 << 18, // Interface contains references to "this" HasImplicitReturn = 1 << 19, // If function implicitly returns on one of codepaths (initialized by binding) HasExplicitReturn = 1 << 20, // If function has explicit reachable return on one of codepaths (initialized by binding) - HasClassExtends = 1 << 21, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding) - HasDecorators = 1 << 22, // If the file has decorators (initialized by binding) - HasParamDecorators = 1 << 23, // If the file has parameter decorators (initialized by binding) - HasAsyncFunctions = 1 << 24, // If the file has async functions (initialized by binding) + GlobalAugmentation = 1 << 21, // Set if module declaration is an augmentation for the global scope + HasClassExtends = 1 << 22, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding) + HasDecorators = 1 << 23, // If the file has decorators (initialized by binding) + HasParamDecorators = 1 << 24, // If the file has parameter decorators (initialized by binding) + HasAsyncFunctions = 1 << 25, // If the file has async functions (initialized by binding) Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, @@ -1583,6 +1585,7 @@ namespace ts { // Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead /* @internal */ resolvedModules: Map; /* @internal */ imports: LiteralExpression[]; + /* @internal */ moduleAugmentations: LiteralExpression[]; } export interface ScriptReferenceHost { @@ -1917,7 +1920,7 @@ namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile; + getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; } export const enum SymbolFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3553430bcd..69941a6095 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -251,6 +251,31 @@ namespace ts { isCatchClauseVariableDeclaration(declaration); } + export function isAmbientModule(node: Node): boolean { + return node && node.kind === SyntaxKind.ModuleDeclaration && + ((node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(node)); + } + + export function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean { + return !!(module.flags & NodeFlags.GlobalAugmentation); + } + + export function isExternalModuleAugmentation(node: Node): boolean { + // external module augmentation is a ambient module declaration that is either: + // - defined in the top level scope and source file is an external module + // - defined inside ambient module declaration located in the top level scope and source file not an external module + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case SyntaxKind.SourceFile: + return isExternalModule(node.parent); + case SyntaxKind.ModuleBlock: + return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); + } + return false; + } + // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { @@ -343,6 +368,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: + case SyntaxKind.TypeAliasDeclaration: errorNode = (node).name; break; } @@ -1115,6 +1141,9 @@ namespace ts { if (node.kind === SyntaxKind.ExportDeclaration) { return (node).moduleSpecifier; } + if (node.kind === SyntaxKind.ModuleDeclaration && (node).name.kind === SyntaxKind.StringLiteral) { + return (node).name; + } } export function hasQuestionToken(node: Node) { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index fd9f1077dd..7cc3a6c96a 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1002,7 +1002,9 @@ namespace ts.server { info.setFormatOptions(this.getFormatCodeOptions()); this.filenameToScriptInfo[fileName] = info; if (!info.isOpen) { - info.fileWatcher = this.host.watchFile(fileName, _ => { this.watchedFileChanged(fileName); }); + info.fileWatcher = this.host.watchFile( + toPath(fileName, fileName, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + _ => { this.watchedFileChanged(fileName); }); } } } @@ -1215,7 +1217,9 @@ namespace ts.server { } } project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project)); + project.projectFileWatcher = this.host.watchFile( + toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + _ => this.watchedProjectConfigFileChanged(project)); this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); project.directoryWatcher = this.host.watchDirectory( ts.getDirectoryPath(configFilename), diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 46ec807a88..f62c6cb170 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -387,7 +387,7 @@ namespace ts.NavigationBar { function getModuleName(moduleDeclaration: ModuleDeclaration): string { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === SyntaxKind.StringLiteral) { + if (isAmbientModule(moduleDeclaration)) { return getTextOfNode(moduleDeclaration.name); } diff --git a/src/services/services.ts b/src/services/services.ts index 8e998760b4..0fae1c0aa4 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -811,6 +811,7 @@ namespace ts { public nameTable: Map; public resolvedModules: Map; public imports: LiteralExpression[]; + public moduleAugmentations: LiteralExpression[]; private namedDeclarations: Map; constructor(kind: SyntaxKind, pos: number, end: number) { @@ -6028,6 +6029,10 @@ namespace ts { */ function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], previousIterationSymbolsCache: SymbolTable): void { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. // For example: @@ -6043,7 +6048,7 @@ namespace ts { return; } - if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { forEach(symbol.getDeclarations(), declaration => { if (declaration.kind === SyntaxKind.ClassDeclaration) { getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); @@ -6292,7 +6297,7 @@ namespace ts { return SemanticMeaning.Value | SemanticMeaning.Type; case SyntaxKind.ModuleDeclaration: - if ((node).name.kind === SyntaxKind.StringLiteral) { + if (isAmbientModule(node)) { return SemanticMeaning.Namespace | SemanticMeaning.Value; } else if (getModuleInstanceState(node) === ModuleInstanceState.Instantiated) { @@ -6823,7 +6828,8 @@ namespace ts { function classifyDisabledMergeCode(text: string, start: number, end: number) { // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. - for (var i = start; i < end; i++) { + let i: number; + for (i = start; i < end; i++) { if (isLineBreak(text.charCodeAt(i))) { break; } diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index c19e8b6cfa..1b0c08bd79 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'? ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ==== @@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): err !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. yield(foo); ~~~ -!!! error TS2304: Cannot find name 'foo'. +!!! error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'? } } \ No newline at end of file diff --git a/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.errors.txt b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.errors.txt new file mode 100644 index 0000000000..0ce9c61461 --- /dev/null +++ b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts(5,17): error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'? + + +==== tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts (1 errors) ==== + class C { + static foo: string; + + bar() { + let k = foo; + ~~~ +!!! error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'? + } + } \ No newline at end of file diff --git a/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.js b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.js new file mode 100644 index 0000000000..763be0568d --- /dev/null +++ b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.js @@ -0,0 +1,18 @@ +//// [accessInstanceMemberFromStaticMethod01.ts] +class C { + static foo: string; + + bar() { + let k = foo; + } +} + +//// [accessInstanceMemberFromStaticMethod01.js] +var C = (function () { + function C() { + } + C.prototype.bar = function () { + var k = foo; + }; + return C; +}()); diff --git a/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.errors.txt b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.errors.txt new file mode 100644 index 0000000000..612a89a104 --- /dev/null +++ b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts(5,17): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts (1 errors) ==== + class C { + foo: string; + + static bar() { + let k = foo; + ~~~ +!!! error TS2304: Cannot find name 'foo'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.js b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.js new file mode 100644 index 0000000000..fd8ee14b2e --- /dev/null +++ b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.js @@ -0,0 +1,18 @@ +//// [accessStaticMemberFromInstanceMethod01.ts] +class C { + foo: string; + + static bar() { + let k = foo; + } +} + +//// [accessStaticMemberFromInstanceMethod01.js] +var C = (function () { + function C() { + } + C.bar = function () { + var k = foo; + }; + return C; +}()); diff --git a/tests/baselines/reference/aliasAssignments.errors.txt b/tests/baselines/reference/aliasAssignments.errors.txt index fe13faba58..18ea36c5d0 100644 --- a/tests/baselines/reference/aliasAssignments.errors.txt +++ b/tests/baselines/reference/aliasAssignments.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. - Property 'someClass' is missing in type 'Number'. tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'. @@ -9,7 +8,6 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes x = 1; // Should be error ~ !!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. -!!! error TS2322: Property 'someClass' is missing in type 'Number'. var y = 1; y = moduleA; // should be error ~ diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt index 0e508470b1..4edf3bf796 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2664: Invalid module name in augmentation, module 'ext' cannot be found. tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): error TS2307: Cannot find module 'ext'. @@ -9,7 +9,7 @@ tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): err declare module "ext" { ~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'ext' cannot be found. export class C { } } diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt index 7e4ac795d0..c892c91bfd 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. -==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (1 errors) ==== +==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (2 errors) ==== module M { export declare module "M" { } + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~ !!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } \ No newline at end of file diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt index e5905aaaf8..1599069e67 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt @@ -1,7 +1,10 @@ -tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. +tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2664: Invalid module name in augmentation, module 'M' cannot be found. -==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (1 errors) ==== +==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (2 errors) ==== export declare module "M" { } + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. \ No newline at end of file +!!! error TS2664: Invalid module name in augmentation, module 'M' cannot be found. \ No newline at end of file diff --git a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt index 812bbe15da..89ef8ded91 100644 --- a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt +++ b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type 'number' is not assignable to type 'IArguments'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts (1 errors) ==== @@ -8,5 +7,4 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS arguments = 10; /// This shouldnt be of type number and result in error. ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'IArguments'. -!!! error TS2322: Property 'length' is missing in type 'Number'. } \ No newline at end of file diff --git a/tests/baselines/reference/arrayAssignmentTest1.errors.txt b/tests/baselines/reference/arrayAssignmentTest1.errors.txt index d3a7fafed0..3cce5658c1 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest1.errors.txt @@ -26,10 +26,13 @@ tests/cases/compiler/arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is Property 'C2M1' is missing in type 'C3'. tests/cases/compiler/arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'. Type 'C2' is not assignable to type 'C3'. + Property 'CM3M1' is missing in type 'C2'. tests/cases/compiler/arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'. Type 'C1' is not assignable to type 'C3'. + Property 'CM3M1' is missing in type 'C1'. tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is not assignable to type 'C3[]'. Type 'I1' is not assignable to type 'C3'. + Property 'CM3M1' is missing in type 'I1'. tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'. Property 'push' is missing in type '() => C1'. tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'. @@ -159,14 +162,17 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2322: Type 'I1' is n ~~~~~~ !!! error TS2322: Type 'C2[]' is not assignable to type 'C3[]'. !!! error TS2322: Type 'C2' is not assignable to type 'C3'. +!!! error TS2322: Property 'CM3M1' is missing in type 'C2'. arr_c3 = arr_c1_2; // should be an error - is ~~~~~~ !!! error TS2322: Type 'C1[]' is not assignable to type 'C3[]'. !!! error TS2322: Type 'C1' is not assignable to type 'C3'. +!!! error TS2322: Property 'CM3M1' is missing in type 'C1'. arr_c3 = arr_i1_2; // should be an error - is ~~~~~~ !!! error TS2322: Type 'I1[]' is not assignable to type 'C3[]'. !!! error TS2322: Type 'I1' is not assignable to type 'C3'. +!!! error TS2322: Property 'CM3M1' is missing in type 'I1'. arr_any = f1; // should be an error - is ~~~~~~~ diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 637fb3e3bc..5409075a55 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -18,7 +18,6 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error Types of parameters 'items' and 'items' are incompatible. Type 'number | string' is not assignable to type 'Number'. Type 'string' is not assignable to type 'Number'. - Property 'toFixed' is missing in type 'String'. ==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== @@ -82,5 +81,4 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Types of parameters 'items' and 'items' are incompatible. !!! error TS2322: Type 'number | string' is not assignable to type 'Number'. !!! error TS2322: Type 'string' is not assignable to type 'Number'. -!!! error TS2322: Property 'toFixed' is missing in type 'String'. \ No newline at end of file diff --git a/tests/baselines/reference/arraySigChecking.errors.txt b/tests/baselines/reference/arraySigChecking.errors.txt index b70b659773..1968957363 100644 --- a/tests/baselines/reference/arraySigChecking.errors.txt +++ b/tests/baselines/reference/arraySigChecking.errors.txt @@ -4,7 +4,6 @@ tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is n tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'. Type 'number[]' is not assignable to type 'number[][]'. Type 'number' is not assignable to type 'number[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/arraySigChecking.ts (3 errors) ==== @@ -39,7 +38,6 @@ tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' !!! error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'. !!! error TS2322: Type 'number[]' is not assignable to type 'number[][]'. !!! error TS2322: Type 'number' is not assignable to type 'number[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. function isEmpty(l: { length: number }) { return l.length === 0; diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt index 41446dfcea..1c37f04be7 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt +++ b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. - Property 'isArray' is missing in type 'Number'. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: '=' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. @@ -16,7 +15,6 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts( var xs3: typeof Array; ~~~ !!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. -!!! error TS2322: Property 'isArray' is missing in type 'Number'. ~ !!! error TS1005: '=' expected. ~ diff --git a/tests/baselines/reference/assignmentCompat1.errors.txt b/tests/baselines/reference/assignmentCompat1.errors.txt index 7539af9288..0936c532ab 100644 --- a/tests/baselines/reference/assignmentCompat1.errors.txt +++ b/tests/baselines/reference/assignmentCompat1.errors.txt @@ -3,9 +3,7 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. Property 'one' is missing in type '{ [index: number]: any; }'. tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. - Index signature is missing in type 'String'. tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'. - Index signature is missing in type 'Boolean'. ==== tests/cases/compiler/assignmentCompat1.ts (4 errors) ==== @@ -25,11 +23,9 @@ tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is y = "foo"; // Error ~ !!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. -!!! error TS2322: Index signature is missing in type 'String'. z = "foo"; // OK, string has numeric indexer z = false; // Error ~ !!! error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'. -!!! error TS2322: Index signature is missing in type 'Boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index e00d1eea04..a75b5fafac 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. Types of parameters 'y' and 'y' are incompatible. Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type 'Base' is not assignable to type '{ foo: number; }'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ==== @@ -76,6 +80,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var b10: (...x: T[]) => T; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 6cd40f6c8c..da9ffba1ee 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. Types of parameters 'y' and 'y' are incompatible. Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type 'Base' is not assignable to type '{ foo: number; }'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'number'. 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; }'. @@ -15,6 +19,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme 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'. + Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(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; }'. @@ -22,6 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme 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'. + Type '{ new (a: T): T; new (a: T): T; }' provides no match for the signature '(a: any): any' ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (6 errors) ==== @@ -90,6 +96,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var b10: new (...x: T[]) => T; @@ -124,6 +134,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! 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[]'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'. +!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any' var b17: new (x: (a: T) => T) => any[]; a17 = b17; // error @@ -137,6 +148,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! 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[]'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type '{ new (a: T): T; new (a: T): T; }' is not assignable to type '(a: any) => any'. +!!! error TS2322: Type '{ new (a: T): T; new (a: T): T; }' provides no match for the signature '(a: any): any' } module WithGenericSignaturesInBaseType { diff --git a/tests/baselines/reference/assignmentCompatability16.errors.txt b/tests/baselines/reference/assignmentCompatability16.errors.txt index 266d72b323..71a93f11b3 100644 --- a/tests/baselines/reference/assignmentCompatability16.errors.txt +++ b/tests/baselines/reference/assignmentCompatability16.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: any[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'any[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability16.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: any[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'any[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability17.errors.txt b/tests/baselines/reference/assignmentCompatability17.errors.txt index b37f39d082..a87bcff2e9 100644 --- a/tests/baselines/reference/assignmentCompatability17.errors.txt +++ b/tests/baselines/reference/assignmentCompatability17.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: any[]; }'. Types of property 'two' are incompatible. Type 'string' is not assignable to type 'any[]'. - Property 'push' is missing in type 'String'. ==== tests/cases/compiler/assignmentCompatability17.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: any[]; }'. !!! error TS2322: Types of property 'two' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'any[]'. -!!! error TS2322: Property 'push' is missing in type 'String'. \ No newline at end of file +!!! error TS2322: Type 'string' is not assignable to type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability18.errors.txt b/tests/baselines/reference/assignmentCompatability18.errors.txt index 2be4a03757..8ab5e5dcd0 100644 --- a/tests/baselines/reference/assignmentCompatability18.errors.txt +++ b/tests/baselines/reference/assignmentCompatability18.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: number[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'number[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability18.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: number[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'number[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'number[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability19.errors.txt b/tests/baselines/reference/assignmentCompatability19.errors.txt index ae97af6aa7..e84e665cef 100644 --- a/tests/baselines/reference/assignmentCompatability19.errors.txt +++ b/tests/baselines/reference/assignmentCompatability19.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: number[]; }'. Types of property 'two' are incompatible. Type 'string' is not assignable to type 'number[]'. - Property 'push' is missing in type 'String'. ==== tests/cases/compiler/assignmentCompatability19.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: number[]; }'. !!! error TS2322: Types of property 'two' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number[]'. -!!! error TS2322: Property 'push' is missing in type 'String'. \ No newline at end of file +!!! error TS2322: Type 'string' is not assignable to type 'number[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability20.errors.txt b/tests/baselines/reference/assignmentCompatability20.errors.txt index 750310ac5c..2e67a2a203 100644 --- a/tests/baselines/reference/assignmentCompatability20.errors.txt +++ b/tests/baselines/reference/assignmentCompatability20.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: string[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'string[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability20.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: string[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'string[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability21.errors.txt b/tests/baselines/reference/assignmentCompatability21.errors.txt index 8da52fe42c..44e24e7d0b 100644 --- a/tests/baselines/reference/assignmentCompatability21.errors.txt +++ b/tests/baselines/reference/assignmentCompatability21.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string[]; }'. Types of property 'two' are incompatible. Type 'string' is not assignable to type 'string[]'. - Property 'push' is missing in type 'String'. ==== tests/cases/compiler/assignmentCompatability21.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string[]; }'. !!! error TS2322: Types of property 'two' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'string[]'. -!!! error TS2322: Property 'push' is missing in type 'String'. \ No newline at end of file +!!! error TS2322: Type 'string' is not assignable to type 'string[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability22.errors.txt b/tests/baselines/reference/assignmentCompatability22.errors.txt index f0799a92f5..cb42a7abae 100644 --- a/tests/baselines/reference/assignmentCompatability22.errors.txt +++ b/tests/baselines/reference/assignmentCompatability22.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: boolean[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'boolean[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability22.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: boolean[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability23.errors.txt b/tests/baselines/reference/assignmentCompatability23.errors.txt index a005eaa02d..7b54e8559e 100644 --- a/tests/baselines/reference/assignmentCompatability23.errors.txt +++ b/tests/baselines/reference/assignmentCompatability23.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: boolean[]; }'. Types of property 'two' are incompatible. Type 'string' is not assignable to type 'boolean[]'. - Property 'push' is missing in type 'String'. ==== tests/cases/compiler/assignmentCompatability23.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: boolean[]; }'. !!! error TS2322: Types of property 'two' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'. -!!! error TS2322: Property 'push' is missing in type 'String'. \ No newline at end of file +!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability29.errors.txt b/tests/baselines/reference/assignmentCompatability29.errors.txt index 194ae4ab67..9ba5c35d52 100644 --- a/tests/baselines/reference/assignmentCompatability29.errors.txt +++ b/tests/baselines/reference/assignmentCompatability29.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: any[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'any[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability29.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: any[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'any[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability30.errors.txt b/tests/baselines/reference/assignmentCompatability30.errors.txt index b025705517..43f7f3f9c0 100644 --- a/tests/baselines/reference/assignmentCompatability30.errors.txt +++ b/tests/baselines/reference/assignmentCompatability30.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: number[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'number[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability30.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: number[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'number[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'number[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability31.errors.txt b/tests/baselines/reference/assignmentCompatability31.errors.txt index 8e19905eba..8874ebf06a 100644 --- a/tests/baselines/reference/assignmentCompatability31.errors.txt +++ b/tests/baselines/reference/assignmentCompatability31.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: string[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'string[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability31.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: string[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'string[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability32.errors.txt b/tests/baselines/reference/assignmentCompatability32.errors.txt index 6d6321f5e5..00164a48fd 100644 --- a/tests/baselines/reference/assignmentCompatability32.errors.txt +++ b/tests/baselines/reference/assignmentCompatability32.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: boolean[]; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'boolean[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/assignmentCompatability32.ts (1 errors) ==== @@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'inte ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ one: boolean[]; }'. !!! error TS2322: Types of property 'one' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt index e5db4f9ab9..33a2269f74 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt +++ b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Applicable'. - Property 'apply' is missing in type 'String'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Applicable'. Property 'apply' is missing in type 'string[]'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Applicable'. - Property 'apply' is missing in type 'Number'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Applicable'. Property 'apply' is missing in type '{}'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Applicable'. @@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi x = ''; ~ !!! error TS2322: Type 'string' is not assignable to type 'Applicable'. -!!! error TS2322: Property 'apply' is missing in type 'String'. x = ['']; ~ !!! error TS2322: Type 'string[]' is not assignable to type 'Applicable'. @@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi x = 4; ~ !!! error TS2322: Type 'number' is not assignable to type 'Applicable'. -!!! error TS2322: Property 'apply' is missing in type 'Number'. x = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'Applicable'. diff --git a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt index f3ff6f1b79..1651e5082e 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt +++ b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Callable'. - Property 'call' is missing in type 'String'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Callable'. Property 'call' is missing in type 'string[]'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Callable'. - Property 'call' is missing in type 'Number'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Callable'. Property 'call' is missing in type '{}'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'. @@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio x = ''; ~ !!! error TS2322: Type 'string' is not assignable to type 'Callable'. -!!! error TS2322: Property 'call' is missing in type 'String'. x = ['']; ~ !!! error TS2322: Type 'string[]' is not assignable to type 'Callable'. @@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio x = 4; ~ !!! error TS2322: Type 'number' is not assignable to type 'Callable'. -!!! error TS2322: Property 'call' is missing in type 'Number'. x = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'Callable'. diff --git a/tests/baselines/reference/booleanAssignment.errors.txt b/tests/baselines/reference/booleanAssignment.errors.txt index 454bd7ef70..15b506d3df 100644 --- a/tests/baselines/reference/booleanAssignment.errors.txt +++ b/tests/baselines/reference/booleanAssignment.errors.txt @@ -1,11 +1,5 @@ tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type 'number' is not assignable to type 'Boolean'. - Types of property 'valueOf' are incompatible. - Type '() => number' is not assignable to type '() => boolean'. - Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type 'string' is not assignable to type 'Boolean'. - Types of property 'valueOf' are incompatible. - Type '() => string' is not assignable to type '() => boolean'. - Type 'string' is not assignable to type 'boolean'. tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'. Types of property 'valueOf' are incompatible. Type '() => Object' is not assignable to type '() => boolean'. @@ -17,15 +11,9 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a b = 1; // Error ~ !!! error TS2322: Type 'number' is not assignable to type 'Boolean'. -!!! error TS2322: Types of property 'valueOf' are incompatible. -!!! error TS2322: Type '() => number' is not assignable to type '() => boolean'. -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. b = "a"; // Error ~ !!! error TS2322: Type 'string' is not assignable to type 'Boolean'. -!!! error TS2322: Types of property 'valueOf' are incompatible. -!!! error TS2322: Type '() => string' is not assignable to type '() => boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. b = {}; // Error ~ !!! error TS2322: Type '{}' is not assignable to type 'Boolean'. diff --git a/tests/baselines/reference/capturedLetConstInLoop11.js b/tests/baselines/reference/capturedLetConstInLoop11.js new file mode 100644 index 0000000000..fa295739d0 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11.js @@ -0,0 +1,35 @@ +//// [capturedLetConstInLoop11.ts] +for (;;) { + let x = 1; + () => x; +} + +function foo() { + for (;;) { + const a = 0; + switch(a) { + case 0: return () => a; + } + } +} + +//// [capturedLetConstInLoop11.js] +var _loop_1 = function() { + var x = 1; + (function () { return x; }); +}; +for (;;) { + _loop_1(); +} +function foo() { + var _loop_2 = function() { + var a = 0; + switch (a) { + case 0: return { value: function () { return a; } }; + } + }; + for (;;) { + var state_2 = _loop_2(); + if (typeof state_2 === "object") return state_2.value + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop11.symbols b/tests/baselines/reference/capturedLetConstInLoop11.symbols new file mode 100644 index 0000000000..2e242906b7 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/capturedLetConstInLoop11.ts === +for (;;) { + let x = 1; +>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7)) + + () => x; +>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7)) +} + +function foo() { +>foo : Symbol(foo, Decl(capturedLetConstInLoop11.ts, 3, 1)) + + for (;;) { + const a = 0; +>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13)) + + switch(a) { +>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13)) + + case 0: return () => a; +>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13)) + } + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop11.types b/tests/baselines/reference/capturedLetConstInLoop11.types new file mode 100644 index 0000000000..93e18f2cb2 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/capturedLetConstInLoop11.ts === +for (;;) { + let x = 1; +>x : number +>1 : number + + () => x; +>() => x : () => number +>x : number +} + +function foo() { +>foo : () => () => number + + for (;;) { + const a = 0; +>a : number +>0 : number + + switch(a) { +>a : number + + case 0: return () => a; +>0 : number +>() => a : () => number +>a : number + } + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop11_ES6.js b/tests/baselines/reference/capturedLetConstInLoop11_ES6.js new file mode 100644 index 0000000000..49f6e9f521 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11_ES6.js @@ -0,0 +1,28 @@ +//// [capturedLetConstInLoop11_ES6.ts] +for (;;) { + let x = 1; + () => x; +} + +function foo() { + for (;;) { + const a = 0; + switch(a) { + case 0: return () => a; + } + } +} + +//// [capturedLetConstInLoop11_ES6.js] +for (;;) { + let x = 1; + (() => x); +} +function foo() { + for (;;) { + const a = 0; + switch (a) { + case 0: return () => a; + } + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop11_ES6.symbols b/tests/baselines/reference/capturedLetConstInLoop11_ES6.symbols new file mode 100644 index 0000000000..6079bf490a --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11_ES6.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts === +for (;;) { + let x = 1; +>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7)) + + () => x; +>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7)) +} + +function foo() { +>foo : Symbol(foo, Decl(capturedLetConstInLoop11_ES6.ts, 3, 1)) + + for (;;) { + const a = 0; +>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13)) + + switch(a) { +>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13)) + + case 0: return () => a; +>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13)) + } + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop11_ES6.types b/tests/baselines/reference/capturedLetConstInLoop11_ES6.types new file mode 100644 index 0000000000..de75d5d151 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop11_ES6.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts === +for (;;) { + let x = 1; +>x : number +>1 : number + + () => x; +>() => x : () => number +>x : number +} + +function foo() { +>foo : () => () => number + + for (;;) { + const a = 0; +>a : number +>0 : number + + switch(a) { +>a : number + + case 0: return () => a; +>0 : number +>() => a : () => number +>a : number + } + } +} diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCannotBeAssigned.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentLHSCannotBeAssigned.errors.txt index 535e4eb1a3..6bbebeb6ec 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCannotBeAssigned.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCannotBeAssigned.errors.txt @@ -2,7 +2,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(8,1): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(11,1): error TS2322: Type 'string' is not assignable to type 'E'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(14,1): error TS2322: Type 'string' is not assignable to type '{ a: string; }'. - Property 'a' is missing in type 'String'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(17,1): error TS2322: Type 'string' is not assignable to type 'void'. @@ -29,7 +28,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen x4 += ''; ~~ !!! error TS2322: Type 'string' is not assignable to type '{ a: string; }'. -!!! error TS2322: Property 'a' is missing in type 'String'. var x5: void; x5 += ''; diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index a8fe1de470..3b9a84fea9 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type 'number' is not assignable to type 'X'. - Property 'foo' is missing in type 'Number'. tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class @@ -9,7 +8,6 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Retur return 1; ~ !!! error TS2322: Type 'number' is not assignable to type 'X'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 1f7d7133bd..421e629c11 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type 'number' is not assignable to type 'D'. - Property 'x' is missing in type 'Number'. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. Types of property 'x' are incompatible. @@ -22,7 +21,6 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl return 1; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'D'. -!!! error TS2322: Property 'x' is missing in type 'Number'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/contextualTyping21.errors.txt b/tests/baselines/reference/contextualTyping21.errors.txt index 362ead49ad..db6ecd32b9 100644 --- a/tests/baselines/reference/contextualTyping21.errors.txt +++ b/tests/baselines/reference/contextualTyping21.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | number' is not assignable to type '{ id: number; }'. Type 'number' is not assignable to type '{ id: number; }'. - Property 'id' is missing in type 'Number'. ==== tests/cases/compiler/contextualTyping21.ts (1 errors) ==== @@ -9,5 +8,4 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: num ~~~ !!! error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | number' is not assignable to type '{ id: number; }'. -!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'. -!!! error TS2322: Property 'id' is missing in type 'Number'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping33.errors.txt b/tests/baselines/reference/contextualTyping33.errors.txt index 4ed0787bde..16c975391a 100644 --- a/tests/baselines/reference/contextualTyping33.errors.txt +++ b/tests/baselines/reference/contextualTyping33.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'. Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. + Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/contextualTyping33.ts (1 errors) ==== @@ -8,4 +9,5 @@ tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'. !!! error TS2345: Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'. -!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. \ No newline at end of file +!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index a1bfaf5633..698a8e789f 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ Index signatures are incompatible. Type 'Date | number' is not assignable to type 'Date'. Type 'number' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'Number'. ==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ==== @@ -16,7 +15,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'Date | number' is not assignable to type 'Date'. !!! error TS2322: Type 'number' is not assignable to type 'Date'. -!!! error TS2322: Property 'toDateString' is missing in type 'Number'. var r2 = x3[1]; r2.getDate(); \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt index 08fe22c08e..be49b7b524 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt @@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS Type '(b: number) => void' is not assignable to type '(a: A) => void'. Types of parameters 'b' and 'a' are incompatible. Type 'number' is not assignable to type 'A'. - Property 'foo' is missing in type 'Number'. ==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ==== @@ -22,5 +21,4 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS !!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void'. !!! error TS2322: Types of parameters 'b' and 'a' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt b/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt index a11f000901..c7b15e8efe 100644 --- a/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt @@ -1,6 +1,5 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. Type 'string' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'String'. tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. Type 'string' is not assignable to type 'Date'. @@ -25,7 +24,6 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): ~ !!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. !!! error TS2345: Type 'string' is not assignable to type 'Date'. -!!! error TS2345: Property 'toDateString' is missing in type 'String'. var r6 = _.forEach(c2, (x) => { return x.toFixed() }); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. diff --git a/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt b/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt new file mode 100644 index 0000000000..2ae0b6a160 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/declarationEmit_UnknownImport.ts(2,1): error TS2304: Cannot find name 'SomeNonExistingName'. +tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. + + +==== tests/cases/compiler/declarationEmit_UnknownImport.ts (3 errors) ==== + + import Foo = SomeNonExistingName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'SomeNonExistingName'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'SomeNonExistingName'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. + export {Foo} \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_UnknownImport.js b/tests/baselines/reference/declarationEmit_UnknownImport.js new file mode 100644 index 0000000000..601d2a92c8 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_UnknownImport.js @@ -0,0 +1,7 @@ +//// [declarationEmit_UnknownImport.ts] + +import Foo = SomeNonExistingName +export {Foo} + +//// [declarationEmit_UnknownImport.js] +"use strict"; diff --git a/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt b/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt new file mode 100644 index 0000000000..0e0bf6690e --- /dev/null +++ b/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,1): error TS2304: Cannot find name 'From'. +tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS2503: Cannot find namespace 'From'. +tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS4000: Import declaration 'Foo' is using private name 'From'. +tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,17): error TS1005: ';' expected. + + +==== tests/cases/compiler/declarationEmit_UnknownImport2.ts (5 errors) ==== + + import Foo From './Foo'; // Syntax error + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'From'. + ~~~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2503: Cannot find namespace 'From'. + ~~~~ +!!! error TS4000: Import declaration 'Foo' is using private name 'From'. + ~~~~~~~ +!!! error TS1005: ';' expected. + export default Foo \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_UnknownImport2.js b/tests/baselines/reference/declarationEmit_UnknownImport2.js new file mode 100644 index 0000000000..213b4fc736 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_UnknownImport2.js @@ -0,0 +1,8 @@ +//// [declarationEmit_UnknownImport2.ts] + +import Foo From './Foo'; // Syntax error +export default Foo + +//// [declarationEmit_UnknownImport2.js] +"use strict"; +'./Foo'; // Syntax error diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 9140528597..3348effe82 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -5,7 +5,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss Types of property '1' are incompatible. Type 'number' is not assignable to type 'boolean'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. - Property 'toFixed' is missing in type 'String'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. @@ -43,7 +42,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss var [b3 = "string", b4, b5] = bar(); // Error ~~ !!! error TS2322: Type 'string' is not assignable to type 'Number'. -!!! error TS2322: Property 'toFixed' is missing in type 'String'. // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index c8037255a3..8c0781571e 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -8,7 +8,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'string[][]'. - Property 'push' is missing in type 'String'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. @@ -34,7 +33,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property '2' are incompatible. Type 'boolean' is not assignable to type '[[any]]'. - Property '0' is missing in type 'Boolean'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. Types of property '2' are incompatible. Type '[[string]]' is not assignable to type '[[number]]'. @@ -78,7 +76,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'string[][]'. -!!! error TS2345: Property 'push' is missing in type 'String'. // If the declaration includes an initializer expression (which is permitted only @@ -146,7 +143,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. !!! error TS2345: Types of property '2' are incompatible. !!! error TS2345: Type 'boolean' is not assignable to type '[[any]]'. -!!! error TS2345: Property '0' is missing in type 'Boolean'. c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer ~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 7e71a2cd75..b08c5b942d 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -6,7 +6,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property '2' are incompatible. Type 'string' is not assignable to type '[[any]]'. - Property '0' is missing in type 'String'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. Property '2' is missing in type '[number, number]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. @@ -53,7 +52,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( !!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. !!! error TS2345: Types of property '2' are incompatible. !!! error TS2345: Type 'string' is not assignable to type '[[any]]'. -!!! error TS2345: Property '0' is missing in type 'String'. a5([1, 2]); // Error, parameter type is [any, any, [[any]]] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt index c60e2b75c3..2afb25502c 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. Types of property 'y' are incompatible. Type 'Class' is not assignable to type 'D'. + Property 'foo' is missing in type 'Class'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. Property 'y' is missing in type '{}'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. @@ -63,6 +64,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts( !!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'. !!! error TS2345: Types of property 'y' are incompatible. !!! error TS2345: Type 'Class' is not assignable to type 'D'. +!!! error TS2345: Property 'foo' is missing in type 'Class'. d3({}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. diff --git a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt index c13a6b5fe2..d53571cc4a 100644 --- a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt +++ b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(1,5): error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. - Property 'x' is missing in type 'Number'. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(3,6): error TS1139: Type parameter declaration expected. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Expression expected. @@ -8,7 +7,6 @@ tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Exp var f: { ~ !!! error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. -!!! error TS2322: Property 'x' is missing in type 'Number'. x: number; <- ~ diff --git a/tests/baselines/reference/enumAssignability.errors.txt b/tests/baselines/reference/enumAssignability.errors.txt index 1316727076..bfabb5eae8 100644 --- a/tests/baselines/reference/enumAssignability.errors.txt +++ b/tests/baselines/reference/enumAssignability.errors.txt @@ -3,23 +3,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(29,9): error TS2322: Type 'E' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(30,9): error TS2322: Type 'E' is not assignable to type 'boolean'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(31,9): error TS2322: Type 'E' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(33,9): error TS2322: Type 'E' is not assignable to type 'void'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(36,9): error TS2322: Type 'E' is not assignable to type '() => {}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(37,9): error TS2322: Type 'E' is not assignable to type 'Function'. - Property 'apply' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(38,9): error TS2322: Type 'E' is not assignable to type '(x: number) => string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(39,5): error TS2322: Type 'E' is not assignable to type 'C'. - Property 'foo' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(40,5): error TS2322: Type 'E' is not assignable to type 'I'. - Property 'foo' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(41,9): error TS2322: Type 'E' is not assignable to type 'number[]'. - Property 'length' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(42,9): error TS2322: Type 'E' is not assignable to type '{ foo: string; }'. - Property 'foo' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'. - Property 'charAt' is missing in type 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'. @@ -69,7 +62,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi var ee: Date = e; ~~ !!! error TS2322: Type 'E' is not assignable to type 'Date'. -!!! error TS2322: Property 'toDateString' is missing in type 'Number'. var f: any = e; // ok var g: void = e; ~ @@ -82,26 +74,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi var k: Function = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'Function'. -!!! error TS2322: Property 'apply' is missing in type 'Number'. var l: (x: number) => string = e; ~ !!! error TS2322: Type 'E' is not assignable to type '(x: number) => string'. ac = e; ~~ !!! error TS2322: Type 'E' is not assignable to type 'C'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. ai = e; ~~ !!! error TS2322: Type 'E' is not assignable to type 'I'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. var m: number[] = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'number[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. var n: { foo: string } = e; ~ !!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. var o: (x: T) => T = e; ~ !!! error TS2322: Type 'E' is not assignable to type '(x: T) => T'. @@ -109,7 +96,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi var q: String = e; ~ !!! error TS2322: Type 'E' is not assignable to type 'String'. -!!! error TS2322: Property 'charAt' is missing in type 'Number'. function foo(x: T, y: U, z: V) { x = e; diff --git a/tests/baselines/reference/enumAssignmentCompat.errors.txt b/tests/baselines/reference/enumAssignmentCompat.errors.txt index 3cddaf4596..f1a0124714 100644 --- a/tests/baselines/reference/enumAssignmentCompat.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/enumAssignmentCompat.ts(26,5): error TS2322: Type 'typeof W' is not assignable to type 'number'. tests/cases/compiler/enumAssignmentCompat.ts(28,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. - Property 'D' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat.ts(30,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. tests/cases/compiler/enumAssignmentCompat.ts(32,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. - Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. @@ -40,7 +38,6 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' var b: typeof W = W.a; // error ~ !!! error TS2322: Type 'W' is not assignable to type 'typeof W'. -!!! error TS2322: Property 'D' is missing in type 'Number'. var c: typeof W.a = W.a; var d: typeof W = 3; // error ~ @@ -49,7 +46,6 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' var f: WStatic = W.a; // error ~ !!! error TS2322: Type 'W' is not assignable to type 'WStatic'. -!!! error TS2322: Property 'a' is missing in type 'Number'. var g: WStatic = 5; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'WStatic'. diff --git a/tests/baselines/reference/enumAssignmentCompat2.errors.txt b/tests/baselines/reference/enumAssignmentCompat2.errors.txt index d87d6acf6a..4e0660eaae 100644 --- a/tests/baselines/reference/enumAssignmentCompat2.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat2.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/enumAssignmentCompat2.ts(25,5): error TS2322: Type 'typeof W' is not assignable to type 'number'. tests/cases/compiler/enumAssignmentCompat2.ts(27,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. - Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat2.ts(29,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. tests/cases/compiler/enumAssignmentCompat2.ts(31,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. - Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. @@ -39,7 +37,6 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' var b: typeof W = W.a; // error ~ !!! error TS2322: Type 'W' is not assignable to type 'typeof W'. -!!! error TS2322: Property 'a' is missing in type 'Number'. var c: typeof W.a = W.a; var d: typeof W = 3; // error ~ @@ -48,7 +45,6 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' var f: WStatic = W.a; // error ~ !!! error TS2322: Type 'W' is not assignable to type 'WStatic'. -!!! error TS2322: Property 'a' is missing in type 'Number'. var g: WStatic = 5; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'WStatic'. diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt index 1247844247..fc1bcaa545 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(34,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(35,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(36,5): error TS2322: Type 'number' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'Number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(38,5): error TS2322: Type 'number' is not assignable to type 'void'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(40,5): error TS2322: Type 'D<{}>' is not assignable to type 'I'. Property 'id' is missing in type 'D<{}>'. @@ -76,7 +75,6 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd var aDate: Date = 9.9; ~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'Date'. -!!! error TS2322: Property 'toDateString' is missing in type 'Number'. var aVoid: void = 9.9; ~~~~~ diff --git a/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt b/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt index 946bc8ee8b..cf63c48925 100644 --- a/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt +++ b/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'. - Property 'a' is missing in type 'Boolean'. ==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ==== @@ -7,7 +6,6 @@ tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument o var x = new foo(true); // Should error ~~~~ !!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'. -!!! error TS2345: Property 'a' is missing in type 'Boolean'. var y = new foo({a: "test", b: 42}); // Should be OK var z: number = y.test.b; ==== tests/cases/conformance/externalModules/foo_0.ts (0 errors) ==== diff --git a/tests/baselines/reference/functionCall7.errors.txt b/tests/baselines/reference/functionCall7.errors.txt index 19e572fa58..576ea9c266 100644 --- a/tests/baselines/reference/functionCall7.errors.txt +++ b/tests/baselines/reference/functionCall7.errors.txt @@ -1,6 +1,5 @@ tests/cases/compiler/functionCall7.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/functionCall7.ts(6,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'. - Property 'a' is missing in type 'Number'. tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -15,7 +14,6 @@ tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do foo(4); ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'. -!!! error TS2345: Property 'a' is missing in type 'Number'. foo(); ~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index 7b3aa92828..d2299894c5 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. - Property 'apply' is missing in type 'Number'. 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'. @@ -20,9 +19,11 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain Type 'F2' provides no match for the signature '(x: string): string' 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'. + Type 'void' is not assignable to type 'string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. Type 'T' is not assignable to type '(x: string) => string'. Type '() => void' is not assignable to type '(x: string) => string'. + Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (13 errors) ==== @@ -33,7 +34,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain foo(1); ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. -!!! error TS2345: Property 'apply' is missing in type 'Number'. foo(() => { }, 1); ~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. @@ -97,10 +97,12 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain ~ !!! error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'. !!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'. +!!! error TS2345: Type 'void' is not assignable to type 'string'. foo2(y); ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. !!! error TS2345: Type 'T' is not assignable to type '(x: string) => string'. !!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'. +!!! error TS2345: Type 'void' is not assignable to type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt index 6ac3c9e670..805bde82b6 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts(11,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'. - Property 'toDateString' is missing in type 'Number'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts (1 errors) ==== @@ -16,5 +15,4 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithCon var r4 = foo(1); // error ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'. -!!! error TS2345: Property 'toDateString' is missing in type 'Number'. var r5 = foo(new Date()); // no error \ No newline at end of file diff --git a/tests/baselines/reference/genericCombinators2.errors.txt b/tests/baselines/reference/genericCombinators2.errors.txt index d590f1030c..5be717109c 100644 --- a/tests/baselines/reference/genericCombinators2.errors.txt +++ b/tests/baselines/reference/genericCombinators2.errors.txt @@ -1,6 +1,5 @@ tests/cases/compiler/genericCombinators2.ts(15,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. Type 'string' is not assignable to type 'Date'. - Property 'toDateString' is missing in type 'String'. tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. Type 'string' is not assignable to type 'Date'. @@ -24,7 +23,6 @@ tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of ty ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. !!! error TS2345: Type 'string' is not assignable to type 'Date'. -!!! error TS2345: Property 'toDateString' is missing in type 'String'. var r5b = _.map(c2, rf1); ~~~ !!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.errors.txt b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.errors.txt index 38818b5986..1e5e3b6ee9 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.errors.txt +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts(11,1): error TS2322: Type 'B' is not assignable to type 'A<{ length: number; foo: number; }>'. Types of property 'x' are incompatible. Type 'string' is not assignable to type '{ length: number; foo: number; }'. - Property 'foo' is missing in type 'String'. ==== tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts (1 errors) ==== @@ -20,5 +19,4 @@ tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts(11,1): error TS23 !!! error TS2322: Type 'B' is not assignable to type 'A<{ length: number; foo: number; }>'. !!! error TS2322: Types of property 'x' are incompatible. !!! error TS2322: Type 'string' is not assignable to type '{ length: number; foo: number; }'. -!!! error TS2322: Property 'foo' is missing in type 'String'. \ No newline at end of file diff --git a/tests/baselines/reference/genericRestArgs.errors.txt b/tests/baselines/reference/genericRestArgs.errors.txt index 99106ebd79..8a97745295 100644 --- a/tests/baselines/reference/genericRestArgs.errors.txt +++ b/tests/baselines/reference/genericRestArgs.errors.txt @@ -4,7 +4,6 @@ tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 's tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/genericRestArgs.ts (4 errors) ==== @@ -29,5 +28,4 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' var a2Gb = makeArrayG(1, ""); var a2Gc = makeArrayG(1, ""); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. -!!! error TS2345: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/globalIsContextualKeyword.js b/tests/baselines/reference/globalIsContextualKeyword.js new file mode 100644 index 0000000000..b6fa566c91 --- /dev/null +++ b/tests/baselines/reference/globalIsContextualKeyword.js @@ -0,0 +1,34 @@ +//// [globalIsContextualKeyword.ts] +function a() { + let global = 1; +} +function b() { + class global {} +} + +namespace global { +} + +function foo(global: number) { +} + +let obj = { + global: "123" +} + +//// [globalIsContextualKeyword.js] +function a() { + var global = 1; +} +function b() { + var global = (function () { + function global() { + } + return global; + }()); +} +function foo(global) { +} +var obj = { + global: "123" +}; diff --git a/tests/baselines/reference/globalIsContextualKeyword.symbols b/tests/baselines/reference/globalIsContextualKeyword.symbols new file mode 100644 index 0000000000..edc1cebbc9 --- /dev/null +++ b/tests/baselines/reference/globalIsContextualKeyword.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/globalIsContextualKeyword.ts === +function a() { +>a : Symbol(a, Decl(globalIsContextualKeyword.ts, 0, 0)) + + let global = 1; +>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 1, 7)) +} +function b() { +>b : Symbol(b, Decl(globalIsContextualKeyword.ts, 2, 1)) + + class global {} +>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 3, 14)) +} + +namespace global { +>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 5, 1)) +} + +function foo(global: number) { +>foo : Symbol(foo, Decl(globalIsContextualKeyword.ts, 8, 1)) +>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 10, 13)) +} + +let obj = { +>obj : Symbol(obj, Decl(globalIsContextualKeyword.ts, 13, 3)) + + global: "123" +>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 13, 11)) +} diff --git a/tests/baselines/reference/globalIsContextualKeyword.types b/tests/baselines/reference/globalIsContextualKeyword.types new file mode 100644 index 0000000000..d0bf624af6 --- /dev/null +++ b/tests/baselines/reference/globalIsContextualKeyword.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/globalIsContextualKeyword.ts === +function a() { +>a : () => void + + let global = 1; +>global : number +>1 : number +} +function b() { +>b : () => void + + class global {} +>global : global +} + +namespace global { +>global : any +} + +function foo(global: number) { +>foo : (global: number) => void +>global : number +} + +let obj = { +>obj : { global: string; } +>{ global: "123"} : { global: string; } + + global: "123" +>global : string +>"123" : string +} diff --git a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt index 34cfe02305..5d70b32aa1 100644 --- a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt +++ b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt @@ -1,6 +1,6 @@ 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(2,16): error TS2664: Invalid module name in augmentation, module 'm1' cannot be found. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): error TS2307: Cannot find module 'externalModule'. @@ -12,7 +12,7 @@ tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): er !!! error TS2307: Cannot find module 'externalModule'. declare module "m1" { ~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'm1' cannot be found. import im2 = require("externalModule"); ~~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'externalModule'. diff --git a/tests/baselines/reference/initializerReferencingConstructorParameters.errors.txt b/tests/baselines/reference/initializerReferencingConstructorParameters.errors.txt index 623bd53574..eb6744d656 100644 --- a/tests/baselines/reference/initializerReferencingConstructorParameters.errors.txt +++ b/tests/baselines/reference/initializerReferencingConstructorParameters.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(4,9): error TS2304: Cannot find name 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(5,15): error TS2304: Cannot find name 'x'. -tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(10,9): error TS2304: Cannot find name 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(10,9): error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'? tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(11,15): error TS2304: Cannot find name 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(17,15): error TS1003: Identifier expected. -tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(23,9): error TS2304: Cannot find name 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(23,9): error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'? ==== tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts (6 errors) ==== @@ -22,7 +22,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencin class D { a = x; // error ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'? b: typeof x; // error ~ !!! error TS2304: Cannot find name 'x'. @@ -41,6 +41,6 @@ tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencin a = this.x; // ok b = x; // error ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'? constructor(public x: T) { } } \ No newline at end of file diff --git a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt index ba93c2ef12..81982ac3ec 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt +++ b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2' incorrectly extends base class 'C1'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'C2'. - Property 'x' is missing in type 'String'. ==== tests/cases/compiler/instanceSubtypeCheck2.ts (1 errors) ==== @@ -14,6 +13,5 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2' !!! error TS2415: Class 'C2' incorrectly extends base class 'C1'. !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'C2'. -!!! error TS2415: Property 'x' is missing in type 'String'. x: string } \ No newline at end of file diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 3d805a6582..a860f5e360 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -9,7 +9,6 @@ tests/cases/compiler/intTypeCheck.ts(101,5): error TS2322: Type 'Base' is not as tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is not assignable to type 'i1'. Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'. - Property 'p' is missing in type 'Boolean'. 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. @@ -38,7 +37,6 @@ tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3 tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. - Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -52,7 +50,6 @@ tests/cases/compiler/intTypeCheck.ts(157,5): error TS2322: Type 'Base' is not as tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is not assignable to type 'i5'. Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'. - Property 'p' is missing in type 'Boolean'. 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. @@ -83,7 +80,6 @@ tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7 tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. - Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -215,7 +211,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj9: i1 = new anyVar; ~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i1'. -!!! error TS2322: Property 'p' is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -307,7 +302,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj42: i4 = new anyVar; ~~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -344,7 +338,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj53: i5 = new anyVar; ~~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i5'. -!!! error TS2322: Property 'p' is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -439,7 +432,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj86: i8 = new anyVar; ~~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ diff --git a/tests/baselines/reference/interfaceImplementation7.errors.txt b/tests/baselines/reference/interfaceImplementation7.errors.txt index b297015dfb..1025a1f529 100644 --- a/tests/baselines/reference/interfaceImplementation7.errors.txt +++ b/tests/baselines/reference/interfaceImplementation7.errors.txt @@ -4,7 +4,6 @@ tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1' Types of property 'name' are incompatible. Type '() => string' is not assignable to type '() => { s: string; n: number; }'. Type 'string' is not assignable to type '{ s: string; n: number; }'. - Property 's' is missing in type 'String'. ==== tests/cases/compiler/interfaceImplementation7.ts (2 errors) ==== @@ -23,7 +22,6 @@ tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1' !!! error TS2420: Types of property 'name' are incompatible. !!! error TS2420: Type '() => string' is not assignable to type '() => { s: string; n: number; }'. !!! error TS2420: Type 'string' is not assignable to type '{ s: string; n: number; }'. -!!! error TS2420: Property 's' is missing in type 'String'. public name(): string { return ""; } } \ No newline at end of file diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt index 4f26cc63ba..d4526c815c 100644 --- a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(19,1): error TS2322: Type 'A' is not assignable to type 'A & B'. Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(20,1): error TS2322: Type 'B' is not assignable to type 'A & B'. Type 'B' is not assignable to type 'A'. Property 'a' is missing in type 'B'. @@ -7,26 +8,32 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(23,1): e Type 'A' is not assignable to type '(A & B) | (C & D)'. Type 'A' is not assignable to type 'C & D'. Type 'A' is not assignable to type 'C'. + Property 'c' is missing in type 'A'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(25,1): error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. Type 'C' is not assignable to type '(A & B) | (C & D)'. Type 'C' is not assignable to type 'C & D'. Type 'C' is not assignable to type 'D'. + Property 'd' is missing in type 'C'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(26,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. Type 'C & D' is not assignable to type 'A & B'. Type 'C & D' is not assignable to type 'A'. Type 'D' is not assignable to type 'A'. + Property 'a' is missing in type 'D'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(27,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. Type 'C & D' is not assignable to type 'A | B'. Type 'C & D' is not assignable to type 'B'. Type 'D' is not assignable to type 'B'. + Property 'b' is missing in type 'D'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. Type 'A & B' is not assignable to type 'C & D'. Type 'A & B' is not assignable to type 'C'. Type 'B' is not assignable to type 'C'. + Property 'c' is missing in type 'B'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. Type 'A & B' is not assignable to type 'C | D'. Type 'A & B' is not assignable to type 'D'. Type 'B' is not assignable to type 'D'. + Property 'd' is missing in type 'B'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. Type 'A & B' is not assignable to type 'C | D'. Type 'A & B' is not assignable to type 'D'. @@ -35,6 +42,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): e Type 'A' is not assignable to type '(A | B) & (C | D)'. Type 'A' is not assignable to type 'C | D'. Type 'A' is not assignable to type 'D'. + Property 'd' is missing in type 'A'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. Type 'C & D' is not assignable to type 'A | B'. Type 'C & D' is not assignable to type 'B'. @@ -43,14 +51,17 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): e Type 'C' is not assignable to type '(A | B) & (C | D)'. Type 'C' is not assignable to type 'A | B'. Type 'C' is not assignable to type 'B'. + Property 'b' is missing in type 'C'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. Type '(A | B) & (C | D)' is not assignable to type 'A'. Type 'C | D' is not assignable to type 'A'. Type 'C' is not assignable to type 'A'. + Property 'a' is missing in type 'C'. tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. Type '(A | B) & (C | D)' is not assignable to type 'C'. Type 'C | D' is not assignable to type 'C'. Type 'D' is not assignable to type 'C'. + Property 'c' is missing in type 'D'. ==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ==== @@ -76,6 +87,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e ~~~ !!! error TS2322: Type 'A' is not assignable to type 'A & B'. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'A'. anb = b; ~~~ !!! error TS2322: Type 'B' is not assignable to type 'A & B'. @@ -89,6 +101,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e !!! error TS2322: Type 'A' is not assignable to type '(A & B) | (C & D)'. !!! error TS2322: Type 'A' is not assignable to type 'C & D'. !!! error TS2322: Type 'A' is not assignable to type 'C'. +!!! error TS2322: Property 'c' is missing in type 'A'. x = cnd; // Ok x = cod; ~ @@ -96,30 +109,35 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e !!! error TS2322: Type 'C' is not assignable to type '(A & B) | (C & D)'. !!! error TS2322: Type 'C' is not assignable to type 'C & D'. !!! error TS2322: Type 'C' is not assignable to type 'D'. +!!! error TS2322: Property 'd' is missing in type 'C'. anb = x; ~~~ !!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. !!! error TS2322: Type 'C & D' is not assignable to type 'A & B'. !!! error TS2322: Type 'C & D' is not assignable to type 'A'. !!! error TS2322: Type 'D' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type 'D'. aob = x; ~~~ !!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. !!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. !!! error TS2322: Type 'C & D' is not assignable to type 'B'. !!! error TS2322: Type 'D' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'D'. cnd = x; ~~~ !!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. !!! error TS2322: Type 'A & B' is not assignable to type 'C & D'. !!! error TS2322: Type 'A & B' is not assignable to type 'C'. !!! error TS2322: Type 'B' is not assignable to type 'C'. +!!! error TS2322: Property 'c' is missing in type 'B'. cod = x; ~~~ !!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. !!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. !!! error TS2322: Type 'A & B' is not assignable to type 'D'. !!! error TS2322: Type 'B' is not assignable to type 'D'. +!!! error TS2322: Property 'd' is missing in type 'B'. y = anb; ~ @@ -133,6 +151,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e !!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'. !!! error TS2322: Type 'A' is not assignable to type 'C | D'. !!! error TS2322: Type 'A' is not assignable to type 'D'. +!!! error TS2322: Property 'd' is missing in type 'A'. y = cnd; ~ !!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. @@ -145,12 +164,14 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e !!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'. !!! error TS2322: Type 'C' is not assignable to type 'A | B'. !!! error TS2322: Type 'C' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'C'. anb = y; ~~~ !!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. !!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'. !!! error TS2322: Type 'C | D' is not assignable to type 'A'. !!! error TS2322: Type 'C' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type 'C'. aob = y; // Ok cnd = y; ~~~ @@ -158,5 +179,6 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e !!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'. !!! error TS2322: Type 'C | D' is not assignable to type 'C'. !!! error TS2322: Type 'D' is not assignable to type 'C'. +!!! error TS2322: Property 'c' is missing in type 'D'. cod = y; // Ok \ No newline at end of file diff --git a/tests/baselines/reference/invalidBooleanAssignments.errors.txt b/tests/baselines/reference/invalidBooleanAssignments.errors.txt index 84ced22611..99d32aff9b 100644 --- a/tests/baselines/reference/invalidBooleanAssignments.errors.txt +++ b/tests/baselines/reference/invalidBooleanAssignments.errors.txt @@ -3,9 +3,7 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(4, tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(5,5): error TS2322: Type 'boolean' is not assignable to type 'void'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(9,5): error TS2322: Type 'boolean' is not assignable to type 'E'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(12,5): error TS2322: Type 'boolean' is not assignable to type 'C'. - Property 'foo' is missing in type 'Boolean'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15,5): error TS2322: Type 'boolean' is not assignable to type 'I'. - Property 'bar' is missing in type 'Boolean'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'boolean' is not assignable to type '() => string'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(24,5): error TS2322: Type 'boolean' is not assignable to type 'T'. @@ -35,13 +33,11 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26 var f: C = x; ~ !!! error TS2322: Type 'boolean' is not assignable to type 'C'. -!!! error TS2322: Property 'foo' is missing in type 'Boolean'. interface I { bar: string } var g: I = x; ~ !!! error TS2322: Type 'boolean' is not assignable to type 'I'. -!!! error TS2322: Property 'bar' is missing in type 'Boolean'. var h: { (): string } = x; ~ diff --git a/tests/baselines/reference/invalidNumberAssignments.errors.txt b/tests/baselines/reference/invalidNumberAssignments.errors.txt index 7eb5e6cb89..fd8acaba03 100644 --- a/tests/baselines/reference/invalidNumberAssignments.errors.txt +++ b/tests/baselines/reference/invalidNumberAssignments.errors.txt @@ -2,13 +2,9 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(3,5) tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(4,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(5,5): error TS2322: Type 'number' is not assignable to type 'void'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(9,5): error TS2322: Type 'number' is not assignable to type 'C'. - Property 'foo' is missing in type 'Number'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(12,5): error TS2322: Type 'number' is not assignable to type 'I'. - Property 'bar' is missing in type 'Number'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. - Property 'baz' is missing in type 'Number'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. - Property '0' is missing in type 'Number'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(21,5): error TS2322: Type 'number' is not assignable to type 'T'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -32,22 +28,18 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1 var e: C = x; ~ !!! error TS2322: Type 'number' is not assignable to type 'C'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. interface I { bar: string; } var f: I = x; ~ !!! error TS2322: Type 'number' is not assignable to type 'I'. -!!! error TS2322: Property 'bar' is missing in type 'Number'. var g: { baz: string } = 1; ~ !!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -!!! error TS2322: Property 'baz' is missing in type 'Number'. var g2: { 0: number } = 1; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. -!!! error TS2322: Property '0' is missing in type 'Number'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/invalidStringAssignments.errors.txt b/tests/baselines/reference/invalidStringAssignments.errors.txt index e67106bef9..d7ac2134dc 100644 --- a/tests/baselines/reference/invalidStringAssignments.errors.txt +++ b/tests/baselines/reference/invalidStringAssignments.errors.txt @@ -2,13 +2,9 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(3,5) tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(4,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(5,5): error TS2322: Type 'string' is not assignable to type 'void'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(9,5): error TS2322: Type 'string' is not assignable to type 'C'. - Property 'foo' is missing in type 'String'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(12,5): error TS2322: Type 'string' is not assignable to type 'I'. - Property 'bar' is missing in type 'String'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. - Property 'baz' is missing in type 'Number'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. - Property '0' is missing in type 'Number'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -33,22 +29,18 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5 var e: C = x; ~ !!! error TS2322: Type 'string' is not assignable to type 'C'. -!!! error TS2322: Property 'foo' is missing in type 'String'. interface I { bar: string; } var f: I = x; ~ !!! error TS2322: Type 'string' is not assignable to type 'I'. -!!! error TS2322: Property 'bar' is missing in type 'String'. var g: { baz: string } = 1; ~ !!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -!!! error TS2322: Property 'baz' is missing in type 'Number'. var g2: { 0: number } = 1; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. -!!! error TS2322: Property '0' is missing in type 'Number'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/invalidVoidAssignments.errors.txt b/tests/baselines/reference/invalidVoidAssignments.errors.txt index 9c6be972d3..af8cec6267 100644 --- a/tests/baselines/reference/invalidVoidAssignments.errors.txt +++ b/tests/baselines/reference/invalidVoidAssignments.errors.txt @@ -4,9 +4,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(5,5): er tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(9,5): error TS2322: Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(12,5): error TS2322: Type 'void' is not assignable to type 'I'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. - Property 'baz' is missing in type 'Number'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. - Property '0' is missing in type 'Number'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(21,5): error TS2322: Type 'void' is not assignable to type 'T'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -42,11 +40,9 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e var g: { baz: string } = 1; ~ !!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -!!! error TS2322: Property 'baz' is missing in type 'Number'. var g2: { 0: number } = 1; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. -!!! error TS2322: Property '0' is missing in type 'Number'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/jsFileCompilationTypeAliasSyntax.errors.txt b/tests/baselines/reference/jsFileCompilationTypeAliasSyntax.errors.txt index bc4d8e903a..2b5112e1ce 100644 --- a/tests/baselines/reference/jsFileCompilationTypeAliasSyntax.errors.txt +++ b/tests/baselines/reference/jsFileCompilationTypeAliasSyntax.errors.txt @@ -1,9 +1,9 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -tests/cases/compiler/a.js(1,1): error TS8008: 'type aliases' can only be used in a .ts file. +tests/cases/compiler/a.js(1,6): error TS8008: 'type aliases' 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) ==== type a = b; - ~~~~~~~~~~~ + ~ !!! error TS8008: 'type aliases' can only be used in a .ts file. \ No newline at end of file diff --git a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt index d503f59c60..ab784eae39 100644 --- a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt +++ b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'. Types of property 'thunk' are incompatible. Type '(num: number) => void' is not assignable to type '(str: string) => void'. + Types of parameters 'num' and 'str' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2300: Duplicate identifier 'thunk'. tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'. tests/cases/compiler/lastPropertyInLiteralWins.ts(13,5): error TS2300: Duplicate identifier 'thunk'. @@ -29,6 +31,8 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate !!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'. !!! error TS2345: Types of property 'thunk' are incompatible. !!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'. +!!! error TS2345: Types of parameters 'num' and 'str' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. test({ // Should be OK. Last 'thunk' is of correct type thunk: (num: number) => {}, diff --git a/tests/baselines/reference/maxConstraints.errors.txt b/tests/baselines/reference/maxConstraints.errors.txt index 03e7158f72..a7d07a5b5f 100644 --- a/tests/baselines/reference/maxConstraints.errors.txt +++ b/tests/baselines/reference/maxConstraints.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. - Property 'compareTo' is missing in type 'Number'. ==== tests/cases/compiler/maxConstraints.ts (1 errors) ==== @@ -12,5 +11,4 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'nu var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; var maxResult = max2(1, 2); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. -!!! error TS2345: Property 'compareTo' is missing in type 'Number'. \ No newline at end of file +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.errors.txt b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.errors.txt new file mode 100644 index 0000000000..8e1bc337b3 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/map1.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. + + +==== tests/cases/compiler/map1.ts (1 errors) ==== + + import { Observable } from "./observable" + + (Observable.prototype).map = function() { } + + declare module "./observable" { + interface I {x0} + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + +==== tests/cases/compiler/map2.ts (1 errors) ==== + import { Observable } from "./observable" + + (Observable.prototype).map = function() { } + + declare module "./observable" { + interface I {x1} + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + + +==== tests/cases/compiler/observable.ts (0 errors) ==== + export declare class Observable { + filter(pred: (e:T) => boolean): Observable; + } + +==== tests/cases/compiler/main.ts (0 errors) ==== + import { Observable } from "./observable" + import "./map1"; + import "./map2"; + + let x: Observable; + \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js new file mode 100644 index 0000000000..60ba221734 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js @@ -0,0 +1,75 @@ +//// [tests/cases/compiler/moduleAugmentationCollidingNamesInAugmentation1.ts] //// + +//// [map1.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface I {x0} +} + +//// [map2.ts] +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface I {x1} +} + + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +//// [main.ts] +import { Observable } from "./observable" +import "./map1"; +import "./map2"; + +let x: Observable; + + +//// [observable.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [map1.js] +define(["require", "exports", "./observable"], function (require, exports, observable_1) { + "use strict"; + observable_1.Observable.prototype.map = function () { }; +}); +//// [map2.js] +define(["require", "exports", "./observable"], function (require, exports, observable_1) { + "use strict"; + observable_1.Observable.prototype.map = function () { }; +}); +//// [main.js] +define(["require", "exports", "./map1", "./map2"], function (require, exports) { + "use strict"; + var x; +}); + + +//// [observable.d.ts] +export declare class Observable { + filter(pred: (e: T) => boolean): Observable; +} +//// [map1.d.ts] +declare module "./observable" { + interface I { + x0: any; + } +} +export {}; +//// [map2.d.ts] +declare module "./observable" { + interface I { + x1: any; + } +} +export {}; +//// [main.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js new file mode 100644 index 0000000000..589d0f506e --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/moduleAugmentationDeclarationEmit1.ts] //// + +//// [map.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + let someValue: number; +} + + +//// [main.ts] +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); + +//// [observable.js] +"use strict"; +var Observable; +(function (Observable) { + var someValue; +})(Observable = exports.Observable || (exports.Observable = {})); +//// [map.js] +"use strict"; +var observable_1 = require("./observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); + + +//// [observable.d.ts] +export declare class Observable { + filter(pred: (e: T) => boolean): Observable; +} +export declare namespace Observable { +} +//// [map.d.ts] +declare module "./observable" { + interface Observable { + map(proj: (e: T) => U): Observable; + } + namespace Observable { + let someAnotherValue: number; + } +} +export {}; +//// [main.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.symbols b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.symbols new file mode 100644 index 0000000000..eca44ec774 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "./observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someAnotherValue: number; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.ts, 0, 36)) +>pred : Symbol(pred, Decl(observable.ts, 1, 11)) +>e : Symbol(e, Decl(observable.ts, 1, 18)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +} + +export namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someValue: number; +>someValue : Symbol(someValue, Decl(observable.ts, 5, 7)) +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 3, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 4, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 3, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 4, 14)) +>x : Symbol(x, Decl(main.ts, 4, 14)) + diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types new file mode 100644 index 0000000000..fad835029c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "./observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: number; +>someAnotherValue : number + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T +} + +export namespace Observable { +>Observable : typeof Observable + + let someValue: number; +>someValue : number +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js new file mode 100644 index 0000000000..d8fd65a146 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js @@ -0,0 +1,73 @@ +//// [tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts] //// + +//// [map.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + export let someValue: number; +} + + +//// [main.ts] +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); + +//// [observable.js] +"use strict"; +var Observable; +(function (Observable) { +})(Observable = exports.Observable || (exports.Observable = {})); +//// [map.js] +"use strict"; +var observable_1 = require("./observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +var observable_1 = require("./observable"); +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); +var z1 = observable_1.Observable.someValue.toFixed(); +var z2 = observable_1.Observable.someAnotherValue.toLowerCase(); + + +//// [observable.d.ts] +export declare class Observable { + filter(pred: (e: T) => boolean): Observable; +} +export declare namespace Observable { + let someValue: number; +} +//// [map.d.ts] +declare module "./observable" { + interface Observable { + map(proj: (e: T) => U): Observable; + } + namespace Observable { + let someAnotherValue: string; + } +} +export {}; +//// [main.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.symbols b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.symbols new file mode 100644 index 0000000000..d0f25f693f --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.symbols @@ -0,0 +1,89 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "./observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someAnotherValue: string; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.ts, 0, 36)) +>pred : Symbol(pred, Decl(observable.ts, 1, 11)) +>e : Symbol(e, Decl(observable.ts, 1, 18)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +} + +export namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + export let someValue: number; +>someValue : Symbol(someValue, Decl(observable.ts, 5, 14)) +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 3, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 4, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 3, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 4, 14)) +>x : Symbol(x, Decl(main.ts, 4, 14)) + +let z1 = Observable.someValue.toFixed(); +>z1 : Symbol(z1, Decl(main.ts, 5, 3)) +>Observable.someValue.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>Observable.someValue : Symbol(Observable.someValue, Decl(observable.ts, 5, 14)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) +>someValue : Symbol(Observable.someValue, Decl(observable.ts, 5, 14)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : Symbol(z2, Decl(main.ts, 6, 3)) +>Observable.someAnotherValue.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>Observable.someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) +>someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types new file mode 100644 index 0000000000..85e4ead2ac --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types @@ -0,0 +1,101 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "./observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: string; +>someAnotherValue : string + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T +} + +export namespace Observable { +>Observable : typeof Observable + + export let someValue: number; +>someValue : number +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + +let z1 = Observable.someValue.toFixed(); +>z1 : string +>Observable.someValue.toFixed() : string +>Observable.someValue.toFixed : (fractionDigits?: number) => string +>Observable.someValue : number +>Observable : typeof Observable +>someValue : number +>toFixed : (fractionDigits?: number) => string + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : string +>Observable.someAnotherValue.toLowerCase() : string +>Observable.someAnotherValue.toLowerCase : () => string +>Observable.someAnotherValue : string +>Observable : typeof Observable +>someAnotherValue : string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt new file mode 100644 index 0000000000..571b288c04 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt @@ -0,0 +1,117 @@ +tests/cases/compiler/x.ts(7,9): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(8,9): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(9,11): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,10): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,14): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,23): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,38): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,43): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(10,48): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(11,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(12,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(15,11): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(16,14): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(17,10): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/x.ts(18,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/x.ts(18,26): error TS2307: Cannot find module './x0'. +tests/cases/compiler/x.ts(19,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/x.ts(19,21): error TS2307: Cannot find module './x0'. +tests/cases/compiler/x.ts(20,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/x.ts(20,19): error TS2307: Cannot find module './x0'. +tests/cases/compiler/x.ts(21,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/x.ts(21,21): error TS2307: Cannot find module './x0'. +tests/cases/compiler/x.ts(25,5): error TS2666: Exports and export assignments are not permitted in module augmentations. + + +==== tests/cases/compiler/x0.ts (0 errors) ==== + + export let a = 1; + +==== tests/cases/compiler/x.ts (23 errors) ==== + + namespace N1 { + export let x = 1; + } + + declare module "./observable" { + var x: number; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + let y: number; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + const z: number; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + let {x1, y1, z0: {n}, z1: {arr: [el1, el2, el3]}}: {x1: number, y1: string, z0: {n: number}, z1: {arr: number[]} } + ~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + interface A { x } + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + namespace N { + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + export class C {} + } + class Cls {} + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + function foo(): number; + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + type T = number; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + import * as all from "./x0"; + ~~~~~~ +!!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. + import {a} from "./x0"; + ~~~~~~ +!!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. + export * from "./x0"; + ~~~~~~ +!!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. + export {a} from "./x0"; + ~~~~~~ +!!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. + } + + declare module "./test" { + export = N1; + ~~~~~~ +!!! error TS2666: Exports and export assignments are not permitted in module augmentations. + } + export {} + +==== tests/cases/compiler/observable.ts (0 errors) ==== + export declare class Observable { + filter(pred: (e:T) => boolean): Observable; + } + export var x = 1; + +==== tests/cases/compiler/test.ts (0 errors) ==== + export let b = 1; + +==== tests/cases/compiler/main.ts (0 errors) ==== + import { Observable } from "./observable" + import "./x"; + \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js new file mode 100644 index 0000000000..8c497d63c4 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts] //// + +//// [x0.ts] + +export let a = 1; + +//// [x.ts] + +namespace N1 { + export let x = 1; +} + +declare module "./observable" { + var x: number; + let y: number; + const z: number; + let {x1, y1, z0: {n}, z1: {arr: [el1, el2, el3]}}: {x1: number, y1: string, z0: {n: number}, z1: {arr: number[]} } + interface A { x } + namespace N { + export class C {} + } + class Cls {} + function foo(): number; + type T = number; + import * as all from "./x0"; + import {a} from "./x0"; + export * from "./x0"; + export {a} from "./x0"; +} + +declare module "./test" { + export = N1; +} +export {} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} +export var x = 1; + +//// [test.ts] +export let b = 1; + +//// [main.ts] +import { Observable } from "./observable" +import "./x"; + + +//// [x0.js] +"use strict"; +exports.a = 1; +//// [x.js] +"use strict"; +var N1; +(function (N1) { + N1.x = 1; +})(N1 || (N1 = {})); +//// [observable.js] +"use strict"; +exports.x = 1; +//// [test.js] +"use strict"; +exports.b = 1; +//// [main.js] +"use strict"; +require("./x"); diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js new file mode 100644 index 0000000000..0a8b1b0b4b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts] //// + +//// [map.ts] + +import { Observable } from "observable" + +(Observable.prototype).map = function() { } + +declare module "observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +//// [observable.d.ts] +declare module "observable" { + class Observable { + filter(pred: (e:T) => boolean): Observable; + } + namespace Observable { + let someValue: number; + } +} + +//// [main.ts] + +/// +import { Observable } from "observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); + +//// [map.js] +"use strict"; +var observable_1 = require("observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.symbols b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.symbols new file mode 100644 index 0000000000..a471651da0 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.symbols @@ -0,0 +1,75 @@ +=== tests/cases/compiler/main.ts === + +/// +import { Observable } from "observable" +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 5, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 6, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 5, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 6, 14)) +>x : Symbol(x, Decl(main.ts, 6, 14)) + +=== tests/cases/compiler/map.ts === + +import { Observable } from "observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) + + let someAnotherValue: number; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.d.ts === +declare module "observable" { + class Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.d.ts, 1, 25)) +>pred : Symbol(pred, Decl(observable.d.ts, 2, 15)) +>e : Symbol(e, Decl(observable.d.ts, 2, 22)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) + + let someValue: number; +>someValue : Symbol(someValue, Decl(observable.d.ts, 5, 11)) + } +} + diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types new file mode 100644 index 0000000000..e6ee79e358 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types @@ -0,0 +1,85 @@ +=== tests/cases/compiler/main.ts === + +/// +import { Observable } from "observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + +=== tests/cases/compiler/map.ts === + +import { Observable } from "observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: number; +>someAnotherValue : number + } +} + +=== tests/cases/compiler/observable.d.ts === +declare module "observable" { + class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T + } + namespace Observable { +>Observable : typeof Observable + + let someValue: number; +>someValue : number + } +} + diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js new file mode 100644 index 0000000000..733f88e612 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/moduleAugmentationExtendAmbientModule2.ts] //// + +//// [map.ts] + +import { Observable } from "observable" + +(Observable.prototype).map = function() { } + +declare module "observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +//// [observable.d.ts] +declare module "observable" { + class Observable { + filter(pred: (e:T) => boolean): Observable; + } + namespace Observable { + export let someValue: number; + } +} + +//// [main.ts] + +/// +import { Observable } from "observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); + +//// [map.js] +"use strict"; +var observable_1 = require("observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +/// +var observable_1 = require("observable"); +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); +var z1 = observable_1.Observable.someValue.toFixed(); +var z2 = observable_1.Observable.someAnotherValue.toLowerCase(); + + +//// [map.d.ts] +declare module "observable" { + interface Observable { + map(proj: (e: T) => U): Observable; + } + namespace Observable { + let someAnotherValue: string; + } +} +export {}; +//// [main.d.ts] +/// diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.symbols b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.symbols new file mode 100644 index 0000000000..f907f4d697 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.symbols @@ -0,0 +1,91 @@ +=== tests/cases/compiler/main.ts === + +/// +import { Observable } from "observable" +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 5, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 6, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 5, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 6, 14)) +>x : Symbol(x, Decl(main.ts, 6, 14)) + +let z1 = Observable.someValue.toFixed(); +>z1 : Symbol(z1, Decl(main.ts, 7, 3)) +>Observable.someValue.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>Observable.someValue : Symbol(Observable.someValue, Decl(observable.d.ts, 5, 18)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) +>someValue : Symbol(Observable.someValue, Decl(observable.d.ts, 5, 18)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : Symbol(z2, Decl(main.ts, 8, 3)) +>Observable.someAnotherValue.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>Observable.someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) +>someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + +=== tests/cases/compiler/map.ts === + +import { Observable } from "observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) + + let someAnotherValue: string; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.d.ts === +declare module "observable" { + class Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.d.ts, 1, 25)) +>pred : Symbol(pred, Decl(observable.d.ts, 2, 15)) +>e : Symbol(e, Decl(observable.d.ts, 2, 22)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.d.ts, 1, 21), Decl(map.ts, 6, 25)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 29), Decl(observable.d.ts, 3, 5), Decl(map.ts, 5, 29), Decl(map.ts, 8, 5)) + + export let someValue: number; +>someValue : Symbol(someValue, Decl(observable.d.ts, 5, 18)) + } +} + diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types new file mode 100644 index 0000000000..70288e48f0 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types @@ -0,0 +1,103 @@ +=== tests/cases/compiler/main.ts === + +/// +import { Observable } from "observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + +let z1 = Observable.someValue.toFixed(); +>z1 : string +>Observable.someValue.toFixed() : string +>Observable.someValue.toFixed : (fractionDigits?: number) => string +>Observable.someValue : number +>Observable : typeof Observable +>someValue : number +>toFixed : (fractionDigits?: number) => string + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : string +>Observable.someAnotherValue.toLowerCase() : string +>Observable.someAnotherValue.toLowerCase : () => string +>Observable.someAnotherValue : string +>Observable : typeof Observable +>someAnotherValue : string +>toLowerCase : () => string + +=== tests/cases/compiler/map.ts === + +import { Observable } from "observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: string; +>someAnotherValue : string + } +} + +=== tests/cases/compiler/observable.d.ts === +declare module "observable" { + class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T + } + namespace Observable { +>Observable : typeof Observable + + export let someValue: number; +>someValue : number + } +} + diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.js b/tests/baselines/reference/moduleAugmentationExtendFileModule1.js new file mode 100644 index 0000000000..a539100c2e --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/moduleAugmentationExtendFileModule1.ts] //// + +//// [map.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + let someValue: number; +} + + +//// [main.ts] +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); + +//// [observable.js] +"use strict"; +var Observable; +(function (Observable) { + var someValue; +})(Observable = exports.Observable || (exports.Observable = {})); +//// [map.js] +"use strict"; +var observable_1 = require("./observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.symbols b/tests/baselines/reference/moduleAugmentationExtendFileModule1.symbols new file mode 100644 index 0000000000..eca44ec774 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "./observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someAnotherValue: number; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.ts, 0, 36)) +>pred : Symbol(pred, Decl(observable.ts, 1, 11)) +>e : Symbol(e, Decl(observable.ts, 1, 18)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +} + +export namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someValue: number; +>someValue : Symbol(someValue, Decl(observable.ts, 5, 7)) +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 3, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 4, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 3, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 4, 14)) +>x : Symbol(x, Decl(main.ts, 4, 14)) + diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.types b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types new file mode 100644 index 0000000000..fad835029c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "./observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: number; +>someAnotherValue : number + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T +} + +export namespace Observable { +>Observable : typeof Observable + + let someValue: number; +>someValue : number +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.js b/tests/baselines/reference/moduleAugmentationExtendFileModule2.js new file mode 100644 index 0000000000..389f2119ab --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.js @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/moduleAugmentationExtendFileModule2.ts] //// + +//// [map.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + export let someValue: number; +} + + +//// [main.ts] +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); + +//// [observable.js] +"use strict"; +var Observable; +(function (Observable) { +})(Observable = exports.Observable || (exports.Observable = {})); +//// [map.js] +"use strict"; +var observable_1 = require("./observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +var observable_1 = require("./observable"); +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); +var z1 = observable_1.Observable.someValue.toFixed(); +var z2 = observable_1.Observable.someAnotherValue.toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.symbols b/tests/baselines/reference/moduleAugmentationExtendFileModule2.symbols new file mode 100644 index 0000000000..d0f25f693f --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.symbols @@ -0,0 +1,89 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) + +(Observable.prototype).map = function() { } +>Observable.prototype : Symbol(Observable.prototype) +>Observable : Symbol(Observable, Decl(map.ts, 1, 8)) +>prototype : Symbol(Observable.prototype) + +declare module "./observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + map(proj: (e:T) => U): Observable +>map : Symbol(map, Decl(map.ts, 6, 29)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>proj : Symbol(proj, Decl(map.ts, 7, 15)) +>e : Symbol(e, Decl(map.ts, 7, 22)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>U : Symbol(U, Decl(map.ts, 7, 12)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>U : Symbol(U, Decl(map.ts, 7, 12)) + } + namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + let someAnotherValue: string; +>someAnotherValue : Symbol(someAnotherValue, Decl(map.ts, 10, 11)) + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) + + filter(pred: (e:T) => boolean): Observable; +>filter : Symbol(filter, Decl(observable.ts, 0, 36)) +>pred : Symbol(pred, Decl(observable.ts, 1, 11)) +>e : Symbol(e, Decl(observable.ts, 1, 18)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) +>T : Symbol(T, Decl(observable.ts, 0, 32), Decl(map.ts, 6, 25)) +} + +export namespace Observable { +>Observable : Symbol(Observable, Decl(observable.ts, 0, 0), Decl(observable.ts, 2, 1), Decl(map.ts, 5, 31), Decl(map.ts, 8, 5)) + + export let someValue: number; +>someValue : Symbol(someValue, Decl(observable.ts, 5, 14)) +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +import "./map"; + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 3, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) + +let y = x.map(x => x + 1); +>y : Symbol(y, Decl(main.ts, 4, 3)) +>x.map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 3, 3)) +>map : Symbol(Observable.map, Decl(map.ts, 6, 29)) +>x : Symbol(x, Decl(main.ts, 4, 14)) +>x : Symbol(x, Decl(main.ts, 4, 14)) + +let z1 = Observable.someValue.toFixed(); +>z1 : Symbol(z1, Decl(main.ts, 5, 3)) +>Observable.someValue.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>Observable.someValue : Symbol(Observable.someValue, Decl(observable.ts, 5, 14)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) +>someValue : Symbol(Observable.someValue, Decl(observable.ts, 5, 14)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : Symbol(z2, Decl(main.ts, 6, 3)) +>Observable.someAnotherValue.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>Observable.someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>Observable : Symbol(Observable, Decl(main.ts, 0, 8)) +>someAnotherValue : Symbol(Observable.someAnotherValue, Decl(map.ts, 10, 11)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.types b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types new file mode 100644 index 0000000000..85e4ead2ac --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types @@ -0,0 +1,101 @@ +=== tests/cases/compiler/map.ts === + +import { Observable } from "./observable" +>Observable : typeof Observable + +(Observable.prototype).map = function() { } +>(Observable.prototype).map = function() { } : () => void +>(Observable.prototype).map : any +>(Observable.prototype) : any +>Observable.prototype : any +>Observable.prototype : Observable +>Observable : typeof Observable +>prototype : Observable +>map : any +>function() { } : () => void + +declare module "./observable" { + interface Observable { +>Observable : Observable +>T : T + + map(proj: (e:T) => U): Observable +>map : (proj: (e: T) => U) => Observable +>U : U +>proj : (e: T) => U +>e : T +>T : T +>U : U +>Observable : Observable +>U : U + } + namespace Observable { +>Observable : typeof Observable + + let someAnotherValue: string; +>someAnotherValue : string + } +} + +=== tests/cases/compiler/observable.ts === +export declare class Observable { +>Observable : Observable +>T : T + + filter(pred: (e:T) => boolean): Observable; +>filter : (pred: (e: T) => boolean) => Observable +>pred : (e: T) => boolean +>e : T +>T : T +>Observable : Observable +>T : T +} + +export namespace Observable { +>Observable : typeof Observable + + export let someValue: number; +>someValue : number +} + + +=== tests/cases/compiler/main.ts === +import { Observable } from "./observable" +>Observable : typeof Observable + +import "./map"; + +let x: Observable; +>x : Observable +>Observable : Observable + +let y = x.map(x => x + 1); +>y : Observable +>x.map(x => x + 1) : Observable +>x.map : (proj: (e: number) => U) => Observable +>x : Observable +>map : (proj: (e: number) => U) => Observable +>x => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : number + +let z1 = Observable.someValue.toFixed(); +>z1 : string +>Observable.someValue.toFixed() : string +>Observable.someValue.toFixed : (fractionDigits?: number) => string +>Observable.someValue : number +>Observable : typeof Observable +>someValue : number +>toFixed : (fractionDigits?: number) => string + +let z2 = Observable.someAnotherValue.toLowerCase(); +>z2 : string +>Observable.someAnotherValue.toLowerCase() : string +>Observable.someAnotherValue.toLowerCase : () => string +>Observable.someAnotherValue : string +>Observable : typeof Observable +>someAnotherValue : string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.js b/tests/baselines/reference/moduleAugmentationGlobal1.js new file mode 100644 index 0000000000..99351642a1 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal1.js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/moduleAugmentationGlobal1.ts] //// + +//// [f1.ts] + +export class A {x: number;} + +//// [f2.ts] +import {A} from "./f1"; + +// change the shape of Array +declare global { + interface Array { + getA(): A; + } +} + +let x = [1]; +let y = x.getA().x; + + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var x = [1]; +var y = x.getA().x; + + +//// [f1.d.ts] +export declare class A { + x: number; +} +//// [f2.d.ts] +import { A } from "./f1"; +declare global { + interface Array { + getA(): A; + } +} diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.symbols b/tests/baselines/reference/moduleAugmentationGlobal1.symbols new file mode 100644 index 0000000000..36139555c9 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal1.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/f1.ts === + +export class A {x: number;} +>A : Symbol(A, Decl(f1.ts, 0, 0)) +>x : Symbol(x, Decl(f1.ts, 1, 16)) + +=== tests/cases/compiler/f2.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f2.ts, 0, 8)) + +// change the shape of Array +declare global { +>global : Symbol(, Decl(f2.ts, 0, 23)) + + interface Array { +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 3, 16)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(f2.ts, 4, 20)) + + getA(): A; +>getA : Symbol(getA, Decl(f2.ts, 4, 24)) +>A : Symbol(A, Decl(f2.ts, 0, 8)) + } +} + +let x = [1]; +>x : Symbol(x, Decl(f2.ts, 9, 3)) + +let y = x.getA().x; +>y : Symbol(y, Decl(f2.ts, 10, 3)) +>x.getA().x : Symbol(A.x, Decl(f1.ts, 1, 16)) +>x.getA : Symbol(Array.getA, Decl(f2.ts, 4, 24)) +>x : Symbol(x, Decl(f2.ts, 9, 3)) +>getA : Symbol(Array.getA, Decl(f2.ts, 4, 24)) +>x : Symbol(A.x, Decl(f1.ts, 1, 16)) + diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.types b/tests/baselines/reference/moduleAugmentationGlobal1.types new file mode 100644 index 0000000000..c1742edd7c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal1.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/f1.ts === + +export class A {x: number;} +>A : A +>x : number + +=== tests/cases/compiler/f2.ts === +import {A} from "./f1"; +>A : typeof A + +// change the shape of Array +declare global { +>global : typeof + + interface Array { +>Array : T[] +>T : T + + getA(): A; +>getA : () => A +>A : A + } +} + +let x = [1]; +>x : number[] +>[1] : number[] +>1 : number + +let y = x.getA().x; +>y : number +>x.getA().x : number +>x.getA() : A +>x.getA : () => A +>x : number[] +>getA : () => A +>x : number + diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.js b/tests/baselines/reference/moduleAugmentationGlobal2.js new file mode 100644 index 0000000000..90e8373302 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal2.js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/moduleAugmentationGlobal2.ts] //// + +//// [f1.ts] + +export class A {}; +//// [f2.ts] + +// change the shape of Array +import {A} from "./f1"; + +declare global { + interface Array { + getCountAsString(): string; + } +} + +let x = [1]; +let y = x.getCountAsString().toLowerCase(); + + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +; +//// [f2.js] +"use strict"; +var x = [1]; +var y = x.getCountAsString().toLowerCase(); + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +declare global { + interface Array { + getCountAsString(): string; + } +} +export {}; diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.symbols b/tests/baselines/reference/moduleAugmentationGlobal2.symbols new file mode 100644 index 0000000000..4ee2b9bace --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/f1.ts === + +export class A {}; +>A : Symbol(A, Decl(f1.ts, 0, 0)) + +=== tests/cases/compiler/f2.ts === + +// change the shape of Array +import {A} from "./f1"; +>A : Symbol(A, Decl(f2.ts, 2, 8)) + +declare global { +>global : Symbol(, Decl(f2.ts, 2, 23)) + + interface Array { +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 4, 16)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(f2.ts, 5, 20)) + + getCountAsString(): string; +>getCountAsString : Symbol(getCountAsString, Decl(f2.ts, 5, 24)) + } +} + +let x = [1]; +>x : Symbol(x, Decl(f2.ts, 10, 3)) + +let y = x.getCountAsString().toLowerCase(); +>y : Symbol(y, Decl(f2.ts, 11, 3)) +>x.getCountAsString().toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>x.getCountAsString : Symbol(Array.getCountAsString, Decl(f2.ts, 5, 24)) +>x : Symbol(x, Decl(f2.ts, 10, 3)) +>getCountAsString : Symbol(Array.getCountAsString, Decl(f2.ts, 5, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.types b/tests/baselines/reference/moduleAugmentationGlobal2.types new file mode 100644 index 0000000000..36ef480d8b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal2.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/f1.ts === + +export class A {}; +>A : A + +=== tests/cases/compiler/f2.ts === + +// change the shape of Array +import {A} from "./f1"; +>A : typeof A + +declare global { +>global : typeof + + interface Array { +>Array : T[] +>T : T + + getCountAsString(): string; +>getCountAsString : () => string + } +} + +let x = [1]; +>x : number[] +>[1] : number[] +>1 : number + +let y = x.getCountAsString().toLowerCase(); +>y : string +>x.getCountAsString().toLowerCase() : string +>x.getCountAsString().toLowerCase : () => string +>x.getCountAsString() : string +>x.getCountAsString : () => string +>x : number[] +>getCountAsString : () => string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.js b/tests/baselines/reference/moduleAugmentationGlobal3.js new file mode 100644 index 0000000000..4cff75f5df --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal3.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/moduleAugmentationGlobal3.ts] //// + +//// [f1.ts] + +export class A {}; +//// [f2.ts] + +// change the shape of Array +import {A} from "./f1"; + +declare global { + interface Array { + getCountAsString(): string; + } +} + +//// [f3.ts] +import "./f2"; + +let x = [1]; +let y = x.getCountAsString().toLowerCase(); + + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +; +//// [f2.js] +"use strict"; +//// [f3.js] +"use strict"; +require("./f2"); +var x = [1]; +var y = x.getCountAsString().toLowerCase(); + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +declare global { + interface Array { + getCountAsString(): string; + } +} +export {}; +//// [f3.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.symbols b/tests/baselines/reference/moduleAugmentationGlobal3.symbols new file mode 100644 index 0000000000..acb9a7b9e5 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal3.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/f1.ts === + +export class A {}; +>A : Symbol(A, Decl(f1.ts, 0, 0)) + +=== tests/cases/compiler/f2.ts === + +// change the shape of Array +import {A} from "./f1"; +>A : Symbol(A, Decl(f2.ts, 2, 8)) + +declare global { +>global : Symbol(, Decl(f2.ts, 2, 23)) + + interface Array { +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 4, 16)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(f2.ts, 5, 20)) + + getCountAsString(): string; +>getCountAsString : Symbol(getCountAsString, Decl(f2.ts, 5, 24)) + } +} + +=== tests/cases/compiler/f3.ts === +import "./f2"; + +let x = [1]; +>x : Symbol(x, Decl(f3.ts, 2, 3)) + +let y = x.getCountAsString().toLowerCase(); +>y : Symbol(y, Decl(f3.ts, 3, 3)) +>x.getCountAsString().toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>x.getCountAsString : Symbol(Array.getCountAsString, Decl(f2.ts, 5, 24)) +>x : Symbol(x, Decl(f3.ts, 2, 3)) +>getCountAsString : Symbol(Array.getCountAsString, Decl(f2.ts, 5, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.types b/tests/baselines/reference/moduleAugmentationGlobal3.types new file mode 100644 index 0000000000..58d7f30faa --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal3.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/f1.ts === + +export class A {}; +>A : A + +=== tests/cases/compiler/f2.ts === + +// change the shape of Array +import {A} from "./f1"; +>A : typeof A + +declare global { +>global : typeof + + interface Array { +>Array : T[] +>T : T + + getCountAsString(): string; +>getCountAsString : () => string + } +} + +=== tests/cases/compiler/f3.ts === +import "./f2"; + +let x = [1]; +>x : number[] +>[1] : number[] +>1 : number + +let y = x.getCountAsString().toLowerCase(); +>y : string +>x.getCountAsString().toLowerCase() : string +>x.getCountAsString().toLowerCase : () => string +>x.getCountAsString() : string +>x.getCountAsString : () => string +>x : number[] +>getCountAsString : () => string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal4.errors.txt new file mode 100644 index 0000000000..fd3444f56b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal4.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/f1.ts(3,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f2.ts(3,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. + + +==== tests/cases/compiler/f1.ts (1 errors) ==== + + declare global { + interface Something {x} + ~~~~~~~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + export {}; +==== tests/cases/compiler/f2.ts (1 errors) ==== + + declare global { + interface Something {y} + ~~~~~~~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + export {}; +==== tests/cases/compiler/f3.ts (0 errors) ==== + import "./f1"; + import "./f2"; + + \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.js b/tests/baselines/reference/moduleAugmentationGlobal4.js new file mode 100644 index 0000000000..11c5d968df --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal4.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/moduleAugmentationGlobal4.ts] //// + +//// [f1.ts] + +declare global { + interface Something {x} +} +export {}; +//// [f2.ts] + +declare global { + interface Something {y} +} +export {}; +//// [f3.ts] +import "./f1"; +import "./f2"; + + + +//// [f1.js] +"use strict"; +//// [f2.js] +"use strict"; +//// [f3.js] +"use strict"; +require("./f1"); +require("./f2"); + + +//// [f1.d.ts] +declare global { + interface Something { + x: any; + } +} +export { }; +export {}; +//// [f2.d.ts] +declare global { + interface Something { + y: any; + } +} +export { }; +export {}; +//// [f3.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal5.errors.txt new file mode 100644 index 0000000000..4f1f913376 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal5.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/f1.d.ts(4,19): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f2.d.ts(3,19): error TS2665: Module augmentation cannot introduce new names in the top level scope. + + +==== tests/cases/compiler/f3.ts (0 errors) ==== + /// + /// + import "A"; + import "B"; + + +==== tests/cases/compiler/f1.d.ts (1 errors) ==== + + declare module "A" { + global { + interface Something {x} + ~~~~~~~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + } +==== tests/cases/compiler/f2.d.ts (1 errors) ==== + declare module "B" { + global { + interface Something {y} + ~~~~~~~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.js b/tests/baselines/reference/moduleAugmentationGlobal5.js new file mode 100644 index 0000000000..3efdd2dbb9 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal5.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/moduleAugmentationGlobal5.ts] //// + +//// [f1.d.ts] + +declare module "A" { + global { + interface Something {x} + } +} +//// [f2.d.ts] +declare module "B" { + global { + interface Something {y} + } +} +//// [f3.ts] +/// +/// +import "A"; +import "B"; + + + +//// [f3.js] +"use strict"; +/// +/// +require("A"); +require("B"); + + +//// [f3.d.ts] +/// +/// diff --git a/tests/baselines/reference/moduleAugmentationGlobal6.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal6.errors.txt new file mode 100644 index 0000000000..849c45111a --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/moduleAugmentationGlobal6.ts(1,9): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + + +==== tests/cases/compiler/moduleAugmentationGlobal6.ts (1 errors) ==== + declare global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + interface Array { x } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal6.js b/tests/baselines/reference/moduleAugmentationGlobal6.js new file mode 100644 index 0000000000..ac988f670d --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal6.js @@ -0,0 +1,6 @@ +//// [moduleAugmentationGlobal6.ts] +declare global { + interface Array { x } +} + +//// [moduleAugmentationGlobal6.js] diff --git a/tests/baselines/reference/moduleAugmentationGlobal6_1.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal6_1.errors.txt new file mode 100644 index 0000000000..01315f9fcb --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal6_1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/moduleAugmentationGlobal6_1.ts(1,1): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. +tests/cases/compiler/moduleAugmentationGlobal6_1.ts(1,1): error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + + +==== tests/cases/compiler/moduleAugmentationGlobal6_1.ts (2 errors) ==== + global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + ~~~~~~ +!!! error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + interface Array { x } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal6_1.js b/tests/baselines/reference/moduleAugmentationGlobal6_1.js new file mode 100644 index 0000000000..5ae85debbe --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal6_1.js @@ -0,0 +1,6 @@ +//// [moduleAugmentationGlobal6_1.ts] +global { + interface Array { x } +} + +//// [moduleAugmentationGlobal6_1.js] diff --git a/tests/baselines/reference/moduleAugmentationGlobal7.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal7.errors.txt new file mode 100644 index 0000000000..3ba8003288 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal7.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/moduleAugmentationGlobal7.ts(2,13): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + + +==== tests/cases/compiler/moduleAugmentationGlobal7.ts (1 errors) ==== + namespace A { + declare global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + interface Array { x } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal7.js b/tests/baselines/reference/moduleAugmentationGlobal7.js new file mode 100644 index 0000000000..54c6ddc0de --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal7.js @@ -0,0 +1,8 @@ +//// [moduleAugmentationGlobal7.ts] +namespace A { + declare global { + interface Array { x } + } +} + +//// [moduleAugmentationGlobal7.js] diff --git a/tests/baselines/reference/moduleAugmentationGlobal7_1.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal7_1.errors.txt new file mode 100644 index 0000000000..c2e8282f2b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal7_1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/moduleAugmentationGlobal7_1.ts(2,5): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. +tests/cases/compiler/moduleAugmentationGlobal7_1.ts(2,5): error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + + +==== tests/cases/compiler/moduleAugmentationGlobal7_1.ts (2 errors) ==== + namespace A { + global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + ~~~~~~ +!!! error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + interface Array { x } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal7_1.js b/tests/baselines/reference/moduleAugmentationGlobal7_1.js new file mode 100644 index 0000000000..745be0d76a --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal7_1.js @@ -0,0 +1,8 @@ +//// [moduleAugmentationGlobal7_1.ts] +namespace A { + global { + interface Array { x } + } +} + +//// [moduleAugmentationGlobal7_1.js] diff --git a/tests/baselines/reference/moduleAugmentationGlobal8.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal8.errors.txt new file mode 100644 index 0000000000..09c84fea2c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal8.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/moduleAugmentationGlobal8.ts(2,13): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + + +==== tests/cases/compiler/moduleAugmentationGlobal8.ts (1 errors) ==== + namespace A { + declare global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + interface Array { x } + } + } + export {} + \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal8.js b/tests/baselines/reference/moduleAugmentationGlobal8.js new file mode 100644 index 0000000000..261dfd21b5 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal8.js @@ -0,0 +1,13 @@ +//// [moduleAugmentationGlobal8.ts] +namespace A { + declare global { + interface Array { x } + } +} +export {} + + +//// [moduleAugmentationGlobal8.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); diff --git a/tests/baselines/reference/moduleAugmentationGlobal8_1.errors.txt b/tests/baselines/reference/moduleAugmentationGlobal8_1.errors.txt new file mode 100644 index 0000000000..022a4f5ec1 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal8_1.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/moduleAugmentationGlobal8_1.ts(2,5): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. +tests/cases/compiler/moduleAugmentationGlobal8_1.ts(2,5): error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + + +==== tests/cases/compiler/moduleAugmentationGlobal8_1.ts (2 errors) ==== + namespace A { + global { + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + ~~~~~~ +!!! error TS2670: Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context. + interface Array { x } + } + } + export {} + \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationGlobal8_1.js b/tests/baselines/reference/moduleAugmentationGlobal8_1.js new file mode 100644 index 0000000000..2ac585a711 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationGlobal8_1.js @@ -0,0 +1,13 @@ +//// [moduleAugmentationGlobal8_1.ts] +namespace A { + global { + interface Array { x } + } +} +export {} + + +//// [moduleAugmentationGlobal8_1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js new file mode 100644 index 0000000000..7159e7b5d0 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js @@ -0,0 +1,71 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports1.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } +declare module "./f1" { + interface A { + foo(): B; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +export declare class B { + n: number; +} +//// [f3.d.ts] +import { B } from "./f2"; +declare module "./f1" { + interface A { + foo(): B; + } +} +//// [f4.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols new file mode 100644 index 0000000000..c641cad522 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols @@ -0,0 +1,56 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 4, 23)) + +=== tests/cases/compiler/f2.ts === +export class B { +>B : Symbol(B, Decl(f2.ts, 0, 0)) + + n: number; +>n : Symbol(n, Decl(f2.ts, 0, 16)) +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f3.ts, 0, 8)) + +import {B} from "./f2"; +>B : Symbol(B, Decl(f3.ts, 1, 8)) + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 5, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(f3.ts, 0, 8)) +>prototype : Symbol(A.prototype) +>foo : Symbol(A.foo, Decl(f3.ts, 5, 17)) +>undefined : Symbol(undefined) + +declare module "./f1" { + interface A { +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 4, 23)) + + foo(): B; +>foo : Symbol(foo, Decl(f3.ts, 5, 17)) +>B : Symbol(B, Decl(f3.ts, 1, 8)) + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +import "./f3"; + +let a: A; +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +let b = a.foo().n; +>b : Symbol(b, Decl(f4.ts, 4, 3)) +>a.foo().n : Symbol(B.n, Decl(f2.ts, 0, 16)) +>a.foo : Symbol(A.foo, Decl(f3.ts, 5, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>foo : Symbol(A.foo, Decl(f3.ts, 5, 17)) +>n : Symbol(B.n, Decl(f2.ts, 0, 16)) + diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types new file mode 100644 index 0000000000..886a04b54e --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types @@ -0,0 +1,59 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/f2.ts === +export class B { +>B : B + + n: number; +>n : number +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : typeof A + +import {B} from "./f2"; +>B : typeof B + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo : () => B +>A.prototype : A +>A : typeof A +>prototype : A +>foo : () => B +>function () { return undefined; } : () => any +>undefined : undefined + +declare module "./f1" { + interface A { +>A : A + + foo(): B; +>foo : () => B +>B : B + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : typeof A + +import "./f3"; + +let a: A; +>a : A +>A : A + +let b = a.foo().n; +>b : number +>a.foo().n : number +>a.foo() : B +>a.foo : () => B +>a : A +>foo : () => B +>n : number + diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt new file mode 100644 index 0000000000..deb3881e20 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt @@ -0,0 +1,73 @@ +tests/cases/compiler/f3.ts(3,13): error TS2339: Property 'foo' does not exist on type 'A'. +tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. +tests/cases/compiler/f3.ts(12,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/f3.ts(12,21): error TS2307: Cannot find module './f2'. +tests/cases/compiler/f3.ts(13,12): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'I' is using private name 'N'. +tests/cases/compiler/f3.ts(14,12): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f3.ts(14,16): error TS4000: Import declaration 'C' is using private name 'N'. +tests/cases/compiler/f3.ts(16,15): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on type 'A'. + + +==== tests/cases/compiler/f1.ts (0 errors) ==== + + export class A {} + +==== tests/cases/compiler/f2.ts (0 errors) ==== + export class B { + n: number; + } + +==== tests/cases/compiler/f3.ts (10 errors) ==== + import {A} from "./f1"; + + A.prototype.foo = function () { return undefined; } + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'A'. + + namespace N { + export interface Ifc { a } + export interface Cls { a } + } + + declare module "./f1" { + import {B} from "./f2"; + ~~~~~~ +!!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. + export {B} from "./f2"; + ~~~~~~ +!!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. + import I = N.Ifc; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS4000: Import declaration 'I' is using private name 'N'. + import C = N.Cls; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS4000: Import declaration 'C' is using private name 'N'. + // should have explicit export + interface A { + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + foo(): B; + bar(): I; + baz(): C; + } + } + +==== tests/cases/compiler/f4.ts (1 errors) ==== + import {A} from "./f1"; + import "./f3"; + + let a: A; + let b = a.foo().n; + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js new file mode 100644 index 0000000000..3a4a807a33 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports2.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a } + export interface Cls { a } +} + +declare module "./f1" { + import {B} from "./f2"; + export {B} from "./f2"; + import I = N.Ifc; + import C = N.Cls; + // should have explicit export + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +export declare class B { + n: number; +} +//// [f4.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt new file mode 100644 index 0000000000..a7c8fa2cff --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt @@ -0,0 +1,56 @@ +tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. +tests/cases/compiler/f3.ts(12,12): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f3.ts(12,16): error TS4000: Import declaration 'I' is using private name 'N'. +tests/cases/compiler/f3.ts(13,12): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using private name 'N'. + + +==== tests/cases/compiler/f1.ts (0 errors) ==== + + export class A {} + +==== tests/cases/compiler/f2.ts (0 errors) ==== + export class B { + n: number; + } + +==== tests/cases/compiler/f3.ts (6 errors) ==== + import {A} from "./f1"; + + A.prototype.foo = function () { return undefined; } + + namespace N { + export interface Ifc { a } + export interface Cls { a } + } + + declare module "./f1" { + import {B} from "./f2"; + ~~~~~~ +!!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. + import I = N.Ifc; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS4000: Import declaration 'I' is using private name 'N'. + import C = N.Cls; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS4000: Import declaration 'C' is using private name 'N'. + interface A { + foo(): B; + bar(): I; + baz(): C; + } + } + +==== tests/cases/compiler/f4.ts (0 errors) ==== + import {A} from "./f1"; + import "./f3"; + + let a: A; + let b = a.foo().n; \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js new file mode 100644 index 0000000000..d872a79e98 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -0,0 +1,74 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports3.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a } + export interface Cls { a } +} + +declare module "./f1" { + import {B} from "./f2"; + import I = N.Ifc; + import C = N.Cls; + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +export declare class B { + n: number; +} +//// [f4.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.js b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js new file mode 100644 index 0000000000..5309555581 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports4.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; +var c = a.bar().a; +var d = a.baz().b; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols new file mode 100644 index 0000000000..94dc05519d --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols @@ -0,0 +1,101 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 12, 23)) + +=== tests/cases/compiler/f2.ts === +export class B { +>B : Symbol(B, Decl(f2.ts, 0, 0)) + + n: number; +>n : Symbol(n, Decl(f2.ts, 0, 16)) +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f3.ts, 0, 8)) + +import {B} from "./f2"; +>B : Symbol(B, Decl(f3.ts, 1, 8)) + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(f3.ts, 0, 8)) +>prototype : Symbol(A.prototype) +>foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>undefined : Symbol(undefined) + +namespace N { +>N : Symbol(N, Decl(f3.ts, 3, 51)) + + export interface Ifc { a: number; } +>Ifc : Symbol(Ifc, Decl(f3.ts, 5, 13)) +>a : Symbol(a, Decl(f3.ts, 6, 26)) + + export interface Cls { b: number; } +>Cls : Symbol(Cls, Decl(f3.ts, 6, 39)) +>b : Symbol(b, Decl(f3.ts, 7, 26)) +} +import I = N.Ifc; +>I : Symbol(I, Decl(f3.ts, 8, 1)) +>N : Symbol(N, Decl(f3.ts, 3, 51)) +>Ifc : Symbol(I, Decl(f3.ts, 5, 13)) + +import C = N.Cls; +>C : Symbol(C, Decl(f3.ts, 9, 17)) +>N : Symbol(N, Decl(f3.ts, 3, 51)) +>Cls : Symbol(C, Decl(f3.ts, 6, 39)) + +declare module "./f1" { + interface A { +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 12, 23)) + + foo(): B; +>foo : Symbol(foo, Decl(f3.ts, 13, 17)) +>B : Symbol(B, Decl(f3.ts, 1, 8)) + + bar(): I; +>bar : Symbol(bar, Decl(f3.ts, 14, 17)) +>I : Symbol(I, Decl(f3.ts, 8, 1)) + + baz(): C; +>baz : Symbol(baz, Decl(f3.ts, 15, 17)) +>C : Symbol(C, Decl(f3.ts, 9, 17)) + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +import "./f3"; + +let a: A; +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +let b = a.foo().n; +>b : Symbol(b, Decl(f4.ts, 4, 3)) +>a.foo().n : Symbol(B.n, Decl(f2.ts, 0, 16)) +>a.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>n : Symbol(B.n, Decl(f2.ts, 0, 16)) + +let c = a.bar().a; +>c : Symbol(c, Decl(f4.ts, 5, 3)) +>a.bar().a : Symbol(N.Ifc.a, Decl(f3.ts, 6, 26)) +>a.bar : Symbol(A.bar, Decl(f3.ts, 14, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>bar : Symbol(A.bar, Decl(f3.ts, 14, 17)) +>a : Symbol(N.Ifc.a, Decl(f3.ts, 6, 26)) + +let d = a.baz().b; +>d : Symbol(d, Decl(f4.ts, 6, 3)) +>a.baz().b : Symbol(N.Cls.b, Decl(f3.ts, 7, 26)) +>a.baz : Symbol(A.baz, Decl(f3.ts, 15, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>baz : Symbol(A.baz, Decl(f3.ts, 15, 17)) +>b : Symbol(N.Cls.b, Decl(f3.ts, 7, 26)) + diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types new file mode 100644 index 0000000000..454dc5d27e --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types @@ -0,0 +1,106 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/f2.ts === +export class B { +>B : B + + n: number; +>n : number +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : typeof A + +import {B} from "./f2"; +>B : typeof B + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo : () => B +>A.prototype : A +>A : typeof A +>prototype : A +>foo : () => B +>function () { return undefined; } : () => any +>undefined : undefined + +namespace N { +>N : any + + export interface Ifc { a: number; } +>Ifc : Ifc +>a : number + + export interface Cls { b: number; } +>Cls : Cls +>b : number +} +import I = N.Ifc; +>I : any +>N : any +>Ifc : I + +import C = N.Cls; +>C : any +>N : any +>Cls : C + +declare module "./f1" { + interface A { +>A : A + + foo(): B; +>foo : () => B +>B : B + + bar(): I; +>bar : () => I +>I : I + + baz(): C; +>baz : () => C +>C : C + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : typeof A + +import "./f3"; + +let a: A; +>a : A +>A : A + +let b = a.foo().n; +>b : number +>a.foo().n : number +>a.foo() : B +>a.foo : () => B +>a : A +>foo : () => B +>n : number + +let c = a.bar().a; +>c : number +>a.bar().a : number +>a.bar() : N.Ifc +>a.bar : () => N.Ifc +>a : A +>bar : () => N.Ifc +>a : number + +let d = a.baz().b; +>d : number +>a.baz().b : number +>a.baz() : N.Cls +>a.baz : () => N.Cls +>a : A +>baz : () => N.Cls +>b : number + diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt new file mode 100644 index 0000000000..5f78345388 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/f3.ts(10,12): error TS4000: Import declaration 'I' is using private name 'N'. +tests/cases/compiler/f3.ts(11,12): error TS4000: Import declaration 'C' is using private name 'N'. + + +==== tests/cases/compiler/f1.ts (0 errors) ==== + + export class A {} + +==== tests/cases/compiler/f2.ts (0 errors) ==== + export class B { + n: number; + } + +==== tests/cases/compiler/f3.ts (2 errors) ==== + import {A} from "./f1"; + import {B} from "./f2"; + + A.prototype.foo = function () { return undefined; } + + namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } + } + import I = N.Ifc; + ~ +!!! error TS4000: Import declaration 'I' is using private name 'N'. + import C = N.Cls; + ~ +!!! error TS4000: Import declaration 'C' is using private name 'N'. + + declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } + } + +==== tests/cases/compiler/f4.ts (0 errors) ==== + import {A} from "./f1"; + import "./f3"; + + let a: A; + let b = a.foo().n; + let c = a.bar().a; + let d = a.baz().b; \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js new file mode 100644 index 0000000000..c9b622ccf2 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports5.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; +var c = a.bar().a; +var d = a.baz().b; + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +export declare class B { + n: number; +} +//// [f4.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js new file mode 100644 index 0000000000..f0b297720b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js @@ -0,0 +1,97 @@ +//// [tests/cases/compiler/moduleAugmentationImportsAndExports6.ts] //// + +//// [f1.ts] + +export class A {} + +//// [f2.ts] +export class B { + n: number; +} + +//// [f3.ts] +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +export namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +//// [f4.ts] +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; + +//// [f1.js] +"use strict"; +var A = (function () { + function A() { + } + return A; +}()); +exports.A = A; +//// [f2.js] +"use strict"; +var B = (function () { + function B() { + } + return B; +}()); +exports.B = B; +//// [f3.js] +"use strict"; +var f1_1 = require("./f1"); +f1_1.A.prototype.foo = function () { return undefined; }; +//// [f4.js] +"use strict"; +require("./f3"); +var a; +var b = a.foo().n; +var c = a.bar().a; +var d = a.baz().b; + + +//// [f1.d.ts] +export declare class A { +} +//// [f2.d.ts] +export declare class B { + n: number; +} +//// [f3.d.ts] +import { B } from "./f2"; +export declare namespace N { + interface Ifc { + a: number; + } + interface Cls { + b: number; + } +} +import I = N.Ifc; +import C = N.Cls; +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} +//// [f4.d.ts] diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols new file mode 100644 index 0000000000..92952ef94b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols @@ -0,0 +1,101 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 12, 23)) + +=== tests/cases/compiler/f2.ts === +export class B { +>B : Symbol(B, Decl(f2.ts, 0, 0)) + + n: number; +>n : Symbol(n, Decl(f2.ts, 0, 16)) +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f3.ts, 0, 8)) + +import {B} from "./f2"; +>B : Symbol(B, Decl(f3.ts, 1, 8)) + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(f3.ts, 0, 8)) +>prototype : Symbol(A.prototype) +>foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>undefined : Symbol(undefined) + +export namespace N { +>N : Symbol(N, Decl(f3.ts, 3, 51)) + + export interface Ifc { a: number; } +>Ifc : Symbol(Ifc, Decl(f3.ts, 5, 20)) +>a : Symbol(a, Decl(f3.ts, 6, 26)) + + export interface Cls { b: number; } +>Cls : Symbol(Cls, Decl(f3.ts, 6, 39)) +>b : Symbol(b, Decl(f3.ts, 7, 26)) +} +import I = N.Ifc; +>I : Symbol(I, Decl(f3.ts, 8, 1)) +>N : Symbol(N, Decl(f3.ts, 3, 51)) +>Ifc : Symbol(I, Decl(f3.ts, 5, 20)) + +import C = N.Cls; +>C : Symbol(C, Decl(f3.ts, 9, 17)) +>N : Symbol(N, Decl(f3.ts, 3, 51)) +>Cls : Symbol(C, Decl(f3.ts, 6, 39)) + +declare module "./f1" { + interface A { +>A : Symbol(A, Decl(f1.ts, 0, 0), Decl(f3.ts, 12, 23)) + + foo(): B; +>foo : Symbol(foo, Decl(f3.ts, 13, 17)) +>B : Symbol(B, Decl(f3.ts, 1, 8)) + + bar(): I; +>bar : Symbol(bar, Decl(f3.ts, 14, 17)) +>I : Symbol(I, Decl(f3.ts, 8, 1)) + + baz(): C; +>baz : Symbol(baz, Decl(f3.ts, 15, 17)) +>C : Symbol(C, Decl(f3.ts, 9, 17)) + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +import "./f3"; + +let a: A; +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>A : Symbol(A, Decl(f4.ts, 0, 8)) + +let b = a.foo().n; +>b : Symbol(b, Decl(f4.ts, 4, 3)) +>a.foo().n : Symbol(B.n, Decl(f2.ts, 0, 16)) +>a.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>n : Symbol(B.n, Decl(f2.ts, 0, 16)) + +let c = a.bar().a; +>c : Symbol(c, Decl(f4.ts, 5, 3)) +>a.bar().a : Symbol(N.Ifc.a, Decl(f3.ts, 6, 26)) +>a.bar : Symbol(A.bar, Decl(f3.ts, 14, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>bar : Symbol(A.bar, Decl(f3.ts, 14, 17)) +>a : Symbol(N.Ifc.a, Decl(f3.ts, 6, 26)) + +let d = a.baz().b; +>d : Symbol(d, Decl(f4.ts, 6, 3)) +>a.baz().b : Symbol(N.Cls.b, Decl(f3.ts, 7, 26)) +>a.baz : Symbol(A.baz, Decl(f3.ts, 15, 17)) +>a : Symbol(a, Decl(f4.ts, 3, 3)) +>baz : Symbol(A.baz, Decl(f3.ts, 15, 17)) +>b : Symbol(N.Cls.b, Decl(f3.ts, 7, 26)) + diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types new file mode 100644 index 0000000000..0c201599b5 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types @@ -0,0 +1,106 @@ +=== tests/cases/compiler/f1.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/f2.ts === +export class B { +>B : B + + n: number; +>n : number +} + +=== tests/cases/compiler/f3.ts === +import {A} from "./f1"; +>A : typeof A + +import {B} from "./f2"; +>B : typeof B + +A.prototype.foo = function () { return undefined; } +>A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo : () => B +>A.prototype : A +>A : typeof A +>prototype : A +>foo : () => B +>function () { return undefined; } : () => any +>undefined : undefined + +export namespace N { +>N : any + + export interface Ifc { a: number; } +>Ifc : Ifc +>a : number + + export interface Cls { b: number; } +>Cls : Cls +>b : number +} +import I = N.Ifc; +>I : any +>N : any +>Ifc : I + +import C = N.Cls; +>C : any +>N : any +>Cls : C + +declare module "./f1" { + interface A { +>A : A + + foo(): B; +>foo : () => B +>B : B + + bar(): I; +>bar : () => I +>I : I + + baz(): C; +>baz : () => C +>C : C + } +} + +=== tests/cases/compiler/f4.ts === +import {A} from "./f1"; +>A : typeof A + +import "./f3"; + +let a: A; +>a : A +>A : A + +let b = a.foo().n; +>b : number +>a.foo().n : number +>a.foo() : B +>a.foo : () => B +>a : A +>foo : () => B +>n : number + +let c = a.bar().a; +>c : number +>a.bar().a : number +>a.bar() : N.Ifc +>a.bar : () => N.Ifc +>a : A +>bar : () => N.Ifc +>a : number + +let d = a.baz().b; +>d : number +>a.baz().b : number +>a.baz() : N.Cls +>a.baz : () => N.Cls +>a : A +>baz : () => N.Cls +>b : number + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule1.js b/tests/baselines/reference/moduleAugmentationInAmbientModule1.js new file mode 100644 index 0000000000..aecb8954d5 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule1.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/moduleAugmentationInAmbientModule1.ts] //// + +//// [O.d.ts] + + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +//// [main.ts] +/// + +import {Observable} from "Observable"; +let x: Observable; +x.foo().x; + + +//// [main.js] +/// +"use strict"; +var x; +x.foo().x; + + +//// [main.d.ts] +/// diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule1.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule1.symbols new file mode 100644 index 0000000000..b59f0766ee --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule1.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +let x: Observable; +>x : Symbol(x, Decl(main.ts, 3, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +x.foo().x; +>x.foo().x : Symbol(Cls.x, Decl(O.d.ts, 7, 15)) +>x.foo : Symbol(Observable.foo, Decl(O.d.ts, 13, 30)) +>x : Symbol(x, Decl(main.ts, 3, 3)) +>foo : Symbol(Observable.foo, Decl(O.d.ts, 13, 30)) +>x : Symbol(Cls.x, Decl(O.d.ts, 7, 15)) + +=== tests/cases/compiler/O.d.ts === + + +declare module "Observable" { + class Observable {} +>Observable : Symbol(Observable, Decl(O.d.ts, 2, 29), Decl(O.d.ts, 12, 25)) +} + +declare module "M" { + class Cls { x: number } +>Cls : Symbol(Cls, Decl(O.d.ts, 6, 20)) +>x : Symbol(x, Decl(O.d.ts, 7, 15)) +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : Symbol(Cls, Decl(O.d.ts, 11, 12)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 2, 29), Decl(O.d.ts, 12, 25)) + + foo(): Cls; +>foo : Symbol(foo, Decl(O.d.ts, 13, 30)) +>Cls : Symbol(Cls, Decl(O.d.ts, 11, 12)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule1.types b/tests/baselines/reference/moduleAugmentationInAmbientModule1.types new file mode 100644 index 0000000000..0be2a787cb --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule1.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : typeof Observable + +let x: Observable; +>x : Observable +>Observable : Observable + +x.foo().x; +>x.foo().x : number +>x.foo() : Cls +>x.foo : () => Cls +>x : Observable +>foo : () => Cls +>x : number + +=== tests/cases/compiler/O.d.ts === + + +declare module "Observable" { + class Observable {} +>Observable : Observable +} + +declare module "M" { + class Cls { x: number } +>Cls : Cls +>x : number +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : typeof Cls + + module "Observable" { + interface Observable { +>Observable : Observable + + foo(): Cls; +>foo : () => Cls +>Cls : Cls + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule2.js b/tests/baselines/reference/moduleAugmentationInAmbientModule2.js new file mode 100644 index 0000000000..5529afc674 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule2.js @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/moduleAugmentationInAmbientModule2.ts] //// + +//// [O.d.ts] + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +//// [main.ts] +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; + + +//// [main.js] +/// +"use strict"; +require("Map"); +var x; +x.foo().x; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule2.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule2.symbols new file mode 100644 index 0000000000..6308e67b3b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule2.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +import "Map"; +let x: Observable; +>x : Symbol(x, Decl(main.ts, 4, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +x.foo().x; +>x.foo().x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) +>x.foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(x, Decl(main.ts, 4, 3)) +>foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25)) +} + +declare module "M" { + class Cls { x: number } +>Cls : Symbol(Cls, Decl(O.d.ts, 5, 20)) +>x : Symbol(x, Decl(O.d.ts, 6, 15)) +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25)) + + foo(): Cls; +>foo : Symbol(foo, Decl(O.d.ts, 12, 30)) +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule2.types b/tests/baselines/reference/moduleAugmentationInAmbientModule2.types new file mode 100644 index 0000000000..31ea8904c2 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule2.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : typeof Observable + +import "Map"; +let x: Observable; +>x : Observable +>Observable : Observable + +x.foo().x; +>x.foo().x : number +>x.foo() : Cls +>x.foo : () => Cls +>x : Observable +>foo : () => Cls +>x : number + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Observable +} + +declare module "M" { + class Cls { x: number } +>Cls : Cls +>x : number +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : typeof Cls + + module "Observable" { + interface Observable { +>Observable : Observable + + foo(): Cls; +>foo : () => Cls +>Cls : Cls + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule3.js b/tests/baselines/reference/moduleAugmentationInAmbientModule3.js new file mode 100644 index 0000000000..3a94c50ef1 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule3.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/moduleAugmentationInAmbientModule3.ts] //// + +//// [O.d.ts] + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +declare module "Map" { + class Cls2 { x2: number } + module "Observable" { + interface Observable { + foo2(): Cls2; + } + } +} + +//// [main.ts] +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; +x.foo2().x2; + + +//// [main.js] +/// +"use strict"; +require("Map"); +var x; +x.foo().x; +x.foo2().x2; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule3.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule3.symbols new file mode 100644 index 0000000000..34eea56753 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule3.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +import "Map"; +let x: Observable; +>x : Symbol(x, Decl(main.ts, 4, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 2, 8)) + +x.foo().x; +>x.foo().x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) +>x.foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(x, Decl(main.ts, 4, 3)) +>foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) + +x.foo2().x2; +>x.foo2().x2 : Symbol(Cls2.x2, Decl(O.d.ts, 19, 16)) +>x.foo2 : Symbol(Observable.foo2, Decl(O.d.ts, 21, 30)) +>x : Symbol(x, Decl(main.ts, 4, 3)) +>foo2 : Symbol(Observable.foo2, Decl(O.d.ts, 21, 30)) +>x2 : Symbol(Cls2.x2, Decl(O.d.ts, 19, 16)) + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O.d.ts, 20, 25)) +} + +declare module "M" { + class Cls { x: number } +>Cls : Symbol(Cls, Decl(O.d.ts, 5, 20)) +>x : Symbol(x, Decl(O.d.ts, 6, 15)) +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O.d.ts, 20, 25)) + + foo(): Cls; +>foo : Symbol(foo, Decl(O.d.ts, 12, 30)) +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + } + } +} + +declare module "Map" { + class Cls2 { x2: number } +>Cls2 : Symbol(Cls2, Decl(O.d.ts, 18, 22)) +>x2 : Symbol(x2, Decl(O.d.ts, 19, 16)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O.d.ts, 20, 25)) + + foo2(): Cls2; +>foo2 : Symbol(foo2, Decl(O.d.ts, 21, 30)) +>Cls2 : Symbol(Cls2, Decl(O.d.ts, 18, 22)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule3.types b/tests/baselines/reference/moduleAugmentationInAmbientModule3.types new file mode 100644 index 0000000000..2cec5edc6b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule3.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/main.ts === +/// + +import {Observable} from "Observable"; +>Observable : typeof Observable + +import "Map"; +let x: Observable; +>x : Observable +>Observable : Observable + +x.foo().x; +>x.foo().x : number +>x.foo() : Cls +>x.foo : () => Cls +>x : Observable +>foo : () => Cls +>x : number + +x.foo2().x2; +>x.foo2().x2 : number +>x.foo2() : Cls2 +>x.foo2 : () => Cls2 +>x : Observable +>foo2 : () => Cls2 +>x2 : number + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Observable +} + +declare module "M" { + class Cls { x: number } +>Cls : Cls +>x : number +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : typeof Cls + + module "Observable" { + interface Observable { +>Observable : Observable + + foo(): Cls; +>foo : () => Cls +>Cls : Cls + } + } +} + +declare module "Map" { + class Cls2 { x2: number } +>Cls2 : Cls2 +>x2 : number + + module "Observable" { + interface Observable { +>Observable : Observable + + foo2(): Cls2; +>foo2 : () => Cls2 +>Cls2 : Cls2 + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule4.js b/tests/baselines/reference/moduleAugmentationInAmbientModule4.js new file mode 100644 index 0000000000..bf0339d310 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule4.js @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/moduleAugmentationInAmbientModule4.ts] //// + +//// [O.d.ts] + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +//// [O2.d.ts] +declare module "Map" { + class Cls2 { x2: number } + module "Observable" { + interface Observable { + foo2(): Cls2; + } + } +} + +//// [main.ts] +/// +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; +x.foo2().x2; + + +//// [main.js] +/// +/// +"use strict"; +require("Map"); +var x; +x.foo().x; +x.foo2().x2; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule4.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule4.symbols new file mode 100644 index 0000000000..55658c2a52 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule4.symbols @@ -0,0 +1,71 @@ +=== tests/cases/compiler/main.ts === +/// +/// + +import {Observable} from "Observable"; +>Observable : Symbol(Observable, Decl(main.ts, 3, 8)) + +import "Map"; +let x: Observable; +>x : Symbol(x, Decl(main.ts, 5, 3)) +>Observable : Symbol(Observable, Decl(main.ts, 3, 8)) + +x.foo().x; +>x.foo().x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) +>x.foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(x, Decl(main.ts, 5, 3)) +>foo : Symbol(Observable.foo, Decl(O.d.ts, 12, 30)) +>x : Symbol(Cls.x, Decl(O.d.ts, 6, 15)) + +x.foo2().x2; +>x.foo2().x2 : Symbol(Cls2.x2, Decl(O2.d.ts, 1, 16)) +>x.foo2 : Symbol(Observable.foo2, Decl(O2.d.ts, 3, 30)) +>x : Symbol(x, Decl(main.ts, 5, 3)) +>foo2 : Symbol(Observable.foo2, Decl(O2.d.ts, 3, 30)) +>x2 : Symbol(Cls2.x2, Decl(O2.d.ts, 1, 16)) + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O2.d.ts, 2, 25)) +} + +declare module "M" { + class Cls { x: number } +>Cls : Symbol(Cls, Decl(O.d.ts, 5, 20)) +>x : Symbol(x, Decl(O.d.ts, 6, 15)) +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O2.d.ts, 2, 25)) + + foo(): Cls; +>foo : Symbol(foo, Decl(O.d.ts, 12, 30)) +>Cls : Symbol(Cls, Decl(O.d.ts, 10, 12)) + } + } +} + +=== tests/cases/compiler/O2.d.ts === +declare module "Map" { + class Cls2 { x2: number } +>Cls2 : Symbol(Cls2, Decl(O2.d.ts, 0, 22)) +>x2 : Symbol(x2, Decl(O2.d.ts, 1, 16)) + + module "Observable" { + interface Observable { +>Observable : Symbol(Observable, Decl(O.d.ts, 1, 29), Decl(O.d.ts, 11, 25), Decl(O2.d.ts, 2, 25)) + + foo2(): Cls2; +>foo2 : Symbol(foo2, Decl(O2.d.ts, 3, 30)) +>Cls2 : Symbol(Cls2, Decl(O2.d.ts, 0, 22)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule4.types b/tests/baselines/reference/moduleAugmentationInAmbientModule4.types new file mode 100644 index 0000000000..04791aef86 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule4.types @@ -0,0 +1,73 @@ +=== tests/cases/compiler/main.ts === +/// +/// + +import {Observable} from "Observable"; +>Observable : typeof Observable + +import "Map"; +let x: Observable; +>x : Observable +>Observable : Observable + +x.foo().x; +>x.foo().x : number +>x.foo() : Cls +>x.foo : () => Cls +>x : Observable +>foo : () => Cls +>x : number + +x.foo2().x2; +>x.foo2().x2 : number +>x.foo2() : Cls2 +>x.foo2 : () => Cls2 +>x : Observable +>foo2 : () => Cls2 +>x2 : number + +=== tests/cases/compiler/O.d.ts === + +declare module "Observable" { + class Observable {} +>Observable : Observable +} + +declare module "M" { + class Cls { x: number } +>Cls : Cls +>x : number +} + +declare module "Map" { + import { Cls } from "M"; +>Cls : typeof Cls + + module "Observable" { + interface Observable { +>Observable : Observable + + foo(): Cls; +>foo : () => Cls +>Cls : Cls + } + } +} + +=== tests/cases/compiler/O2.d.ts === +declare module "Map" { + class Cls2 { x2: number } +>Cls2 : Cls2 +>x2 : number + + module "Observable" { + interface Observable { +>Observable : Observable + + foo2(): Cls2; +>foo2 : () => Cls2 +>Cls2 : Cls2 + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js new file mode 100644 index 0000000000..fab9cebb17 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/moduleAugmentationInAmbientModule5.ts] //// + +//// [array.d.ts] + +declare module "A" { + class A { x: number; } +} + +declare module "array" { + import {A} from "A"; + global { + interface Array { + getA(): A; + } + } +} + +//// [f.ts] +/// +import "array"; + +let x = [1]; +let y = x.getA().x; + + +//// [f.js] +"use strict"; +/// +require("array"); +var x = [1]; +var y = x.getA().x; + + +//// [f.d.ts] +/// diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols new file mode 100644 index 0000000000..a663efca64 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/f.ts === +/// +import "array"; + +let x = [1]; +>x : Symbol(x, Decl(f.ts, 3, 3)) + +let y = x.getA().x; +>y : Symbol(y, Decl(f.ts, 4, 3)) +>x.getA().x : Symbol(A.x, Decl(array.d.ts, 2, 13)) +>x.getA : Symbol(Array.getA, Decl(array.d.ts, 8, 28)) +>x : Symbol(x, Decl(f.ts, 3, 3)) +>getA : Symbol(Array.getA, Decl(array.d.ts, 8, 28)) +>x : Symbol(A.x, Decl(array.d.ts, 2, 13)) + +=== tests/cases/compiler/array.d.ts === + +declare module "A" { + class A { x: number; } +>A : Symbol(A, Decl(array.d.ts, 1, 20)) +>x : Symbol(x, Decl(array.d.ts, 2, 13)) +} + +declare module "array" { + import {A} from "A"; +>A : Symbol(A, Decl(array.d.ts, 6, 12)) + + global { +>global : Symbol(, Decl(array.d.ts, 6, 24)) + + interface Array { +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(array.d.ts, 7, 12)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(array.d.ts, 8, 24)) + + getA(): A; +>getA : Symbol(getA, Decl(array.d.ts, 8, 28)) +>A : Symbol(A, Decl(array.d.ts, 6, 12)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.types b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types new file mode 100644 index 0000000000..d04cdca489 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/f.ts === +/// +import "array"; + +let x = [1]; +>x : number[] +>[1] : number[] +>1 : number + +let y = x.getA().x; +>y : number +>x.getA().x : number +>x.getA() : A +>x.getA : () => A +>x : number[] +>getA : () => A +>x : number + +=== tests/cases/compiler/array.d.ts === + +declare module "A" { + class A { x: number; } +>A : A +>x : number +} + +declare module "array" { + import {A} from "A"; +>A : typeof A + + global { +>global : typeof + + interface Array { +>Array : T[] +>T : T + + getA(): A; +>getA : () => A +>A : A + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationNoNewNames.errors.txt b/tests/baselines/reference/moduleAugmentationNoNewNames.errors.txt new file mode 100644 index 0000000000..7c7f17cd64 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationNoNewNames.errors.txt @@ -0,0 +1,47 @@ +tests/cases/compiler/map.ts(10,11): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map.ts(11,9): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map.ts(11,20): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map.ts(12,13): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map.ts(12,19): error TS2665: Module augmentation cannot introduce new names in the top level scope. +tests/cases/compiler/map.ts(13,12): error TS2665: Module augmentation cannot introduce new names in the top level scope. + + +==== tests/cases/compiler/map.ts (6 errors) ==== + + import { Observable } from "./observable" + + (Observable.prototype).map = function() { } + + declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + class Bar {} + ~~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + let y: number, z: string; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + let {a: x, b: x1}: {a: number, b: number}; + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + ~~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + module Z {} + ~ +!!! error TS2665: Module augmentation cannot introduce new names in the top level scope. + } + +==== tests/cases/compiler/observable.ts (0 errors) ==== + export declare class Observable { + filter(pred: (e:T) => boolean): Observable; + } + +==== tests/cases/compiler/main.ts (0 errors) ==== + import { Observable } from "./observable" + import "./map"; + + let x: Observable; + let y = x.map(x => x + 1); \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationNoNewNames.js b/tests/baselines/reference/moduleAugmentationNoNewNames.js new file mode 100644 index 0000000000..ccd4a66849 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationNoNewNames.js @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/moduleAugmentationNoNewNames.ts] //// + +//// [map.ts] + +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + class Bar {} + let y: number, z: string; + let {a: x, b: x1}: {a: number, b: number}; + module Z {} +} + +//// [observable.ts] +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +//// [main.ts] +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); + +//// [observable.js] +"use strict"; +//// [map.js] +"use strict"; +var observable_1 = require("./observable"); +observable_1.Observable.prototype.map = function () { }; +//// [main.js] +"use strict"; +require("./map"); +var x; +var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js new file mode 100644 index 0000000000..92916206e7 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js @@ -0,0 +1,142 @@ +//// [tests/cases/compiler/moduleAugmentationsBundledOutput1.ts] //// + +//// [m1.ts] + +export class Cls { +} + +//// [m2.ts] +import {Cls} from "./m1"; +(Cls.prototype).foo = function() { return 1; }; +(Cls.prototype).bar = function() { return "1"; }; + +declare module "./m1" { + interface Cls { + foo(): number; + } +} + +declare module "./m1" { + interface Cls { + bar(): string; + } +} + +//// [m3.ts] +export class C1 { x: number } +export class C2 { x: string } + +//// [m4.ts] +import {Cls} from "./m1"; +import {C1, C2} from "./m3"; +(Cls.prototype).baz1 = function() { return undefined }; +(Cls.prototype).baz2 = function() { return undefined }; + +declare module "./m1" { + interface Cls { + baz1(): C1; + } +} + +declare module "./m1" { + interface Cls { + baz2(): C2; + } +} + +//// [test.ts] +import { Cls } from "./m1"; +import "m2"; +import "m4"; +let c: Cls; +c.foo().toExponential(); +c.bar().toLowerCase(); +c.baz1().x.toExponential(); +c.baz2().x.toLowerCase(); + + +//// [out.js] +define("m1", ["require", "exports"], function (require, exports) { + "use strict"; + var Cls = (function () { + function Cls() { + } + return Cls; + }()); + exports.Cls = Cls; +}); +define("m2", ["require", "exports", "m1"], function (require, exports, m1_1) { + "use strict"; + m1_1.Cls.prototype.foo = function () { return 1; }; + m1_1.Cls.prototype.bar = function () { return "1"; }; +}); +define("m3", ["require", "exports"], function (require, exports) { + "use strict"; + var C1 = (function () { + function C1() { + } + return C1; + }()); + exports.C1 = C1; + var C2 = (function () { + function C2() { + } + return C2; + }()); + exports.C2 = C2; +}); +define("m4", ["require", "exports", "m1"], function (require, exports, m1_2) { + "use strict"; + m1_2.Cls.prototype.baz1 = function () { return undefined; }; + m1_2.Cls.prototype.baz2 = function () { return undefined; }; +}); +define("test", ["require", "exports", "m2", "m4"], function (require, exports) { + "use strict"; + var c; + c.foo().toExponential(); + c.bar().toLowerCase(); + c.baz1().x.toExponential(); + c.baz2().x.toLowerCase(); +}); + + +//// [out.d.ts] +declare module "m1" { + export class Cls { + } +} +declare module "m2" { + module "m1" { + interface Cls { + foo(): number; + } + } + module "m1" { + interface Cls { + bar(): string; + } + } +} +declare module "m3" { + export class C1 { + x: number; + } + export class C2 { + x: string; + } +} +declare module "m4" { + import { C1, C2 } from "m3"; + module "m1" { + interface Cls { + baz1(): C1; + } + } + module "m1" { + interface Cls { + baz2(): C2; + } + } +} +declare module "test" { +} diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.symbols b/tests/baselines/reference/moduleAugmentationsBundledOutput1.symbols new file mode 100644 index 0000000000..47160cbc17 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.symbols @@ -0,0 +1,129 @@ +=== tests/cases/compiler/m1.ts === + +export class Cls { +>Cls : Symbol(Cls, Decl(m1.ts, 0, 0), Decl(m2.ts, 4, 23), Decl(m2.ts, 10, 23), Decl(m4.ts, 5, 23), Decl(m4.ts, 11, 23)) +} + +=== tests/cases/compiler/m2.ts === +import {Cls} from "./m1"; +>Cls : Symbol(Cls, Decl(m2.ts, 0, 8)) + +(Cls.prototype).foo = function() { return 1; }; +>Cls.prototype : Symbol(Cls.prototype) +>Cls : Symbol(Cls, Decl(m2.ts, 0, 8)) +>prototype : Symbol(Cls.prototype) + +(Cls.prototype).bar = function() { return "1"; }; +>Cls.prototype : Symbol(Cls.prototype) +>Cls : Symbol(Cls, Decl(m2.ts, 0, 8)) +>prototype : Symbol(Cls.prototype) + +declare module "./m1" { + interface Cls { +>Cls : Symbol(Cls, Decl(m1.ts, 0, 0), Decl(m2.ts, 4, 23), Decl(m2.ts, 10, 23), Decl(m4.ts, 5, 23), Decl(m4.ts, 11, 23)) + + foo(): number; +>foo : Symbol(foo, Decl(m2.ts, 5, 19)) + } +} + +declare module "./m1" { + interface Cls { +>Cls : Symbol(Cls, Decl(m1.ts, 0, 0), Decl(m2.ts, 4, 23), Decl(m2.ts, 10, 23), Decl(m4.ts, 5, 23), Decl(m4.ts, 11, 23)) + + bar(): string; +>bar : Symbol(bar, Decl(m2.ts, 11, 19)) + } +} + +=== tests/cases/compiler/m3.ts === +export class C1 { x: number } +>C1 : Symbol(C1, Decl(m3.ts, 0, 0)) +>x : Symbol(x, Decl(m3.ts, 0, 17)) + +export class C2 { x: string } +>C2 : Symbol(C2, Decl(m3.ts, 0, 29)) +>x : Symbol(x, Decl(m3.ts, 1, 17)) + +=== tests/cases/compiler/m4.ts === +import {Cls} from "./m1"; +>Cls : Symbol(Cls, Decl(m4.ts, 0, 8)) + +import {C1, C2} from "./m3"; +>C1 : Symbol(C1, Decl(m4.ts, 1, 8)) +>C2 : Symbol(C2, Decl(m4.ts, 1, 11)) + +(Cls.prototype).baz1 = function() { return undefined }; +>Cls.prototype : Symbol(Cls.prototype) +>Cls : Symbol(Cls, Decl(m4.ts, 0, 8)) +>prototype : Symbol(Cls.prototype) +>undefined : Symbol(undefined) + +(Cls.prototype).baz2 = function() { return undefined }; +>Cls.prototype : Symbol(Cls.prototype) +>Cls : Symbol(Cls, Decl(m4.ts, 0, 8)) +>prototype : Symbol(Cls.prototype) +>undefined : Symbol(undefined) + +declare module "./m1" { + interface Cls { +>Cls : Symbol(Cls, Decl(m1.ts, 0, 0), Decl(m2.ts, 4, 23), Decl(m2.ts, 10, 23), Decl(m4.ts, 5, 23), Decl(m4.ts, 11, 23)) + + baz1(): C1; +>baz1 : Symbol(baz1, Decl(m4.ts, 6, 19)) +>C1 : Symbol(C1, Decl(m4.ts, 1, 8)) + } +} + +declare module "./m1" { + interface Cls { +>Cls : Symbol(Cls, Decl(m1.ts, 0, 0), Decl(m2.ts, 4, 23), Decl(m2.ts, 10, 23), Decl(m4.ts, 5, 23), Decl(m4.ts, 11, 23)) + + baz2(): C2; +>baz2 : Symbol(baz2, Decl(m4.ts, 12, 19)) +>C2 : Symbol(C2, Decl(m4.ts, 1, 11)) + } +} + +=== tests/cases/compiler/test.ts === +import { Cls } from "./m1"; +>Cls : Symbol(Cls, Decl(test.ts, 0, 8)) + +import "m2"; +import "m4"; +let c: Cls; +>c : Symbol(c, Decl(test.ts, 3, 3)) +>Cls : Symbol(Cls, Decl(test.ts, 0, 8)) + +c.foo().toExponential(); +>c.foo().toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) +>c.foo : Symbol(Cls.foo, Decl(m2.ts, 5, 19)) +>c : Symbol(c, Decl(test.ts, 3, 3)) +>foo : Symbol(Cls.foo, Decl(m2.ts, 5, 19)) +>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) + +c.bar().toLowerCase(); +>c.bar().toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>c.bar : Symbol(Cls.bar, Decl(m2.ts, 11, 19)) +>c : Symbol(c, Decl(test.ts, 3, 3)) +>bar : Symbol(Cls.bar, Decl(m2.ts, 11, 19)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + +c.baz1().x.toExponential(); +>c.baz1().x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) +>c.baz1().x : Symbol(C1.x, Decl(m3.ts, 0, 17)) +>c.baz1 : Symbol(Cls.baz1, Decl(m4.ts, 6, 19)) +>c : Symbol(c, Decl(test.ts, 3, 3)) +>baz1 : Symbol(Cls.baz1, Decl(m4.ts, 6, 19)) +>x : Symbol(C1.x, Decl(m3.ts, 0, 17)) +>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) + +c.baz2().x.toLowerCase(); +>c.baz2().x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>c.baz2().x : Symbol(C2.x, Decl(m3.ts, 1, 17)) +>c.baz2 : Symbol(Cls.baz2, Decl(m4.ts, 12, 19)) +>c : Symbol(c, Decl(test.ts, 3, 3)) +>baz2 : Symbol(Cls.baz2, Decl(m4.ts, 12, 19)) +>x : Symbol(C2.x, Decl(m3.ts, 1, 17)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.types b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types new file mode 100644 index 0000000000..80e9127905 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types @@ -0,0 +1,163 @@ +=== tests/cases/compiler/m1.ts === + +export class Cls { +>Cls : Cls +} + +=== tests/cases/compiler/m2.ts === +import {Cls} from "./m1"; +>Cls : typeof Cls + +(Cls.prototype).foo = function() { return 1; }; +>(Cls.prototype).foo = function() { return 1; } : () => number +>(Cls.prototype).foo : any +>(Cls.prototype) : any +>Cls.prototype : any +>Cls.prototype : Cls +>Cls : typeof Cls +>prototype : Cls +>foo : any +>function() { return 1; } : () => number +>1 : number + +(Cls.prototype).bar = function() { return "1"; }; +>(Cls.prototype).bar = function() { return "1"; } : () => string +>(Cls.prototype).bar : any +>(Cls.prototype) : any +>Cls.prototype : any +>Cls.prototype : Cls +>Cls : typeof Cls +>prototype : Cls +>bar : any +>function() { return "1"; } : () => string +>"1" : string + +declare module "./m1" { + interface Cls { +>Cls : Cls + + foo(): number; +>foo : () => number + } +} + +declare module "./m1" { + interface Cls { +>Cls : Cls + + bar(): string; +>bar : () => string + } +} + +=== tests/cases/compiler/m3.ts === +export class C1 { x: number } +>C1 : C1 +>x : number + +export class C2 { x: string } +>C2 : C2 +>x : string + +=== tests/cases/compiler/m4.ts === +import {Cls} from "./m1"; +>Cls : typeof Cls + +import {C1, C2} from "./m3"; +>C1 : typeof C1 +>C2 : typeof C2 + +(Cls.prototype).baz1 = function() { return undefined }; +>(Cls.prototype).baz1 = function() { return undefined } : () => any +>(Cls.prototype).baz1 : any +>(Cls.prototype) : any +>Cls.prototype : any +>Cls.prototype : Cls +>Cls : typeof Cls +>prototype : Cls +>baz1 : any +>function() { return undefined } : () => any +>undefined : undefined + +(Cls.prototype).baz2 = function() { return undefined }; +>(Cls.prototype).baz2 = function() { return undefined } : () => any +>(Cls.prototype).baz2 : any +>(Cls.prototype) : any +>Cls.prototype : any +>Cls.prototype : Cls +>Cls : typeof Cls +>prototype : Cls +>baz2 : any +>function() { return undefined } : () => any +>undefined : undefined + +declare module "./m1" { + interface Cls { +>Cls : Cls + + baz1(): C1; +>baz1 : () => C1 +>C1 : C1 + } +} + +declare module "./m1" { + interface Cls { +>Cls : Cls + + baz2(): C2; +>baz2 : () => C2 +>C2 : C2 + } +} + +=== tests/cases/compiler/test.ts === +import { Cls } from "./m1"; +>Cls : typeof Cls + +import "m2"; +import "m4"; +let c: Cls; +>c : Cls +>Cls : Cls + +c.foo().toExponential(); +>c.foo().toExponential() : string +>c.foo().toExponential : (fractionDigits?: number) => string +>c.foo() : number +>c.foo : () => number +>c : Cls +>foo : () => number +>toExponential : (fractionDigits?: number) => string + +c.bar().toLowerCase(); +>c.bar().toLowerCase() : string +>c.bar().toLowerCase : () => string +>c.bar() : string +>c.bar : () => string +>c : Cls +>bar : () => string +>toLowerCase : () => string + +c.baz1().x.toExponential(); +>c.baz1().x.toExponential() : string +>c.baz1().x.toExponential : (fractionDigits?: number) => string +>c.baz1().x : number +>c.baz1() : C1 +>c.baz1 : () => C1 +>c : Cls +>baz1 : () => C1 +>x : number +>toExponential : (fractionDigits?: number) => string + +c.baz2().x.toLowerCase(); +>c.baz2().x.toLowerCase() : string +>c.baz2().x.toLowerCase : () => string +>c.baz2().x : string +>c.baz2() : C2 +>c.baz2 : () => C2 +>c : Cls +>baz2 : () => C2 +>x : string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationsImports1.js b/tests/baselines/reference/moduleAugmentationsImports1.js new file mode 100644 index 0000000000..2c635a0719 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports1.js @@ -0,0 +1,104 @@ +//// [tests/cases/compiler/moduleAugmentationsImports1.ts] //// + +//// [a.ts] + +export class A {} + +//// [b.ts] +export class B {x: number;} + +//// [c.d.ts] +declare module "C" { + class Cls {y: string; } +} + +//// [d.ts] +/// + +import {A} from "./a"; +import {B} from "./b"; +import {Cls} from "C"; + +A.prototype.getB = function () { return undefined; } +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getB(): B; + } +} + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +//// [main.ts] +import {A} from "./a"; +import "d"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); + +//// [f.js] +define("a", ["require", "exports"], function (require, exports) { + "use strict"; + var A = (function () { + function A() { + } + return A; + }()); + exports.A = A; +}); +define("b", ["require", "exports"], function (require, exports) { + "use strict"; + var B = (function () { + function B() { + } + return B; + }()); + exports.B = B; +}); +/// +define("d", ["require", "exports", "a"], function (require, exports, a_1) { + "use strict"; + a_1.A.prototype.getB = function () { return undefined; }; + a_1.A.prototype.getCls = function () { return undefined; }; +}); +define("main", ["require", "exports", "d"], function (require, exports) { + "use strict"; + var a; + var b = a.getB().x.toFixed(); + var c = a.getCls().y.toLowerCase(); +}); + + +//// [f.d.ts] +/// +declare module "a" { + export class A { + } +} +declare module "b" { + export class B { + x: number; + } +} +declare module "d" { + import { B } from "b"; + import { Cls } from "C"; + module "a" { + interface A { + getB(): B; + } + } + module "a" { + interface A { + getCls(): Cls; + } + } +} +declare module "main" { +} diff --git a/tests/baselines/reference/moduleAugmentationsImports1.symbols b/tests/baselines/reference/moduleAugmentationsImports1.symbols new file mode 100644 index 0000000000..38ef8f5522 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports1.symbols @@ -0,0 +1,95 @@ +=== tests/cases/compiler/a.ts === + +export class A {} +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 9, 22), Decl(d.ts, 15, 22)) + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : Symbol(B, Decl(b.ts, 0, 0)) +>x : Symbol(x, Decl(b.ts, 0, 16)) + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Symbol(Cls, Decl(c.d.ts, 0, 20)) +>y : Symbol(y, Decl(c.d.ts, 1, 15)) +} + +=== tests/cases/compiler/d.ts === +/// + +import {A} from "./a"; +>A : Symbol(A, Decl(d.ts, 2, 8)) + +import {B} from "./b"; +>B : Symbol(B, Decl(d.ts, 3, 8)) + +import {Cls} from "C"; +>Cls : Symbol(Cls, Decl(d.ts, 4, 8)) + +A.prototype.getB = function () { return undefined; } +>A.prototype.getB : Symbol(A.getB, Decl(d.ts, 10, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(d.ts, 2, 8)) +>prototype : Symbol(A.prototype) +>getB : Symbol(A.getB, Decl(d.ts, 10, 17)) +>undefined : Symbol(undefined) + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls : Symbol(A.getCls, Decl(d.ts, 16, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(d.ts, 2, 8)) +>prototype : Symbol(A.prototype) +>getCls : Symbol(A.getCls, Decl(d.ts, 16, 17)) +>undefined : Symbol(undefined) + +declare module "./a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 9, 22), Decl(d.ts, 15, 22)) + + getB(): B; +>getB : Symbol(getB, Decl(d.ts, 10, 17)) +>B : Symbol(B, Decl(d.ts, 3, 8)) + } +} + +declare module "./a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 9, 22), Decl(d.ts, 15, 22)) + + getCls(): Cls; +>getCls : Symbol(getCls, Decl(d.ts, 16, 17)) +>Cls : Symbol(Cls, Decl(d.ts, 4, 8)) + } +} + +=== tests/cases/compiler/main.ts === +import {A} from "./a"; +>A : Symbol(A, Decl(main.ts, 0, 8)) + +import "d"; + +let a: A; +>a : Symbol(a, Decl(main.ts, 3, 3)) +>A : Symbol(A, Decl(main.ts, 0, 8)) + +let b = a.getB().x.toFixed(); +>b : Symbol(b, Decl(main.ts, 4, 3)) +>a.getB().x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>a.getB().x : Symbol(B.x, Decl(b.ts, 0, 16)) +>a.getB : Symbol(A.getB, Decl(d.ts, 10, 17)) +>a : Symbol(a, Decl(main.ts, 3, 3)) +>getB : Symbol(A.getB, Decl(d.ts, 10, 17)) +>x : Symbol(B.x, Decl(b.ts, 0, 16)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let c = a.getCls().y.toLowerCase(); +>c : Symbol(c, Decl(main.ts, 5, 3)) +>a.getCls().y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>a.getCls().y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>a.getCls : Symbol(A.getCls, Decl(d.ts, 16, 17)) +>a : Symbol(a, Decl(main.ts, 3, 3)) +>getCls : Symbol(A.getCls, Decl(d.ts, 16, 17)) +>y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationsImports1.types b/tests/baselines/reference/moduleAugmentationsImports1.types new file mode 100644 index 0000000000..bf0bfee0a7 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports1.types @@ -0,0 +1,103 @@ +=== tests/cases/compiler/a.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : B +>x : number + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Cls +>y : string +} + +=== tests/cases/compiler/d.ts === +/// + +import {A} from "./a"; +>A : typeof A + +import {B} from "./b"; +>B : typeof B + +import {Cls} from "C"; +>Cls : typeof Cls + +A.prototype.getB = function () { return undefined; } +>A.prototype.getB = function () { return undefined; } : () => any +>A.prototype.getB : () => B +>A.prototype : A +>A : typeof A +>prototype : A +>getB : () => B +>function () { return undefined; } : () => any +>undefined : undefined + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls : () => Cls +>A.prototype : A +>A : typeof A +>prototype : A +>getCls : () => Cls +>function () { return undefined; } : () => any +>undefined : undefined + +declare module "./a" { + interface A { +>A : A + + getB(): B; +>getB : () => B +>B : B + } +} + +declare module "./a" { + interface A { +>A : A + + getCls(): Cls; +>getCls : () => Cls +>Cls : Cls + } +} + +=== tests/cases/compiler/main.ts === +import {A} from "./a"; +>A : typeof A + +import "d"; + +let a: A; +>a : A +>A : A + +let b = a.getB().x.toFixed(); +>b : string +>a.getB().x.toFixed() : string +>a.getB().x.toFixed : (fractionDigits?: number) => string +>a.getB().x : number +>a.getB() : B +>a.getB : () => B +>a : A +>getB : () => B +>x : number +>toFixed : (fractionDigits?: number) => string + +let c = a.getCls().y.toLowerCase(); +>c : string +>a.getCls().y.toLowerCase() : string +>a.getCls().y.toLowerCase : () => string +>a.getCls().y : string +>a.getCls() : Cls +>a.getCls : () => Cls +>a : A +>getCls : () => Cls +>y : string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationsImports2.js b/tests/baselines/reference/moduleAugmentationsImports2.js new file mode 100644 index 0000000000..f70426b49b --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports2.js @@ -0,0 +1,114 @@ +//// [tests/cases/compiler/moduleAugmentationsImports2.ts] //// + +//// [a.ts] + +export class A {} + +//// [b.ts] +export class B {x: number;} + +//// [c.d.ts] +declare module "C" { + class Cls {y: string; } +} + +//// [d.ts] +/// + +import {A} from "./a"; +import {B} from "./b"; + +A.prototype.getB = function () { return undefined; } + +declare module "./a" { + interface A { + getB(): B; + } +} + +//// [e.ts] +import {A} from "./a"; +import {Cls} from "C"; + +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +//// [main.ts] +import {A} from "./a"; +import "d"; +import "e"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); + +//// [f.js] +define("a", ["require", "exports"], function (require, exports) { + "use strict"; + var A = (function () { + function A() { + } + return A; + }()); + exports.A = A; +}); +define("b", ["require", "exports"], function (require, exports) { + "use strict"; + var B = (function () { + function B() { + } + return B; + }()); + exports.B = B; +}); +/// +define("d", ["require", "exports", "a"], function (require, exports, a_1) { + "use strict"; + a_1.A.prototype.getB = function () { return undefined; }; +}); +define("e", ["require", "exports", "a"], function (require, exports, a_2) { + "use strict"; + a_2.A.prototype.getCls = function () { return undefined; }; +}); +define("main", ["require", "exports", "d", "e"], function (require, exports) { + "use strict"; + var a; + var b = a.getB().x.toFixed(); + var c = a.getCls().y.toLowerCase(); +}); + + +//// [f.d.ts] +/// +declare module "a" { + export class A { + } +} +declare module "b" { + export class B { + x: number; + } +} +declare module "d" { + import { B } from "b"; + module "a" { + interface A { + getB(): B; + } + } +} +declare module "e" { + import { Cls } from "C"; + module "a" { + interface A { + getCls(): Cls; + } + } +} +declare module "main" { +} diff --git a/tests/baselines/reference/moduleAugmentationsImports2.symbols b/tests/baselines/reference/moduleAugmentationsImports2.symbols new file mode 100644 index 0000000000..643ccf20eb --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports2.symbols @@ -0,0 +1,100 @@ +=== tests/cases/compiler/a.ts === + +export class A {} +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 7, 22), Decl(e.ts, 5, 22)) + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : Symbol(B, Decl(b.ts, 0, 0)) +>x : Symbol(x, Decl(b.ts, 0, 16)) + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Symbol(Cls, Decl(c.d.ts, 0, 20)) +>y : Symbol(y, Decl(c.d.ts, 1, 15)) +} + +=== tests/cases/compiler/d.ts === +/// + +import {A} from "./a"; +>A : Symbol(A, Decl(d.ts, 2, 8)) + +import {B} from "./b"; +>B : Symbol(B, Decl(d.ts, 3, 8)) + +A.prototype.getB = function () { return undefined; } +>A.prototype.getB : Symbol(A.getB, Decl(d.ts, 8, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(d.ts, 2, 8)) +>prototype : Symbol(A.prototype) +>getB : Symbol(A.getB, Decl(d.ts, 8, 17)) +>undefined : Symbol(undefined) + +declare module "./a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 7, 22), Decl(e.ts, 5, 22)) + + getB(): B; +>getB : Symbol(getB, Decl(d.ts, 8, 17)) +>B : Symbol(B, Decl(d.ts, 3, 8)) + } +} + +=== tests/cases/compiler/e.ts === +import {A} from "./a"; +>A : Symbol(A, Decl(e.ts, 0, 8)) + +import {Cls} from "C"; +>Cls : Symbol(Cls, Decl(e.ts, 1, 8)) + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls : Symbol(A.getCls, Decl(e.ts, 6, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(e.ts, 0, 8)) +>prototype : Symbol(A.prototype) +>getCls : Symbol(A.getCls, Decl(e.ts, 6, 17)) +>undefined : Symbol(undefined) + +declare module "./a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.ts, 7, 22), Decl(e.ts, 5, 22)) + + getCls(): Cls; +>getCls : Symbol(getCls, Decl(e.ts, 6, 17)) +>Cls : Symbol(Cls, Decl(e.ts, 1, 8)) + } +} + +=== tests/cases/compiler/main.ts === +import {A} from "./a"; +>A : Symbol(A, Decl(main.ts, 0, 8)) + +import "d"; +import "e"; + +let a: A; +>a : Symbol(a, Decl(main.ts, 4, 3)) +>A : Symbol(A, Decl(main.ts, 0, 8)) + +let b = a.getB().x.toFixed(); +>b : Symbol(b, Decl(main.ts, 5, 3)) +>a.getB().x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>a.getB().x : Symbol(B.x, Decl(b.ts, 0, 16)) +>a.getB : Symbol(A.getB, Decl(d.ts, 8, 17)) +>a : Symbol(a, Decl(main.ts, 4, 3)) +>getB : Symbol(A.getB, Decl(d.ts, 8, 17)) +>x : Symbol(B.x, Decl(b.ts, 0, 16)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let c = a.getCls().y.toLowerCase(); +>c : Symbol(c, Decl(main.ts, 6, 3)) +>a.getCls().y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>a.getCls().y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>a.getCls : Symbol(A.getCls, Decl(e.ts, 6, 17)) +>a : Symbol(a, Decl(main.ts, 4, 3)) +>getCls : Symbol(A.getCls, Decl(e.ts, 6, 17)) +>y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/moduleAugmentationsImports2.types b/tests/baselines/reference/moduleAugmentationsImports2.types new file mode 100644 index 0000000000..56b4062560 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports2.types @@ -0,0 +1,108 @@ +=== tests/cases/compiler/a.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : B +>x : number + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Cls +>y : string +} + +=== tests/cases/compiler/d.ts === +/// + +import {A} from "./a"; +>A : typeof A + +import {B} from "./b"; +>B : typeof B + +A.prototype.getB = function () { return undefined; } +>A.prototype.getB = function () { return undefined; } : () => any +>A.prototype.getB : () => B +>A.prototype : A +>A : typeof A +>prototype : A +>getB : () => B +>function () { return undefined; } : () => any +>undefined : undefined + +declare module "./a" { + interface A { +>A : A + + getB(): B; +>getB : () => B +>B : B + } +} + +=== tests/cases/compiler/e.ts === +import {A} from "./a"; +>A : typeof A + +import {Cls} from "C"; +>Cls : typeof Cls + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls : () => Cls +>A.prototype : A +>A : typeof A +>prototype : A +>getCls : () => Cls +>function () { return undefined; } : () => any +>undefined : undefined + +declare module "./a" { + interface A { +>A : A + + getCls(): Cls; +>getCls : () => Cls +>Cls : Cls + } +} + +=== tests/cases/compiler/main.ts === +import {A} from "./a"; +>A : typeof A + +import "d"; +import "e"; + +let a: A; +>a : A +>A : A + +let b = a.getB().x.toFixed(); +>b : string +>a.getB().x.toFixed() : string +>a.getB().x.toFixed : (fractionDigits?: number) => string +>a.getB().x : number +>a.getB() : B +>a.getB : () => B +>a : A +>getB : () => B +>x : number +>toFixed : (fractionDigits?: number) => string + +let c = a.getCls().y.toLowerCase(); +>c : string +>a.getCls().y.toLowerCase() : string +>a.getCls().y.toLowerCase : () => string +>a.getCls().y : string +>a.getCls() : Cls +>a.getCls : () => Cls +>a : A +>getCls : () => Cls +>y : string +>toLowerCase : () => string + diff --git a/tests/baselines/reference/moduleAugmentationsImports3.js b/tests/baselines/reference/moduleAugmentationsImports3.js new file mode 100644 index 0000000000..3654583b5c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports3.js @@ -0,0 +1,101 @@ +//// [tests/cases/compiler/moduleAugmentationsImports3.ts] //// + +//// [a.ts] + +export class A {} + +//// [b.ts] +export class B {x: number;} + +//// [c.d.ts] +declare module "C" { + class Cls {y: string; } +} + +//// [d.d.ts] +declare module "D" { + import {A} from "a"; + import {B} from "b"; + module "a" { + interface A { + getB(): B; + } + } +} + +//// [e.ts] +/// +import {A} from "./a"; +import {Cls} from "C"; + +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +//// [main.ts] +/// +import {A} from "./a"; +import "D"; +import "e"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); + +//// [f.js] +define("a", ["require", "exports"], function (require, exports) { + "use strict"; + var A = (function () { + function A() { + } + return A; + }()); + exports.A = A; +}); +define("b", ["require", "exports"], function (require, exports) { + "use strict"; + var B = (function () { + function B() { + } + return B; + }()); + exports.B = B; +}); +define("e", ["require", "exports", "a"], function (require, exports, a_1) { + "use strict"; + a_1.A.prototype.getCls = function () { return undefined; }; +}); +define("main", ["require", "exports", "D", "e"], function (require, exports) { + "use strict"; + var a; + var b = a.getB().x.toFixed(); + var c = a.getCls().y.toLowerCase(); +}); + + +//// [f.d.ts] +/// +/// +declare module "a" { + export class A { + } +} +declare module "b" { + export class B { + x: number; + } +} +declare module "e" { + import { Cls } from "C"; + module "a" { + interface A { + getCls(): Cls; + } + } +} +declare module "main" { +} diff --git a/tests/baselines/reference/moduleAugmentationsImports3.symbols b/tests/baselines/reference/moduleAugmentationsImports3.symbols new file mode 100644 index 0000000000..db8eee074c --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports3.symbols @@ -0,0 +1,94 @@ +=== tests/cases/compiler/main.ts === +/// +import {A} from "./a"; +>A : Symbol(A, Decl(main.ts, 1, 8)) + +import "D"; +import "e"; + +let a: A; +>a : Symbol(a, Decl(main.ts, 5, 3)) +>A : Symbol(A, Decl(main.ts, 1, 8)) + +let b = a.getB().x.toFixed(); +>b : Symbol(b, Decl(main.ts, 6, 3)) +>a.getB().x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>a.getB().x : Symbol(B.x, Decl(b.ts, 0, 16)) +>a.getB : Symbol(A.getB, Decl(d.d.ts, 4, 21)) +>a : Symbol(a, Decl(main.ts, 5, 3)) +>getB : Symbol(A.getB, Decl(d.d.ts, 4, 21)) +>x : Symbol(B.x, Decl(b.ts, 0, 16)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let c = a.getCls().y.toLowerCase(); +>c : Symbol(c, Decl(main.ts, 7, 3)) +>a.getCls().y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>a.getCls().y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>a.getCls : Symbol(A.getCls, Decl(e.ts, 7, 17)) +>a : Symbol(a, Decl(main.ts, 5, 3)) +>getCls : Symbol(A.getCls, Decl(e.ts, 7, 17)) +>y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + +=== tests/cases/compiler/a.ts === + +export class A {} +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.ts, 6, 22)) + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : Symbol(B, Decl(b.ts, 0, 0)) +>x : Symbol(x, Decl(b.ts, 0, 16)) + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Symbol(Cls, Decl(c.d.ts, 0, 20)) +>y : Symbol(y, Decl(c.d.ts, 1, 15)) +} + +=== tests/cases/compiler/d.d.ts === +declare module "D" { + import {A} from "a"; +>A : Symbol(A, Decl(d.d.ts, 1, 12)) + + import {B} from "b"; +>B : Symbol(B, Decl(d.d.ts, 2, 12)) + + module "a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.ts, 6, 22)) + + getB(): B; +>getB : Symbol(getB, Decl(d.d.ts, 4, 21)) +>B : Symbol(B, Decl(d.d.ts, 2, 12)) + } + } +} + +=== tests/cases/compiler/e.ts === +/// +import {A} from "./a"; +>A : Symbol(A, Decl(e.ts, 1, 8)) + +import {Cls} from "C"; +>Cls : Symbol(Cls, Decl(e.ts, 2, 8)) + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls : Symbol(A.getCls, Decl(e.ts, 7, 17)) +>A.prototype : Symbol(A.prototype) +>A : Symbol(A, Decl(e.ts, 1, 8)) +>prototype : Symbol(A.prototype) +>getCls : Symbol(A.getCls, Decl(e.ts, 7, 17)) +>undefined : Symbol(undefined) + +declare module "./a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.ts, 6, 22)) + + getCls(): Cls; +>getCls : Symbol(getCls, Decl(e.ts, 7, 17)) +>Cls : Symbol(Cls, Decl(e.ts, 2, 8)) + } +} + diff --git a/tests/baselines/reference/moduleAugmentationsImports3.types b/tests/baselines/reference/moduleAugmentationsImports3.types new file mode 100644 index 0000000000..04d17296c5 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports3.types @@ -0,0 +1,100 @@ +=== tests/cases/compiler/main.ts === +/// +import {A} from "./a"; +>A : typeof A + +import "D"; +import "e"; + +let a: A; +>a : A +>A : A + +let b = a.getB().x.toFixed(); +>b : string +>a.getB().x.toFixed() : string +>a.getB().x.toFixed : (fractionDigits?: number) => string +>a.getB().x : number +>a.getB() : B +>a.getB : () => B +>a : A +>getB : () => B +>x : number +>toFixed : (fractionDigits?: number) => string + +let c = a.getCls().y.toLowerCase(); +>c : string +>a.getCls().y.toLowerCase() : string +>a.getCls().y.toLowerCase : () => string +>a.getCls().y : string +>a.getCls() : Cls +>a.getCls : () => Cls +>a : A +>getCls : () => Cls +>y : string +>toLowerCase : () => string + +=== tests/cases/compiler/a.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : B +>x : number + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Cls +>y : string +} + +=== tests/cases/compiler/d.d.ts === +declare module "D" { + import {A} from "a"; +>A : typeof A + + import {B} from "b"; +>B : typeof B + + module "a" { + interface A { +>A : A + + getB(): B; +>getB : () => B +>B : B + } + } +} + +=== tests/cases/compiler/e.ts === +/// +import {A} from "./a"; +>A : typeof A + +import {Cls} from "C"; +>Cls : typeof Cls + +A.prototype.getCls = function () { return undefined; } +>A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls : () => Cls +>A.prototype : A +>A : typeof A +>prototype : A +>getCls : () => Cls +>function () { return undefined; } : () => any +>undefined : undefined + +declare module "./a" { + interface A { +>A : A + + getCls(): Cls; +>getCls : () => Cls +>Cls : Cls + } +} + diff --git a/tests/baselines/reference/moduleAugmentationsImports4.js b/tests/baselines/reference/moduleAugmentationsImports4.js new file mode 100644 index 0000000000..9b64016113 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports4.js @@ -0,0 +1,90 @@ +//// [tests/cases/compiler/moduleAugmentationsImports4.ts] //// + +//// [a.ts] + +export class A {} + +//// [b.ts] +export class B {x: number;} + +//// [c.d.ts] +declare module "C" { + class Cls {y: string; } +} + +//// [d.d.ts] +declare module "D" { + import {A} from "a"; + import {B} from "b"; + module "a" { + interface A { + getB(): B; + } + } +} + +//// [e.d.ts] +/// +declare module "E" { + import {A} from "a"; + import {Cls} from "C"; + + module "a" { + interface A { + getCls(): Cls; + } + } +} + +//// [main.ts] +/// +/// +import {A} from "./a"; +import "D"; +import "E"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); + +//// [f.js] +define("a", ["require", "exports"], function (require, exports) { + "use strict"; + var A = (function () { + function A() { + } + return A; + }()); + exports.A = A; +}); +define("b", ["require", "exports"], function (require, exports) { + "use strict"; + var B = (function () { + function B() { + } + return B; + }()); + exports.B = B; +}); +define("main", ["require", "exports", "D", "E"], function (require, exports) { + "use strict"; + var a; + var b = a.getB().x.toFixed(); + var c = a.getCls().y.toLowerCase(); +}); + + +//// [f.d.ts] +/// +/// +declare module "a" { + export class A { + } +} +declare module "b" { + export class B { + x: number; + } +} +declare module "main" { +} diff --git a/tests/baselines/reference/moduleAugmentationsImports4.symbols b/tests/baselines/reference/moduleAugmentationsImports4.symbols new file mode 100644 index 0000000000..8d203de851 --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports4.symbols @@ -0,0 +1,89 @@ +=== tests/cases/compiler/main.ts === +/// +/// +import {A} from "./a"; +>A : Symbol(A, Decl(main.ts, 2, 8)) + +import "D"; +import "E"; + +let a: A; +>a : Symbol(a, Decl(main.ts, 6, 3)) +>A : Symbol(A, Decl(main.ts, 2, 8)) + +let b = a.getB().x.toFixed(); +>b : Symbol(b, Decl(main.ts, 7, 3)) +>a.getB().x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) +>a.getB().x : Symbol(B.x, Decl(b.ts, 0, 16)) +>a.getB : Symbol(A.getB, Decl(d.d.ts, 4, 21)) +>a : Symbol(a, Decl(main.ts, 6, 3)) +>getB : Symbol(A.getB, Decl(d.d.ts, 4, 21)) +>x : Symbol(B.x, Decl(b.ts, 0, 16)) +>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --)) + +let c = a.getCls().y.toLowerCase(); +>c : Symbol(c, Decl(main.ts, 8, 3)) +>a.getCls().y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>a.getCls().y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>a.getCls : Symbol(A.getCls, Decl(e.d.ts, 6, 21)) +>a : Symbol(a, Decl(main.ts, 6, 3)) +>getCls : Symbol(A.getCls, Decl(e.d.ts, 6, 21)) +>y : Symbol(Cls.y, Decl(c.d.ts, 1, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + +=== tests/cases/compiler/a.ts === + +export class A {} +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.d.ts, 5, 16)) + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : Symbol(B, Decl(b.ts, 0, 0)) +>x : Symbol(x, Decl(b.ts, 0, 16)) + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Symbol(Cls, Decl(c.d.ts, 0, 20)) +>y : Symbol(y, Decl(c.d.ts, 1, 15)) +} + +=== tests/cases/compiler/d.d.ts === +declare module "D" { + import {A} from "a"; +>A : Symbol(A, Decl(d.d.ts, 1, 12)) + + import {B} from "b"; +>B : Symbol(B, Decl(d.d.ts, 2, 12)) + + module "a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.d.ts, 5, 16)) + + getB(): B; +>getB : Symbol(getB, Decl(d.d.ts, 4, 21)) +>B : Symbol(B, Decl(d.d.ts, 2, 12)) + } + } +} + +=== tests/cases/compiler/e.d.ts === +/// +declare module "E" { + import {A} from "a"; +>A : Symbol(A, Decl(e.d.ts, 2, 12)) + + import {Cls} from "C"; +>Cls : Symbol(Cls, Decl(e.d.ts, 3, 12)) + + module "a" { + interface A { +>A : Symbol(A, Decl(a.ts, 0, 0), Decl(d.d.ts, 3, 16), Decl(e.d.ts, 5, 16)) + + getCls(): Cls; +>getCls : Symbol(getCls, Decl(e.d.ts, 6, 21)) +>Cls : Symbol(Cls, Decl(e.d.ts, 3, 12)) + } + } +} + diff --git a/tests/baselines/reference/moduleAugmentationsImports4.types b/tests/baselines/reference/moduleAugmentationsImports4.types new file mode 100644 index 0000000000..53d570e14e --- /dev/null +++ b/tests/baselines/reference/moduleAugmentationsImports4.types @@ -0,0 +1,93 @@ +=== tests/cases/compiler/main.ts === +/// +/// +import {A} from "./a"; +>A : typeof A + +import "D"; +import "E"; + +let a: A; +>a : A +>A : A + +let b = a.getB().x.toFixed(); +>b : string +>a.getB().x.toFixed() : string +>a.getB().x.toFixed : (fractionDigits?: number) => string +>a.getB().x : number +>a.getB() : B +>a.getB : () => B +>a : A +>getB : () => B +>x : number +>toFixed : (fractionDigits?: number) => string + +let c = a.getCls().y.toLowerCase(); +>c : string +>a.getCls().y.toLowerCase() : string +>a.getCls().y.toLowerCase : () => string +>a.getCls().y : string +>a.getCls() : Cls +>a.getCls : () => Cls +>a : A +>getCls : () => Cls +>y : string +>toLowerCase : () => string + +=== tests/cases/compiler/a.ts === + +export class A {} +>A : A + +=== tests/cases/compiler/b.ts === +export class B {x: number;} +>B : B +>x : number + +=== tests/cases/compiler/c.d.ts === +declare module "C" { + class Cls {y: string; } +>Cls : Cls +>y : string +} + +=== tests/cases/compiler/d.d.ts === +declare module "D" { + import {A} from "a"; +>A : typeof A + + import {B} from "b"; +>B : typeof B + + module "a" { + interface A { +>A : A + + getB(): B; +>getB : () => B +>B : B + } + } +} + +=== tests/cases/compiler/e.d.ts === +/// +declare module "E" { + import {A} from "a"; +>A : typeof A + + import {Cls} from "C"; +>Cls : typeof Cls + + module "a" { + interface A { +>A : A + + getCls(): Cls; +>getCls : () => Cls +>Cls : Cls + } + } +} + diff --git a/tests/baselines/reference/numericIndexerConstraint1.errors.txt b/tests/baselines/reference/numericIndexerConstraint1.errors.txt index 42cf293fe6..0d4bb17002 100644 --- a/tests/baselines/reference/numericIndexerConstraint1.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint1.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/numericIndexerConstraint1.ts(3,5): error TS2322: Type 'number' is not assignable to type 'Foo'. - Property 'foo' is missing in type 'Number'. ==== tests/cases/compiler/numericIndexerConstraint1.ts (1 errors) ==== @@ -8,5 +7,4 @@ tests/cases/compiler/numericIndexerConstraint1.ts(3,5): error TS2322: Type 'numb var result: Foo = x["one"]; // error ~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'Foo'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index c35e49f02a..f825c41631 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. + Property 'y' is missing in type 'A'. ==== tests/cases/compiler/objectLiteralIndexerErrors.ts (1 errors) ==== @@ -21,4 +22,5 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ !!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Property 'y' is missing in type 'A'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt index e1b0bb3452..6f45030a65 100644 --- a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt @@ -2,7 +2,6 @@ tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeBy tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode. tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type 'string' is not assignable to type 'IArguments'. - Property 'callee' is missing in type 'String'. ==== tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts (4 errors) ==== @@ -20,6 +19,5 @@ tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeBy !!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. ~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'IArguments'. -!!! error TS2322: Property 'callee' is missing in type 'String'. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index 66afa3d010..963ce12ddf 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -7,11 +7,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(25,17): er tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(41,12): error TS2304: Cannot find name 'ActiveXObject'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(43,19): error TS2304: Cannot find name 'require'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(44,14): error TS2304: Cannot find name 'require'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(341,13): error TS2304: Cannot find name 'errorHandlerStack'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(347,13): error TS2304: Cannot find name 'errorHandlerStack'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(351,17): error TS2304: Cannot find name 'errorHandlerStack'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,17): error TS2304: Cannot find name 'errorHandlerStack'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,35): error TS2304: Cannot find name 'errorHandlerStack'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(341,13): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(347,13): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(351,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,35): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(691,50): error TS2304: Cannot find name 'ITextWriter'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(716,47): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(721,62): error TS2304: Cannot find name 'ITextWriter'. @@ -471,7 +471,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): static pushGlobalErrorHandler(done: IDone) { errorHandlerStack.push(function (e) { ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'errorHandlerStack'. +!!! error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? done(e); }); } @@ -479,20 +479,20 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): static popGlobalErrorHandler() { errorHandlerStack.pop(); ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'errorHandlerStack'. +!!! error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? } static handleError(e: Error) { if (errorHandlerStack.length === 0) { ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'errorHandlerStack'. +!!! error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? IO.printLine('Global error: ' + e); } else { errorHandlerStack[errorHandlerStack.length - 1](e); ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'errorHandlerStack'. +!!! error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? ~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'errorHandlerStack'. +!!! error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? } } } diff --git a/tests/baselines/reference/parserindenter.errors.txt b/tests/baselines/reference/parserindenter.errors.txt index a332abab7b..8ccc922071 100644 --- a/tests/baselines/reference/parserindenter.errors.txt +++ b/tests/baselines/reference/parserindenter.errors.txt @@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(152,63): tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(153,30): error TS2304: Cannot find name 'List_TextEditInfo'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(155,32): error TS2304: Cannot find name 'AuthorTokenKind'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(182,79): error TS2503: Cannot find namespace 'Services'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(183,20): error TS2304: Cannot find name 'GetIndentSizeFromText'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(183,20): error TS2662: Cannot find name 'GetIndentSizeFromText'. Did you mean the static member 'Indenter.GetIndentSizeFromText'? tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(186,67): error TS2503: Cannot find namespace 'Services'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(207,50): error TS2304: Cannot find name 'TokenSpan'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(207,67): error TS2304: Cannot find name 'ParseNode'. @@ -373,7 +373,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): !!! error TS2503: Cannot find namespace 'Services'. return GetIndentSizeFromText(indentText, editorOptions, /*includeNonIndentChars:*/ false); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'GetIndentSizeFromText'. +!!! error TS2662: Cannot find name 'GetIndentSizeFromText'. Did you mean the static member 'Indenter.GetIndentSizeFromText'? } static GetIndentSizeFromText(text: string, editorOptions: Services.EditorOptions, includeNonIndentChars: boolean): number { diff --git a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt index 236418a10a..05bb3559f1 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/privacyGloImportParseErrors.ts(22,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. tests/cases/compiler/privacyGloImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyGloImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyGloImportParseErrors.ts(49,29): error TS4000: Import declaration 'm1_im2_private' is using private name 'm1_M2_private'. @@ -13,12 +14,12 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(125,45): error TS1147: Impor tests/cases/compiler/privacyGloImportParseErrors.ts(133,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyGloImportParseErrors.ts(133,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyGloImportParseErrors.ts(138,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. -tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2664: Invalid module name in augmentation, module 'abc3' cannot be found. tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Import declarations in a namespace cannot reference a module. -==== tests/cases/compiler/privacyGloImportParseErrors.ts (18 errors) ==== +==== tests/cases/compiler/privacyGloImportParseErrors.ts (19 errors) ==== module m1 { export module m1_M1_public { export class c1 { @@ -41,6 +42,8 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor } export declare module "m1_M3_public" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~ !!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); @@ -191,7 +194,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor } module "abc3" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'abc3' cannot be found. } } diff --git a/tests/baselines/reference/privacyImportParseErrors.errors.txt b/tests/baselines/reference/privacyImportParseErrors.errors.txt index 5bae45f405..1826ac7226 100644 --- a/tests/baselines/reference/privacyImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyImportParseErrors.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/privacyImportParseErrors.ts(22,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. tests/cases/compiler/privacyImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS1147: Import declarations in a namespace cannot reference a module. @@ -6,6 +7,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS1147: Import de tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS2307: Cannot find module 'm1_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(81,43): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(82,43): error TS1147: Import declarations in a namespace cannot reference a module. +tests/cases/compiler/privacyImportParseErrors.ts(106,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. tests/cases/compiler/privacyImportParseErrors.ts(106,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(114,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS1147: Import declarations in a namespace cannot reference a module. @@ -14,31 +16,35 @@ tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS1147: Import d tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS2307: Cannot find module 'm2_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(166,43): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(167,43): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. -tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(180,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. +tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2664: Invalid module name in augmentation, module 'glo_M2_public' cannot be found. +tests/cases/compiler/privacyImportParseErrors.ts(198,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. +tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2664: Invalid module name in augmentation, module 'glo_M4_private' cannot be found. tests/cases/compiler/privacyImportParseErrors.ts(218,34): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(238,34): error TS2307: Cannot find module 'glo_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(251,40): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(252,40): error TS2307: Cannot find module 'glo_M4_private'. -tests/cases/compiler/privacyImportParseErrors.ts(255,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(255,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. +tests/cases/compiler/privacyImportParseErrors.ts(255,23): error TS2664: Invalid module name in augmentation, module 'use_glo_M1_public' cannot be found. tests/cases/compiler/privacyImportParseErrors.ts(258,45): error TS2304: Cannot find name 'use_glo_M1_public'. tests/cases/compiler/privacyImportParseErrors.ts(261,39): error TS2304: Cannot find name 'use_glo_M1_public'. tests/cases/compiler/privacyImportParseErrors.ts(264,40): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(273,38): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(277,45): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(284,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(284,16): error TS2664: Invalid module name in augmentation, module 'use_glo_M3_private' cannot be found. tests/cases/compiler/privacyImportParseErrors.ts(287,46): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(290,40): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(293,41): error TS2307: Cannot find module 'glo_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(302,38): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(306,45): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(312,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(312,16): error TS2664: Invalid module name in augmentation, module 'anotherParseError' cannot be found. tests/cases/compiler/privacyImportParseErrors.ts(314,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyImportParseErrors.ts(314,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(319,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(322,12): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(326,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. tests/cases/compiler/privacyImportParseErrors.ts(326,9): error TS1029: 'export' modifier must precede 'declare' modifier. -tests/cases/compiler/privacyImportParseErrors.ts(326,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(326,23): error TS2664: Invalid module name in augmentation, module 'anotherParseError2' cannot be found. tests/cases/compiler/privacyImportParseErrors.ts(328,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyImportParseErrors.ts(328,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(333,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. @@ -49,7 +55,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import declarations in a namespace cannot reference a module. -==== tests/cases/compiler/privacyImportParseErrors.ts (49 errors) ==== +==== tests/cases/compiler/privacyImportParseErrors.ts (55 errors) ==== export module m1 { export module m1_M1_public { export class c1 { @@ -72,6 +78,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d } export declare module "m1_M3_public" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~ !!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); @@ -172,6 +180,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d } export declare module "m2_M3_public" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~ !!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); @@ -262,8 +272,10 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d } export declare module "glo_M2_public" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'glo_M2_public' cannot be found. export function f1(); export class c1 { } @@ -282,8 +294,10 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d } export declare module "glo_M4_private" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'glo_M4_private' cannot be found. export function f1(); export class c1 { } @@ -349,8 +363,10 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "use_glo_M1_public" { + ~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'use_glo_M1_public' cannot be found. import use_glo_M1_public = glo_M1_public; export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; export var use_glo_M1_public_v2_public: use_glo_M1_public; @@ -391,7 +407,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "use_glo_M3_private" { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'use_glo_M3_private' cannot be found. import use_glo_M3_private = glo_M3_private; export var use_glo_M3_private_v1_public: { new (): use_glo_M3_private.c1; }; export var use_glo_M3_private_v2_public: use_glo_M3_private; @@ -431,7 +447,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "anotherParseError" { ~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'anotherParseError' cannot be found. module m2 { declare module "abc" { ~~~~~~~ @@ -454,10 +470,12 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d } declare export module "anotherParseError2" { + ~~~~~~~ +!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. ~~~~~~ !!! error TS1029: 'export' modifier must precede 'declare' modifier. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. +!!! error TS2664: Invalid module name in augmentation, module 'anotherParseError2' cannot be found. module m2 { declare module "abc" { ~~~~~~~ diff --git a/tests/baselines/reference/promiseChaining1.errors.txt b/tests/baselines/reference/promiseChaining1.errors.txt index bd3e52fcc1..7396d03059 100644 --- a/tests/baselines/reference/promiseChaining1.errors.txt +++ b/tests/baselines/reference/promiseChaining1.errors.txt @@ -1,6 +1,5 @@ tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. Type 'string' is not assignable to type 'Function'. - Property 'apply' is missing in type 'String'. ==== tests/cases/compiler/promiseChaining1.ts (1 errors) ==== @@ -14,7 +13,6 @@ tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type ' ~~~~~~~~~~ !!! error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. !!! error TS2345: Type 'string' is not assignable to type 'Function'. -!!! error TS2345: Property 'apply' is missing in type 'String'. return new Chain2(result); } } \ No newline at end of file diff --git a/tests/baselines/reference/promiseChaining2.errors.txt b/tests/baselines/reference/promiseChaining2.errors.txt index f12baebd4d..a31c4335da 100644 --- a/tests/baselines/reference/promiseChaining2.errors.txt +++ b/tests/baselines/reference/promiseChaining2.errors.txt @@ -1,6 +1,5 @@ tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. Type 'string' is not assignable to type 'Function'. - Property 'apply' is missing in type 'String'. ==== tests/cases/compiler/promiseChaining2.ts (1 errors) ==== @@ -14,7 +13,6 @@ tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type ' ~~~~~~~~~~ !!! error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. !!! error TS2345: Type 'string' is not assignable to type 'Function'. -!!! error TS2345: Property 'apply' is missing in type 'String'. return new Chain2(result); } } \ No newline at end of file diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index a74938f5dd..4edfff05a5 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. - Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -157,7 +156,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. -!!! error TS2345: Property 'then' is missing in type 'Number'. var r4: IPromise; var sIPromise: (x: any) => IPromise; diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 8afceeae0f..dda9a08b38 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/promisePermutations2.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. - Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations2.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -156,7 +155,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. -!!! error TS2345: Property 'then' is missing in type 'Number'. var r4: IPromise; var sIPromise: (x: any) => IPromise; diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index b17021a02b..c6c2bca62a 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. - Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. @@ -159,7 +158,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. -!!! error TS2345: Property 'then' is missing in type 'Number'. var s3: Promise; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); diff --git a/tests/baselines/reference/qualify.errors.txt b/tests/baselines/reference/qualify.errors.txt index f38fc93ccd..c3447664c9 100644 --- a/tests/baselines/reference/qualify.errors.txt +++ b/tests/baselines/reference/qualify.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/qualify.ts(21,13): error TS2322: Type 'number' is not assignable to type 'I'. - Property 'p' is missing in type 'Number'. tests/cases/compiler/qualify.ts(30,13): error TS2322: Type 'number' is not assignable to type 'I2'. - Property 'q' is missing in type 'Number'. tests/cases/compiler/qualify.ts(45,13): error TS2322: Type 'I4' is not assignable to type 'I3'. Property 'zeep' is missing in type 'I4'. tests/cases/compiler/qualify.ts(46,13): error TS2322: Type 'I4' is not assignable to type 'I3[]'. @@ -40,7 +38,6 @@ tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable var z:I=3; ~ !!! error TS2322: Type 'number' is not assignable to type 'I'. -!!! error TS2322: Property 'p' is missing in type 'Number'. export interface I2 { q; } @@ -52,7 +49,6 @@ tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable var z:T.U.I2=3; ~ !!! error TS2322: Type 'number' is not assignable to type 'I2'. -!!! error TS2322: Property 'q' is missing in type 'Number'. } } diff --git a/tests/baselines/reference/recursiveClassReferenceTest.errors.txt b/tests/baselines/reference/recursiveClassReferenceTest.errors.txt index 088d7222f4..4a1a6f1782 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.errors.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/recursiveClassReferenceTest.ts(16,19): error TS2304: Cannot find name 'Element'. -tests/cases/compiler/recursiveClassReferenceTest.ts(56,11): error TS2304: Cannot find name 'domNode'. -tests/cases/compiler/recursiveClassReferenceTest.ts(88,36): error TS2304: Cannot find name 'mode'. +tests/cases/compiler/recursiveClassReferenceTest.ts(56,11): error TS2663: Cannot find name 'domNode'. Did you mean the instance member 'this.domNode'? +tests/cases/compiler/recursiveClassReferenceTest.ts(88,36): error TS2663: Cannot find name 'mode'. Did you mean the instance member 'this.mode'? tests/cases/compiler/recursiveClassReferenceTest.ts(95,21): error TS2345: Argument of type 'Window' is not assignable to parameter of type 'IMode'. Property 'getInitialState' is missing in type 'Window'. @@ -65,7 +65,7 @@ tests/cases/compiler/recursiveClassReferenceTest.ts(95,21): error TS2345: Argume public getDomNode() { return domNode; ~~~~~~~ -!!! error TS2304: Cannot find name 'domNode'. +!!! error TS2663: Cannot find name 'domNode'. Did you mean the instance member 'this.domNode'? } public destroy() { @@ -99,7 +99,7 @@ tests/cases/compiler/recursiveClassReferenceTest.ts(95,21): error TS2345: Argume public getMode(): IMode { return mode; } ~~~~ -!!! error TS2304: Cannot find name 'mode'. +!!! error TS2663: Cannot find name 'mode'. Did you mean the instance member 'this.mode'? } export class Mode extends AbstractMode { diff --git a/tests/baselines/reference/restArgAssignmentCompat.errors.txt b/tests/baselines/reference/restArgAssignmentCompat.errors.txt index 2ea0739509..c17d28cb28 100644 --- a/tests/baselines/reference/restArgAssignmentCompat.errors.txt +++ b/tests/baselines/reference/restArgAssignmentCompat.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/restArgAssignmentCompat.ts(7,1): error TS2322: Type '(...x: number[]) => void' is not assignable to type '(x: number[], y: string) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'number[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/compiler/restArgAssignmentCompat.ts (1 errors) ==== @@ -16,6 +15,5 @@ tests/cases/compiler/restArgAssignmentCompat.ts(7,1): error TS2322: Type '(...x: !!! error TS2322: Type '(...x: number[]) => void' is not assignable to type '(x: number[], y: string) => void'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'number[]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. n([4], 'foo'); \ No newline at end of file diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index dbe3b9e5ee..30f629f9f8 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,8 +1,6 @@ tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type 'number' is not assignable to type 'B'. - Property 'foo' is missing in type 'Number'. tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type 'string' is not assignable to type 'D'. - Property 'foo' is missing in type 'String'. tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. Types of property 'foo' are incompatible. @@ -28,7 +26,6 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o return 1; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'B'. -!!! error TS2322: Property 'foo' is missing in type 'Number'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } @@ -47,7 +44,6 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o return "test"; // error ~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'D'. -!!! error TS2322: Property 'foo' is missing in type 'String'. ~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/scannertest1.errors.txt b/tests/baselines/reference/scannertest1.errors.txt index 14a19b2885..3831dbe398 100644 --- a/tests/baselines/reference/scannertest1.errors.txt +++ b/tests/baselines/reference/scannertest1.errors.txt @@ -1,14 +1,14 @@ tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(1,1): error TS6053: File 'tests/cases/conformance/scanner/ecmascript5/References.ts' not found. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(5,21): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(5,47): error TS2304: Cannot find name 'CharacterCodes'. -tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(9,16): error TS2304: Cannot find name 'isDecimalDigit'. +tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(9,16): error TS2662: Cannot find name 'isDecimalDigit'. Did you mean the static member 'CharacterInfo.isDecimalDigit'? tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(10,22): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(10,47): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(11,22): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(11,47): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(15,9): error TS2304: Cannot find name 'Debug'. -tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(15,22): error TS2304: Cannot find name 'isHexDigit'. -tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(16,16): error TS2304: Cannot find name 'isDecimalDigit'. +tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(15,22): error TS2662: Cannot find name 'isHexDigit'. Did you mean the static member 'CharacterInfo.isHexDigit'? +tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(16,16): error TS2662: Cannot find name 'isDecimalDigit'. Did you mean the static member 'CharacterInfo.isDecimalDigit'? tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(17,20): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(18,21): error TS2304: Cannot find name 'CharacterCodes'. tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(18,46): error TS2304: Cannot find name 'CharacterCodes'. @@ -33,7 +33,7 @@ tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(20,23): error TS2304 public static isHexDigit(c: number): boolean { return isDecimalDigit(c) || ~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'isDecimalDigit'. +!!! error TS2662: Cannot find name 'isDecimalDigit'. Did you mean the static member 'CharacterInfo.isDecimalDigit'? (c >= CharacterCodes.A && c <= CharacterCodes.F) || ~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'CharacterCodes'. @@ -51,10 +51,10 @@ tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(20,23): error TS2304 ~~~~~ !!! error TS2304: Cannot find name 'Debug'. ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'isHexDigit'. +!!! error TS2662: Cannot find name 'isHexDigit'. Did you mean the static member 'CharacterInfo.isHexDigit'? return isDecimalDigit(c) ~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'isDecimalDigit'. +!!! error TS2662: Cannot find name 'isDecimalDigit'. Did you mean the static member 'CharacterInfo.isDecimalDigit'? ? (c - CharacterCodes._0) ~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'CharacterCodes'. diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.errors.txt b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.errors.txt index c59171bdf0..378e20f19b 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.errors.txt +++ b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts(4,7): error TS2304: Cannot find name 'v'. -tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts(6,7): error TS2304: Cannot find name 's'. +tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts(4,7): error TS2663: Cannot find name 'v'. Did you mean the instance member 'this.v'? +tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts(6,7): error TS2662: Cannot find name 's'. Did you mean the static member 'D.s'? ==== tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/scopeCheckExtendedClassInsidePublicMethod2.ts(6,7): error T public c() { v = 1; ~ -!!! error TS2304: Cannot find name 'v'. +!!! error TS2663: Cannot find name 'v'. Did you mean the instance member 'this.v'? this.p = 1; s = 1; ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS2662: Cannot find name 's'. Did you mean the static member 'D.s'? } } \ No newline at end of file diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.errors.txt b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.errors.txt index a6ecd48827..dd3e5ef446 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.errors.txt +++ b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts(4,7): error TS2304: Cannot find name 'v'. tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts(5,12): error TS2339: Property 'p' does not exist on type 'typeof D'. -tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts(6,7): error TS2304: Cannot find name 's'. +tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts(6,7): error TS2662: Cannot find name 's'. Did you mean the static member 'D.s'? ==== tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts (3 errors) ==== @@ -15,6 +15,6 @@ tests/cases/compiler/scopeCheckExtendedClassInsideStaticMethod1.ts(6,7): error T !!! error TS2339: Property 'p' does not exist on type 'typeof D'. s = 1; ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS2662: Cannot find name 's'. Did you mean the static member 'D.s'? } } \ No newline at end of file diff --git a/tests/baselines/reference/scopeCheckInsidePublicMethod1.errors.txt b/tests/baselines/reference/scopeCheckInsidePublicMethod1.errors.txt index 5c9473a787..ec93fea736 100644 --- a/tests/baselines/reference/scopeCheckInsidePublicMethod1.errors.txt +++ b/tests/baselines/reference/scopeCheckInsidePublicMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/scopeCheckInsidePublicMethod1.ts(4,7): error TS2304: Cannot find name 's'. +tests/cases/compiler/scopeCheckInsidePublicMethod1.ts(4,7): error TS2662: Cannot find name 's'. Did you mean the static member 'C.s'? ==== tests/cases/compiler/scopeCheckInsidePublicMethod1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/scopeCheckInsidePublicMethod1.ts(4,7): error TS2304: Cannot public a() { s = 1; // ERR ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS2662: Cannot find name 's'. Did you mean the static member 'C.s'? } } \ No newline at end of file diff --git a/tests/baselines/reference/staticClassMemberError.errors.txt b/tests/baselines/reference/staticClassMemberError.errors.txt index 9483e3387b..43a2cd6934 100644 --- a/tests/baselines/reference/staticClassMemberError.errors.txt +++ b/tests/baselines/reference/staticClassMemberError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/staticClassMemberError.ts(4,3): error TS2304: Cannot find name 's'. +tests/cases/compiler/staticClassMemberError.ts(4,3): error TS2662: Cannot find name 's'. Did you mean the static member 'C.s'? tests/cases/compiler/staticClassMemberError.ts(9,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/staticClassMemberError.ts(9,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2300: Duplicate identifier 'Foo'. @@ -10,7 +10,7 @@ tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2300: Duplicate id public a() { s = 1; ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS2662: Cannot find name 's'. Did you mean the static member 'C.s'? } } diff --git a/tests/baselines/reference/staticVisibility.errors.txt b/tests/baselines/reference/staticVisibility.errors.txt index dccad4a2e2..a92cb7f88c 100644 --- a/tests/baselines/reference/staticVisibility.errors.txt +++ b/tests/baselines/reference/staticVisibility.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/staticVisibility.ts(10,9): error TS2304: Cannot find name 's'. -tests/cases/compiler/staticVisibility.ts(13,9): error TS2304: Cannot find name 'b'. +tests/cases/compiler/staticVisibility.ts(10,9): error TS2662: Cannot find name 's'. Did you mean the static member 'C1.s'? +tests/cases/compiler/staticVisibility.ts(13,9): error TS2662: Cannot find name 'b'. Did you mean the static member 'C1.b'? tests/cases/compiler/staticVisibility.ts(18,9): error TS2304: Cannot find name 'v'. tests/cases/compiler/staticVisibility.ts(19,14): error TS2339: Property 'p' does not exist on type 'typeof C1'. tests/cases/compiler/staticVisibility.ts(31,12): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -19,12 +19,12 @@ tests/cases/compiler/staticVisibility.ts(33,29): error TS2304: Cannot find name s = 1; // should be error ~ -!!! error TS2304: Cannot find name 's'. +!!! error TS2662: Cannot find name 's'. Did you mean the static member 'C1.s'? C1.s = 1; // should be ok b(); // should be error ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2662: Cannot find name 'b'. Did you mean the static member 'C1.b'? C1.b(); // should be ok } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt index 5dd39e0ad6..3f6de942d2 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt @@ -1,11 +1,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'string' is not assignable to type 'Derived'. - Property 'bar' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,11): error TS2415: Class 'B' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. - Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. @@ -29,7 +27,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Derived'. -!!! error TS2415: Property 'bar' is missing in type 'String'. [x: number]: string; // error } @@ -43,7 +40,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. -!!! error TS2415: Property 'foo' is missing in type 'String'. ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. diff --git a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt index e292c0867a..a5d4152b45 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(12,7): error TS2415: Class 'B' incorrectly extends base class 'A'. Types of property 'bar' are incompatible. Type 'string' is not assignable to type 'Base'. - Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(22,7): error TS2415: Class 'B2' incorrectly extends base class 'A2'. Types of property '2.0' are incompatible. Type 'string' is not assignable to type 'Base'. @@ -36,7 +35,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B' incorrectly extends base class 'A'. !!! error TS2415: Types of property 'bar' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. -!!! error TS2415: Property 'foo' is missing in type 'String'. foo: Derived; // ok bar: string; // error } diff --git a/tests/baselines/reference/subtypingWithObjectMembers2.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers2.errors.txt index 3d46a6e5dc..cdcc54c5ee 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers2.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers2.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers2.ts(17,15): error TS2430: Interface 'B' incorrectly extends interface 'A'. Types of property 'bar' are incompatible. Type 'string' is not assignable to type 'Base'. - Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers2.ts(27,15): error TS2430: Interface 'B2' incorrectly extends interface 'A2'. Types of property '2.0' are incompatible. Type 'string' is not assignable to type 'Base'. @@ -41,7 +40,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Interface 'B' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'bar' are incompatible. !!! error TS2430: Type 'string' is not assignable to type 'Base'. -!!! error TS2430: Property 'foo' is missing in type 'String'. foo: Derived; // ok bar: string; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt index 4aa889444e..8d4328cdd2 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt @@ -1,11 +1,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'string' is not assignable to type 'Derived'. - Property 'bar' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,11): error TS2415: Class 'B' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. - Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. @@ -29,7 +27,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Derived'. -!!! error TS2415: Property 'bar' is missing in type 'String'. [x: string]: string; // error } @@ -43,7 +40,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Class 'B' incorrectly extends base class 'A'. !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. -!!! error TS2415: Property 'foo' is missing in type 'String'. ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. diff --git a/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt b/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt index d7cf5e83b8..1131b6e1a6 100644 --- a/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt +++ b/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. - Property 'toDateString' is missing in type 'String'. tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. @@ -10,7 +9,6 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: foo1(""); // should error ~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. -!!! error TS2345: Property 'toDateString' is missing in type 'String'. diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 4756b83b30..9ecad00767 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -44,7 +44,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'. - Property 'm1' is missing in type 'Boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS2304: Cannot find name 'p1'. @@ -249,7 +248,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 return true; ~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'D'. -!!! error TS2322: Property 'm1' is missing in type 'Boolean'. ~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.js b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.js new file mode 100644 index 0000000000..0bd0389017 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.js @@ -0,0 +1,45 @@ +//// [typeGuardOfFormTypeOfPrimitiveSubtype.ts] +let a: {}; +let b: {toString(): string}; +if (typeof a === "number") { + let c: number = a; +} +if (typeof a === "string") { + let c: string = a; +} +if (typeof a === "boolean") { + let c: boolean = a; +} + +if (typeof b === "number") { + let c: number = b; +} +if (typeof b === "string") { + let c: string = b; +} +if (typeof b === "boolean") { + let c: boolean = b; +} + + +//// [typeGuardOfFormTypeOfPrimitiveSubtype.js] +var a; +var b; +if (typeof a === "number") { + var c = a; +} +if (typeof a === "string") { + var c = a; +} +if (typeof a === "boolean") { + var c = a; +} +if (typeof b === "number") { + var c = b; +} +if (typeof b === "string") { + var c = b; +} +if (typeof b === "boolean") { + var c = b; +} diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.symbols new file mode 100644 index 0000000000..da962b6060 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts === +let a: {}; +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) + +let b: {toString(): string}; +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) +>toString : Symbol(toString, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 8)) + +if (typeof a === "number") { +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) + + let c: number = a; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 3, 7)) +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) +} +if (typeof a === "string") { +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) + + let c: string = a; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 6, 7)) +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) +} +if (typeof a === "boolean") { +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) + + let c: boolean = a; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 9, 7)) +>a : Symbol(a, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 0, 3)) +} + +if (typeof b === "number") { +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) + + let c: number = b; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 13, 7)) +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) +} +if (typeof b === "string") { +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) + + let c: string = b; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 16, 7)) +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) +} +if (typeof b === "boolean") { +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) + + let c: boolean = b; +>c : Symbol(c, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 19, 7)) +>b : Symbol(b, Decl(typeGuardOfFormTypeOfPrimitiveSubtype.ts, 1, 3)) +} + diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types new file mode 100644 index 0000000000..7e88ca5cb9 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts === +let a: {}; +>a : {} + +let b: {toString(): string}; +>b : { toString(): string; } +>toString : () => string + +if (typeof a === "number") { +>typeof a === "number" : boolean +>typeof a : string +>a : {} +>"number" : string + + let c: number = a; +>c : number +>a : number +} +if (typeof a === "string") { +>typeof a === "string" : boolean +>typeof a : string +>a : {} +>"string" : string + + let c: string = a; +>c : string +>a : string +} +if (typeof a === "boolean") { +>typeof a === "boolean" : boolean +>typeof a : string +>a : {} +>"boolean" : string + + let c: boolean = a; +>c : boolean +>a : boolean +} + +if (typeof b === "number") { +>typeof b === "number" : boolean +>typeof b : string +>b : { toString(): string; } +>"number" : string + + let c: number = b; +>c : number +>b : number +} +if (typeof b === "string") { +>typeof b === "string" : boolean +>typeof b : string +>b : { toString(): string; } +>"string" : string + + let c: string = b; +>c : string +>b : string +} +if (typeof b === "boolean") { +>typeof b === "boolean" : boolean +>typeof b : string +>b : { toString(): string; } +>"boolean" : string + + let c: boolean = b; +>c : boolean +>b : boolean +} + diff --git a/tests/baselines/reference/typeName1.errors.txt b/tests/baselines/reference/typeName1.errors.txt index 84c8be360b..152a5b951e 100644 --- a/tests/baselines/reference/typeName1.errors.txt +++ b/tests/baselines/reference/typeName1.errors.txt @@ -1,31 +1,19 @@ tests/cases/compiler/typeName1.ts(9,5): error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. - Property 'f' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(10,5): error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; }'. - Property 'f' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(11,5): error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; }'. tests/cases/compiler/typeName1.ts(12,5): error TS2322: Type 'number' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. - Property 'x' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(13,5): error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. - Property 'x' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. - Property 'z' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(15,5): error TS2322: Type 'number' is not assignable to type '(s: string) => boolean'. tests/cases/compiler/typeName1.ts(16,5): error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. - Property 'z' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(16,10): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. tests/cases/compiler/typeName1.ts(17,5): error TS2322: Type 'number' is not assignable to type 'I'. - Property 'k' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(18,5): error TS2322: Type 'number' is not assignable to type 'I[][][][]'. - Property 'length' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(19,5): error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; }[][]'. - Property 'length' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(20,5): error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. - Property 'length' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(20,50): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. tests/cases/compiler/typeName1.ts(21,5): error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. - Property 'x' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(22,5): error TS2322: Type 'number' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. - Property 'f' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not assignable to type 'number'. @@ -41,61 +29,49 @@ tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not as var x1:{ f(s:string):number;f(n:number):string; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. -!!! error TS2322: Property 'f' is missing in type 'Number'. var x2:{ f(s:string):number; } =3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; }'. -!!! error TS2322: Property 'f' is missing in type 'Number'. var x3:{ (s:string):number;(n:number):string; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; }'. var x4:{ x;y;z:number;f(n:number):string;f(s:string):number; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. -!!! error TS2322: Property 'x' is missing in type 'Number'. var x5:{ (s:string):number;(n:number):string;x;y;z:number;f(n:number):string;f(s:string):number; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. -!!! error TS2322: Property 'x' is missing in type 'Number'. var x6:{ z:number;f:{(n:number):string;(s:string):number;}; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. -!!! error TS2322: Property 'z' is missing in type 'Number'. var x7:(s:string)=>boolean=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '(s: string) => boolean'. var x8:{ z:I;[s:string]:{ x; y; };[n:number]:{x; y;};():boolean; }=3; ~~ !!! error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. -!!! error TS2322: Property 'z' is missing in type 'Number'. ~~~~ !!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. var x9:I=3; ~~ !!! error TS2322: Type 'number' is not assignable to type 'I'. -!!! error TS2322: Property 'k' is missing in type 'Number'. var x10:I[][][][]=3; ~~~ !!! error TS2322: Type 'number' is not assignable to type 'I[][][][]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. var x11:{z:I;x:boolean;}[][]=3; ~~~ !!! error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; }[][]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. var x12:{z:I;x:boolean;y:(s:string)=>boolean;w:{ z:I;[s:string]:{ x; y; };[n:number]:{x; y;};():boolean; };}[][]=3; ~~~ !!! error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. -!!! error TS2322: Property 'length' is missing in type 'Number'. ~~~~ !!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. var x13:{ new(): number; new(n:number):number; x: string; w: {y: number;}; (): {}; } = 3; ~~~ !!! error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. -!!! error TS2322: Property 'x' is missing in type 'Number'. var x14:{ f(x:number):boolean; p; q; ():string; }=3; ~~~ !!! error TS2322: Type 'number' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. -!!! error TS2322: Property 'f' is missing in type 'Number'. var x15:number=C; ~~~ !!! error TS2322: Type 'typeof C' is not assignable to type 'number'. diff --git a/tests/baselines/reference/typeOfOnTypeArg.errors.txt b/tests/baselines/reference/typeOfOnTypeArg.errors.txt index 8562b7f134..46b48983f2 100644 --- a/tests/baselines/reference/typeOfOnTypeArg.errors.txt +++ b/tests/baselines/reference/typeOfOnTypeArg.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/typeOfOnTypeArg.ts(7,6): error TS2345: Argument of type 'number' is not assignable to parameter of type '{ '': number; }'. - Property '''' is missing in type 'Number'. ==== tests/cases/compiler/typeOfOnTypeArg.ts (1 errors) ==== @@ -12,5 +11,4 @@ tests/cases/compiler/typeOfOnTypeArg.ts(7,6): error TS2345: Argument of type 'nu fill(32); ~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type '{ '': number; }'. -!!! error TS2345: Property '''' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt index 282e942e0f..0e148cb568 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt @@ -10,7 +10,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(18,10): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. Types of property 'length' are incompatible. Type 'number' is not assignable to type 'any[]'. - Property 'length' is missing in type 'Number'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts (6 errors) ==== @@ -49,5 +48,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy ~~~~ !!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. !!! error TS2345: Types of property 'length' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'any[]'. -!!! error TS2345: Property 'length' is missing in type 'Number'. \ No newline at end of file +!!! error TS2345: Type 'number' is not assignable to type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/undefinedTypeAssignment1.errors.txt b/tests/baselines/reference/undefinedTypeAssignment1.errors.txt index b8dd74a58a..61021a463a 100644 --- a/tests/baselines/reference/undefinedTypeAssignment1.errors.txt +++ b/tests/baselines/reference/undefinedTypeAssignment1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/undefinedTypeAssignment1.ts(1,1): error TS2397: Declaration name conflicts with built-in global identifier 'undefined'. +tests/cases/compiler/undefinedTypeAssignment1.ts(1,6): 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; diff --git a/tests/baselines/reference/unqualifiedCallToClassStatic1.errors.txt b/tests/baselines/reference/unqualifiedCallToClassStatic1.errors.txt index af9edd115e..4152c182d4 100644 --- a/tests/baselines/reference/unqualifiedCallToClassStatic1.errors.txt +++ b/tests/baselines/reference/unqualifiedCallToClassStatic1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unqualifiedCallToClassStatic1.ts(4,3): error TS2304: Cannot find name 'foo'. +tests/cases/compiler/unqualifiedCallToClassStatic1.ts(4,3): error TS2662: Cannot find name 'foo'. Did you mean the static member 'Vector.foo'? ==== tests/cases/compiler/unqualifiedCallToClassStatic1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unqualifiedCallToClassStatic1.ts(4,3): error TS2304: Cannot // 'foo' cannot be called in an unqualified manner. foo(); ~~~ -!!! error TS2304: Cannot find name 'foo'. +!!! error TS2662: Cannot find name 'foo'. Did you mean the static member 'Vector.foo'? } } \ No newline at end of file diff --git a/tests/baselines/reference/wrappedRecursiveGenericType.errors.txt b/tests/baselines/reference/wrappedRecursiveGenericType.errors.txt index 5afc7361a2..da97e05713 100644 --- a/tests/baselines/reference/wrappedRecursiveGenericType.errors.txt +++ b/tests/baselines/reference/wrappedRecursiveGenericType.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/wrappedRecursiveGenericType.ts(13,1): error TS2322: Type 'number' is not assignable to type 'X'. - Property 'e' is missing in type 'Number'. tests/cases/compiler/wrappedRecursiveGenericType.ts(14,1): error TS2322: Type 'number' is not assignable to type 'X'. @@ -19,7 +18,6 @@ tests/cases/compiler/wrappedRecursiveGenericType.ts(14,1): error TS2322: Type 'n x.a.b.val = 5; // val -> X (This should be an error) ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'X'. -!!! error TS2322: Property 'e' is missing in type 'Number'. x.a.b.a.val = 5; // val -> X (This should be an error) ~~~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'X'. \ No newline at end of file diff --git a/tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts b/tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts new file mode 100644 index 0000000000..cdca697f13 --- /dev/null +++ b/tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts @@ -0,0 +1,7 @@ +class C { + static foo: string; + + bar() { + let k = foo; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts b/tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts new file mode 100644 index 0000000000..654ae39aac --- /dev/null +++ b/tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts @@ -0,0 +1,7 @@ +class C { + foo: string; + + static bar() { + let k = foo; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/capturedLetConstInLoop11.ts b/tests/cases/compiler/capturedLetConstInLoop11.ts new file mode 100644 index 0000000000..bda0cec9d6 --- /dev/null +++ b/tests/cases/compiler/capturedLetConstInLoop11.ts @@ -0,0 +1,13 @@ +for (;;) { + let x = 1; + () => x; +} + +function foo() { + for (;;) { + const a = 0; + switch(a) { + case 0: return () => a; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/capturedLetConstInLoop11_ES6.ts b/tests/cases/compiler/capturedLetConstInLoop11_ES6.ts new file mode 100644 index 0000000000..24005ed483 --- /dev/null +++ b/tests/cases/compiler/capturedLetConstInLoop11_ES6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +for (;;) { + let x = 1; + () => x; +} + +function foo() { + for (;;) { + const a = 0; + switch(a) { + case 0: return () => a; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_UnknownImport.ts b/tests/cases/compiler/declarationEmit_UnknownImport.ts new file mode 100644 index 0000000000..9f6344322b --- /dev/null +++ b/tests/cases/compiler/declarationEmit_UnknownImport.ts @@ -0,0 +1,6 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +import Foo = SomeNonExistingName +export {Foo} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_UnknownImport2.ts b/tests/cases/compiler/declarationEmit_UnknownImport2.ts new file mode 100644 index 0000000000..035d1d860c --- /dev/null +++ b/tests/cases/compiler/declarationEmit_UnknownImport2.ts @@ -0,0 +1,6 @@ +// @target: es5 +// @module: commonjs +// @declaration: true + +import Foo From './Foo'; // Syntax error +export default Foo \ No newline at end of file diff --git a/tests/cases/compiler/globalIsContextualKeyword.ts b/tests/cases/compiler/globalIsContextualKeyword.ts new file mode 100644 index 0000000000..ceae834a26 --- /dev/null +++ b/tests/cases/compiler/globalIsContextualKeyword.ts @@ -0,0 +1,16 @@ +function a() { + let global = 1; +} +function b() { + class global {} +} + +namespace global { +} + +function foo(global: number) { +} + +let obj = { + global: "123" +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationCollidingNamesInAugmentation1.ts b/tests/cases/compiler/moduleAugmentationCollidingNamesInAugmentation1.ts new file mode 100644 index 0000000000..7cbb78a333 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationCollidingNamesInAugmentation1.ts @@ -0,0 +1,33 @@ +// @module: amd +// @declaration: true + +// @filename: map1.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface I {x0} +} + +// @filename: map2.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface I {x1} +} + + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +// @filename: main.ts +import { Observable } from "./observable" +import "./map1"; +import "./map2"; + +let x: Observable; diff --git a/tests/cases/compiler/moduleAugmentationDeclarationEmit1.ts b/tests/cases/compiler/moduleAugmentationDeclarationEmit1.ts new file mode 100644 index 0000000000..460cdfc53b --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationDeclarationEmit1.ts @@ -0,0 +1,33 @@ +// @module: commonjs +// @declaration: true + +// @filename: map.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + let someValue: number; +} + + +// @filename: main.ts +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts b/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts new file mode 100644 index 0000000000..22cb439267 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts @@ -0,0 +1,35 @@ +// @module: commonjs +// @declaration: true + +// @filename: map.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + export let someValue: number; +} + + +// @filename: main.ts +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts b/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts new file mode 100644 index 0000000000..b4b286db50 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts @@ -0,0 +1,46 @@ +// @module: commonjs + +// @filename: x0.ts +export let a = 1; + +// @filename: x.ts + +namespace N1 { + export let x = 1; +} + +declare module "./observable" { + var x: number; + let y: number; + const z: number; + let {x1, y1, z0: {n}, z1: {arr: [el1, el2, el3]}}: {x1: number, y1: string, z0: {n: number}, z1: {arr: number[]} } + interface A { x } + namespace N { + export class C {} + } + class Cls {} + function foo(): number; + type T = number; + import * as all from "./x0"; + import {a} from "./x0"; + export * from "./x0"; + export {a} from "./x0"; +} + +declare module "./test" { + export = N1; +} +export {} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} +export var x = 1; + +// @filename: test.ts +export let b = 1; + +// @filename: main.ts +import { Observable } from "./observable" +import "./x"; diff --git a/tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts b/tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts new file mode 100644 index 0000000000..b8b144fcc1 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationExtendAmbientModule1.ts @@ -0,0 +1,34 @@ +// @module: commonjs + +// @filename: map.ts +import { Observable } from "observable" + +(Observable.prototype).map = function() { } + +declare module "observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +// @filename: observable.d.ts +declare module "observable" { + class Observable { + filter(pred: (e:T) => boolean): Observable; + } + namespace Observable { + let someValue: number; + } +} + +// @filename: main.ts + +/// +import { Observable } from "observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationExtendAmbientModule2.ts b/tests/cases/compiler/moduleAugmentationExtendAmbientModule2.ts new file mode 100644 index 0000000000..6e6614ce9f --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationExtendAmbientModule2.ts @@ -0,0 +1,37 @@ +// @module: commonjs +// @declaration: true + +// @filename: map.ts +import { Observable } from "observable" + +(Observable.prototype).map = function() { } + +declare module "observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +// @filename: observable.d.ts +declare module "observable" { + class Observable { + filter(pred: (e:T) => boolean): Observable; + } + namespace Observable { + export let someValue: number; + } +} + +// @filename: main.ts + +/// +import { Observable } from "observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationExtendFileModule1.ts b/tests/cases/compiler/moduleAugmentationExtendFileModule1.ts new file mode 100644 index 0000000000..f87757b487 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationExtendFileModule1.ts @@ -0,0 +1,32 @@ +// @module: commonjs + +// @filename: map.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: number; + } +} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + let someValue: number; +} + + +// @filename: main.ts +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationExtendFileModule2.ts b/tests/cases/compiler/moduleAugmentationExtendFileModule2.ts new file mode 100644 index 0000000000..454e514879 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationExtendFileModule2.ts @@ -0,0 +1,34 @@ +// @module: commonjs + +// @filename: map.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + namespace Observable { + let someAnotherValue: string; + } +} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +export namespace Observable { + export let someValue: number; +} + + +// @filename: main.ts +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); +let z1 = Observable.someValue.toFixed(); +let z2 = Observable.someAnotherValue.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationGlobal1.ts b/tests/cases/compiler/moduleAugmentationGlobal1.ts new file mode 100644 index 0000000000..bef373ff13 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal1.ts @@ -0,0 +1,18 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {x: number;} + +// @filename: f2.ts +import {A} from "./f1"; + +// change the shape of Array +declare global { + interface Array { + getA(): A; + } +} + +let x = [1]; +let y = x.getA().x; diff --git a/tests/cases/compiler/moduleAugmentationGlobal2.ts b/tests/cases/compiler/moduleAugmentationGlobal2.ts new file mode 100644 index 0000000000..5a5c44f110 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal2.ts @@ -0,0 +1,18 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {}; +// @filename: f2.ts + +// change the shape of Array +import {A} from "./f1"; + +declare global { + interface Array { + getCountAsString(): string; + } +} + +let x = [1]; +let y = x.getCountAsString().toLowerCase(); diff --git a/tests/cases/compiler/moduleAugmentationGlobal3.ts b/tests/cases/compiler/moduleAugmentationGlobal3.ts new file mode 100644 index 0000000000..5986b689c5 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal3.ts @@ -0,0 +1,21 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {}; +// @filename: f2.ts + +// change the shape of Array +import {A} from "./f1"; + +declare global { + interface Array { + getCountAsString(): string; + } +} + +// @filename: f3.ts +import "./f2"; + +let x = [1]; +let y = x.getCountAsString().toLowerCase(); diff --git a/tests/cases/compiler/moduleAugmentationGlobal4.ts b/tests/cases/compiler/moduleAugmentationGlobal4.ts new file mode 100644 index 0000000000..44ba2ba9c5 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal4.ts @@ -0,0 +1,18 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +declare global { + interface Something {x} +} +export {}; +// @filename: f2.ts + +declare global { + interface Something {y} +} +export {}; +// @filename: f3.ts +import "./f1"; +import "./f2"; + diff --git a/tests/cases/compiler/moduleAugmentationGlobal5.ts b/tests/cases/compiler/moduleAugmentationGlobal5.ts new file mode 100644 index 0000000000..6d2920fd55 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal5.ts @@ -0,0 +1,21 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.d.ts +declare module "A" { + global { + interface Something {x} + } +} +// @filename: f2.d.ts +declare module "B" { + global { + interface Something {y} + } +} +// @filename: f3.ts +/// +/// +import "A"; +import "B"; + diff --git a/tests/cases/compiler/moduleAugmentationGlobal6.ts b/tests/cases/compiler/moduleAugmentationGlobal6.ts new file mode 100644 index 0000000000..37e5e33725 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal6.ts @@ -0,0 +1,3 @@ +declare global { + interface Array { x } +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationGlobal6_1.ts b/tests/cases/compiler/moduleAugmentationGlobal6_1.ts new file mode 100644 index 0000000000..d255b7f831 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal6_1.ts @@ -0,0 +1,3 @@ +global { + interface Array { x } +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationGlobal7.ts b/tests/cases/compiler/moduleAugmentationGlobal7.ts new file mode 100644 index 0000000000..66dd41c8bc --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal7.ts @@ -0,0 +1,5 @@ +namespace A { + declare global { + interface Array { x } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationGlobal7_1.ts b/tests/cases/compiler/moduleAugmentationGlobal7_1.ts new file mode 100644 index 0000000000..b7d99dfd41 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal7_1.ts @@ -0,0 +1,5 @@ +namespace A { + global { + interface Array { x } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationGlobal8.ts b/tests/cases/compiler/moduleAugmentationGlobal8.ts new file mode 100644 index 0000000000..e28b07d6bf --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal8.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @module: amd +namespace A { + declare global { + interface Array { x } + } +} +export {} diff --git a/tests/cases/compiler/moduleAugmentationGlobal8_1.ts b/tests/cases/compiler/moduleAugmentationGlobal8_1.ts new file mode 100644 index 0000000000..9031e4742b --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationGlobal8_1.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @module: amd +namespace A { + global { + interface Array { x } + } +} +export {} diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts new file mode 100644 index 0000000000..165057cf02 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts @@ -0,0 +1,28 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } +declare module "./f1" { + interface A { + foo(): B; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts new file mode 100644 index 0000000000..8e76475c40 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a } + export interface Cls { a } +} + +declare module "./f1" { + import {B} from "./f2"; + export {B} from "./f2"; + import I = N.Ifc; + import C = N.Cls; + // should have explicit export + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts new file mode 100644 index 0000000000..ea1d5e435d --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts @@ -0,0 +1,38 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a } + export interface Cls { a } +} + +declare module "./f1" { + import {B} from "./f2"; + import I = N.Ifc; + import C = N.Cls; + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts new file mode 100644 index 0000000000..3f3b9e1940 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts @@ -0,0 +1,39 @@ +// @module: commonjs + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts new file mode 100644 index 0000000000..8dbff8f7cc --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts new file mode 100644 index 0000000000..e9e216cbbb --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @declaration: true + +// @filename: f1.ts +export class A {} + +// @filename: f2.ts +export class B { + n: number; +} + +// @filename: f3.ts +import {A} from "./f1"; +import {B} from "./f2"; + +A.prototype.foo = function () { return undefined; } + +export namespace N { + export interface Ifc { a: number; } + export interface Cls { b: number; } +} +import I = N.Ifc; +import C = N.Cls; + +declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } +} + +// @filename: f4.ts +import {A} from "./f1"; +import "./f3"; + +let a: A; +let b = a.foo().n; +let c = a.bar().a; +let d = a.baz().b; \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationInAmbientModule1.ts b/tests/cases/compiler/moduleAugmentationInAmbientModule1.ts new file mode 100644 index 0000000000..07b7ccb99c --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationInAmbientModule1.ts @@ -0,0 +1,28 @@ +// @module: commonjs +// @declaration: true + +// @filename: O.d.ts + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +// @filename: main.ts +/// + +import {Observable} from "Observable"; +let x: Observable; +x.foo().x; diff --git a/tests/cases/compiler/moduleAugmentationInAmbientModule2.ts b/tests/cases/compiler/moduleAugmentationInAmbientModule2.ts new file mode 100644 index 0000000000..e297947857 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationInAmbientModule2.ts @@ -0,0 +1,28 @@ +// @module: commonjs +// @declaration: true; +// @filename: O.d.ts + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +// @filename: main.ts +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; diff --git a/tests/cases/compiler/moduleAugmentationInAmbientModule3.ts b/tests/cases/compiler/moduleAugmentationInAmbientModule3.ts new file mode 100644 index 0000000000..bc233294ed --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationInAmbientModule3.ts @@ -0,0 +1,38 @@ +// @module: commonjs +// @declaration: true; +// @filename: O.d.ts + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +declare module "Map" { + class Cls2 { x2: number } + module "Observable" { + interface Observable { + foo2(): Cls2; + } + } +} + +// @filename: main.ts +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; +x.foo2().x2; diff --git a/tests/cases/compiler/moduleAugmentationInAmbientModule4.ts b/tests/cases/compiler/moduleAugmentationInAmbientModule4.ts new file mode 100644 index 0000000000..59386ad3d0 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationInAmbientModule4.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @declaration: true; +// @filename: O.d.ts + +declare module "Observable" { + class Observable {} +} + +declare module "M" { + class Cls { x: number } +} + +declare module "Map" { + import { Cls } from "M"; + module "Observable" { + interface Observable { + foo(): Cls; + } + } +} + +// @filename: O2.d.ts +declare module "Map" { + class Cls2 { x2: number } + module "Observable" { + interface Observable { + foo2(): Cls2; + } + } +} + +// @filename: main.ts +/// +/// + +import {Observable} from "Observable"; +import "Map"; +let x: Observable; +x.foo().x; +x.foo2().x2; diff --git a/tests/cases/compiler/moduleAugmentationInAmbientModule5.ts b/tests/cases/compiler/moduleAugmentationInAmbientModule5.ts new file mode 100644 index 0000000000..5068ba396c --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationInAmbientModule5.ts @@ -0,0 +1,23 @@ +// @module: commonjs +// @declaration: true + +// @filename: array.d.ts +declare module "A" { + class A { x: number; } +} + +declare module "array" { + import {A} from "A"; + global { + interface Array { + getA(): A; + } + } +} + +// @filename: f.ts +/// +import "array"; + +let x = [1]; +let y = x.getA().x; diff --git a/tests/cases/compiler/moduleAugmentationNoNewNames.ts b/tests/cases/compiler/moduleAugmentationNoNewNames.ts new file mode 100644 index 0000000000..2ab82ba5f0 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationNoNewNames.ts @@ -0,0 +1,28 @@ +// @module: commonjs + +// @filename: map.ts +import { Observable } from "./observable" + +(Observable.prototype).map = function() { } + +declare module "./observable" { + interface Observable { + map(proj: (e:T) => U): Observable + } + class Bar {} + let y: number, z: string; + let {a: x, b: x1}: {a: number, b: number}; + module Z {} +} + +// @filename: observable.ts +export declare class Observable { + filter(pred: (e:T) => boolean): Observable; +} + +// @filename: main.ts +import { Observable } from "./observable" +import "./map"; + +let x: Observable; +let y = x.map(x => x + 1); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationsBundledOutput1.ts b/tests/cases/compiler/moduleAugmentationsBundledOutput1.ts new file mode 100644 index 0000000000..e633e355d8 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationsBundledOutput1.ts @@ -0,0 +1,57 @@ +// @target: es5 +// @module: amd +// @declaration: true +// @out: out.js + +// @filename: m1.ts +export class Cls { +} + +// @filename: m2.ts +import {Cls} from "./m1"; +(Cls.prototype).foo = function() { return 1; }; +(Cls.prototype).bar = function() { return "1"; }; + +declare module "./m1" { + interface Cls { + foo(): number; + } +} + +declare module "./m1" { + interface Cls { + bar(): string; + } +} + +// @filename: m3.ts +export class C1 { x: number } +export class C2 { x: string } + +// @filename: m4.ts +import {Cls} from "./m1"; +import {C1, C2} from "./m3"; +(Cls.prototype).baz1 = function() { return undefined }; +(Cls.prototype).baz2 = function() { return undefined }; + +declare module "./m1" { + interface Cls { + baz1(): C1; + } +} + +declare module "./m1" { + interface Cls { + baz2(): C2; + } +} + +// @filename: test.ts +import { Cls } from "./m1"; +import "m2"; +import "m4"; +let c: Cls; +c.foo().toExponential(); +c.bar().toLowerCase(); +c.baz1().x.toExponential(); +c.baz2().x.toLowerCase(); diff --git a/tests/cases/compiler/moduleAugmentationsImports1.ts b/tests/cases/compiler/moduleAugmentationsImports1.ts new file mode 100644 index 0000000000..ad029bdfc4 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationsImports1.ts @@ -0,0 +1,44 @@ +// @module: amd +// @declaration: true +// @out: f.js + +// @filename: a.ts +export class A {} + +// @filename: b.ts +export class B {x: number;} + +// @filename: c.d.ts +declare module "C" { + class Cls {y: string; } +} + +// @filename: d.ts +/// + +import {A} from "./a"; +import {B} from "./b"; +import {Cls} from "C"; + +A.prototype.getB = function () { return undefined; } +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getB(): B; + } +} + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +// @filename: main.ts +import {A} from "./a"; +import "d"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationsImports2.ts b/tests/cases/compiler/moduleAugmentationsImports2.ts new file mode 100644 index 0000000000..bf5b4b1cd1 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationsImports2.ts @@ -0,0 +1,49 @@ +// @module: amd +// @declaration: true +// @out: f.js + +// @filename: a.ts +export class A {} + +// @filename: b.ts +export class B {x: number;} + +// @filename: c.d.ts +declare module "C" { + class Cls {y: string; } +} + +// @filename: d.ts +/// + +import {A} from "./a"; +import {B} from "./b"; + +A.prototype.getB = function () { return undefined; } + +declare module "./a" { + interface A { + getB(): B; + } +} + +// @filename: e.ts +import {A} from "./a"; +import {Cls} from "C"; + +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +// @filename: main.ts +import {A} from "./a"; +import "d"; +import "e"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationsImports3.ts b/tests/cases/compiler/moduleAugmentationsImports3.ts new file mode 100644 index 0000000000..92cc6c73a3 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationsImports3.ts @@ -0,0 +1,48 @@ +// @module: amd +// @declaration: true +// @out: f.js + +// @filename: a.ts +export class A {} + +// @filename: b.ts +export class B {x: number;} + +// @filename: c.d.ts +declare module "C" { + class Cls {y: string; } +} + +// @filename: d.d.ts +declare module "D" { + import {A} from "a"; + import {B} from "b"; + module "a" { + interface A { + getB(): B; + } + } +} + +// @filename: e.ts +/// +import {A} from "./a"; +import {Cls} from "C"; + +A.prototype.getCls = function () { return undefined; } + +declare module "./a" { + interface A { + getCls(): Cls; + } +} + +// @filename: main.ts +/// +import {A} from "./a"; +import "D"; +import "e"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/compiler/moduleAugmentationsImports4.ts b/tests/cases/compiler/moduleAugmentationsImports4.ts new file mode 100644 index 0000000000..5e48954c09 --- /dev/null +++ b/tests/cases/compiler/moduleAugmentationsImports4.ts @@ -0,0 +1,49 @@ +// @module: amd +// @declaration: true +// @out: f.js + +// @filename: a.ts +export class A {} + +// @filename: b.ts +export class B {x: number;} + +// @filename: c.d.ts +declare module "C" { + class Cls {y: string; } +} + +// @filename: d.d.ts +declare module "D" { + import {A} from "a"; + import {B} from "b"; + module "a" { + interface A { + getB(): B; + } + } +} + +// @filename: e.d.ts +/// +declare module "E" { + import {A} from "a"; + import {Cls} from "C"; + + module "a" { + interface A { + getCls(): Cls; + } + } +} + +// @filename: main.ts +/// +/// +import {A} from "./a"; +import "D"; +import "E"; + +let a: A; +let b = a.getB().x.toFixed(); +let c = a.getCls().y.toLowerCase(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts new file mode 100644 index 0000000000..b0493db428 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts @@ -0,0 +1,21 @@ +let a: {}; +let b: {toString(): string}; +if (typeof a === "number") { + let c: number = a; +} +if (typeof a === "string") { + let c: string = a; +} +if (typeof a === "boolean") { + let c: boolean = a; +} + +if (typeof b === "number") { + let c: number = b; +} +if (typeof b === "string") { + let c: string = b; +} +if (typeof b === "boolean") { + let c: boolean = b; +} diff --git a/tests/cases/fourslash/formattingGlobalAugmentation1.ts b/tests/cases/fourslash/formattingGlobalAugmentation1.ts new file mode 100644 index 0000000000..0499100653 --- /dev/null +++ b/tests/cases/fourslash/formattingGlobalAugmentation1.ts @@ -0,0 +1,8 @@ +/// + +/////*1*/declare global { +////} + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("declare global {"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingGlobalAugmentation2.ts b/tests/cases/fourslash/formattingGlobalAugmentation2.ts new file mode 100644 index 0000000000..74f05e1a93 --- /dev/null +++ b/tests/cases/fourslash/formattingGlobalAugmentation2.ts @@ -0,0 +1,10 @@ +/// + +////declare module "A" { +/////*1*/ global { +//// } +////} + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs(" global {"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics8.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics8.ts index ba2d9faae8..562f42124a 100644 --- a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics8.ts +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics8.ts @@ -7,8 +7,8 @@ verify.getSemanticDiagnostics(`[ { "message": "'type aliases' can only be used in a .ts file.", - "start": 0, - "length": 11, + "start": 5, + "length": 1, "category": "error", "code": 8008 } diff --git a/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts b/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts new file mode 100644 index 0000000000..0c89de63a4 --- /dev/null +++ b/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts @@ -0,0 +1,9 @@ +/// + +// @Filename: file1.ts +//// class ClassA implements IInterface { +//// private /*1*/value: number; +//// } + +goTo.marker("1"); +verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInAugmentations1.ts b/tests/cases/fourslash/indentationInAugmentations1.ts new file mode 100644 index 0000000000..8a9b81fdd6 --- /dev/null +++ b/tests/cases/fourslash/indentationInAugmentations1.ts @@ -0,0 +1,9 @@ +/// + +// @module: amd +//// export {} +//// declare global {/*1*/ + +goTo.marker("1"); +edit.insertLine(""); +verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInAugmentations2.ts b/tests/cases/fourslash/indentationInAugmentations2.ts new file mode 100644 index 0000000000..df2400207b --- /dev/null +++ b/tests/cases/fourslash/indentationInAugmentations2.ts @@ -0,0 +1,8 @@ +/// + +//// declare module "A" { +//// global {/*1*/ + +goTo.marker("1"); +edit.insertLine(""); +verify.indentationIs(8); \ No newline at end of file