diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 44e6487c7c4..ea8fb3eea8d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -236,8 +236,9 @@ namespace ts { if (symbolFlags & SymbolFlags.Value) { const { valueDeclaration } = symbol; if (!valueDeclaration || + (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { - // other kinds of value declarations take precedence over modules + // other kinds of value declarations take precedence over modules and assignment declarations symbol.valueDeclaration = node; } } @@ -373,7 +374,8 @@ namespace ts { // prototype symbols like methods. symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } - else { + else if (!(includes & SymbolFlags.Variable && symbol.flags & SymbolFlags.JSContainer)) { + // JSContainers are allowed to merge with variables, no matter what other flags they have. if (isNamedDeclaration(node)) { node.name.parent = node; } @@ -733,6 +735,8 @@ namespace ts { return isNarrowingBinaryExpression(expr); case SyntaxKind.PrefixUnaryExpression: return (expr).operator === SyntaxKind.ExclamationToken && isNarrowingExpression((expr).operand); + case SyntaxKind.TypeOfExpression: + return isNarrowingExpression((expr).expression); } return false; } @@ -1729,10 +1733,6 @@ namespace ts { } } - function bindBlockScopedVariableDeclaration(node: Declaration) { - bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); - } - function delayedBindJSDocTypedefTag() { if (!delayedTypeAliases) { return; @@ -2078,8 +2078,8 @@ namespace ts { if (isInJavaScriptFile(node) && file.commonJsModuleIndicator && isModuleExportsPropertyAccessExpression(node as PropertyAccessExpression) && - !lookupSymbolForNameWorker(container, "module" as __String)) { - declareSymbol(container.locals!, /*parent*/ undefined, (node as PropertyAccessExpression).expression as Identifier, + !lookupSymbolForNameWorker(blockScopeContainer, "module" as __String)) { + declareSymbol(file.locals!, /*parent*/ undefined, (node as PropertyAccessExpression).expression as Identifier, SymbolFlags.FunctionScopedVariable | SymbolFlags.ModuleExports, SymbolFlags.FunctionScopedVariableExcludes); } break; @@ -2510,11 +2510,10 @@ namespace ts { function bindPropertyAssignment(name: EntityNameExpression, propertyAccess: PropertyAccessEntityNameExpression, isPrototypeProperty: boolean) { let namespaceSymbol = lookupSymbolForPropertyAccess(name); - const isToplevelNamespaceableInitializer = isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === SyntaxKind.SourceFile && - !!getJavascriptInitializer(getInitializerOfBinaryExpression(propertyAccess.parent), isPrototypeAccess(propertyAccess.parent.left)) + const isToplevel = isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === SyntaxKind.SourceFile : propertyAccess.parent.parent.kind === SyntaxKind.SourceFile; - if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & SymbolFlags.Namespace)) && isToplevelNamespaceableInitializer) { + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & SymbolFlags.Namespace)) && isToplevel) { // make symbols or add declarations for intermediate containers const flags = SymbolFlags.Module | SymbolFlags.JSContainer; const excludeFlags = SymbolFlags.ValueModuleExcludes & ~SymbolFlags.JSContainer; @@ -2537,12 +2536,10 @@ namespace ts { (namespaceSymbol.members || (namespaceSymbol.members = createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = createSymbolTable())); - // Declare the method/property - const jsContainerFlag = isToplevelNamespaceableInitializer ? SymbolFlags.JSContainer : 0; const isMethod = isFunctionLikeDeclaration(getAssignedJavascriptInitializer(propertyAccess)!); - const symbolFlags = (isMethod ? SymbolFlags.Method : SymbolFlags.Property) | jsContainerFlag; - const symbolExcludes = (isMethod ? SymbolFlags.MethodExcludes : SymbolFlags.PropertyExcludes) & ~jsContainerFlag; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + const includes = isMethod ? SymbolFlags.Method : SymbolFlags.Property; + const excludes = isMethod ? SymbolFlags.MethodExcludes : SymbolFlags.PropertyExcludes; + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | SymbolFlags.JSContainer, excludes & ~SymbolFlags.JSContainer); } /** @@ -2573,7 +2570,7 @@ namespace ts { return false; } - function getParentOfBinaryExpression(expr: BinaryExpression) { + function getParentOfBinaryExpression(expr: Node) { while (isBinaryExpression(expr.parent)) { expr = expr.parent; } @@ -2660,8 +2657,11 @@ namespace ts { } if (!isBindingPattern(node.name)) { + const isEnum = !!getJSDocEnumTag(node); + const enumFlags = (isEnum ? SymbolFlags.RegularEnum : SymbolFlags.None); + const enumExcludes = (isEnum ? SymbolFlags.RegularEnumExcludes : SymbolFlags.None); if (isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); + bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable | enumFlags, SymbolFlags.BlockScopedVariableExcludes | enumExcludes); } else if (isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -2676,7 +2676,7 @@ namespace ts { declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable | enumFlags, SymbolFlags.FunctionScopedVariableExcludes | enumExcludes); } } } @@ -2804,9 +2804,7 @@ namespace ts { // report error on class declarations node.kind === SyntaxKind.ClassDeclaration || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(node)) || - // report error on regular enums and const enums if preserveConstEnums is set - (isEnumDeclaration(node) && (!isEnumConst(node) || options.preserveConstEnums)); + (node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; @@ -2851,7 +2849,7 @@ namespace ts { // As opposed to a pure declaration like an `interface` function isExecutableStatement(s: Statement): boolean { // Don't remove statements that can validly be used before they appear. - return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && + return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) && // `var x;` may declare a variable used above !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.Let | NodeFlags.Const)) && s.declarationList.declarations.some(d => !d.initializer)); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce59899703b..ae0124616a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -837,8 +837,9 @@ namespace ts { target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || + isAssignmentDeclaration(target.valueDeclaration) || isEffectiveModuleDeclaration(target.valueDeclaration) && !isEffectiveModuleDeclaration(source.valueDeclaration))) { - // other kinds of value declarations take precedence over modules + // other kinds of value declarations take precedence over modules and assignment declarations target.valueDeclaration = source.valueDeclaration; } addRange(target.declarations, source.declarations); @@ -1210,23 +1211,17 @@ namespace ts { // local types not visible outside the function body : false; } - if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.Variable) { - // expression inside parameter will lookup as normal variable scope when targeting es2015+ - if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && !isParameterPropertyDeclaration(lastLocation) && result.valueDeclaration !== lastLocation) { - useResult = false; - } - else if (result.flags & SymbolFlags.FunctionScopedVariable) { - // parameters are visible only inside function body, parameter list and return type - // technically for parameter list case here we might mix parameters and variables declared in function, - // however it is detected separately when checking initializers of parameters - // to make sure that they reference no variables declared after them. - useResult = + if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.FunctionScopedVariable) { + // parameters are visible only inside function body, parameter list and return type + // technically for parameter list case here we might mix parameters and variables declared in function, + // however it is detected separately when checking initializers of parameters + // to make sure that they reference no variables declared after them. + useResult = lastLocation.kind === SyntaxKind.Parameter || ( lastLocation === (location).type && !!findAncestor(result.valueDeclaration, isParameter) ); - } } } else if (location.kind === SyntaxKind.ConditionalType) { @@ -1708,6 +1703,9 @@ namespace ts { } else { Debug.assert(!!(result.flags & SymbolFlags.ConstEnum)); + if (compilerOptions.preserveConstEnums) { + diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName); + } } if (diagnosticMessage) { @@ -2145,7 +2143,7 @@ namespace ts { } } - function getJSSpecialAssignmentLocation(node: TypeReferenceNode): Declaration | undefined { + function getJSSpecialAssignmentLocation(node: TypeReferenceNode): Node | undefined { const typeAlias = findAncestor(node, node => !(isJSDocNode(node) || node.flags & NodeFlags.JSDoc) ? "quit" : isJSDocTypeAlias(node)); if (typeAlias) { return; @@ -2154,8 +2152,20 @@ namespace ts { if (isExpressionStatement(host) && isBinaryExpression(host.expression) && getSpecialPropertyAssignmentKind(host.expression) === SpecialPropertyAssignmentKind.PrototypeProperty) { + // X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration const symbol = getSymbolOfNode(host.expression.left); - return symbol && symbol.parent!.valueDeclaration; + if (symbol) { + return getDeclarationOfJSPrototypeContainer(symbol); + } + } + if ((isObjectLiteralMethod(host) || isPropertyAssignment(host)) && + isBinaryExpression(host.parent.parent) && + getSpecialPropertyAssignmentKind(host.parent.parent) === SpecialPropertyAssignmentKind.Prototype) { + // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration + const symbol = getSymbolOfNode(host.parent.parent.left); + if (symbol) { + return getDeclarationOfJSPrototypeContainer(symbol); + } } const sig = getHostSignatureFromJSDocHost(host); if (sig) { @@ -2164,6 +2174,14 @@ namespace ts { } } + function getDeclarationOfJSPrototypeContainer(symbol: Symbol) { + const decl = symbol.parent!.valueDeclaration; + const initializer = isAssignmentDeclaration(decl) ? getAssignedJavascriptInitializer(decl) : + hasOnlyExpressionInitializer(decl) ? getDeclaredJavascriptInitializer(decl) : + undefined; + return initializer || decl; + } + function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol | undefined { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0); } @@ -2257,7 +2275,7 @@ namespace ts { else if (!compilerOptions.resolveJsonModule && fileExtensionIs(moduleReference, Extension.Json) && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs && - getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS) { + hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } else { @@ -2269,14 +2287,17 @@ namespace ts { } function errorOnImplicitAnyModule(isError: boolean, errorNode: Node, { packageId, resolvedFileName }: ResolvedModuleFull, moduleReference: string): void { - const errorInfo = packageId - ? chainDiagnosticMessages( - /*details*/ undefined, - typesPackageExists(packageId.name) - ? Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1 - : Diagnostics.Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, - packageId.name, - mangleScopedPackageName(packageId.name)) + const errorInfo = !isExternalModuleNameRelative(moduleReference) && packageId + ? typesPackageExists(packageId.name) + ? chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1, + packageId.name, mangleScopedPackageName(packageId.name)) + : chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, + moduleReference, + mangleScopedPackageName(packageId.name)) : undefined; errorOrSuggestion(isError, errorNode, chainDiagnosticMessages( errorInfo, @@ -2733,7 +2754,11 @@ namespace ts { && symbolFromSymbolTable.escapedName !== InternalSymbolName.Default && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name - && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { + && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) + // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ + // See similar comment in `resolveName` for details + && (ignoreQualification || !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) + ) { const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { @@ -2849,7 +2874,18 @@ namespace ts { // we are going to see if c can be accessed in scope directly. // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible // It is accessible if the parent m is accessible because then m.c can be accessed through qualification - const parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible); + + let containers = getContainersOfSymbol(symbol, enclosingDeclaration); + // If we're trying to reference some object literal in, eg `var a = { x: 1 }`, the symbol for the literal, `__object`, is distinct + // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, + // we'd like to make that connection here - potentially causing us to paint the declararation's visibiility, and therefore the literal. + const firstDecl: Node = first(symbol.declarations); + if (!length(containers) && meaning & SymbolFlags.Value && firstDecl && isObjectLiteralExpression(firstDecl)) { + if (firstDecl.parent && isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { + containers = [getSymbolOfNode(firstDecl.parent)]; + } + } + const parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible); if (parentResult) { return parentResult; } @@ -3933,7 +3969,7 @@ namespace ts { // specifier preference const { moduleResolverHost } = context.tracker; const specifierCompilerOptions = isBundle ? { ...compilerOptions, baseUrl: moduleResolverHost.getCommonSourceDirectory() } : compilerOptions; - specifier = first(first(moduleSpecifiers.getModuleSpecifiers( + specifier = first(moduleSpecifiers.getModuleSpecifiers( symbol, specifierCompilerOptions, contextFile, @@ -3941,7 +3977,7 @@ namespace ts { host.getSourceFiles(), { importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" }, host.redirectTargetsMap, - ))); + )); links.specifierCache = links.specifierCache || createMap(); links.specifierCache.set(contextFile.path, specifier); } @@ -5097,7 +5133,14 @@ namespace ts { // Handle export default expressions if (isSourceFile(declaration)) { const jsonSourceFile = cast(declaration, isJsonSourceFile); - return jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; + if (!jsonSourceFile.statements.length) { + return emptyObjectType; + } + const type = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); + if (type.flags & TypeFlags.Object) { + return getRegularTypeOfObjectLiteral(type); + } + return type; } if (declaration.kind === SyntaxKind.ExportAssignment) { return checkExpression((declaration).expression); @@ -5864,9 +5907,9 @@ namespace ts { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { for (const member of (declaration).members) { - const memberType = getLiteralType(getEnumMemberValue(member)!, enumCount, getSymbolOfNode(member)); // TODO: GH#18217 + const memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member)!, enumCount, getSymbolOfNode(member))); // TODO: GH#18217 getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(memberType); + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); } } } @@ -8189,11 +8232,17 @@ namespace ts { return type; } + // JS are 'string' or 'number', not an enum type. + const enumTag = symbol.valueDeclaration && getJSDocEnumTag(symbol.valueDeclaration); + if (enumTag) { + return enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; + } + // Get type from reference to named type that cannot be generic (enum or type parameter) const res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & TypeFlags.TypeParameter ? getConstrainedTypeVariable(res, node) : res : + res.flags & TypeFlags.TypeParameter ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } @@ -8224,10 +8273,6 @@ namespace ts { // TODO: GH#18217 (should the `|| assignedType` be at a lower precedence?) return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType)!; } - const enumTag = getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag && enumTag.typeExpression) { - return getTypeFromTypeNode(enumTag.typeExpression); - } } function getTypeReferenceTypeWorker(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[] | undefined): Type | undefined { @@ -8696,10 +8741,7 @@ namespace ts { const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues); if (index < 0) { - if (!(flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous && - type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) { - typeSet.splice(~index, 0, type); - } + typeSet.splice(~index, 0, type); } } } @@ -8715,15 +8757,6 @@ namespace ts { return includes; } - function containsIdenticalType(types: ReadonlyArray, type: Type) { - for (const t of types) { - if (isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function isSubtypeOfAny(source: Type, targets: ReadonlyArray): boolean { for (const target of targets) { if (source !== target && isTypeSubtypeOf(source, target) && ( @@ -8904,10 +8937,7 @@ namespace ts { if (flags & TypeFlags.AnyOrUnknown) { if (type === wildcardType) includes |= TypeFlags.Wildcard; } - else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type) && - !(flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous && - type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && - containsIdenticalType(typeSet, type))) { + else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type)) { typeSet.push(type); } } @@ -9361,13 +9391,24 @@ namespace ts { const apparentObjectType = getApparentType(objectType); if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) { const propTypes: Type[] = []; + let wasMissingProp = false; for (const t of (indexType).types) { const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false, missingType); if (propType === missingType) { - return missingType; + if (!accessNode) { + // If there's no error node, we can immeditely stop, since error reporting is off + return missingType; + } + else { + // Otherwise we set a flag and return at the end of the loop so we still mark all errors + wasMissingProp = true; + } } propTypes.push(propType); } + if (wasMissingProp) { + return missingType; + } return getUnionType(propTypes); } return getPropertyTypeForIndexType(apparentObjectType, indexType, accessNode, /*cacheSymbol*/ true, missingType); @@ -10527,9 +10568,13 @@ namespace ts { * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. */ function checkTypeAssignableToAndOptionallyElaborate(source: Type, target: Type, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { - if (isTypeAssignableTo(source, target)) return true; - if (!elaborateError(expr, source, target)) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain); + } + + function checkTypeRelatedToAndOptionallyElaborate(source: Type, target: Type, relation: Map, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { + if (isTypeRelatedTo(source, target, relation)) return true; + if (!errorNode || !elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain); } return false; } @@ -11185,13 +11230,10 @@ namespace ts { } } - if (relation !== comparableRelation && - !(source.flags & TypeFlags.Union) && - !(target.flags & TypeFlags.Union) && - !isIntersectionConstituent && - source !== globalObjectType && + if (relation !== comparableRelation && !isIntersectionConstituent && + source.flags & (TypeFlags.Primitive | TypeFlags.Object | TypeFlags.Intersection) && source !== globalObjectType && + target.flags & (TypeFlags.Object | TypeFlags.Intersection) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - isWeakType(target) && !hasCommonProperties(source, target)) { if (reportErrors) { const calls = getSignaturesOfType(source, SignatureKind.Call); @@ -11323,7 +11365,7 @@ namespace ts { return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } for (const prop of getPropertiesOfObjectType(source)) { - if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // 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 @@ -11367,6 +11409,10 @@ namespace ts { return false; } + function isPropertyFromSpread(prop: Symbol, container: Symbol) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + } + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; const sourceTypes = source.types; @@ -11395,7 +11441,8 @@ namespace ts { const bestMatchingType = findMatchingDiscriminantType(source, target) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || - findBestTypeForObjectLiteral(source, target); + findBestTypeForObjectLiteral(source, target) || + findBestTypeForInvokable(source, target); isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } @@ -11426,6 +11473,15 @@ namespace ts { } } + function findBestTypeForInvokable(source: Type, unionTarget: UnionOrIntersectionType) { + let signatureKind = SignatureKind.Call; + const hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || + (signatureKind = SignatureKind.Construct, getSignaturesOfType(source, signatureKind).length > 0); + if (hasSignatures) { + return find(unionTarget.types, t => getSignaturesOfType(t, signatureKind).length > 0); + } + } + // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) { let match: Type | undefined; @@ -11832,6 +11888,9 @@ namespace ts { errorInfo = saveErrorInfo; } } + else if (isTupleType(source) && (isArrayType(target) || isReadonlyArrayType(target)) || isArrayType(source) && isReadonlyArrayType(target)) { + return isRelatedTo(getIndexTypeOfType(source, IndexKind.Number) || anyType, getIndexTypeOfType(target, IndexKind.Number) || anyType, reportErrors); + } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates @@ -12011,34 +12070,6 @@ namespace ts { return result; } - /** - * A type is 'weak' if it is an object type with at least one optional property - * and no required properties, call/construct signatures or index signatures - */ - function isWeakType(type: Type): boolean { - if (type.flags & TypeFlags.Object) { - const resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && - !resolved.stringIndexInfo && !resolved.numberIndexInfo && - resolved.properties.length > 0 && - every(resolved.properties, p => !!(p.flags & SymbolFlags.Optional)); - } - if (type.flags & TypeFlags.Intersection) { - return every((type).types, isWeakType); - } - return false; - } - - function hasCommonProperties(source: Type, target: Type) { - const isComparingJsxAttributes = !!(getObjectFlags(source) & ObjectFlags.JsxAttributes); - for (const prop of getPropertiesOfType(source)) { - if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { - return true; - } - } - return false; - } - function propertiesIdenticalTo(source: Type, target: Type): Ternary { if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) { return Ternary.False; @@ -12283,6 +12314,34 @@ namespace ts { } } + /** + * A type is 'weak' if it is an object type with at least one optional property + * and no required properties, call/construct signatures or index signatures + */ + function isWeakType(type: Type): boolean { + if (type.flags & TypeFlags.Object) { + const resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && + !resolved.stringIndexInfo && !resolved.numberIndexInfo && + resolved.properties.length > 0 && + every(resolved.properties, p => !!(p.flags & SymbolFlags.Optional)); + } + if (type.flags & TypeFlags.Intersection) { + return every((type).types, isWeakType); + } + return false; + } + + function hasCommonProperties(source: Type, target: Type) { + const isComparingJsxAttributes = !!(getObjectFlags(source) & ObjectFlags.JsxAttributes); + for (const prop of getPropertiesOfType(source)) { + if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + return true; + } + } + return false; + } + // Return a type reference where the source type parameter is replaced with the target marker // type, and flag the result as a marker type reference. function getMarkerTypeReference(type: GenericType, source: TypeParameter, target: Type) { @@ -12677,7 +12736,7 @@ namespace ts { } function getWidenedLiteralType(type: Type): Type { - return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type) : + return type.flags & TypeFlags.EnumLiteral && type.flags & TypeFlags.FreshLiteral ? getBaseTypeOfEnumLiteralType(type) : type.flags & TypeFlags.StringLiteral && type.flags & TypeFlags.FreshLiteral ? stringType : type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : @@ -13065,6 +13124,14 @@ namespace ts { const paramCount = targetRestType ? Math.min(targetCount - 1, sourceCount) : sourceRestType ? targetCount : Math.min(sourceCount, targetCount); + + const sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + const targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + callback(sourceThisType, targetThisType); + } + } for (let i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } @@ -13658,7 +13725,7 @@ namespace ts { return inference.priority! & InferencePriority.PriorityImpliesCombination ? getIntersectionType(inference.contraCandidates!) : getCommonSubtype(inference.contraCandidates!); } - function getCovariantInference(inference: InferenceInfo, context: InferenceContext, signature: Signature) { + function getCovariantInference(inference: InferenceInfo, signature: Signature) { // Extract all object literal types and replace them with a single widened and normalized type. const candidates = widenObjectLiteralCandidates(inference.candidates!); // We widen inferred literal types if @@ -13671,10 +13738,9 @@ namespace ts { const baseCandidates = primitiveConstraint ? sameMap(candidates, getRegularTypeOfLiteralType) : widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) : candidates; - // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if - // union types were requested or if all inferences were made from the return type position, infer a - // union type. Otherwise, infer a common supertype. - const unwidenedType = context.flags & InferenceFlags.InferUnionTypes || inference.priority! & InferencePriority.PriorityImpliesCombination ? + // If all inferences were made from a position that implies a combined result, infer a union type. + // Otherwise, infer a common supertype. + const unwidenedType = inference.priority! & InferencePriority.PriorityImpliesCombination ? getUnionType(baseCandidates, UnionReduction.Subtype) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -13694,7 +13760,7 @@ namespace ts { inference.contraCandidates = undefined; } if (inference.candidates) { - inferredType = getCovariantInference(inference, context, signature); + inferredType = getCovariantInference(inference, signature); } else if (context.flags & InferenceFlags.NoDefault) { // We use silentNeverType as the wildcard that signals no inferences. @@ -14226,6 +14292,23 @@ namespace ts { return links.switchTypes; } + // Get the types from all cases in a switch on `typeof`. An + // `undefined` element denotes an explicit `default` clause. + function getSwitchClauseTypeOfWitnesses(switchStatement: SwitchStatement): (string | undefined)[] { + const witnesses: (string | undefined)[] = []; + for (const clause of switchStatement.caseBlock.clauses) { + if (clause.kind === SyntaxKind.CaseClause) { + if (clause.expression.kind === SyntaxKind.StringLiteral) { + witnesses.push((clause.expression as StringLiteral).text); + continue; + } + return emptyArray; + } + witnesses.push(/*explicitDefaultStatement*/ undefined); + } + return witnesses; + } + function eachTypeContainedIn(source: Type, types: Type[]) { return source.flags & TypeFlags.Union ? !forEach((source).types, t => !contains(types, t)) : contains(types, source); } @@ -14648,6 +14731,9 @@ namespace ts { expr as PropertyAccessExpression | ElementAccessExpression, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); } + else if (expr.kind === SyntaxKind.TypeOfExpression && isMatchingReference(reference, (expr as TypeOfExpression).expression)) { + type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); + } return createFlowType(type, isIncomplete(flowType)); } @@ -14914,27 +15000,34 @@ namespace ts { if (type.flags & TypeFlags.Any && literal.text === "function") { return type; } - if (assumeTrue && !(type.flags & TypeFlags.Union)) { - // We narrow a non-union type to an exact primitive type if the non-union type - // is a supertype of that primitive type. For example, type 'any' can be narrowed - // to one of the primitive types. - const targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); - if (targetType) { - if (isTypeSubtypeOf(targetType, type)) { - return targetType; - } - if (type.flags & TypeFlags.Instantiable) { - const constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(targetType, constraint)) { - return getIntersectionType([type, targetType]); - } - } - } - } const facts = assumeTrue ? typeofEQFacts.get(literal.text) || TypeFacts.TypeofEQHostObject : typeofNEFacts.get(literal.text) || TypeFacts.TypeofNEHostObject; - return getTypeWithFacts(type, facts); + return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); + + function narrowTypeForTypeof(type: Type) { + if (assumeTrue && !(type.flags & TypeFlags.Union)) { + if (type.flags & TypeFlags.Unknown && literal.text === "object") { + return getUnionType([nonPrimitiveType, nullType]); + } + // We narrow a non-union type to an exact primitive type if the non-union type + // is a supertype of that primitive type. For example, type 'any' can be narrowed + // to one of the primitive types. + const targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return isTypeAny(type) ? targetType : getIntersectionType([type, targetType]); // Intersection to handle `string` being a subtype of `keyof T` + } + if (type.flags & TypeFlags.Instantiable) { + const constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } + } + } + return type; + } } function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) { @@ -14956,6 +15049,83 @@ namespace ts { return caseType.flags & TypeFlags.Never ? defaultType : getUnionType([caseType, defaultType]); } + function narrowBySwitchOnTypeOf(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): Type { + const switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); + if (!switchWitnesses.length) { + return type; + } + // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause + const defaultCaseLocation = findIndex(switchWitnesses, elem => elem === undefined); + const hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd); + let clauseWitnesses: string[]; + let switchFacts: TypeFacts; + if (defaultCaseLocation > -1) { + // We no longer need the undefined denoting an + // explicit default case. Remove the undefined and + // fix-up clauseStart and clauseEnd. This means + // that we don't have to worry about undefined + // in the witness array. + const witnesses = switchWitnesses.filter(witness => witness !== undefined); + // The adjust clause start and end after removing the `default` statement. + const fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; + const fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; + clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); + switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause); + } + else { + clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); + switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); + } + /* + The implied type is the raw type suggested by a + value being caught in this clause. + + When the clause contains a default case we ignore + the implied type and try to narrow using any facts + we can learn: see `switchFacts`. + + Example: + switch (typeof x) { + case 'number': + case 'string': break; + default: break; + case 'number': + case 'boolean': break + } + + In the first clause (case `number` and `string`) the + implied type is number | string. + + In the default clause we de not compute an implied type. + + In the third clause (case `number` and `boolean`) + the naive implied type is number | boolean, however + we use the type facts to narrow the implied type to + boolean. We know that number cannot be selected + because it is caught in the first clause. + */ + if (!(hasDefaultClause || (type.flags & TypeFlags.Union))) { + let impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(text => typeofTypesByName.get(text) || neverType)), switchFacts); + if (impliedType.flags & TypeFlags.Union) { + impliedType = getAssignmentReducedType(impliedType as UnionType, getBaseConstraintOfType(type) || type); + } + if (!(impliedType.flags & TypeFlags.Never)) { + if (isTypeSubtypeOf(impliedType, type)) { + return impliedType; + } + if (type.flags & TypeFlags.Instantiable) { + const constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(impliedType, constraint)) { + return getIntersectionType([type, impliedType]); + } + } + } + } + return hasDefaultClause ? + filterType(type, t => (getTypeFacts(t) & switchFacts) === switchFacts) : + getTypeWithFacts(type, switchFacts); + } + function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { const left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { @@ -16092,7 +16262,14 @@ namespace ts { const { left, operatorToken, right } = binaryExpression; switch (operatorToken.kind) { case SyntaxKind.EqualsToken: - return node === right && isContextSensitiveAssignment(binaryExpression) ? getTypeOfExpression(left) : undefined; + if (node !== right) { + return undefined; + } + const contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression); + if (!contextSensitive) { + return undefined; + } + return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; case SyntaxKind.BarBarToken: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, @@ -16110,7 +16287,7 @@ namespace ts { // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for special property assignments unless there is a type tag on the assignment, to avoid circularity from checking the right operand. - function isContextSensitiveAssignment(binaryExpression: BinaryExpression): boolean { + function getIsContextSensitiveAssignmentOrContextType(binaryExpression: BinaryExpression): boolean | Type { const kind = getSpecialPropertyAssignmentKind(binaryExpression); switch (kind) { case SpecialPropertyAssignmentKind.None: @@ -16129,19 +16306,44 @@ namespace ts { if (!decl) { return false; } - if (isInJavaScriptFile(decl)) { - return !!getJSDocTypeTag(decl); + const lhs = binaryExpression.left as PropertyAccessExpression; + const overallAnnotation = getEffectiveTypeAnnotationNode(decl); + if (overallAnnotation) { + return getTypeFromTypeNode(overallAnnotation); } - else if (isIdentifier((binaryExpression.left as PropertyAccessExpression).expression)) { - const id = (binaryExpression.left as PropertyAccessExpression).expression as Identifier; + else if (isIdentifier(lhs.expression)) { + const id = lhs.expression; const parentSymbol = resolveName(id, id.escapedText, SymbolFlags.Value, undefined, id.escapedText, /*isUse*/ true); - return !isFunctionSymbol(parentSymbol); + if (parentSymbol) { + const annotated = getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated) { + const type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); + return type || false; + } + return false; + } } - return true; + return !isInJavaScriptFile(decl); } - case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.ModuleExports: - return !binaryExpression.symbol || binaryExpression.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.symbol.valueDeclaration); + case SpecialPropertyAssignmentKind.ThisProperty: + if (!binaryExpression.symbol) return true; + if (binaryExpression.symbol.valueDeclaration) { + const annotated = getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration); + if (annotated) { + const type = getTypeFromTypeNode(annotated); + if (type) { + return type; + } + } + } + if (kind === SpecialPropertyAssignmentKind.ModuleExports) return false; + const thisAccess = binaryExpression.left as PropertyAccessExpression; + if (!isObjectLiteralMethod(getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { + return false; + } + const thisType = checkThisExpression(thisAccess.expression); + return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; default: return Debug.assertNever(kind); } @@ -17902,7 +18104,7 @@ namespace ts { // Referencing abstract properties within their own constructors is not allowed if ((flags & ModifierFlags.Abstract) && isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)!); - if (declaringClassDeclaration && isNodeWithinConstructorOfClass(node, declaringClassDeclaration)) { + if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node, declaringClassDeclaration)) { error(errorNode, Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), getTextOfIdentifierOrLiteral(declaringClassDeclaration.name!)); // TODO: GH#18217 return false; } @@ -18416,6 +18618,13 @@ namespace ts { error(indexExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } + if (isTupleType(objectType) && !objectType.target.hasRestElement && isNumericLiteral(indexExpression)) { + const index = +indexExpression.text; + const maximumIndex = length(objectType.target.typeParameters); + if (index >= maximumIndex) { + error(indexExpression, Diagnostics.Index_0_is_out_of_bounds_in_tuple_of_length_1, index, maximumIndex); + } + } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType, node), node); } @@ -18633,7 +18842,7 @@ namespace ts { // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper?: TypeMapper, compareTypes?: TypeComparer): Signature { - const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.InferUnionTypes, compareTypes); + const context = createInferenceContext(signature.typeParameters!, signature, InferenceFlags.None, compareTypes); const sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; forEachMatchingParameterType(sourceSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -18859,7 +19068,7 @@ namespace ts { // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). const checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, reportErrors ? arg : undefined, headMessage)) { + if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage)) { return false; } } @@ -19154,14 +19363,17 @@ namespace ts { else if (candidateForTypeArgumentError) { checkTypeArguments(candidateForTypeArgumentError, (node as CallExpression | TaggedTemplateExpression).typeArguments!, /*reportErrors*/ true, fallbackError); } - else if (typeArguments && every(signatures, sig => typeArguments!.length < getMinTypeArgumentCount(sig.typeParameters) || typeArguments!.length > length(sig.typeParameters))) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); - } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signatures, args)); - } - else if (fallbackError) { - diagnostics.add(createDiagnosticForNode(node, fallbackError)); + else { + const signaturesWithCorrectTypeArgumentArity = filter(signatures, s => hasCorrectTypeArgumentArity(s, typeArguments)); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments!)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(createDiagnosticForNode(node, fallbackError)); + } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -20467,10 +20679,62 @@ namespace ts { : Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } + /** + * Collect the TypeFacts learned from a typeof switch with + * total clauses `witnesses`, and the active clause ranging + * from `start` to `end`. Parameter `hasDefault` denotes + * whether the active clause contains a default clause. + */ + function getFactsFromTypeofSwitch(start: number, end: number, witnesses: string[], hasDefault: boolean): TypeFacts { + let facts: TypeFacts = TypeFacts.None; + // When in the default we only collect inequality facts + // because default is 'in theory' a set of infinite + // equalities. + if (hasDefault) { + // Value is not equal to any types after the active clause. + for (let i = end; i < witnesses.length; i++) { + facts |= typeofNEFacts.get(witnesses[i]) || TypeFacts.TypeofNEHostObject; + } + // Remove inequalities for types that appear in the + // active clause because they appear before other + // types collected so far. + for (let i = start; i < end; i++) { + facts &= ~(typeofNEFacts.get(witnesses[i]) || 0); + } + // Add inequalities for types before the active clause unconditionally. + for (let i = 0; i < start; i++) { + facts |= typeofNEFacts.get(witnesses[i]) || TypeFacts.TypeofNEHostObject; + } + } + // When in an active clause without default the set of + // equalities is finite. + else { + // Add equalities for all types in the active clause. + for (let i = start; i < end; i++) { + facts |= typeofEQFacts.get(witnesses[i]) || TypeFacts.TypeofEQHostObject; + } + // Remove equalities for types that appear before the + // active clause. + for (let i = 0; i < start; i++) { + facts &= ~(typeofEQFacts.get(witnesses[i]) || 0); + } + } + return facts; + } + function isExhaustiveSwitchStatement(node: SwitchStatement): boolean { if (!node.possiblyExhaustive) { return false; } + if (node.expression.kind === SyntaxKind.TypeOfExpression) { + const operandType = getTypeOfExpression((node.expression as TypeOfExpression).expression); + // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. + const witnesses = getSwitchClauseTypeOfWitnesses(node); + // notEqualFacts states that the type of the switched value is not equal to every type in the switch. + const notEqualFacts = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); + const type = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type, t => (getTypeFacts(t) & notEqualFacts) === notEqualFacts).flags & TypeFlags.Never); + } const type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { return false; @@ -21629,7 +21893,7 @@ namespace ts { const initializer = getEffectiveInitializer(declaration)!; const type = getTypeOfExpression(initializer, /*cache*/ true); const widened = getCombinedNodeFlags(declaration) & NodeFlags.Const || - (getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration)) || + isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (isInJavaScriptFile(declaration)) { if (widened.flags & TypeFlags.Nullable) { @@ -22902,6 +23166,12 @@ namespace ts { } } + const enum DeclarationSpaces { + None = 0, + ExportValue = 1 << 0, + ExportType = 1 << 1, + ExportNamespace = 1 << 2, + } function checkExportsOnMergedDeclarations(node: Node): void { if (!produceDiagnostics) { return; @@ -22966,12 +23236,6 @@ namespace ts { } } - const enum DeclarationSpaces { - None = 0, - ExportValue = 1 << 0, - ExportType = 1 << 1, - ExportNamespace = 1 << 2, - } function getDeclarationSpaces(decl: Declaration): DeclarationSpaces { let d = decl as Node; switch (d.kind) { @@ -26347,7 +26611,7 @@ namespace ts { function checkExportSpecifier(node: ExportSpecifier) { checkAliasSymbol(node); - if (compilerOptions.declaration) { + if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); } if (!node.parent.parent.moduleSpecifier) { @@ -26388,7 +26652,7 @@ namespace ts { if (node.expression.kind === SyntaxKind.Identifier) { markExportAsReferenced(node); - if (compilerOptions.declaration) { + if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression as Identifier, /*setVisibility*/ true); } } @@ -27026,9 +27290,9 @@ namespace ts { return result; } - function isNodeWithinConstructorOfClass(node: Node, classDeclaration: ClassLikeDeclaration) { - return findAncestor(node, element => { - if (isConstructorDeclaration(element) && nodeIsPresent(element.body) && element.parent === classDeclaration) { + function isNodeUsedDuringClassInitialization(node: Node, classDeclaration: ClassLikeDeclaration) { + return !!findAncestor(node, element => { + if ((isConstructorDeclaration(element) && nodeIsPresent(element.body) || isPropertyDeclaration(element)) && element.parent === classDeclaration) { return true; } else if (element === classDeclaration || isFunctionLikeDeclaration(element)) { @@ -27335,12 +27599,10 @@ namespace ts { } if (isPartOfTypeNode(node)) { - let typeFromTypeNode = getTypeFromTypeNode(node); + const typeFromTypeNode = getTypeFromTypeNode(node); if (isExpressionWithTypeArgumentsInClassImplementsClause(node)) { - const containingClass = getContainingClass(node)!; - const classType = getTypeOfNode(containingClass) as InterfaceType; - typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + return getTypeWithThisArgument(typeFromTypeNode, getTypeOfClassContainingHeritageClause(node).thisType); } return typeFromTypeNode; @@ -27353,8 +27615,7 @@ namespace ts { if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - const classNode = getContainingClass(node)!; - const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; + const classType = getTypeOfClassContainingHeritageClause(node); const baseType = firstOrUndefined(getBaseTypes(classType)); return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType; } @@ -27396,6 +27657,10 @@ namespace ts { return errorType; } + function getTypeOfClassContainingHeritageClause(node: ExpressionWithTypeArguments): InterfaceType { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node.parent.parent)); + } + // Gets the type of object literal or array literal of destructuring assignment. // { a } from // for ( { a } of elems) { @@ -28002,20 +28267,21 @@ namespace ts { } function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { - if (isVariableDeclaration(node) && isVarConst(node)) { + if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral); } return false; } - function literalTypeToNode(type: LiteralType): Expression { - return createLiteral(type.value); + function literalTypeToNode(type: LiteralType, enclosing: Node): Expression { + const enumResult = type.flags & TypeFlags.EnumLiteral && nodeBuilder.symbolToExpression(type.symbol, SymbolFlags.Value, enclosing); + return enumResult || createLiteral(type.value); } function createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration) { const type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type); + return literalTypeToNode(type, node); } function createResolver(): EmitResolver { @@ -28730,11 +28996,40 @@ namespace ts { } } + function getNonSimpleParameters(parameters: ReadonlyArray): ReadonlyArray { + return filter(parameters, parameter => !!parameter.initializer || isBindingPattern(parameter.name) || isRestParameter(parameter)); + } + + function checkGrammarForUseStrictSimpleParameterList(node: FunctionLikeDeclaration): boolean { + if (languageVersion >= ScriptTarget.ES2016) { + const useStrictDirective = node.body && isBlock(node.body) && findUseStrictPrologue(node.body.statements); + if (useStrictDirective) { + const nonSimpleParameters = getNonSimpleParameters(node.parameters); + if (length(nonSimpleParameters)) { + forEach(nonSimpleParameters, parameter => { + addRelatedInfo( + error(parameter, Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), + createDiagnosticForNode(useStrictDirective, Diagnostics.use_strict_directive_used_here) + ); + }); + + const diagnostics = nonSimpleParameters.map((parameter, index) => ( + index === 0 ? createDiagnosticForNode(parameter, Diagnostics.Non_simple_parameter_declared_here) : createDiagnosticForNode(parameter, Diagnostics.and_here) + )) as [DiagnosticWithLocation, ...DiagnosticWithLocation[]]; + addRelatedInfo(error(useStrictDirective, Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list), ...diagnostics); + return true; + } + } + } + return false; + } + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration | MethodSignature): boolean { // Prevent cascading error by short-circuit const file = getSourceFileOfNode(node); return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || - checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); + checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) || + (isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node)); } function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { @@ -28941,10 +29236,14 @@ namespace ts { } } - function checkGrammarForInvalidQuestionMark(questionToken: Node | undefined, message: DiagnosticMessage): boolean { + function checkGrammarForInvalidQuestionMark(questionToken: QuestionToken | undefined, message: DiagnosticMessage): boolean { return !!questionToken && grammarErrorOnNode(questionToken, message); } + function checkGrammarForInvalidExclamationToken(exclamationToken: ExclamationToken | undefined, message: DiagnosticMessage): boolean { + return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); + } + function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) { const enum Flags { Property = 1, @@ -28989,8 +29288,10 @@ namespace ts { // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields let currentKind: Flags; switch (prop.kind) { - case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: + checkGrammarForInvalidExclamationToken(prop.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); + /* tslint:disable:no-switch-case-fall-through */ + case SyntaxKind.PropertyAssignment: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { @@ -29231,6 +29532,9 @@ namespace ts { else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } + else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) { + return true; + } else if (node.body === undefined) { return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{"); } @@ -29340,26 +29644,35 @@ namespace ts { (expr).operand.kind === SyntaxKind.NumericLiteral; } + function isSimpleLiteralEnumReference(expr: Expression) { + if ( + (isPropertyAccessExpression(expr) || (isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && + isEntityNameExpression(expr.expression) + ) return !!(checkExpressionCached(expr).flags & TypeFlags.EnumLiteral); + } + + function checkAmbientInitializer(node: VariableDeclaration | PropertyDeclaration | PropertySignature) { + if (node.initializer) { + const isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer)); + const isConstOrReadonly = isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node); + if (isConstOrReadonly && !node.type) { + if (isInvalidInitializer) { + return grammarErrorOnNode(node.initializer!, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + } + } + else { + return grammarErrorOnNode(node.initializer!, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + if (!isConstOrReadonly || isInvalidInitializer) { + return grammarErrorOnNode(node.initializer!, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + } + function checkGrammarVariableDeclaration(node: VariableDeclaration) { if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { if (node.flags & NodeFlags.Ambient) { - if (node.initializer) { - if (isVarConst(node) && !node.type) { - if (!isStringOrNumberLiteralExpression(node.initializer)) { - return grammarErrorOnNode(node.initializer, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); - } - } - else { - // Error on equals token which immediate precedes the initializer - const equalsTokenLength = "=".length; - return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - if (node.initializer && !(isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { - // Error on equals token which immediate precedes the initializer - const equalsTokenLength = "=".length; - return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } + checkAmbientInitializer(node); } else if (!node.initializer) { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { @@ -29552,8 +29865,8 @@ namespace ts { } } - if (node.flags & NodeFlags.Ambient && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + if (node.flags & NodeFlags.Ambient) { + checkAmbientInitializer(node); } if (isPropertyDeclaration(node) && node.exclamationToken && (!isClassLike(node.parent) || !node.type || node.initializer || diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f1dd4093956..e4c4edcb4db 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -62,9 +62,7 @@ namespace ts { /* @internal */ export const libMap = createMapFromEntries(libEntries); - /* @internal */ - export const optionDeclarations: CommandLineOption[] = [ - // CommandLine only options + const commonOptionsWithBuild: CommandLineOption[] = [ { name: "help", shortName: "h", @@ -78,6 +76,27 @@ namespace ts { shortName: "?", type: "boolean" }, + { + name: "preserveWatchOutput", + type: "boolean", + showInSimplifiedHelpView: false, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Watch_input_files, + }, + ]; + + /* @internal */ + export const optionDeclarations: CommandLineOption[] = [ + // CommandLine only options + ...commonOptionsWithBuild, { name: "all", type: "boolean", @@ -125,21 +144,6 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, - { - name: "preserveWatchOutput", - type: "boolean", - showInSimplifiedHelpView: false, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - showInSimplifiedHelpView: true, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Watch_input_files, - }, // Basic { @@ -754,6 +758,38 @@ namespace ts { } ]; + /* @internal */ + export const buildOpts: CommandLineOption[] = [ + ...commonOptionsWithBuild, + { + name: "verbose", + shortName: "v", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Enable_verbose_logging, + type: "boolean" + }, + { + name: "dry", + shortName: "d", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, + type: "boolean" + }, + { + name: "force", + shortName: "f", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, + type: "boolean" + }, + { + name: "clean", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Delete_the_outputs_of_all_projects, + type: "boolean" + } + ]; + /* @internal */ export const typeAcquisitionDeclarations: CommandLineOption[] = [ { @@ -997,6 +1033,58 @@ namespace ts { return optionNameMap.get(optionName); } + /*@internal*/ + export interface ParsedBuildCommand { + buildOptions: BuildOptions; + projects: string[]; + errors: ReadonlyArray; + } + + /*@internal*/ + export function parseBuildCommand(args: string[]): ParsedBuildCommand { + let buildOptionNameMap: OptionNameMap | undefined; + const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts))); + + const buildOptions: BuildOptions = {}; + const projects: string[] = []; + let errors: Diagnostic[] | undefined; + for (const arg of args) { + if (arg.charCodeAt(0) === CharacterCodes.minus) { + const opt = getOptionDeclarationFromName(returnBuildOptionNameMap, arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1), /*allowShort*/ true); + if (opt) { + buildOptions[opt.name as keyof BuildOptions] = true; + } + else { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Unknown_build_option_0, arg)); + } + } + else { + // Not a flag, parse as filename + projects.push(arg); + } + } + + if (projects.length === 0) { + // tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ." + projects.push("."); + } + + // Nonsensical combinations + if (buildOptions.clean && buildOptions.force) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force")); + } + if (buildOptions.clean && buildOptions.verbose) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose")); + } + if (buildOptions.clean && buildOptions.watch) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch")); + } + if (buildOptions.watch && buildOptions.dry) { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry")); + } + + return { buildOptions, projects, errors: errors || emptyArray }; + } function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string { const diagnostic = createCompilerDiagnostic.apply(undefined, arguments); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5e4d42a890e..9eabae70d2e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -790,11 +790,8 @@ namespace ts { * @param comparer An optional `Comparer` used to sort entries before comparison, though the * result will remain in the original order in `array`. */ - export function deduplicate(array: ReadonlyArray, equalityComparer?: EqualityComparer, comparer?: Comparer): T[]; - export function deduplicate(array: ReadonlyArray | undefined, equalityComparer?: EqualityComparer, comparer?: Comparer): T[] | undefined; - export function deduplicate(array: ReadonlyArray | undefined, equalityComparer: EqualityComparer, comparer?: Comparer): T[] | undefined { - return !array ? undefined : - array.length === 0 ? [] : + export function deduplicate(array: ReadonlyArray, equalityComparer: EqualityComparer, comparer?: Comparer): T[] { + return array.length === 0 ? [] : array.length === 1 ? array.slice() : comparer ? deduplicateRelational(array, equalityComparer, comparer) : deduplicateEquality(array, equalityComparer); @@ -803,10 +800,7 @@ namespace ts { /** * Deduplicates an array that has already been sorted. */ - function deduplicateSorted(array: ReadonlyArray, comparer: EqualityComparer | Comparer): T[]; - function deduplicateSorted(array: ReadonlyArray | undefined, comparer: EqualityComparer | Comparer): T[] | undefined; - function deduplicateSorted(array: ReadonlyArray | undefined, comparer: EqualityComparer | Comparer): T[] | undefined { - if (!array) return undefined; + function deduplicateSorted(array: ReadonlyArray, comparer: EqualityComparer | Comparer): T[] { if (array.length === 0) return []; let last = array[0]; @@ -1273,7 +1267,7 @@ namespace ts { if (!left || !right) return false; for (const key in left) { if (hasOwnProperty.call(left, key)) { - if (!hasOwnProperty.call(right, key) === undefined) return false; + if (!hasOwnProperty.call(right, key)) return false; if (!equalityComparer(left[key], right[key])) return false; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a1e33f00d8f..4384167a4e0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -835,7 +835,7 @@ "category": "Error", "code": 1253 }, - "A 'const' initializer in an ambient context must be a string or numeric literal.": { + "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.": { "category": "Error", "code": 1254 }, @@ -991,6 +991,22 @@ "category": "Error", "code": 1345 }, + "This parameter is not allowed with 'use strict' directive.": { + "category": "Error", + "code": 1346 + }, + "'use strict' directive cannot be used with non-simple parameter list.": { + "category": "Error", + "code": 1347 + }, + "Non-simple parameter declared here.": { + "category": "Error", + "code": 1348 + }, + "'use strict' directive used here.": { + "category": "Error", + "code": 1349 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -2437,6 +2453,10 @@ "category": "Error", "code": 2732 }, + "Index '{0}' is out-of-bounds in tuple of length {1}.": { + "category": "Error", + "code": 2733 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2892,7 +2912,7 @@ "category": "Error", "code": 5070 }, - "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'.": { + "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.": { "category": "Error", "code": 5071 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 613fe7f5c84..8cb1d4f34a9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1780,7 +1780,9 @@ namespace ts { function emitExpressionStatement(node: ExpressionStatement) { emitExpression(node.expression); - if (!isJsonSourceFile(currentSourceFile)) { + // Emit semicolon in non json files + // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) + if (!isJsonSourceFile(currentSourceFile) || nodeIsSynthesized(node.expression)) { writeSemicolon(); } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4bb374682e0..984e6d59b2e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3894,6 +3894,20 @@ namespace ts { return statementOffset; } + export function findUseStrictPrologue(statements: ReadonlyArray): Statement | undefined { + for (const statement of statements) { + if (isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + return statement; + } + } + else { + break; + } + } + return undefined; + } + export function startsWithUseStrict(statements: ReadonlyArray) { const firstStatement = firstOrUndefined(statements); return firstStatement !== undefined @@ -3907,18 +3921,7 @@ namespace ts { * @param statements An array of statements */ export function ensureUseStrict(statements: NodeArray): NodeArray { - let foundUseStrict = false; - for (const statement of statements) { - if (isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement as ExpressionStatement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } + const foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { return setTextRange( diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index b30e68c8998..cb19dcde1e2 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -75,10 +75,10 @@ namespace ts.moduleSpecifiers { const info = getInfo(importingSourceFileName, host); const modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return firstDefined(modulePaths, moduleFileName => tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions)) || - first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // For each symlink/original for a module, returns a list of ways to import that file. + // Returns an import for each symlink and for the realpath. export function getModuleSpecifiers( moduleSymbol: Symbol, compilerOptions: CompilerOptions, @@ -87,9 +87,9 @@ namespace ts.moduleSpecifiers { files: ReadonlyArray, userPreferences: UserPreferences, redirectTargetsMap: RedirectTargetsMap, - ): ReadonlyArray> { + ): ReadonlyArray { const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); - if (ambient) return [[ambient]]; + if (ambient) return [ambient]; const info = getInfo(importingSourceFile.path, host); const moduleSourceFile = getSourceFileOfNode(moduleSymbol.valueDeclaration || getNonAugmentationDeclaration(moduleSymbol)); @@ -97,8 +97,7 @@ namespace ts.moduleSpecifiers { const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const global = mapDefined(modulePaths, moduleFileName => tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions)); - return global.length ? global.map(g => [g]) : modulePaths.map(moduleFileName => - getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences)); + return global.length ? global : modulePaths.map(moduleFileName => getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences)); } interface Info { @@ -112,68 +111,40 @@ namespace ts.moduleSpecifiers { return { getCanonicalFileName, sourceDirectory }; } - function getLocalModuleSpecifiers(moduleFileName: string, { getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, { ending, relativePreference }: Preferences): ReadonlyArray { + function getLocalModuleSpecifier(moduleFileName: string, { getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, { ending, relativePreference }: Preferences): string { const { baseUrl, paths, rootDirs } = compilerOptions; const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === RelativePreference.Relative) { - return [relativePath]; + return relativePath; } const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); if (!relativeToBaseUrl) { - return [relativePath]; + return relativePath; } const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - if (paths) { - const fromPaths = tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } + const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + const nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths; if (relativePreference === RelativePreference.NonRelative) { - return [importRelativeToBaseUrl]; + return nonRelative; } if (relativePreference !== RelativePreference.Auto) Debug.assertNever(relativePreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; + // Prefer a relative import over a baseUrl import if it has fewer components. + return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; + } + + function countPathComponents(path: string): number { + let count = 0; + for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) { + if (path.charCodeAt(i) === CharacterCodes.slash) count++; } - - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - const pathFromSourceToBaseUrl = ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - const relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + return count; } function usesJsExtensionOnImports({ imports }: SourceFile): boolean { @@ -245,15 +216,6 @@ namespace ts.moduleSpecifiers { return result; } - function getRelativePathNParents(relativePath: string): number { - const components = getPathComponents(relativePath); - if (components[0] || components.length === 1) return 0; - for (let i = 1; i < components.length; i++) { - if (components[i] !== "..") return i - 1; - } - return components.length - 1; - } - function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { const decl = find(moduleSymbol.declarations, d => isNonGlobalAmbientModule(d) && (!isExternalModuleAugmentation(d) || !isExternalModuleNameRelative(getTextOfIdentifierOrLiteral(d.name))) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e9eb953d22a..1d65e31b490 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -86,6 +86,7 @@ namespace ts { visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).exclamationToken) || visitNode(cbNode, (node).equalsToken) || visitNode(cbNode, (node).objectAssignmentInitializer); case SyntaxKind.SpreadAssignment: @@ -156,6 +157,7 @@ namespace ts { visitNode(cbNode, (node).asteriskToken) || visitNode(cbNode, (node).name) || visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).exclamationToken) || visitNodes(cbNode, cbNodes, (node).typeParameters) || visitNodes(cbNode, cbNodes, (node).parameters) || visitNode(cbNode, (node).type) || @@ -2377,8 +2379,10 @@ namespace ts { } function parseJSDocType(): TypeNode { + scanner.setInJSDocType(true); const dotdotdot = parseOptionalToken(SyntaxKind.DotDotDotToken); let type = parseTypeOrTypePredicate(); + scanner.setInJSDocType(false); if (dotdotdot) { const variadic = createNode(SyntaxKind.JSDocVariadicType, dotdotdot.pos) as JSDocVariadicType; variadic.type = type; @@ -4711,8 +4715,10 @@ namespace ts { const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); const tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); - // Disallowing of optional property assignments happens in the grammar checker. + // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. (node).questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + (node).exclamationToken = parseOptionalToken(SyntaxKind.ExclamationToken); + if (asteriskToken || token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { return parseMethodDeclaration(node, asteriskToken); } @@ -6856,7 +6862,7 @@ namespace ts { function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); - skipWhitespace(); + skipWhitespaceOrAsterisk(); const typedefTag = createNode(SyntaxKind.JSDocTypedefTag, atToken.pos); typedefTag.atToken = atToken; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 56300a03f67..c97f1a61d27 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -953,8 +953,11 @@ namespace ts { // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState: OldProgramState): boolean { + if (!oldProgramState.program) { + return false; + } const resolutionToFile = getResolvedModule(oldProgramState.oldSourceFile!, moduleName); // TODO: GH#18217 - const resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + const resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -962,16 +965,11 @@ namespace ts { // because the normal module resolution algorithm will find this anyway. return false; } - const ambientModule = oldProgramState.program && oldProgramState.program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); - if (!(ambientModule && ambientModule.declarations)) { - return false; - } // at least one of declarations should come from non-modified source file - const firstUnmodifiedFile = forEach(ambientModule.declarations, d => { - const f = getSourceFileOfNode(d); - return !contains(oldProgramState.modifiedFilePaths, f.path) && f; - }); + const firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find( + f => !contains(oldProgramState.modifiedFilePaths, f.path) && contains(f.ambientModuleNames, moduleName) + ); if (!firstUnmodifiedFile) { return false; @@ -1180,7 +1178,8 @@ namespace ts { } } if (resolveTypeReferenceDirectiveNamesWorker) { - const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName); + // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. + const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, ref => ref.fileName.toLocaleLowerCase()); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); // ensure that types resolutions are still correct const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo); @@ -1259,8 +1258,6 @@ namespace ts { } function getProjectReferences() { - if (!resolvedProjectReferences) return; - return resolvedProjectReferences; } @@ -2434,12 +2431,14 @@ namespace ts { } // List of collected files is complete; validate exhautiveness if this is a project with a file list - if (options.composite && rootNames.length < files.length) { - const normalizedRootNames = rootNames.map(r => normalizePath(r).toLowerCase()); - const sourceFiles = files.filter(f => !f.isDeclarationFile).map(f => normalizePath(f.path).toLowerCase()); - for (const file of sourceFiles) { - if (normalizedRootNames.every(r => r !== file)) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); + if (options.composite) { + const sourceFiles = files.filter(f => !f.isDeclarationFile); + if (rootNames.length < sourceFiles.length) { + const normalizedRootNames = rootNames.map(r => normalizePath(r).toLowerCase()); + for (const file of sourceFiles.map(f => normalizePath(f.path).toLowerCase())) { + if (normalizedRootNames.indexOf(file) === -1) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); + } } } } @@ -2551,9 +2550,9 @@ namespace ts { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } - // Any emit other than common js is error - else if (getEmitModuleKind(options) !== ModuleKind.CommonJS) { - createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs, "resolveJsonModule", "module"); + // Any emit other than common js, amd, es2015 or esnext is error + else if (!hasJsonModuleEmitEnabled(options)) { + createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 61ce8330bff..b339220c38e 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -42,6 +42,8 @@ namespace ts { setScriptTarget(scriptTarget: ScriptTarget): void; setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; + /* @internal */ + setInJSDocType(inType: boolean): void; // Invokes the provided callback then unconditionally restores the scanner to the state it // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. @@ -824,6 +826,8 @@ namespace ts { let tokenValue!: string; let tokenFlags: TokenFlags; + let inJSDocType = 0; + setText(text, start, length); return { @@ -854,6 +858,7 @@ namespace ts { setLanguageVariant, setOnError, setTextPos, + setInJSDocType, tryScan, lookAhead, scanRange, @@ -1350,6 +1355,7 @@ namespace ts { function scan(): SyntaxKind { startPos = pos; tokenFlags = 0; + let asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { @@ -1390,6 +1396,24 @@ namespace ts { case CharacterCodes.verticalTab: case CharacterCodes.formFeed: case CharacterCodes.space: + case CharacterCodes.nonBreakingSpace: + case CharacterCodes.ogham: + case CharacterCodes.enQuad: + case CharacterCodes.emQuad: + case CharacterCodes.enSpace: + case CharacterCodes.emSpace: + case CharacterCodes.threePerEmSpace: + case CharacterCodes.fourPerEmSpace: + case CharacterCodes.sixPerEmSpace: + case CharacterCodes.figureSpace: + case CharacterCodes.punctuationSpace: + case CharacterCodes.thinSpace: + case CharacterCodes.hairSpace: + case CharacterCodes.zeroWidthSpace: + case CharacterCodes.narrowNoBreakSpace: + case CharacterCodes.mathematicalSpace: + case CharacterCodes.ideographicSpace: + case CharacterCodes.byteOrderMark: if (skipTrivia) { pos++; continue; @@ -1447,6 +1471,11 @@ namespace ts { return pos += 2, token = SyntaxKind.AsteriskAsteriskToken; } pos++; + if (inJSDocType && !asteriskSeen && (tokenFlags & TokenFlags.PrecedingLineBreak)) { + // decoration at the start of a JSDoc comment line + asteriskSeen = true; + continue; + } return token = SyntaxKind.AsteriskToken; case CharacterCodes.plus: if (text.charCodeAt(pos + 1) === CharacterCodes.plus) { @@ -2078,5 +2107,9 @@ namespace ts { tokenValue = undefined!; tokenFlags = 0; } + + function setInJSDocType(inType: boolean) { + inJSDocType += inType ? 1 : -1; + } } } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index eff4eddf438..49e89417ca0 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1331,12 +1331,13 @@ namespace ts { } type CanHaveLiteralInitializer = VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration; - function canHaveLiteralInitializer(node: Node): node is CanHaveLiteralInitializer { + function canHaveLiteralInitializer(node: Node): boolean { switch (node.kind) { - case SyntaxKind.VariableDeclaration: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: + return !hasModifier(node, ModifierFlags.Private); case SyntaxKind.Parameter: + case SyntaxKind.VariableDeclaration: return true; } return false; diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index bffdc5809b0..dcb0d9ac208 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2060,14 +2060,11 @@ namespace ts { setTextRange(declarationList, node); setCommentRange(declarationList, node); + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. if (node.transformFlags & TransformFlags.ContainsBindingPattern && (isBindingPattern(node.declarations[0].name) || isBindingPattern(last(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - const firstDeclaration = firstOrUndefined(declarations); - if (firstDeclaration) { - setSourceMapRange(declarationList, createRange(firstDeclaration.pos, last(declarations).end)); - } + setSourceMapRange(declarationList, getRangeUnion(declarations)); } return declarationList; @@ -2075,6 +2072,17 @@ namespace ts { return visitEachChild(node, visitor, context); } + function getRangeUnion(declarations: ReadonlyArray): TextRange { + // declarations may not be sorted by position. + // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. + let pos = -1, end = -1; + for (const node of declarations) { + pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); + end = Math.max(end, node.end); + } + return createRange(pos, end); + } + /** * Gets a value indicating whether we should emit an explicit initializer for a variable * declaration in a `let` declaration list. diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 09bf1b75b9c..1b3a623c32d 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -53,7 +53,10 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile || !(isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & TransformFlags.ContainsDynamicImport)) { + if (node.isDeclarationFile || + !(isEffectiveExternalModule(node, compilerOptions) || + node.transformFlags & TransformFlags.ContainsDynamicImport || + (isJsonSourceFile(node) && hasJsonModuleEmitEnabled(compilerOptions) && (compilerOptions.out || compilerOptions.outFile)))) { return node; } @@ -117,6 +120,7 @@ namespace ts { function transformAMDModule(node: SourceFile) { const define = createIdentifier("define"); const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); + const jsonSourceFile = isJsonSourceFile(node) && node; // An AMD define function has the following shape: // @@ -158,7 +162,7 @@ namespace ts { // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - createArrayLiteral([ + createArrayLiteral(jsonSourceFile ? emptyArray : [ createLiteral("require"), createLiteral("exports"), ...aliasedModuleNames, @@ -168,7 +172,9 @@ namespace ts { // Add the module body function argument: // // function (require, exports, module1, module2) ... - createFunctionExpression( + jsonSourceFile ? + jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : createObjectLiteral() : + createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index e52c743bb36..4ddda98a41f 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -429,6 +429,7 @@ namespace ts { projectPendingBuild.removeKey(proj); if (!projectPendingBuild.getSize()) { invalidatedProjectQueue.length = 0; + nextIndex = 0; } return proj; } @@ -506,6 +507,7 @@ namespace ts { const configFileCache = createConfigFileCache(host); let context = createBuildContext(defaultOptions); let timerToBuildInvalidatedProject: any; + let reportFileChangeDetected = false; const existingWatchersForWildcards = createMap(); return { @@ -583,7 +585,7 @@ namespace ts { } function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) { - reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + reportFileChangeDetected = true; invalidateProject(resolved); scheduleBuildInvalidatedProject(); } @@ -816,6 +818,10 @@ namespace ts { function buildInvalidatedProject() { timerToBuildInvalidatedProject = undefined; + if (reportFileChangeDetected) { + reportFileChangeDetected = false; + reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + } const buildProject = context.getNextInvalidatedProject(); buildSomeProjects(p => p === buildProject); if (context.hasPendingInvalidatedProjects()) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 54e19154376..279fef73d5e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -739,6 +739,7 @@ namespace ts { } export interface ComputedPropertyName extends Node { + parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } @@ -883,6 +884,7 @@ namespace ts { kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; // used when ObjectLiteralExpression is used in ObjectAssignmentPattern // it is grammar error to appear in actual object initializer equalsToken?: Token; @@ -941,6 +943,7 @@ namespace ts { asteriskToken?: AsteriskToken; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; body?: Block | Expression; } @@ -3441,8 +3444,8 @@ namespace ts { Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, - Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | JSContainer, - Type = Class | Interface | Enum | EnumMember | TypeLiteral | ObjectLiteral | TypeParameter | TypeAlias | JSContainer, + Value = Variable | Property | EnumMember | ObjectLiteral | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | JSContainer, + Type = Class | Interface | Enum | EnumMember | TypeLiteral | TypeParameter | TypeAlias | JSContainer, Namespace = ValueModule | NamespaceModule | Enum, Module = ValueModule | NamespaceModule, Accessor = GetAccessor | SetAccessor, @@ -3463,7 +3466,7 @@ namespace ts { InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums - ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), + ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule | JSContainer), NamespaceModuleExcludes = 0, MethodExcludes = Value & ~Method, GetAccessorExcludes = Value & ~SetAccessor, @@ -4175,9 +4178,8 @@ namespace ts { /* @internal */ export const enum InferenceFlags { None = 0, // No special inference behaviors - InferUnionTypes = 1 << 0, // Infer union types for disjoint candidates (otherwise unknownType) - NoDefault = 1 << 1, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType) - AnyDefault = 1 << 2, // Infer anyType for no inferences (otherwise emptyObjectType) + NoDefault = 1 << 0, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType) + AnyDefault = 1 << 1, // Infer anyType for no inferences (otherwise emptyObjectType) } /** diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 451bc212918..5191fe1cc47 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -489,12 +489,23 @@ namespace ts { return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia); } + function isJSDocTypeExpressionOrChild(node: Node): boolean { + return node.kind === SyntaxKind.JSDocTypeExpression || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + } + export function getTextOfNodeFromSourceText(sourceText: string, node: Node, includeTrivia = false): string { if (nodeIsMissing(node)) { return ""; } - return sourceText.substring(includeTrivia ? node.pos : skipTrivia(sourceText, node.pos), node.end); + let text = sourceText.substring(includeTrivia ? node.pos : skipTrivia(sourceText, node.pos), node.end); + + if (isJSDocTypeExpressionOrChild(node)) { + // strip space + asterisk at line start + text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + } + + return text; } export function getTextOfNode(node: Node, includeTrivia = false): string { @@ -910,6 +921,10 @@ namespace ts { return !!(getCombinedModifierFlags(node) & ModifierFlags.Const); } + export function isDeclarationReadonly(declaration: Declaration): boolean { + return !!(getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration)); + } + export function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean { return !!(getCombinedNodeFlags(node) & NodeFlags.Const); } @@ -1761,6 +1776,10 @@ namespace ts { return decl; } + export function isAssignmentDeclaration(decl: Declaration) { + return isBinaryExpression(decl) || isPropertyAccessExpression(decl) || isIdentifier(decl); + } + /** Get the initializer, taking into account defaulted Javascript initializers */ export function getEffectiveInitializer(node: HasExpressionInitializer) { if (isInJavaScriptFile(node) && node.initializer && @@ -2111,6 +2130,10 @@ namespace ts { result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration)); break; } + if (node.kind === SyntaxKind.TypeParameter) { + result = addRange(result, getJSDocTypeParameterTags(node as TypeParameterDeclaration)); + break; + } node = getNextJSDocCommentLocation(node); } return result || emptyArray; @@ -2360,29 +2383,33 @@ namespace ts { } // See GH#16030 - export function isAnyDeclarationName(name: Node): boolean { + export function getDeclarationFromName(name: Node): Declaration | undefined { + const parent = name.parent; switch (name.kind) { - case SyntaxKind.Identifier: case SyntaxKind.StringLiteral: - case SyntaxKind.NumericLiteral: { - const parent = name.parent; + case SyntaxKind.NumericLiteral: + if (isComputedPropertyName(parent)) return parent.parent; + // falls through + + case SyntaxKind.Identifier: if (isDeclaration(parent)) { - return parent.name === name; + return parent.name === name ? parent : undefined; } - else if (isQualifiedName(name.parent)) { - const tag = name.parent.parent; - return isJSDocParameterTag(tag) && tag.name === name.parent; + else if (isQualifiedName(parent)) { + const tag = parent.parent; + return isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined; } else { - const binExp = name.parent.parent; + const binExp = parent.parent; return isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None && (binExp.left.symbol || binExp.symbol) && - getNameOfDeclaration(binExp) === name; + getNameOfDeclaration(binExp) === name + ? binExp + : undefined; } - } default: - return false; + return undefined; } } @@ -3742,7 +3769,7 @@ namespace ts { return false; } - export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean { + export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): node is ExpressionWithTypeArguments { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } @@ -4057,7 +4084,8 @@ namespace ts { * @param pos The start position. * @param end The end position. */ - export function createRange(pos: number, end: number): TextRange { + export function createRange(pos: number, end: number = pos): TextRange { + Debug.assert(end >= pos || end === -1); return { pos, end }; } @@ -4521,12 +4549,6 @@ namespace ts { return { start, length }; } - /* @internal */ - export function createTextRange(pos: number, end: number = pos): TextRange { - Debug.assert(end >= pos); - return { pos, end }; - } - export function createTextSpanFromBounds(start: number, end: number) { return createTextSpan(start, end - start); } @@ -5010,15 +5032,14 @@ namespace ts { /** * Gets the JSDoc parameter tags for the node if present. * - * @remarks Returns any JSDoc param tag that matches the provided + * @remarks Returns any JSDoc param tag whose name matches the provided * parameter, whether a param tag on a containing function * expression, or a param tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are returned first, so in the previous example, the param * tag on the containing function expression would be first. * - * Does not return tags for binding patterns, because JSDoc matches - * parameters by name and binding patterns do not have a name. + * For binding patterns, parameter tags are matched by position. */ export function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray { if (param.name) { @@ -5039,6 +5060,22 @@ namespace ts { return emptyArray; } + /** + * Gets the JSDoc type parameter tags for the node if present. + * + * @remarks Returns any JSDoc template tag whose names match the provided + * parameter, whether a template tag on a containing function + * expression, or a template tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the template + * tag on the containing function expression would be first. + */ + export function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray { + const name = param.name.escapedText; + return getJSDocTags(param.parent).filter((tag): tag is JSDocTemplateTag => + isJSDocTemplateTag(tag) && tag.typeParameters.some(tp => tp.name.escapedText === name)); + } + /** * Return true if the node has JSDoc parameter tags. * @@ -7020,6 +7057,18 @@ namespace ts { return moduleResolution; } + export function hasJsonModuleEmitEnabled(options: CompilerOptions) { + switch (getEmitModuleKind(options)) { + case ModuleKind.CommonJS: + case ModuleKind.AMD: + case ModuleKind.ES2015: + case ModuleKind.ESNext: + return true; + default: + return false; + } + } + export function unreachableCodeIsError(options: CompilerOptions): boolean { return options.allowUnreachableCode === false; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index c00f37c260d..015eec5c3e0 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1378,6 +1378,16 @@ type Extract = T extends U ? T : never; */ type NonNullable = T extends null | undefined ? never : T; +/** + * Obtain the parameters of a function type in a tuple + */ +type Parameters any> = T extends (...args: infer P) => any ? P : never; + +/** + * Obtain the parameters of a constructor function type in a tuple + */ +type ConstructorParameters any> = T extends new (...args: infer P) => any ? P : never; + /** * Obtain the return type of a function type */ diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index b602e8cc0e8..33bee0c205e 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -11,7 +11,7 @@ interface ReadonlyArray { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|U[], + callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, thisArg?: This ): U[] @@ -125,7 +125,7 @@ interface Array { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|U[], + callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, thisArg?: This ): U[] diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 98bdf52817b..9d03da8d9b3 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1,10139 +1,10139 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - or -. For example '{0}' or '{1}'.]]> - - 또는 - 형식이어야 합니다. 예를 들어 '{0}' 또는 '{1}'입니다.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - type.]]> - - 형식이어야 합니다.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ()' instead.]]> - - ()'를 사용하세요.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or -. For example '{0}' or '{1}'.]]> + + 또는 - 형식이어야 합니다. 예를 들어 '{0}' 또는 '{1}'입니다.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + type.]]> + + 형식이어야 합니다.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ()' instead.]]> + + ()'를 사용하세요.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index dc8079b6a53..cf26e2044e7 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -588,7 +588,7 @@ - + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index b4382410717..ddbfd8ac389 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -487,7 +487,7 @@ namespace ts.server { this.globalPlugins = opts.globalPlugins || emptyArray; this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray; this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads; - this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(this.getExecutingFilePath(), "../typesMap.json") : opts.typesMapLocation; + this.typesMapLocation = (opts.typesMapLocation === undefined) ? combinePaths(getDirectoryPath(this.getExecutingFilePath()), "typesMap.json") : opts.typesMapLocation; this.syntaxOnly = opts.syntaxOnly; Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); diff --git a/src/server/session.ts b/src/server/session.ts index d923942cd5c..5d364abc757 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -266,8 +266,6 @@ namespace ts.server { getValue: (path: Path) => T, projects: Projects, action: (project: Project, value: T) => ReadonlyArray | U | undefined, - comparer?: (a: U, b: U) => number, - areEqual?: (a: U, b: U) => boolean, ): U[] { const outputs = flatMap(isArray(projects) ? projects : projects.projects, project => action(project, defaultValue)); if (!isArray(projects) && projects.symLinkedProjects) { @@ -276,10 +274,7 @@ namespace ts.server { outputs.push(...flatMap(projects, project => action(project, value))); }); } - - return comparer - ? sortAndDeduplicate(outputs, comparer, areEqual) - : deduplicate(outputs, areEqual); + return deduplicate(outputs, equateValues); } function combineProjectOutputFromEveryProject(projectService: ProjectService, action: (project: Project) => ReadonlyArray, areEqual: (a: T, b: T) => boolean) { diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 195586c6b6e..76cdf471466 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -42,7 +42,18 @@ namespace ts.codefix { function convertToAsyncFunction(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker, context: CodeFixContextBase): void { // get the function declaration - returns a promise - const functionToConvert: FunctionLikeDeclaration = getContainingFunction(getTokenAtPosition(sourceFile, position)) as FunctionLikeDeclaration; + const tokenAtPosition = getTokenAtPosition(sourceFile, position); + let functionToConvert: FunctionLikeDeclaration | undefined; + + // if the parent of a FunctionLikeDeclaration is a variable declaration, the convertToAsync diagnostic will be reported on the variable name + if (isIdentifier(tokenAtPosition) && isVariableDeclaration(tokenAtPosition.parent) && + tokenAtPosition.parent.initializer && isFunctionLikeDeclaration(tokenAtPosition.parent.initializer)) { + functionToConvert = tokenAtPosition.parent.initializer; + } + else { + functionToConvert = tryCast(getContainingFunction(getTokenAtPosition(sourceFile, position)), isFunctionLikeDeclaration); + } + if (!functionToConvert) { return; } diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index 87a1f49cc48..65ea757d060 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -208,7 +208,7 @@ namespace ts.codefix { return replacement[1]; } else { - changes.replaceRangeWithText(sourceFile, createTextRange(left.getStart(sourceFile), right.pos), "export default"); + changes.replaceRangeWithText(sourceFile, createRange(left.getStart(sourceFile), right.pos), "export default"); return true; } } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 7ff5d30c954..963d1cd64f2 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -283,14 +283,13 @@ namespace ts.codefix { preferences: UserPreferences, ): ReadonlyArray { const isJs = isSourceFileJavaScript(sourceFile); - const choicesForEachExportingModule = flatMap>(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) => { - const modulePathsGroups = moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap); - return modulePathsGroups.map(group => group.map((moduleSpecifier): FixAddNewImport | FixUseImportType => + const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) => + moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) + .map((moduleSpecifier): FixAddNewImport | FixUseImportType => // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. exportedSymbolIsTypeOnly && isJs ? { kind: ImportFixKind.ImportType, moduleSpecifier, position: Debug.assertDefined(position) } : { kind: ImportFixKind.AddNew, moduleSpecifier, importKind })); - }); - // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together - return flatten(choicesForEachExportingModule.sort((a, b) => first(a).moduleSpecifier.length - first(b).moduleSpecifier.length)); + // Sort to keep the shortest paths first + return choicesForEachExportingModule.sort((a, b) => a.moduleSpecifier.length - b.moduleSpecifier.length); } function getFixesForAddImport( diff --git a/src/services/completions.ts b/src/services/completions.ts index a82c4e02882..3edc1cc4f56 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -264,6 +264,9 @@ namespace ts.Completions { } function quote(text: string, preferences: UserPreferences): string { + if (/^\d+$/.test(text)) { + return text; + } const quoted = JSON.stringify(text); switch (preferences.quotePreference) { case undefined: @@ -983,7 +986,10 @@ namespace ts.Completions { break; case SyntaxKind.Identifier: // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. + if (parent !== previousToken.parent && + !(parent as JsxAttribute).initializer && + findChildOfKind(parent, SyntaxKind.EqualsToken, sourceFile)) { isJsxInitializer = previousToken as Identifier; } } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 81da5a0d82f..b857a05dffb 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -5,12 +5,13 @@ namespace ts.FindAllReferences { references: Entry[]; } + export const enum DefinitionKind { Symbol, Label, Keyword, This, String } export type Definition = - | { type: "symbol"; symbol: Symbol } - | { type: "label"; node: Identifier } - | { type: "keyword"; node: Node } - | { type: "this"; node: Node } - | { type: "string"; node: StringLiteral }; + | { readonly type: DefinitionKind.Symbol; readonly symbol: Symbol } + | { readonly type: DefinitionKind.Label; readonly node: Identifier } + | { readonly type: DefinitionKind.Keyword; readonly node: Node } + | { readonly type: DefinitionKind.This; readonly node: Node } + | { readonly type: DefinitionKind.String; readonly node: StringLiteral }; export type Entry = NodeEntry | SpanEntry; export interface NodeEntry { @@ -98,29 +99,29 @@ namespace ts.FindAllReferences { function definitionToReferencedSymbolDefinitionInfo(def: Definition, checker: TypeChecker, originalNode: Node): ReferencedSymbolDefinitionInfo { const info = (() => { switch (def.type) { - case "symbol": { + case DefinitionKind.Symbol: { const { symbol } = def; const { displayParts, kind } = getDefinitionKindAndDisplayParts(symbol, checker, originalNode); const name = displayParts.map(p => p.text).join(""); return { node: symbol.declarations ? getNameOfDeclaration(first(symbol.declarations)) || first(symbol.declarations) : originalNode, name, kind, displayParts }; } - case "label": { + case DefinitionKind.Label: { const { node } = def; return { node, name: node.text, kind: ScriptElementKind.label, displayParts: [displayPart(node.text, SymbolDisplayPartKind.text)] }; } - case "keyword": { + case DefinitionKind.Keyword: { const { node } = def; const name = tokenToString(node.kind)!; return { node, name, kind: ScriptElementKind.keyword, displayParts: [{ text: name, kind: ScriptElementKind.keyword }] }; } - case "this": { + case DefinitionKind.This: { const { node } = def; const symbol = checker.getSymbolAtLocation(node); const displayParts = symbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( checker, symbol, node.getSourceFile(), getContainerNode(node), node).displayParts || [textPart("this")]; return { node, name: "this", kind: ScriptElementKind.variableElement, displayParts }; } - case "string": { + case DefinitionKind.String: { const { node } = def; return { node, name: node.text, kind: ScriptElementKind.variableElement, displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] }; } @@ -154,7 +155,7 @@ namespace ts.FindAllReferences { textSpan: getTextSpan(node, sourceFile), isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === SyntaxKind.DefaultKeyword - || isAnyDeclarationName(node) + || !!getDeclarationFromName(node) || isLiteralComputedPropertyDeclarationName(node), isInString, }; @@ -223,7 +224,68 @@ namespace ts.FindAllReferences { /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node: Node): boolean { - return node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isWriteAccess(node); + const decl = getDeclarationFromName(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === SyntaxKind.DefaultKeyword || isWriteAccess(node); + } + + /** + * True if 'decl' provides a value, as in `function f() {}`; + * false if 'decl' is just a location for a future write, as in 'let x;' + */ + function declarationIsWriteAccess(decl: Declaration): boolean { + // Consider anything in an ambient declaration to be a write access since it may be coming from JS. + if (!!(decl.flags & NodeFlags.Ambient)) return true; + + switch (decl.kind) { + case SyntaxKind.BinaryExpression: + case SyntaxKind.BindingElement: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.EnumMember: + case SyntaxKind.ExportSpecifier: + case SyntaxKind.ImportClause: // default import + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.JSDocCallbackTag: + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JsxAttribute: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.NamespaceExportDeclaration: + case SyntaxKind.NamespaceImport: + case SyntaxKind.Parameter: + case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.TypeParameter: + return true; + + case SyntaxKind.PropertyAssignment: + // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) + return !isArrayLiteralOrObjectLiteralDestructuringPattern((decl as PropertyAssignment).parent); + + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return !!(decl as FunctionDeclaration | FunctionExpression | ConstructorDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration).body; + + case SyntaxKind.VariableDeclaration: + case SyntaxKind.PropertyDeclaration: + return !!(decl as VariableDeclaration | PropertyDeclaration).initializer || isCatchClause(decl.parent); + + case SyntaxKind.MethodSignature: + case SyntaxKind.PropertySignature: + case SyntaxKind.JSDocPropertyTag: + case SyntaxKind.JSDocParameterTag: + return false; + + default: + return Debug.failBadSyntaxKind(decl); + } } } @@ -313,7 +375,7 @@ namespace ts.FindAllReferences.Core { } } - return references.length ? [{ definition: { type: "symbol", symbol }, references }] : emptyArray; + return references.length ? [{ definition: { type: DefinitionKind.Symbol, symbol }, references }] : emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -524,7 +586,7 @@ namespace ts.FindAllReferences.Core { let references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: "symbol", symbol: searchSymbol }, references }); + this.result.push({ definition: { type: DefinitionKind.Symbol, symbol: searchSymbol }, references }); } return node => references.push(nodeEntry(node)); } @@ -818,7 +880,7 @@ namespace ts.FindAllReferences.Core { const references = mapDefined(getPossibleSymbolReferenceNodes(sourceFile, labelName, container), node => // Only pick labels that are either the target label, or have a target that is the target label node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined); - return [{ definition: { type: "label", node: targetLabel }, references }]; + return [{ definition: { type: DefinitionKind.Label, node: targetLabel }, references }]; } function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { @@ -850,7 +912,7 @@ namespace ts.FindAllReferences.Core { return mapDefined(getPossibleSymbolReferenceNodes(sourceFile, tokenToString(keywordKind)!, sourceFile), referenceLocation => referenceLocation.kind === keywordKind ? nodeEntry(referenceLocation) : undefined); }); - return references.length ? [{ definition: { type: "keyword", node: references[0].node }, references }] : undefined; + return references.length ? [{ definition: { type: DefinitionKind.Keyword, node: references[0].node }, references }] : undefined; } function getReferencesInSourceFile(sourceFile: SourceFile, search: Search, state: State, addReferencesHere = true): void { @@ -1292,7 +1354,7 @@ namespace ts.FindAllReferences.Core { return container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol }, references }]; + return [{ definition: { type: DefinitionKind.Symbol, symbol: searchSpaceNode.symbol }, references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken): SymbolAndEntries[] | undefined { @@ -1355,8 +1417,9 @@ namespace ts.FindAllReferences.Core { }); }).map(n => nodeEntry(n)); + const thisParameter = firstDefined(references, r => isParameter(r.node.parent) ? r.node : undefined); return [{ - definition: { type: "this", node: thisOrSuperKeyword }, + definition: { type: DefinitionKind.This, node: thisParameter || thisOrSuperKeyword }, references }]; } @@ -1369,7 +1432,7 @@ namespace ts.FindAllReferences.Core { }); return [{ - definition: { type: "string", node }, + definition: { type: DefinitionKind.String, node }, references }]; } diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index 4fe024787f3..07c3eb7ad22 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -221,7 +221,7 @@ namespace ts { } function createStringRange(node: StringLiteralLike, sourceFile: SourceFileLike): TextRange { - return createTextRange(node.getStart(sourceFile) + 1, node.end - 1); + return createRange(node.getStart(sourceFile) + 1, node.end - 1); } function forEachProperty(objectLiteral: Expression, cb: (property: PropertyAssignment, propertyName: string) => void) { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 5211b244e21..b6174be75e0 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -591,6 +591,6 @@ namespace ts.SignatureHelp { const param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration)!; printer.writeNode(EmitHint.Unspecified, param, sourceFile, writer); }); - return { name: typeParameter.symbol.name, documentation: emptyArray, displayParts, isOptional: false }; + return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts, isOptional: false }; } } diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 51a1701c351..167bcb6bbac 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -3,7 +3,7 @@ namespace ts { export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] { program.getSemanticDiagnostics(sourceFile, cancellationToken); const diags: DiagnosticWithLocation[] = []; - const checker = program.getDiagnosticsProducingTypeChecker(); + const checker = program.getTypeChecker(); if (sourceFile.commonJsModuleIndicator && (programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -115,11 +115,12 @@ namespace ts { function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void { - const functionType = node.type ? checker.getTypeFromTypeNode(node.type) : undefined; - if (isAsyncFunction(node) || !node.body || !functionType) { + if (isAsyncFunction(node) || !node.body) { return; } + const functionType = checker.getTypeAtLocation(node); + const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call); const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 51e60d08741..32d6360e90c 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -291,7 +291,7 @@ namespace ts.textChanges { } public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { - this.replaceRange(sourceFile, createTextRange(pos), newNode, options); + this.replaceRange(sourceFile, createRange(pos), newNode, options); } private insertNodesAt(sourceFile: SourceFile, pos: number, newNodes: ReadonlyArray, options: ReplaceWithMultipleNodesOptions = {}): void { @@ -334,7 +334,7 @@ namespace ts.textChanges { } public insertText(sourceFile: SourceFile, pos: number, text: string): void { - this.replaceRangeWithText(sourceFile, createTextRange(pos), text); + this.replaceRangeWithText(sourceFile, createRange(pos), text); } /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ @@ -456,7 +456,7 @@ namespace ts.textChanges { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI if (sourceFile.text.charCodeAt(after.end - 1) !== CharacterCodes.semicolon) { - this.replaceRange(sourceFile, createTextRange(after.end), createToken(SyntaxKind.SemicolonToken)); + this.replaceRange(sourceFile, createRange(after.end), createToken(SyntaxKind.SemicolonToken)); } } const endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -595,7 +595,7 @@ namespace ts.textChanges { // write separator and leading trivia of the next element as suffix const suffix = `${tokenToString(nextToken.kind)}${sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile))}`; - this.replaceRange(sourceFile, createTextRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix, suffix }); + this.replaceRange(sourceFile, createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix, suffix }); } } else { @@ -629,7 +629,7 @@ namespace ts.textChanges { } if (multilineList) { // insert separator immediately following the 'after' node to preserve comments in trailing trivia - this.replaceRange(sourceFile, createTextRange(end), createToken(separator)); + this.replaceRange(sourceFile, createRange(end), createToken(separator)); // use the same indentation as 'after' item const indentation = formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.formatContext.options); // insert element before the line break on the line that contains 'after' element @@ -637,10 +637,10 @@ namespace ts.textChanges { if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { insertPos--; } - this.replaceRange(sourceFile, createTextRange(insertPos), newNode, { indentation, prefix: this.newLineCharacter }); + this.replaceRange(sourceFile, createRange(insertPos), newNode, { indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, createTextRange(end), newNode, { prefix: `${tokenToString(separator)} ` }); + this.replaceRange(sourceFile, createRange(end), newNode, { prefix: `${tokenToString(separator)} ` }); } } return this; @@ -652,7 +652,7 @@ namespace ts.textChanges { const [openBraceEnd, closeBraceEnd] = getClassBraceEnds(cls, sourceFile); // For `class C { }` remove the whitespace inside the braces. if (positionsAreOnSameLine(openBraceEnd, closeBraceEnd, sourceFile) && openBraceEnd !== closeBraceEnd - 1) { - this.deleteRange(sourceFile, createTextRange(openBraceEnd, closeBraceEnd - 1)); + this.deleteRange(sourceFile, createRange(openBraceEnd, closeBraceEnd - 1)); } }); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 9e7b823fe54..b8a235bbeb4 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -755,7 +755,7 @@ namespace ts { return result; function find(n: Node): Node | undefined { - if (isNonWhitespaceToken(n)) { + if (isNonWhitespaceToken(n) && n.kind !== SyntaxKind.EndOfFileToken) { return n; } @@ -786,16 +786,14 @@ namespace ts { } } - Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || isJSDocCommentContainingNode(n)); + Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile || n.kind === SyntaxKind.EndOfFileToken || isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' - if (children.length) { - const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); - return candidate && findRightmostToken(candidate, sourceFile); - } + const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + return candidate && findRightmostToken(candidate, sourceFile); } } @@ -1048,7 +1046,7 @@ namespace ts { function nodeHasTokens(n: Node, sourceFile: SourceFileLike): boolean { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.getWidth(sourceFile) !== 0; + return n.kind === SyntaxKind.EndOfFileToken ? !!(n as EndOfFileToken).jsDoc : n.getWidth(sourceFile) !== 0; } export function getNodeModifiers(node: Node): string { @@ -1165,7 +1163,7 @@ namespace ts { } export function createTextRangeFromNode(node: Node, sourceFile: SourceFile): TextRange { - return createTextRange(node.getStart(sourceFile), node.end); + return createRange(node.getStart(sourceFile), node.end); } export function createTextSpanFromRange(range: TextRange): TextSpan { @@ -1173,7 +1171,7 @@ namespace ts { } export function createTextRangeFromSpan(span: TextSpan): TextRange { - return createTextRange(span.start, span.start + span.length); + return createRange(span.start, span.start + span.length); } export function createTextChangeFromStartLength(start: number, length: number, newText: string): TextChange { diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index c90eb1aa535..42edf839964 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -46,6 +46,7 @@ "unittests/cancellableLanguageServiceOperations.ts", "unittests/commandLineParsing.ts", "unittests/compileOnSave.ts", + "unittests/compilerCore.ts", "unittests/configurationExtension.ts", "unittests/convertCompilerOptionsFromJson.ts", "unittests/convertToAsyncFunction.ts", diff --git a/src/testRunner/unittests/commandLineParsing.ts b/src/testRunner/unittests/commandLineParsing.ts index 7145b9e5ec4..7ac9504f1f8 100644 --- a/src/testRunner/unittests/commandLineParsing.ts +++ b/src/testRunner/unittests/commandLineParsing.ts @@ -366,4 +366,120 @@ namespace ts { }); }); }); + + describe("parseBuildOptions", () => { + function assertParseResult(commandLine: string[], expectedParsedBuildCommand: ParsedBuildCommand) { + const parsed = parseBuildCommand(commandLine); + const parsedBuildOptions = JSON.stringify(parsed.buildOptions); + const expectedBuildOptions = JSON.stringify(expectedParsedBuildCommand.buildOptions); + assert.equal(parsedBuildOptions, expectedBuildOptions); + + const parsedErrors = parsed.errors; + const expectedErrors = expectedParsedBuildCommand.errors; + assert.isTrue(parsedErrors.length === expectedErrors.length, `Expected error: ${JSON.stringify(expectedErrors)}. Actual error: ${JSON.stringify(parsedErrors)}.`); + for (let i = 0; i < parsedErrors.length; i++) { + const parsedError = parsedErrors[i]; + const expectedError = expectedErrors[i]; + assert.equal(parsedError.code, expectedError.code); + assert.equal(parsedError.category, expectedError.category); + assert.equal(parsedError.messageText, expectedError.messageText); + } + + const parsedProjects = parsed.projects; + const expectedProjects = expectedParsedBuildCommand.projects; + assert.deepEqual(parsedProjects, expectedProjects, `Expected projects: [${JSON.stringify(expectedProjects)}]. Actual projects: [${JSON.stringify(parsedProjects)}].`); + } + it("parse build without any options ", () => { + // --lib es6 0.ts + assertParseResult([], + { + errors: [], + projects: ["."], + buildOptions: {} + }); + }); + + it("Parse multiple options", () => { + // --lib es5,es2015.symbol.wellknown 0.ts + assertParseResult(["--verbose", "--force", "tests"], + { + errors: [], + projects: ["tests"], + buildOptions: { verbose: true, force: true } + }); + }); + + it("Parse option with invalid option ", () => { + // --lib es5,invalidOption 0.ts + assertParseResult(["--verbose", "--invalidOption"], + { + errors: [{ + messageText: "Unknown build option '--invalidOption'.", + category: Diagnostics.Unknown_build_option_0.category, + code: Diagnostics.Unknown_build_option_0.code, + file: undefined, + start: undefined, + length: undefined, + }], + projects: ["."], + buildOptions: { verbose: true } + }); + }); + + it("Parse multiple flags with input projects at the end", () => { + // --lib es5,es2015.symbol.wellknown --target es5 0.ts + assertParseResult(["--force", "--verbose", "src", "tests"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + it("Parse multiple flags with input projects in the middle", () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult(["--force", "src", "tests", "--verbose"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + it("Parse multiple flags with input projects in the beginning", () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult(["src", "tests", "--force", "--verbose"], + { + errors: [], + projects: ["src", "tests"], + buildOptions: { force: true, verbose: true } + }); + }); + + describe("Combining options that make no sense together", () => { + function verifyInvalidCombination(flag1: keyof BuildOptions, flag2: keyof BuildOptions) { + it(`--${flag1} and --${flag2} together is invalid`, () => { + // --module commonjs --target es5 0.ts --lib es5,es2015.symbol.wellknown + assertParseResult([`--${flag1}`, `--${flag2}`], + { + errors: [{ + messageText: `Options '${flag1}' and '${flag2}' cannot be combined.`, + category: Diagnostics.Options_0_and_1_cannot_be_combined.category, + code: Diagnostics.Options_0_and_1_cannot_be_combined.code, + file: undefined, + start: undefined, + length: undefined, + }], + projects: ["."], + buildOptions: { [flag1]: true, [flag2]: true } + }); + }); + } + + verifyInvalidCombination("clean", "force"); + verifyInvalidCombination("clean", "verbose"); + verifyInvalidCombination("clean", "watch"); + verifyInvalidCombination("watch", "dry"); + }); + }); } diff --git a/src/testRunner/unittests/compilerCore.ts b/src/testRunner/unittests/compilerCore.ts new file mode 100644 index 00000000000..27f5cdc0887 --- /dev/null +++ b/src/testRunner/unittests/compilerCore.ts @@ -0,0 +1,33 @@ +namespace ts { + describe("compilerCore", () => { + describe("equalOwnProperties", () => { + it("correctly equates objects", () => { + assert.isTrue(equalOwnProperties({}, {})); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: 1 })); + assert.isTrue(equalOwnProperties({ a: 1, b: 2 }, { b: 2, a: 1 })); + }); + it("correctly identifies unmatched objects", () => { + assert.isFalse(equalOwnProperties({}, { a: 1 }), "missing left property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}), "missing right property"); + assert.isFalse(equalOwnProperties({ a: 1 }, { a: 2 }), "differing property"); + }); + it("correctly identifies undefined vs hasOwnProperty", () => { + assert.isFalse(equalOwnProperties({}, { a: undefined }), "missing left property"); + assert.isFalse(equalOwnProperties({ a: undefined }, {}), "missing right property"); + }); + it("truthiness", () => { + const trythyTest = (l: any, r: any) => !!l === !!r; + assert.isFalse(equalOwnProperties({}, { a: 1 }, trythyTest), "missing left truthy property"); + assert.isFalse(equalOwnProperties({}, { a: 0 }, trythyTest), "missing left falsey property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}, trythyTest), "missing right truthy property"); + assert.isFalse(equalOwnProperties({ a: 0 }, {}, trythyTest), "missing right falsey property"); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: "foo" }, trythyTest), "valid equality"); + }); + it("all equal", () => { + assert.isFalse(equalOwnProperties({}, { a: 1 }, () => true), "missing left property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}, () => true), "missing right property"); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: 2 }, () => true), "valid equality"); + }); + }); + }); +} diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index f39b8080ed2..99788e1310e 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -319,7 +319,7 @@ interface String { charAt: any; } interface Array {}` }; - function testConvertToAsyncFunction(caption: string, text: string, baselineFolder: string, description: DiagnosticMessage, includeLib?: boolean) { + function testConvertToAsyncFunction(caption: string, text: string, baselineFolder: string, diagnosticDescription: DiagnosticMessage, codeFixDescription: DiagnosticMessage, includeLib?: boolean) { const t = getTest(text); const selectionRange = t.ranges.get("selection")!; if (!selectionRange) { @@ -361,12 +361,14 @@ interface Array {}` }; const diagnostics = languageService.getSuggestionDiagnostics(f.path); - const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === description.message); - assert.isNotNull(diagnostic); + const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === diagnosticDescription.message); + assert.exists(diagnostic); + assert.equal(diagnostic!.start, context.span.start); + assert.equal(diagnostic!.length, context.span.length); const actions = codefix.getFixes(context); - const action = find(actions, action => action.description === description.message)!; - assert.isNotNull(action); + const action = find(actions, action => action.description === codeFixDescription.message)!; + assert.exists(action); const data: string[] = []; data.push(`// ==ORIGINAL==`); @@ -423,6 +425,10 @@ interface Array {}` _testConvertToAsyncFunction("convertToAsyncFunction_basic", ` function [#|f|](): Promise{ return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +}`); + _testConvertToAsyncFunction("convertToAsyncFunction_basicNoReturnTypeAnnotation", ` +function [#|f|]() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); }`); _testConvertToAsyncFunction("convertToAsyncFunction_basicWithComments", ` function [#|f|](): Promise{ @@ -436,6 +442,10 @@ function [#|f|](): Promise{ _testConvertToAsyncFunction("convertToAsyncFunction_ArrowFunction", ` [#|():Promise => {|] return fetch('https://typescriptlang.org').then(result => console.log(result)); +}`); + _testConvertToAsyncFunction("convertToAsyncFunction_ArrowFunctionNoAnnotation", ` +[#|() => {|] + return fetch('https://typescriptlang.org').then(result => console.log(result)); }`); _testConvertToAsyncFunction("convertToAsyncFunction_Catch", ` function [#|f|]():Promise { @@ -1178,11 +1188,17 @@ function [#|f|]() { } `); + _testConvertToAsyncFunction("convertToAsyncFunction_simpleFunctionExpression", ` +const [#|foo|] = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +`); + }); function _testConvertToAsyncFunction(caption: string, text: string) { - testConvertToAsyncFunction(caption, text, "convertToAsyncFunction", Diagnostics.Convert_to_async_function, /*includeLib*/ true); + testConvertToAsyncFunction(caption, text, "convertToAsyncFunction", Diagnostics.This_may_be_converted_to_an_async_function, Diagnostics.Convert_to_async_function, /*includeLib*/ true); } function _testConvertToAsyncFunctionFailed(caption: string, text: string) { diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index 0b2c53a0ec2..7a9e4278c57 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -1,14 +1,21 @@ namespace ts { - export function checkResolvedModule(expected: ResolvedModuleFull | undefined, actual: ResolvedModuleFull): boolean { - if (!expected === !actual) { - if (expected) { - assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.extension === actual.extension, `'ext': expected '${expected.extension}' to be equal to '${actual.extension}'`); - assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); + export function checkResolvedModule(actual: ResolvedModuleFull | undefined, expected: ResolvedModuleFull | undefined): boolean { + if (!expected) { + if (actual) { + assert.fail(actual, expected, "expected resolved module to be undefined"); + return false; } return true; } - return false; + else if (!actual) { + assert.fail(actual, expected, "expected resolved module to be defined"); + return false; + } + + assert.isTrue(actual.resolvedFileName === expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); + assert.isTrue(actual.extension === expected.extension, `'ext': expected '${actual.extension}' to be equal to '${expected.extension}'`); + assert.isTrue(actual.isExternalLibraryImport === expected.isExternalLibraryImport, `'isExternalLibraryImport': expected '${actual.isExternalLibraryImport}' to be equal to '${expected.isExternalLibraryImport}'`); + return true; } export function checkResolvedModuleWithFailedLookupLocations(actual: ResolvedModuleWithFailedLookupLocations, expectedResolvedModule: ResolvedModuleFull, expectedFailedLookupLocations: string[]): void { @@ -396,8 +403,12 @@ namespace ts { function testPreserveSymlinks(preserveSymlinks: boolean) { it(`preserveSymlinks: ${preserveSymlinks}`, () => { const realFileName = "/linked/index.d.ts"; - const symlinkFileName = "/app/node_modulex/linked/index.d.ts"; - const host = createModuleResolutionHost(/*hasDirectoryExists*/ true, { name: realFileName, symlinks: [symlinkFileName] }); + const symlinkFileName = "/app/node_modules/linked/index.d.ts"; + const host = createModuleResolutionHost( + /*hasDirectoryExists*/ true, + { name: realFileName, symlinks: [symlinkFileName] }, + { name: "/app/node_modules/linked/package.json", content: '{"version": "0.0.0", "main": "./index"}' }, + ); const resolution = nodeModuleNameResolver("linked", "/app/app.ts", { preserveSymlinks }, host); const resolvedFileName = preserveSymlinks ? symlinkFileName : realFileName; checkResolvedModule(resolution.resolvedModule, createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ true)); diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index 44082f3a302..f0f9cc6493b 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -177,15 +177,10 @@ namespace ts { file.text = file.text.updateProgram(newProgramText); } - function checkResolvedTypeDirective(expected: ResolvedTypeReferenceDirective, actual: ResolvedTypeReferenceDirective): boolean { - if (!expected === !actual) { - if (expected) { - assert.equal(expected.resolvedFileName, actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.equal(expected.primary, actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); - } - return true; - } - return false; + function checkResolvedTypeDirective(actual: ResolvedTypeReferenceDirective, expected: ResolvedTypeReferenceDirective) { + assert.equal(actual.resolvedFileName, expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); + assert.equal(actual.primary, expected.primary, `'primary': expected '${actual.primary}' to be equal to '${expected.primary}'`); + return true; } function checkCache(caption: string, program: Program, fileName: string, expectedContent: Map | undefined, getCache: (f: SourceFile) => Map | undefined, entryChecker: (expected: T, original: T) => boolean): void { @@ -399,6 +394,30 @@ namespace ts { assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a"), "'a' is not an unresolved module after re-use"); }); + it("works with updated SourceFiles", () => { + // adapted repro from https://github.com/Microsoft/TypeScript/issues/26166 + const files = [ + { name: "/a.ts", text: SourceText.New("", "", 'import * as a from "a";a;') }, + { name: "/types/zzz/index.d.ts", text: SourceText.New("", "", 'declare module "a" { }') }, + ]; + const host = createTestCompilerHost(files, target); + const options: CompilerOptions = { target, typeRoots: ["/types"] }; + const program1 = createProgram(["/a.ts"], options, host); + let sourceFile = program1.getSourceFile("/a.ts")!; + assert.isDefined(sourceFile, "'/a.ts' is included in the program"); + sourceFile = updateSourceFile(sourceFile, "'use strict';" + sourceFile.text, { newLength: "'use strict';".length, span: { start: 0, length: 0 } }); + assert.strictEqual(sourceFile.statements[2].getSourceFile(), sourceFile, "parent pointers are updated"); + const updateHost: TestCompilerHost = { + ...host, + getSourceFile(fileName) { + return fileName === sourceFile.fileName ? sourceFile : program1.getSourceFile(fileName); + } + }; + const program2 = createProgram(["/a.ts"], options, updateHost, program1); + assert.isDefined(program2.getSourceFile("/a.ts")!.resolvedModules!.get("a"), "'a' is not an unresolved module after re-use"); + assert.strictEqual(sourceFile.statements[2].getSourceFile(), sourceFile, "parent pointers are not altered"); + }); + it("resolved type directives cache follows type directives", () => { const files = [ { name: "/a.ts", text: SourceText.New("/// ", "", "var x = $") }, diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index d1405fa9e2c..daa1276e023 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -98,34 +98,55 @@ namespace ts.tscWatch { for (const stamp of outputFileStamps) { assert.isDefined(stamp[1], `${stamp[0]} expected to be present`); } - return { host, outputFileStamps }; + return host; } it("creates solution in watch mode", () => { createSolutionInWatchMode(); }); it("change builds changes and reports found errors message", () => { - const { host, outputFileStamps } = createSolutionInWatchMode(); - host.writeFile(core[1].path, `${core[1].content} + const host = createSolutionInWatchMode(); + verifyChange(`${core[1].content} export class someClass { }`); - host.checkTimeoutQueueLengthAndRun(1); // Builds core - const changedCore = getOutputFileStamps(host); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really - ...getOutputFileNames(SubProject.core, "index") - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds tests - const changedTests = getOutputFileStamps(host); - verifyChangedFiles(changedTests, changedCore, [ - ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds logic - const changedLogic = getOutputFileStamps(host); - verifyChangedFiles(changedLogic, changedTests, [ - ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLength(0); - checkOutputErrorsIncremental(host, emptyArray); + + // Another change requeues and builds it + verifyChange(core[1].content); + + // Two changes together report only single time message: File change detected. Starting incremental compilation... + const outputFileStamps = getOutputFileStamps(host); + const change1 = `${core[1].content} +export class someClass { }`; + host.writeFile(core[1].path, change1); + host.writeFile(core[1].path, `${change1} +export class someClass2 { }`); + verifyChangeAfterTimeout(outputFileStamps); + + function verifyChange(coreContent: string) { + const outputFileStamps = getOutputFileStamps(host); + host.writeFile(core[1].path, coreContent); + verifyChangeAfterTimeout(outputFileStamps); + } + + function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[]) { + host.checkTimeoutQueueLengthAndRun(1); // Builds core + const changedCore = getOutputFileStamps(host); + verifyChangedFiles(changedCore, outputFileStamps, [ + ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really + ...getOutputFileNames(SubProject.core, "index") + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds tests + const changedTests = getOutputFileStamps(host); + verifyChangedFiles(changedTests, changedCore, [ + ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds logic + const changedLogic = getOutputFileStamps(host); + verifyChangedFiles(changedLogic, changedTests, [ + ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLength(0); + checkOutputErrorsIncremental(host, emptyArray); + } }); // TODO: write tests reporting errors but that will have more involved work since file diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index a1e0c0932b2..7114759b097 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -9555,6 +9555,65 @@ export function Test2() { }); }); + describe("tsserverProjectSystem typeReferenceDirectives", () => { + it("when typeReferenceDirective contains UpperCasePackage", () => { + const projectLocation = "/user/username/projects/myproject"; + const libProjectLocation = `${projectLocation}/lib`; + const typeLib: File = { + path: `${libProjectLocation}/@types/UpperCasePackage/index.d.ts`, + content: `declare class BrokenTest { + constructor(name: string, width: number, height: number, onSelect: Function); + Name: string; + SelectedFile: string; +}` + }; + const appLib: File = { + path: `${libProjectLocation}/@app/lib/index.d.ts`, + content: `/// +declare class TestLib { + issue: BrokenTest; + constructor(); + test(): void; +}` + }; + const testProjectLocation = `${projectLocation}/test`; + const testFile: File = { + path: `${testProjectLocation}/test.ts`, + content: `class TestClass1 { + + constructor() { + var l = new TestLib(); + + } + + public test2() { + var x = new BrokenTest('',0,0,null); + + } +}` + }; + const testConfig: File = { + path: `${testProjectLocation}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + module: "amd", + typeRoots: ["../lib/@types", "../lib/@app"] + } + }) + }; + + const files = [typeLib, appLib, testFile, testConfig, libFile]; + const host = createServerHost(files); + const service = createProjectService(host); + service.openClientFile(testFile.path); + checkNumberOfProjects(service, { configuredProjects: 1 }); + const project = service.configuredProjects.get(testConfig.path)!; + checkProjectActualFiles(project, files.map(f => f.path)); + host.writeFile(appLib.path, appLib.content.replace("test()", "test2()")); + host.checkTimeoutQueueLengthAndRun(2); + }); + }); + describe("tsserverProjectSystem project references", () => { const aTs: File = { path: "/a/a.ts", diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 1685dfc3449..d3966071265 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -165,79 +165,10 @@ namespace ts { } function performBuild(args: string[]): number | undefined { - const buildOpts: CommandLineOption[] = [ - { - name: "help", - shortName: "h", - type: "boolean", - showInSimplifiedHelpView: true, - category: Diagnostics.Command_line_Options, - description: Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "verbose", - shortName: "v", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Enable_verbose_logging, - type: "boolean" - }, - { - name: "dry", - shortName: "d", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, - type: "boolean" - }, - { - name: "force", - shortName: "f", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, - type: "boolean" - }, - { - name: "clean", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Delete_the_outputs_of_all_projects, - type: "boolean" - }, - { - name: "watch", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Watch_input_files, - type: "boolean" - }, - { - name: "preserveWatchOutput", - type: "boolean", - category: Diagnostics.Command_line_Options, - description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, - }, - ]; - let buildOptionNameMap: OptionNameMap | undefined; - const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts))); - - const buildOptions: BuildOptions = {}; - const projects: string[] = []; - for (const arg of args) { - if (arg.charCodeAt(0) === CharacterCodes.minus) { - const opt = getOptionDeclarationFromName(returnBuildOptionNameMap, arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1), /*allowShort*/ true); - if (opt) { - buildOptions[opt.name as keyof BuildOptions] = true; - } - else { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unknown_build_option_0, arg)); - } - } - else { - // Not a flag, parse as filename - addProject(arg); - } + const { buildOptions, projects: buildProjects, errors } = parseBuildCommand(args); + if (errors.length > 0) { + errors.forEach(reportDiagnostic); + return ExitStatus.DiagnosticsPresent_OutputsSkipped; } if (buildOptions.help) { @@ -248,6 +179,21 @@ namespace ts { // Update to pretty if host supports it updateReportDiagnostic(); + const projects = mapDefined(buildProjects, project => { + const fileName = resolvePath(sys.getCurrentDirectory(), project); + const refPath = resolveProjectReferencePath(sys, { path: fileName }); + if (!sys.fileExists(refPath)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, fileName)); + return undefined; + } + return refPath; + }); + + if (projects.length === 0) { + printVersion(); + printHelp(buildOpts, "--build "); + return ExitStatus.Success; + } if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--build")); @@ -257,29 +203,6 @@ namespace ts { reportWatchModeWithoutSysSupport(); } - // Nonsensical combinations - if (buildOptions.clean && buildOptions.force) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.clean && buildOptions.verbose) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.clean && buildOptions.watch) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - if (buildOptions.watch && buildOptions.dry) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry")); - return ExitStatus.DiagnosticsPresent_OutputsSkipped; - } - - if (projects.length === 0) { - // tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ." - addProject("."); - } - // TODO: change this to host if watch => watchHost otherwiue without wathc const builder = createSolutionBuilder(createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()), projects, buildOptions); if (buildOptions.clean) { @@ -293,15 +216,6 @@ namespace ts { } return builder.buildAllProjects(); - - function addProject(projectSpecification: string) { - const fileName = resolvePath(sys.getCurrentDirectory(), projectSpecification); - const refPath = resolveProjectReferencePath(sys, { path: fileName }); - if (!sys.fileExists(refPath)) { - return reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, fileName)); - } - projects.push(refPath); - } } function performCompilation(rootNames: string[], projectReferences: ReadonlyArray | undefined, options: CompilerOptions, configFileParsingDiagnostics?: ReadonlyArray) { diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index 53d052eefb3..95b228f6e96 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -924,7 +924,7 @@ namespace ts.server { setStackTraceLimit(); const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation)!; // TODO: GH#18217 - const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(sys.getExecutingFilePath(), "../typesMap.json"); + const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(getDirectoryPath(sys.getExecutingFilePath()), "typesMap.json"); const npmLocation = findArgument(Arguments.NpmLocation); function parseStringArray(argName: string): ReadonlyArray { diff --git a/tests/baselines/reference/abstractPropertyInConstructor.errors.txt b/tests/baselines/reference/abstractPropertyInConstructor.errors.txt index 0798d91ce78..5337bfc538a 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.errors.txt +++ b/tests/baselines/reference/abstractPropertyInConstructor.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(4,24): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. tests/cases/compiler/abstractPropertyInConstructor.ts(7,18): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. tests/cases/compiler/abstractPropertyInConstructor.ts(9,14): error TS2715: Abstract property 'cb' in class 'AbstractClass' cannot be accessed in the constructor. +tests/cases/compiler/abstractPropertyInConstructor.ts(25,18): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. -==== tests/cases/compiler/abstractPropertyInConstructor.ts (3 errors) ==== +==== tests/cases/compiler/abstractPropertyInConstructor.ts (4 errors) ==== abstract class AbstractClass { constructor(str: string, other: AbstractClass) { this.method(parseInt(str)); @@ -34,6 +35,11 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(9,14): error TS2715: Abstr abstract method(num: number): void; + other = this.prop; + ~~~~ +!!! error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. + fn = () => this.prop; + method2() { this.prop = this.prop + "!"; } diff --git a/tests/baselines/reference/abstractPropertyInConstructor.js b/tests/baselines/reference/abstractPropertyInConstructor.js index 5a4feda110f..782419ac67b 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.js +++ b/tests/baselines/reference/abstractPropertyInConstructor.js @@ -23,6 +23,9 @@ abstract class AbstractClass { abstract method(num: number): void; + other = this.prop; + fn = () => this.prop; + method2() { this.prop = this.prop + "!"; } @@ -42,6 +45,8 @@ class User { var AbstractClass = /** @class */ (function () { function AbstractClass(str, other) { var _this = this; + this.other = this.prop; + this.fn = function () { return _this.prop; }; this.method(parseInt(str)); var val = this.prop.toLowerCase(); if (!str) { diff --git a/tests/baselines/reference/abstractPropertyInConstructor.symbols b/tests/baselines/reference/abstractPropertyInConstructor.symbols index f1baa962072..71f897118c8 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.symbols +++ b/tests/baselines/reference/abstractPropertyInConstructor.symbols @@ -67,8 +67,20 @@ abstract class AbstractClass { >method : Symbol(AbstractClass.method, Decl(abstractPropertyInConstructor.ts, 20, 37)) >num : Symbol(num, Decl(abstractPropertyInConstructor.ts, 22, 20)) + other = this.prop; +>other : Symbol(AbstractClass.other, Decl(abstractPropertyInConstructor.ts, 22, 39)) +>this.prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) +>this : Symbol(AbstractClass, Decl(abstractPropertyInConstructor.ts, 0, 0)) +>prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) + + fn = () => this.prop; +>fn : Symbol(AbstractClass.fn, Decl(abstractPropertyInConstructor.ts, 24, 22)) +>this.prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) +>this : Symbol(AbstractClass, Decl(abstractPropertyInConstructor.ts, 0, 0)) +>prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) + method2() { ->method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 22, 39)) +>method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 25, 25)) this.prop = this.prop + "!"; >this.prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) @@ -81,31 +93,31 @@ abstract class AbstractClass { } class User { ->User : Symbol(User, Decl(abstractPropertyInConstructor.ts, 27, 1)) +>User : Symbol(User, Decl(abstractPropertyInConstructor.ts, 30, 1)) constructor(a: AbstractClass) { ->a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 30, 16)) +>a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 33, 16)) >AbstractClass : Symbol(AbstractClass, Decl(abstractPropertyInConstructor.ts, 0, 0)) a.prop; >a.prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) ->a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 30, 16)) +>a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 33, 16)) >prop : Symbol(AbstractClass.prop, Decl(abstractPropertyInConstructor.ts, 17, 5)) a.cb("hi"); >a.cb : Symbol(AbstractClass.cb, Decl(abstractPropertyInConstructor.ts, 19, 26)) ->a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 30, 16)) +>a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 33, 16)) >cb : Symbol(AbstractClass.cb, Decl(abstractPropertyInConstructor.ts, 19, 26)) a.method(12); >a.method : Symbol(AbstractClass.method, Decl(abstractPropertyInConstructor.ts, 20, 37)) ->a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 30, 16)) +>a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 33, 16)) >method : Symbol(AbstractClass.method, Decl(abstractPropertyInConstructor.ts, 20, 37)) a.method2(); ->a.method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 22, 39)) ->a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 30, 16)) ->method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 22, 39)) +>a.method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 25, 25)) +>a : Symbol(a, Decl(abstractPropertyInConstructor.ts, 33, 16)) +>method2 : Symbol(AbstractClass.method2, Decl(abstractPropertyInConstructor.ts, 25, 25)) } } diff --git a/tests/baselines/reference/abstractPropertyInConstructor.types b/tests/baselines/reference/abstractPropertyInConstructor.types index 23e1aac50f7..465e0fb2f04 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.types +++ b/tests/baselines/reference/abstractPropertyInConstructor.types @@ -75,6 +75,19 @@ abstract class AbstractClass { >method : (num: number) => void >num : number + other = this.prop; +>other : string +>this.prop : string +>this : this +>prop : string + + fn = () => this.prop; +>fn : () => string +>() => this.prop : () => string +>this.prop : string +>this : this +>prop : string + method2() { >method2 : () => void diff --git a/tests/baselines/reference/ambientConstLiterals.js b/tests/baselines/reference/ambientConstLiterals.js index 7c7da7321c3..b0b222128ac 100644 --- a/tests/baselines/reference/ambientConstLiterals.js +++ b/tests/baselines/reference/ambientConstLiterals.js @@ -3,7 +3,7 @@ function f(x: T): T { return x; } -enum E { A, B, C } +enum E { A, B, C, "non identifier" } const c1 = "abc"; const c2 = 123; @@ -13,6 +13,7 @@ const c5 = f(123); const c6 = f(-123); const c7 = true; const c8 = E.A; +const c8b = E["non identifier"]; const c9 = { x: "abc" }; const c10 = [123]; const c11 = "abc" + "def"; @@ -29,6 +30,7 @@ var E; E[E["A"] = 0] = "A"; E[E["B"] = 1] = "B"; E[E["C"] = 2] = "C"; + E[E["non identifier"] = 3] = "non identifier"; })(E || (E = {})); var c1 = "abc"; var c2 = 123; @@ -38,6 +40,7 @@ var c5 = f(123); var c6 = f(-123); var c7 = true; var c8 = E.A; +var c8b = E["non identifier"]; var c9 = { x: "abc" }; var c10 = [123]; var c11 = "abc" + "def"; @@ -51,7 +54,8 @@ declare function f(x: T): T; declare enum E { A = 0, B = 1, - C = 2 + C = 2, + "non identifier" = 3 } declare const c1 = "abc"; declare const c2 = 123; @@ -60,7 +64,8 @@ declare const c4 = 123; declare const c5 = 123; declare const c6 = -123; declare const c7: boolean; -declare const c8: E; +declare const c8 = E.A; +declare const c8b = E["non identifier"]; declare const c9: { x: string; }; diff --git a/tests/baselines/reference/ambientConstLiterals.symbols b/tests/baselines/reference/ambientConstLiterals.symbols index 905ec3fd4fd..482300a3218 100644 --- a/tests/baselines/reference/ambientConstLiterals.symbols +++ b/tests/baselines/reference/ambientConstLiterals.symbols @@ -10,11 +10,12 @@ function f(x: T): T { >x : Symbol(x, Decl(ambientConstLiterals.ts, 0, 14)) } -enum E { A, B, C } +enum E { A, B, C, "non identifier" } >E : Symbol(E, Decl(ambientConstLiterals.ts, 2, 1)) >A : Symbol(E.A, Decl(ambientConstLiterals.ts, 4, 8)) >B : Symbol(E.B, Decl(ambientConstLiterals.ts, 4, 11)) >C : Symbol(E.C, Decl(ambientConstLiterals.ts, 4, 14)) +>"non identifier" : Symbol(E["non identifier"], Decl(ambientConstLiterals.ts, 4, 17)) const c1 = "abc"; >c1 : Symbol(c1, Decl(ambientConstLiterals.ts, 6, 5)) @@ -47,27 +48,32 @@ const c8 = E.A; >E : Symbol(E, Decl(ambientConstLiterals.ts, 2, 1)) >A : Symbol(E.A, Decl(ambientConstLiterals.ts, 4, 8)) +const c8b = E["non identifier"]; +>c8b : Symbol(c8b, Decl(ambientConstLiterals.ts, 14, 5)) +>E : Symbol(E, Decl(ambientConstLiterals.ts, 2, 1)) +>"non identifier" : Symbol(E["non identifier"], Decl(ambientConstLiterals.ts, 4, 17)) + const c9 = { x: "abc" }; ->c9 : Symbol(c9, Decl(ambientConstLiterals.ts, 14, 5)) ->x : Symbol(x, Decl(ambientConstLiterals.ts, 14, 12)) +>c9 : Symbol(c9, Decl(ambientConstLiterals.ts, 15, 5)) +>x : Symbol(x, Decl(ambientConstLiterals.ts, 15, 12)) const c10 = [123]; ->c10 : Symbol(c10, Decl(ambientConstLiterals.ts, 15, 5)) +>c10 : Symbol(c10, Decl(ambientConstLiterals.ts, 16, 5)) const c11 = "abc" + "def"; ->c11 : Symbol(c11, Decl(ambientConstLiterals.ts, 16, 5)) +>c11 : Symbol(c11, Decl(ambientConstLiterals.ts, 17, 5)) const c12 = 123 + 456; ->c12 : Symbol(c12, Decl(ambientConstLiterals.ts, 17, 5)) +>c12 : Symbol(c12, Decl(ambientConstLiterals.ts, 18, 5)) const c13 = Math.random() > 0.5 ? "abc" : "def"; ->c13 : Symbol(c13, Decl(ambientConstLiterals.ts, 18, 5)) +>c13 : Symbol(c13, Decl(ambientConstLiterals.ts, 19, 5)) >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) const c14 = Math.random() > 0.5 ? 123 : 456; ->c14 : Symbol(c14, Decl(ambientConstLiterals.ts, 19, 5)) +>c14 : Symbol(c14, Decl(ambientConstLiterals.ts, 20, 5)) >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/ambientConstLiterals.types b/tests/baselines/reference/ambientConstLiterals.types index e27776e1847..a40532f8017 100644 --- a/tests/baselines/reference/ambientConstLiterals.types +++ b/tests/baselines/reference/ambientConstLiterals.types @@ -7,11 +7,12 @@ function f(x: T): T { >x : T } -enum E { A, B, C } +enum E { A, B, C, "non identifier" } >E : E >A : E.A >B : E.B >C : E.C +>"non identifier" : E.non identifier const c1 = "abc"; >c1 : "abc" @@ -52,6 +53,12 @@ const c8 = E.A; >E : typeof E >A : E.A +const c8b = E["non identifier"]; +>c8b : E.non identifier +>E["non identifier"] : E.non identifier +>E : typeof E +>"non identifier" : "non identifier" + const c9 = { x: "abc" }; >c9 : { x: string; } >{ x: "abc" } : { x: string; } diff --git a/tests/baselines/reference/ambientEnum1.types b/tests/baselines/reference/ambientEnum1.types index 968299f4d0a..29573226568 100644 --- a/tests/baselines/reference/ambientEnum1.types +++ b/tests/baselines/reference/ambientEnum1.types @@ -3,7 +3,7 @@ >E1 : E1 y = 4.23 ->y : E1 +>y : E1.y >4.23 : 4.23 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer1.types b/tests/baselines/reference/ambientEnumElementInitializer1.types index 11ef7449504..4fa9d5efdf7 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer1.types +++ b/tests/baselines/reference/ambientEnumElementInitializer1.types @@ -3,6 +3,6 @@ declare enum E { >E : E e = 3 ->e : E +>e : E.e >3 : 3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer2.types b/tests/baselines/reference/ambientEnumElementInitializer2.types index 47d85bf3c84..218863379d7 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer2.types +++ b/tests/baselines/reference/ambientEnumElementInitializer2.types @@ -3,7 +3,7 @@ declare enum E { >E : E e = -3 // Negative ->e : E +>e : E.e >-3 : -3 >3 : 3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.types b/tests/baselines/reference/ambientEnumElementInitializer3.types index 3c099d00ede..e4cf5678d7b 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer3.types +++ b/tests/baselines/reference/ambientEnumElementInitializer3.types @@ -3,6 +3,6 @@ declare enum E { >E : E e = 3.3 // Decimal ->e : E +>e : E.e >3.3 : 3.3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer4.types b/tests/baselines/reference/ambientEnumElementInitializer4.types index 3bef657f5bb..2cd8c75600d 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer4.types +++ b/tests/baselines/reference/ambientEnumElementInitializer4.types @@ -3,6 +3,6 @@ declare enum E { >E : E e = 0xA ->e : E +>e : E.e >0xA : 10 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer5.types b/tests/baselines/reference/ambientEnumElementInitializer5.types index b3020a6d777..71919718a6e 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer5.types +++ b/tests/baselines/reference/ambientEnumElementInitializer5.types @@ -3,7 +3,7 @@ declare enum E { >E : E e = -0xA ->e : E +>e : E.e >-0xA : -10 >0xA : 10 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer6.types b/tests/baselines/reference/ambientEnumElementInitializer6.types index f093d0e2dfe..9caad2dde7a 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer6.types +++ b/tests/baselines/reference/ambientEnumElementInitializer6.types @@ -6,7 +6,7 @@ declare module M { >E : E e = 3 ->e : E +>e : E.e >3 : 3 } } diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 7b42085e0c2..05e72ccc879 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(2,17): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(29,9): error TS1066: In ambient enum declarations member initializer must be constant expression. -tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(34,13): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(38,13): error TS1039: Initializers are not allowed in ambient contexts. @@ -17,7 +17,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export ==== tests/cases/conformance/ambient/ambientErrors.ts (14 errors) ==== // Ambient variable with an initializer declare var x = 4; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. // Ambient functions with invalid overloads @@ -57,7 +57,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export // Ambient module with initializers for values, bodies for functions / classes declare module M1 { var x = 3; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. function fn() { } ~ diff --git a/tests/baselines/reference/ambientErrors.types b/tests/baselines/reference/ambientErrors.types index 6286d4320ad..a1d33d29eeb 100644 --- a/tests/baselines/reference/ambientErrors.types +++ b/tests/baselines/reference/ambientErrors.types @@ -46,7 +46,7 @@ declare enum E1 { >E1 : E1 y = 4.23 ->y : E1 +>y : E1.y >4.23 : 4.23 } diff --git a/tests/baselines/reference/ambientErrors1.errors.txt b/tests/baselines/reference/ambientErrors1.errors.txt index db7a155cc3f..5ae2b615eec 100644 --- a/tests/baselines/reference/ambientErrors1.errors.txt +++ b/tests/baselines/reference/ambientErrors1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/ambientErrors1.ts(1,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/ambientErrors1.ts(1,17): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/ambientErrors1.ts (1 errors) ==== declare var x = 4; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/ambientStatement1.errors.txt b/tests/baselines/reference/ambientStatement1.errors.txt index be7c7bb750c..1a5fb644113 100644 --- a/tests/baselines/reference/ambientStatement1.errors.txt +++ b/tests/baselines/reference/ambientStatement1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/ambientStatement1.ts(2,6): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientStatement1.ts(4,20): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/ambientStatement1.ts(4,22): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/ambientStatement1.ts (2 errors) ==== @@ -9,6 +9,6 @@ tests/cases/compiler/ambientStatement1.ts(4,20): error TS1039: Initializers are !!! error TS1036: Statements are not allowed in ambient contexts. export var v1 = () => false; - ~ + ~~~~~~~~~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/anyAssignabilityInInheritance.types b/tests/baselines/reference/anyAssignabilityInInheritance.types index f0c1684d63c..7afcf99fb2c 100644 --- a/tests/baselines/reference/anyAssignabilityInInheritance.types +++ b/tests/baselines/reference/anyAssignabilityInInheritance.types @@ -199,7 +199,7 @@ var r3 = foo3(a); // any enum E { A } >E : E ->A : E +>A : E.A declare function foo14(x: E): E; >foo14 : { (x: E): E; (x: any): any; } diff --git a/tests/baselines/reference/anyAssignableToEveryType.types b/tests/baselines/reference/anyAssignableToEveryType.types index c4ac27e5b67..17d8ddea497 100644 --- a/tests/baselines/reference/anyAssignableToEveryType.types +++ b/tests/baselines/reference/anyAssignableToEveryType.types @@ -20,7 +20,7 @@ var ai: I; enum E { A } >E : E ->A : E +>A : E.A var ae: E; >ae : E diff --git a/tests/baselines/reference/anyAssignableToEveryType2.types b/tests/baselines/reference/anyAssignableToEveryType2.types index c4c21f503b6..146251c4a7a 100644 --- a/tests/baselines/reference/anyAssignableToEveryType2.types +++ b/tests/baselines/reference/anyAssignableToEveryType2.types @@ -129,7 +129,7 @@ interface I13 { enum E { A } >E : E ->A : E +>A : E.A interface I14 { [x: string]: E; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 911fd328f3b..2fa23f14a7b 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -536,6 +536,7 @@ declare namespace ts { name?: Identifier | StringLiteral | NumericLiteral; } interface ComputedPropertyName extends Node { + parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } @@ -632,6 +633,7 @@ declare namespace ts { kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; equalsToken?: Token; objectAssignmentInitializer?: Expression; } @@ -668,6 +670,7 @@ declare namespace ts { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; body?: Block | Expression; } type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; @@ -2060,28 +2063,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67216319, - Type = 67901928, + Value = 67220415, + Type = 67897832, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67216318, - BlockScopedVariableExcludes = 67216319, - ParameterExcludes = 67216319, + FunctionScopedVariableExcludes = 67220414, + BlockScopedVariableExcludes = 67220415, + ParameterExcludes = 67220415, PropertyExcludes = 0, EnumMemberExcludes = 68008959, - FunctionExcludes = 67215791, + FunctionExcludes = 67219887, ClassExcludes = 68008383, - InterfaceExcludes = 67901832, + InterfaceExcludes = 67897736, RegularEnumExcludes = 68008191, ConstEnumExcludes = 68008831, - ValueModuleExcludes = 67215503, + ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67208127, - GetAccessorExcludes = 67150783, - SetAccessorExcludes = 67183551, - TypeParameterExcludes = 67639784, - TypeAliasExcludes = 67901928, + MethodExcludes = 67212223, + GetAccessorExcludes = 67154879, + SetAccessorExcludes = 67187647, + TypeParameterExcludes = 67635688, + TypeAliasExcludes = 67897832, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -3208,17 +3211,27 @@ declare namespace ts { /** * Gets the JSDoc parameter tags for the node if present. * - * @remarks Returns any JSDoc param tag that matches the provided + * @remarks Returns any JSDoc param tag whose name matches the provided * parameter, whether a param tag on a containing function * expression, or a param tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are returned first, so in the previous example, the param * tag on the containing function expression would be first. * - * Does not return tags for binding patterns, because JSDoc matches - * parameters by name and binding patterns do not have a name. + * For binding patterns, parameter tags are matched by position. */ function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + /** + * Gets the JSDoc type parameter tags for the node if present. + * + * @remarks Returns any JSDoc template tag whose names match the provided + * parameter, whether a template tag on a containing function + * expression, or a template tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the template + * tag on the containing function expression would be first. + */ + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; /** * Return true if the node has JSDoc parameter tags. * diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c12d797bea8..8290cb96236 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -536,6 +536,7 @@ declare namespace ts { name?: Identifier | StringLiteral | NumericLiteral; } interface ComputedPropertyName extends Node { + parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } @@ -632,6 +633,7 @@ declare namespace ts { kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; equalsToken?: Token; objectAssignmentInitializer?: Expression; } @@ -668,6 +670,7 @@ declare namespace ts { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; + exclamationToken?: ExclamationToken; body?: Block | Expression; } type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; @@ -2060,28 +2063,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67216319, - Type = 67901928, + Value = 67220415, + Type = 67897832, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67216318, - BlockScopedVariableExcludes = 67216319, - ParameterExcludes = 67216319, + FunctionScopedVariableExcludes = 67220414, + BlockScopedVariableExcludes = 67220415, + ParameterExcludes = 67220415, PropertyExcludes = 0, EnumMemberExcludes = 68008959, - FunctionExcludes = 67215791, + FunctionExcludes = 67219887, ClassExcludes = 68008383, - InterfaceExcludes = 67901832, + InterfaceExcludes = 67897736, RegularEnumExcludes = 68008191, ConstEnumExcludes = 68008831, - ValueModuleExcludes = 67215503, + ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67208127, - GetAccessorExcludes = 67150783, - SetAccessorExcludes = 67183551, - TypeParameterExcludes = 67639784, - TypeAliasExcludes = 67901928, + MethodExcludes = 67212223, + GetAccessorExcludes = 67154879, + SetAccessorExcludes = 67187647, + TypeParameterExcludes = 67635688, + TypeAliasExcludes = 67897832, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -3208,17 +3211,27 @@ declare namespace ts { /** * Gets the JSDoc parameter tags for the node if present. * - * @remarks Returns any JSDoc param tag that matches the provided + * @remarks Returns any JSDoc param tag whose name matches the provided * parameter, whether a param tag on a containing function * expression, or a param tag on a variable declaration whose * initializer is the containing function. The tags closest to the * node are returned first, so in the previous example, the param * tag on the containing function expression would be first. * - * Does not return tags for binding patterns, because JSDoc matches - * parameters by name and binding patterns do not have a name. + * For binding patterns, parameter tags are matched by position. */ function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + /** + * Gets the JSDoc type parameter tags for the node if present. + * + * @remarks Returns any JSDoc template tag whose names match the provided + * parameter, whether a template tag on a containing function + * expression, or a template tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the template + * tag on the containing function expression would be first. + */ + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; /** * Return true if the node has JSDoc parameter tags. * diff --git a/tests/baselines/reference/arrayFlatMap.js b/tests/baselines/reference/arrayFlatMap.js new file mode 100644 index 00000000000..3c35cedc1f3 --- /dev/null +++ b/tests/baselines/reference/arrayFlatMap.js @@ -0,0 +1,12 @@ +//// [arrayFlatMap.ts] +const array: number[] = []; +const readonlyArray: ReadonlyArray = []; +array.flatMap((): ReadonlyArray => []); // ok +readonlyArray.flatMap((): ReadonlyArray => []); // ok + + +//// [arrayFlatMap.js] +var array = []; +var readonlyArray = []; +array.flatMap(function () { return []; }); // ok +readonlyArray.flatMap(function () { return []; }); // ok diff --git a/tests/baselines/reference/arrayFlatMap.symbols b/tests/baselines/reference/arrayFlatMap.symbols new file mode 100644 index 00000000000..0a97341657b --- /dev/null +++ b/tests/baselines/reference/arrayFlatMap.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/arrayFlatMap.ts === +const array: number[] = []; +>array : Symbol(array, Decl(arrayFlatMap.ts, 0, 5)) + +const readonlyArray: ReadonlyArray = []; +>readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) + +array.flatMap((): ReadonlyArray => []); // ok +>array.flatMap : Symbol(Array.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>array : Symbol(array, Decl(arrayFlatMap.ts, 0, 5)) +>flatMap : Symbol(Array.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) + +readonlyArray.flatMap((): ReadonlyArray => []); // ok +>readonlyArray.flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5)) +>flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.array.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.esnext.array.d.ts, --, --)) + diff --git a/tests/baselines/reference/arrayFlatMap.types b/tests/baselines/reference/arrayFlatMap.types new file mode 100644 index 00000000000..7eb4d444ecf --- /dev/null +++ b/tests/baselines/reference/arrayFlatMap.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/arrayFlatMap.ts === +const array: number[] = []; +>array : number[] +>[] : undefined[] + +const readonlyArray: ReadonlyArray = []; +>readonlyArray : ReadonlyArray +>[] : undefined[] + +array.flatMap((): ReadonlyArray => []); // ok +>array.flatMap((): ReadonlyArray => []) : number[] +>array.flatMap : (callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray, thisArg?: This) => U[] +>array : number[] +>flatMap : (callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray, thisArg?: This) => U[] +>(): ReadonlyArray => [] : () => ReadonlyArray +>[] : undefined[] + +readonlyArray.flatMap((): ReadonlyArray => []); // ok +>readonlyArray.flatMap((): ReadonlyArray => []) : number[] +>readonlyArray.flatMap : (callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray, thisArg?: This) => U[] +>readonlyArray : ReadonlyArray +>flatMap : (callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray, thisArg?: This) => U[] +>(): ReadonlyArray => [] : () => ReadonlyArray +>[] : undefined[] + diff --git a/tests/baselines/reference/arrayIndexWithArrayFails.errors.txt b/tests/baselines/reference/arrayIndexWithArrayFails.errors.txt new file mode 100644 index 00000000000..bfe75e6d79c --- /dev/null +++ b/tests/baselines/reference/arrayIndexWithArrayFails.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/arrayIndexWithArrayFails.ts(3,16): error TS2538: Type 'string[]' cannot be used as an index type. + + +==== tests/cases/compiler/arrayIndexWithArrayFails.ts (1 errors) ==== + declare const arr1: (string | string[])[]; + declare const arr2: number[]; + const j = arr2[arr1[0]]; // should error + ~~~~~~~ +!!! error TS2538: Type 'string[]' cannot be used as an index type. \ No newline at end of file diff --git a/tests/baselines/reference/arrayIndexWithArrayFails.js b/tests/baselines/reference/arrayIndexWithArrayFails.js new file mode 100644 index 00000000000..e5541a50704 --- /dev/null +++ b/tests/baselines/reference/arrayIndexWithArrayFails.js @@ -0,0 +1,7 @@ +//// [arrayIndexWithArrayFails.ts] +declare const arr1: (string | string[])[]; +declare const arr2: number[]; +const j = arr2[arr1[0]]; // should error + +//// [arrayIndexWithArrayFails.js] +var j = arr2[arr1[0]]; // should error diff --git a/tests/baselines/reference/arrayIndexWithArrayFails.symbols b/tests/baselines/reference/arrayIndexWithArrayFails.symbols new file mode 100644 index 00000000000..e389f29fbef --- /dev/null +++ b/tests/baselines/reference/arrayIndexWithArrayFails.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/arrayIndexWithArrayFails.ts === +declare const arr1: (string | string[])[]; +>arr1 : Symbol(arr1, Decl(arrayIndexWithArrayFails.ts, 0, 13)) + +declare const arr2: number[]; +>arr2 : Symbol(arr2, Decl(arrayIndexWithArrayFails.ts, 1, 13)) + +const j = arr2[arr1[0]]; // should error +>j : Symbol(j, Decl(arrayIndexWithArrayFails.ts, 2, 5)) +>arr2 : Symbol(arr2, Decl(arrayIndexWithArrayFails.ts, 1, 13)) +>arr1 : Symbol(arr1, Decl(arrayIndexWithArrayFails.ts, 0, 13)) + diff --git a/tests/baselines/reference/arrayIndexWithArrayFails.types b/tests/baselines/reference/arrayIndexWithArrayFails.types new file mode 100644 index 00000000000..7e9b28f733c --- /dev/null +++ b/tests/baselines/reference/arrayIndexWithArrayFails.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/arrayIndexWithArrayFails.ts === +declare const arr1: (string | string[])[]; +>arr1 : (string | string[])[] + +declare const arr2: number[]; +>arr2 : number[] + +const j = arr2[arr1[0]]; // should error +>j : any +>arr2[arr1[0]] : any +>arr2 : number[] +>arr1[0] : string | string[] +>arr1 : (string | string[])[] +>0 : 0 + diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 7ae20699c85..66a659b3863 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -1,13 +1,11 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. - Type 'A[]' is not assignable to type 'B[]'. - Type 'A' is not assignable to type 'B'. - Property 'b' is missing in type 'A'. + Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. Types of property 'concat' are incompatible. Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. ==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== @@ -26,11 +24,8 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T rrb = ara; // error: 'A' is not assignable to 'B' ~~~ !!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. -!!! error TS2322: Types of property 'concat' are incompatible. -!!! error TS2322: Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. -!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. -!!! error TS2322: Property 'b' is missing in type 'A'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'A'. rra = cra; rra = crb; // OK, C is assignable to ReadonlyArray @@ -41,4 +36,5 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T !!! error TS2322: Types of property 'concat' are incompatible. !!! error TS2322: Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. !!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/assignAnyToEveryType.types b/tests/baselines/reference/assignAnyToEveryType.types index bddd4fcb45c..11aa0e48a77 100644 --- a/tests/baselines/reference/assignAnyToEveryType.types +++ b/tests/baselines/reference/assignAnyToEveryType.types @@ -42,7 +42,7 @@ enum E { >E : E A ->A : E +>A : E.A } var g: E = x; diff --git a/tests/baselines/reference/assignEveryTypeToAny.types b/tests/baselines/reference/assignEveryTypeToAny.types index a0b397a003b..8cec100b8be 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.types +++ b/tests/baselines/reference/assignEveryTypeToAny.types @@ -76,7 +76,7 @@ enum E { >E : E A ->A : E +>A : E.A } x = E.A; diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt index 03dcee9baf3..b17973302c6 100644 --- a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt @@ -1,8 +1,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. - Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]'. Property '0' is missing in type '{}[]'. @@ -27,10 +25,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme numArray = numStrTuple; ~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. emptyObjTuple = emptyObjArray; ~~~~~~~~~~~~~ !!! error TS2322: Type '{}[]' is not assignable to type '[{}]'. diff --git a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt index 2316320f480..6686167cf1e 100644 --- a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt +++ b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,5): error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'. - Types of property 'name' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,17): error TS2322: Type 'false' is not assignable to type 'string'. tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'. Property 'id' is missing in type '{ name: string; }'. @@ -13,10 +11,9 @@ tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS foo({ id: 1234 }); // Ok foo({ id: 1234, name: "hello" }); // Ok foo({ id: 1234, name: false }); // Error, name of wrong type - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'. -!!! error TS2345: Types of property 'name' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. + ~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts:1:31: The expected type comes from property 'name' which is declared here on type '{ id: number; name?: string; }' foo({ name: "hello" }); // Error, id required but missing ~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index 28fe7c738a6..441810033d2 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(85,1): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(86,1): error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (15 errors) ==== // these are all permitted with the current rules, since we do not do contextual signature instantiation class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 39d3a2a3593..0a2ae478989 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(66,9): error TS2322: Type '(x: Base[], y: Derived2[]) => Derived[]' is not assignable to type '(x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(69,9): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(70,9): error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -156,8 +158,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index ba8f5304aa2..57944ae9863 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(40,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(52,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(55,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(58,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (4 errors) ==== // checking assignment compat for function types. No errors in this file class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: (x: { a: U; b: V; }) => U[]; a15 = b15; // ok, T = U, T = V b15 = a15; // ok ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index b8399a1855b..e3d7fda7ba3 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(30,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(39,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(42,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index f9a5be732c9..3bce93635d0 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(85,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(86,1): error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (15 errors) ==== // checking assignment compatibility relations for function types. All of these are valid. class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: new (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 8679b1d85f1..620e83e1603 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(66,9): error TS2322: Type 'new (x: Base[], y: Derived2[]) => Derived[]' is not assignable to type 'new (x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(69,9): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(70,9): error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -172,8 +174,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 23e0c682fdc..5445d9ee35a 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(40,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(52,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(55,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(58,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (4 errors) ==== // checking assignment compat for function types. All valid class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: new (x: { a: U; b: V; }) => U[]; a15 = b15; // ok b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: new (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index f89db500202..399a56e4136 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(30,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(39,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(42,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid. class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: new (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 7e39c3305a3..38f03ca68c4 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(15,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of parameters 'y' and 'y' are incompatible. + Type 'T[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(16,1): error TS2322: Type 'A' is not assignable to type 'B'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'S[]'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (2 errors) ==== // some complex cases of assignment compat of generic signatures. No contextual signature instantiation interface A { @@ -17,8 +20,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var a: A; var b: B; - // Both ok + // Both errors a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type 'T[]' is not assignable to type 'T'. b = a; ~ !!! error TS2322: Type 'A' is not assignable to type 'B'. diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js index dd9b553791d..057cbebb382 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js @@ -12,7 +12,7 @@ interface B { var a: A; var b: B; -// Both ok +// Both errors a = b; b = a; @@ -21,6 +21,6 @@ b = a; // some complex cases of assignment compat of generic signatures. No contextual signature instantiation var a; var b; -// Both ok +// Both errors a = b; b = a; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols index 73991a789a2..9a37bebd6e2 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols @@ -31,7 +31,7 @@ var b: B; >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) >B : Symbol(B, Decl(assignmentCompatWithGenericCallSignatures2.ts, 4, 1)) -// Both ok +// Both errors a = b; >a : Symbol(a, Decl(assignmentCompatWithGenericCallSignatures2.ts, 10, 3)) >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types index 31b075d5bce..ab5bc2d49e8 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types @@ -19,7 +19,7 @@ var a: A; var b: B; >b : B -// Both ok +// Both errors a = b; >a = b : B >a : A diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types index ab95fb8cb2f..98083655144 100644 --- a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types @@ -294,7 +294,7 @@ enum E { >E : E A ->A : E +>A : E.A } E = undefined; // Error >E = undefined : undefined diff --git a/tests/baselines/reference/assignments.types b/tests/baselines/reference/assignments.types index f83b6eadbe0..03d53e22825 100644 --- a/tests/baselines/reference/assignments.types +++ b/tests/baselines/reference/assignments.types @@ -24,7 +24,7 @@ C = null; // Error enum E { A } >E : E ->A : E +>A : E.A E = null; // Error >E = null : null diff --git a/tests/baselines/reference/asyncEnum_es5.types b/tests/baselines/reference/asyncEnum_es5.types index 2f94fd33152..97d27a1a093 100644 --- a/tests/baselines/reference/asyncEnum_es5.types +++ b/tests/baselines/reference/asyncEnum_es5.types @@ -3,5 +3,5 @@ async enum E { >E : E Value ->Value : E +>Value : E.Value } diff --git a/tests/baselines/reference/asyncEnum_es6.types b/tests/baselines/reference/asyncEnum_es6.types index c28b646edf9..22a560c2ca1 100644 --- a/tests/baselines/reference/asyncEnum_es6.types +++ b/tests/baselines/reference/asyncEnum_es6.types @@ -3,5 +3,5 @@ async enum E { >E : E Value ->Value : E +>Value : E.Value } diff --git a/tests/baselines/reference/augmentedTypesClass.types b/tests/baselines/reference/augmentedTypesClass.types index 6bee329d24e..91bffcf0d2a 100644 --- a/tests/baselines/reference/augmentedTypesClass.types +++ b/tests/baselines/reference/augmentedTypesClass.types @@ -15,5 +15,5 @@ class c4 { public foo() { } } enum c4 { One } // error >c4 : c4 ->One : c4 +>One : c4.One diff --git a/tests/baselines/reference/augmentedTypesClass2.types b/tests/baselines/reference/augmentedTypesClass2.types index df4379508b8..4f80fe6d16a 100644 --- a/tests/baselines/reference/augmentedTypesClass2.types +++ b/tests/baselines/reference/augmentedTypesClass2.types @@ -32,7 +32,7 @@ class c33 { } enum c33 { One }; >c33 : c33 ->One : c33 +>One : c33.One // class then import class c44 { diff --git a/tests/baselines/reference/augmentedTypesEnum.types b/tests/baselines/reference/augmentedTypesEnum.types index d6fcf87f138..27ce4f7c400 100644 --- a/tests/baselines/reference/augmentedTypesEnum.types +++ b/tests/baselines/reference/augmentedTypesEnum.types @@ -2,7 +2,7 @@ // enum then var enum e1111 { One } // error >e1111 : e1111 ->One : e1111 +>One : e1111.One var e1111 = 1; // error >e1111 : number @@ -11,14 +11,14 @@ var e1111 = 1; // error // enum then function enum e2 { One } // error >e2 : e2 ->One : e2 +>One : e2.One function e2() { } // error >e2 : () => void enum e3 { One } // error >e3 : e3 ->One : e3 +>One : e3.One var e3 = () => { } // error >e3 : () => void @@ -27,7 +27,7 @@ var e3 = () => { } // error // enum then class enum e4 { One } // error >e4 : e4 ->One : e4 +>One : e4.One class e4 { public foo() { } } // error >e4 : e4 @@ -36,30 +36,30 @@ class e4 { public foo() { } } // error // enum then enum enum e5 { One } >e5 : e5 ->One : e5 +>One : e5.One enum e5 { Two } // error >e5 : e5 ->Two : e5 +>Two : e5.One enum e5a { One } // error >e5a : e5a ->One : e5a +>One : e5a.One enum e5a { One } // error >e5a : e5a ->One : e5a +>One : e5a.One // enum then internal module enum e6 { One } >e6 : e6 ->One : e6 +>One : e6.One module e6 { } // ok enum e6a { One } >e6a : e6a ->One : e6a +>One : e6a.One module e6a { var y = 2; } // should be error >e6a : typeof e6a @@ -68,7 +68,7 @@ module e6a { var y = 2; } // should be error enum e6b { One } >e6b : e6b ->One : e6b +>One : e6b.One module e6b { export var y = 2; } // should be error >e6b : typeof e6b diff --git a/tests/baselines/reference/augmentedTypesEnum2.types b/tests/baselines/reference/augmentedTypesEnum2.types index 4b77d0eb90b..16232e0f3ff 100644 --- a/tests/baselines/reference/augmentedTypesEnum2.types +++ b/tests/baselines/reference/augmentedTypesEnum2.types @@ -2,7 +2,7 @@ // enum then interface enum e1 { One } // error >e1 : e1 ->One : e1 +>One : e1.One interface e1 { // error foo(): void; @@ -14,7 +14,7 @@ interface e1 { // error // enum then class enum e2 { One }; // error >e2 : e2 ->One : e2 +>One : e2.One class e2 { // error >e2 : e2 diff --git a/tests/baselines/reference/augmentedTypesEnum3.types b/tests/baselines/reference/augmentedTypesEnum3.types index d3c2e933506..10e17c56d98 100644 --- a/tests/baselines/reference/augmentedTypesEnum3.types +++ b/tests/baselines/reference/augmentedTypesEnum3.types @@ -25,13 +25,13 @@ enum A { >A : A b ->b : A +>b : A.b } enum A { >A : A c ->c : A +>c : A.b } module A { >A : typeof A diff --git a/tests/baselines/reference/augmentedTypesFunction.types b/tests/baselines/reference/augmentedTypesFunction.types index b019c02d90c..e30d38179c6 100644 --- a/tests/baselines/reference/augmentedTypesFunction.types +++ b/tests/baselines/reference/augmentedTypesFunction.types @@ -41,7 +41,7 @@ function y4() { } // error enum y4 { One } // error >y4 : y4 ->One : y4 +>One : y4.One // function then internal module function y5() { } diff --git a/tests/baselines/reference/augmentedTypesInterface.types b/tests/baselines/reference/augmentedTypesInterface.types index 6b6ef88015f..1ee66d267c7 100644 --- a/tests/baselines/reference/augmentedTypesInterface.types +++ b/tests/baselines/reference/augmentedTypesInterface.types @@ -35,7 +35,7 @@ interface i3 { // error } enum i3 { One }; // error >i3 : i3 ->One : i3 +>One : i3.One // interface then import interface i4 { diff --git a/tests/baselines/reference/augmentedTypesModules.types b/tests/baselines/reference/augmentedTypesModules.types index 1a03b9991ed..c377381f769 100644 --- a/tests/baselines/reference/augmentedTypesModules.types +++ b/tests/baselines/reference/augmentedTypesModules.types @@ -174,7 +174,7 @@ module m4a { var y = 2; } enum m4a { One } >m4a : m4a ->One : m4a +>One : m4a.One module m4b { export var y = 2; } >m4b : typeof m4b @@ -183,14 +183,14 @@ module m4b { export var y = 2; } enum m4b { One } >m4b : m4b ->One : m4b +>One : m4b.One module m4c { interface I { foo(): void } } >foo : () => void enum m4c { One } >m4c : m4c ->One : m4c +>One : m4c.One module m4d { class C { foo() { } } } >m4d : typeof m4d @@ -199,7 +199,7 @@ module m4d { class C { foo() { } } } enum m4d { One } >m4d : m4d ->One : m4d +>One : m4d.One //// module then module diff --git a/tests/baselines/reference/augmentedTypesModules4.types b/tests/baselines/reference/augmentedTypesModules4.types index d1dd8fe19ec..61083db2591 100644 --- a/tests/baselines/reference/augmentedTypesModules4.types +++ b/tests/baselines/reference/augmentedTypesModules4.types @@ -12,7 +12,7 @@ module m4a { var y = 2; } enum m4a { One } >m4a : m4a ->One : m4a +>One : m4a.One module m4b { export var y = 2; } >m4b : typeof m4b @@ -21,14 +21,14 @@ module m4b { export var y = 2; } enum m4b { One } >m4b : m4b ->One : m4b +>One : m4b.One module m4c { interface I { foo(): void } } >foo : () => void enum m4c { One } >m4c : m4c ->One : m4c +>One : m4c.One module m4d { class C { foo() { } } } >m4d : typeof m4d @@ -37,7 +37,7 @@ module m4d { class C { foo() { } } } enum m4d { One } >m4d : m4d ->One : m4d +>One : m4d.One //// module then module diff --git a/tests/baselines/reference/augmentedTypesVar.types b/tests/baselines/reference/augmentedTypesVar.types index f2ced2b5426..13a9db43c08 100644 --- a/tests/baselines/reference/augmentedTypesVar.types +++ b/tests/baselines/reference/augmentedTypesVar.types @@ -47,7 +47,7 @@ var x5 = 1; enum x5 { One } // error >x5 : x5 ->One : x5 +>One : x5.One // var then module var x6 = 1; diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.errors.txt b/tests/baselines/reference/bestCommonTypeOfTuple.errors.txt new file mode 100644 index 00000000000..2c57099c3e8 --- /dev/null +++ b/tests/baselines/reference/bestCommonTypeOfTuple.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple.ts(22,13): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple.ts(23,13): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple.ts(24,13): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple.ts(25,13): error TS2733: Index '3' is out-of-bounds in tuple of length 3. + + +==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple.ts (4 errors) ==== + function f1(x: number): string { return "foo"; } + + function f2(x: number): number { return 10; } + + function f3(x: number): boolean { return true; } + + enum E1 { one } + + enum E2 { two } + + + var t1: [(x: number) => string, (x: number) => number]; + var t2: [E1, E2]; + var t3: [number, any]; + var t4: [E1, E2, number]; + + // no error + t1 = [f1, f2]; + t2 = [E1.one, E2.two]; + t3 = [5, undefined]; + t4 = [E1.one, E2.two, 20]; + var e1 = t1[2]; // {} + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var e2 = t2[2]; // {} + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var e3 = t3[2]; // any + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var e4 = t4[3]; // number + ~ +!!! error TS2733: Index '3' is out-of-bounds in tuple of length 3. \ No newline at end of file diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index 67c6c08654b..612403084a5 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -16,11 +16,11 @@ function f3(x: number): boolean { return true; } enum E1 { one } >E1 : E1 ->one : E1 +>one : E1.one enum E2 { two } >E2 : E2 ->two : E2 +>two : E2.two var t1: [(x: number) => string, (x: number) => number]; @@ -46,9 +46,9 @@ t1 = [f1, f2]; >f2 : (x: number) => number t2 = [E1.one, E2.two]; ->t2 = [E1.one, E2.two] : [E1, E2] +>t2 = [E1.one, E2.two] : [E1.one, E2.two] >t2 : [E1, E2] ->[E1.one, E2.two] : [E1, E2] +>[E1.one, E2.two] : [E1.one, E2.two] >E1.one : E1 >E1 : typeof E1 >one : E1 @@ -64,9 +64,9 @@ t3 = [5, undefined]; >undefined : undefined t4 = [E1.one, E2.two, 20]; ->t4 = [E1.one, E2.two, 20] : [E1, E2, number] +>t4 = [E1.one, E2.two, 20] : [E1.one, E2.two, number] >t4 : [E1, E2, number] ->[E1.one, E2.two, 20] : [E1, E2, number] +>[E1.one, E2.two, 20] : [E1.one, E2.two, number] >E1.one : E1 >E1 : typeof E1 >one : E1 diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.errors.txt b/tests/baselines/reference/bestCommonTypeOfTuple2.errors.txt new file mode 100644 index 00000000000..80f40c74a07 --- /dev/null +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts(17,14): error TS2733: Index '4' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts(18,14): error TS2733: Index '4' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts(19,14): error TS2733: Index '4' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts(20,14): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts(21,14): error TS2733: Index '2' is out-of-bounds in tuple of length 2. + + +==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfTuple2.ts (5 errors) ==== + interface base { } + interface base1 { i } + class C implements base { c } + class D implements base { d } + class E implements base { e } + class F extends C { f } + + class C1 implements base1 { i = "foo"; c } + class D1 extends C1 { i = "bar"; d } + + var t1: [C, base]; + var t2: [C, D]; + var t3: [C1, D1]; + var t4: [base1, C1]; + var t5: [C1, F] + + var e11 = t1[4]; // base + ~ +!!! error TS2733: Index '4' is out-of-bounds in tuple of length 2. + var e21 = t2[4]; // {} + ~ +!!! error TS2733: Index '4' is out-of-bounds in tuple of length 2. + var e31 = t3[4]; // C1 + ~ +!!! error TS2733: Index '4' is out-of-bounds in tuple of length 2. + var e41 = t4[2]; // base1 + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var e51 = t5[2]; // {} + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.errors.txt b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.errors.txt new file mode 100644 index 00000000000..5927caba434 --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts(2,12): error TS2450: Enum 'E' used before its declaration. + + +==== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts (1 errors) ==== + function foo1() { + return E.A + ~ +!!! error TS2450: Enum 'E' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts:3:10: 'E' is declared here. + enum E { A } + } + + function foo2() { + return E.A + const enum E { A } + } \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js new file mode 100644 index 00000000000..552d099b07c --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js @@ -0,0 +1,22 @@ +//// [blockScopedEnumVariablesUseBeforeDef.ts] +function foo1() { + return E.A + enum E { A } +} + +function foo2() { + return E.A + const enum E { A } +} + +//// [blockScopedEnumVariablesUseBeforeDef.js] +function foo1() { + return E.A; + var E; + (function (E) { + E[E["A"] = 0] = "A"; + })(E || (E = {})); +} +function foo2() { + return 0 /* A */; +} diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.symbols b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.symbols new file mode 100644 index 00000000000..73f8419c8c1 --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts === +function foo1() { +>foo1 : Symbol(foo1, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 0, 0)) + + return E.A +>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 2, 12)) +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 1, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 2, 12)) + + enum E { A } +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 1, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 2, 12)) +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 3, 1)) + + return E.A +>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 7, 18)) +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 6, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 7, 18)) + + const enum E { A } +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 6, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef.ts, 7, 18)) +} diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.types b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.types new file mode 100644 index 00000000000..8b8aef0f911 --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts === +function foo1() { +>foo1 : () => E + + return E.A +>E.A : E +>E : typeof E +>A : E + + enum E { A } +>E : E +>A : E.A +} + +function foo2() { +>foo2 : () => E + + return E.A +>E.A : E +>E : typeof E +>A : E + + const enum E { A } +>E : E +>A : E.A +} diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.errors.txt b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.errors.txt new file mode 100644 index 00000000000..94b2ff97d9f --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts(2,12): error TS2450: Enum 'E' used before its declaration. +tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts(7,12): error TS2449: Class 'E' used before its declaration. + + +==== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts (2 errors) ==== + function foo1() { + return E.A + ~ +!!! error TS2450: Enum 'E' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts:3:10: 'E' is declared here. + enum E { A } + } + + function foo2() { + return E.A + ~ +!!! error TS2449: Class 'E' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts:8:16: 'E' is declared here. + const enum E { A } + } \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js new file mode 100644 index 00000000000..239a87f0042 --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js @@ -0,0 +1,26 @@ +//// [blockScopedEnumVariablesUseBeforeDef_preserve.ts] +function foo1() { + return E.A + enum E { A } +} + +function foo2() { + return E.A + const enum E { A } +} + +//// [blockScopedEnumVariablesUseBeforeDef_preserve.js] +function foo1() { + return E.A; + var E; + (function (E) { + E[E["A"] = 0] = "A"; + })(E || (E = {})); +} +function foo2() { + return 0 /* A */; + var E; + (function (E) { + E[E["A"] = 0] = "A"; + })(E || (E = {})); +} diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.symbols b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.symbols new file mode 100644 index 00000000000..b76089c0a0f --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts === +function foo1() { +>foo1 : Symbol(foo1, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 0, 0)) + + return E.A +>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 2, 12)) +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 1, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 2, 12)) + + enum E { A } +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 1, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 2, 12)) +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 3, 1)) + + return E.A +>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 7, 18)) +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 6, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 7, 18)) + + const enum E { A } +>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 6, 14)) +>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_preserve.ts, 7, 18)) +} diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.types b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.types new file mode 100644 index 00000000000..29ca892b1d7 --- /dev/null +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts === +function foo1() { +>foo1 : () => E + + return E.A +>E.A : E +>E : typeof E +>A : E + + enum E { A } +>E : E +>A : E.A +} + +function foo2() { +>foo2 : () => E + + return E.A +>E.A : E +>E : typeof E +>A : E + + const enum E { A } +>E : E +>A : E.A +} diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt index 4de97fa02a4..91bd5dde00c 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt @@ -119,4 +119,5 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: !!! related TS2728 tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts:102:9: 'x' is declared here. } let x - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index b14ea2a3069..7e6b452302b 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -101,7 +101,8 @@ function foo14() { a: x } let x -} +} + //// [blockScopedVariablesUseBeforeDef.js] function foo0() { diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols index 9dcb26712fb..83cb91db1d0 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols @@ -212,3 +212,4 @@ function foo14() { let x >x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 101, 7)) } + diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types index 771518e5901..3098b8c0f91 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types @@ -224,3 +224,4 @@ function foo14() { let x >x : any } + diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 6913975d757..fe8f9330a5f 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok a15: (x: T) => T[]; // ok a16: (x: T) => number[]; // ok a17: (x: (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols index 849bcb1cf60..14e25b4e9d9 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) a15: (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 37)) +>a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 40)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) >x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 13)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types index ab6daaf8b5b..065d0027ed3 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: (x: T) => T[]; // ok >a15 : (x: T) => T[] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 5bf725b06e3..33af0d9f4bf 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(76,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(80,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => number' is not assignable to type '(x: { a: string; b: number; }) => number'. @@ -131,8 +133,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index c04d5bcb2ab..9d7dbc9eab6 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok } //// [callSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols index 4a9030e443b..de3bdf742d0 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types index 2d133bc6d65..3f892ff0b17 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index 67b20f4bcbe..a7ccc2cd4e0 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -265,7 +265,7 @@ var r14 = foo14(); enum e1 { A } >e1 : e1 ->A : e1 +>A : e1.A module e1 { export var y = 1; } >e1 : typeof e1 diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index c7b00e2a0ca..e8bc9133a8a 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/types/tuple/castingTuple.ts(14,15): error TS2352: Conver tests/cases/conformance/types/tuple/castingTuple.ts(15,14): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. tests/cases/conformance/types/tuple/castingTuple.ts(18,21): error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property '2' is missing in type '[C, D]'. +tests/cases/conformance/types/tuple/castingTuple.ts(20,33): error TS2733: Index '5' is out-of-bounds in tuple of length 3. tests/cases/conformance/types/tuple/castingTuple.ts(30,10): error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'string' is not comparable to type 'number'. tests/cases/conformance/types/tuple/castingTuple.ts(31,10): error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. @@ -15,7 +16,7 @@ tests/cases/conformance/types/tuple/castingTuple.ts(32,5): error TS2403: Subsequ tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot find name 't4'. -==== tests/cases/conformance/types/tuple/castingTuple.ts (8 errors) ==== +==== tests/cases/conformance/types/tuple/castingTuple.ts (9 errors) ==== interface I { } class A { a = 10; } class C implements I { c }; @@ -48,6 +49,8 @@ tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot !!! error TS2352: Property '2' is missing in type '[C, D]'. var eleFromCDA1 = classCDATuple[2]; // A var eleFromCDA2 = classCDATuple[5]; // C | D | A + ~ +!!! error TS2733: Index '5' is out-of-bounds in tuple of length 3. var t10: [E1, E2] = [E1.one, E2.one]; var t11 = <[number, number]>t10; var array1 = <{}[]>emptyObjTuple; diff --git a/tests/baselines/reference/castingTuple.types b/tests/baselines/reference/castingTuple.types index 5280ca4962b..729c090e1ca 100644 --- a/tests/baselines/reference/castingTuple.types +++ b/tests/baselines/reference/castingTuple.types @@ -25,11 +25,11 @@ class F extends A { f }; enum E1 { one } >E1 : E1 ->one : E1 +>one : E1.one enum E2 { one } >E2 : E2 ->one : E2 +>one : E2.one // no error var numStrTuple: [number, string] = [5, "foo"]; @@ -90,7 +90,7 @@ var eleFromCDA2 = classCDATuple[5]; // C | D | A var t10: [E1, E2] = [E1.one, E2.one]; >t10 : [E1, E2] ->[E1.one, E2.one] : [E1, E2] +>[E1.one, E2.one] : [E1.one, E2.one] >E1.one : E1 >E1 : typeof E1 >one : E1 diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.symbols b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.symbols index 24d39dce20a..68693872a4b 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.symbols +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.symbols @@ -4,7 +4,7 @@ var lol = "hello Lol" >lol : Symbol(lol, Decl(0.js, 1, 3)) const obj = { ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) /** @type {string|undefined} */ foo: undefined, @@ -40,31 +40,31 @@ const obj = { } obj.foo = 'string' >obj.foo : Symbol(foo, Decl(0.js, 2, 13)) ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) >foo : Symbol(foo, Decl(0.js, 2, 13)) obj.lol >obj.lol : Symbol(lol, Decl(0.js, 10, 4)) ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) >lol : Symbol(lol, Decl(0.js, 10, 4)) obj.bar = undefined; >obj.bar : Symbol(bar, Decl(0.js, 4, 17)) ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) >bar : Symbol(bar, Decl(0.js, 4, 17)) >undefined : Symbol(undefined) var k = obj.method1(0); >k : Symbol(k, Decl(0.js, 21, 3)) >obj.method1 : Symbol(method1, Decl(0.js, 6, 12)) ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) >method1 : Symbol(method1, Decl(0.js, 6, 12)) obj.bar1 = "42"; ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) obj.arrowFunc(0); >obj.arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20)) ->obj : Symbol(obj, Decl(0.js, 2, 5)) +>obj : Symbol(obj, Decl(0.js, 2, 5), Decl(0.js, 17, 1)) >arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20)) diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt index 4851bc3b466..8e7a3adb518 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? -tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'. +tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: (((user: IUser) => Element) | ((user: IUser) => Element))[]; }' is not assignable to type 'IFetchUserProps'. Types of property 'children' are incompatible. - Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'. - Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'. + Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' is not assignable to type '(user: IUser) => Element'. + Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' provides no match for the signature '(user: IUser): Element'. ==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== @@ -42,10 +42,10 @@ tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: ((u return ( ~~~~~~~~~ -!!! error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'. +!!! error TS2322: Type '{ children: (((user: IUser) => Element) | ((user: IUser) => Element))[]; }' is not assignable to type 'IFetchUserProps'. !!! error TS2322: Types of property 'children' are incompatible. -!!! error TS2322: Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'. -!!! error TS2322: Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'. +!!! error TS2322: Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' is not assignable to type '(user: IUser) => Element'. +!!! error TS2322: Type '(((user: IUser) => Element) | ((user: IUser) => Element))[]' provides no match for the signature '(user: IUser): Element'. diff --git a/tests/baselines/reference/classCanExtendConstructorFunction.symbols b/tests/baselines/reference/classCanExtendConstructorFunction.symbols index 58aae6eee07..2a794718f4c 100644 --- a/tests/baselines/reference/classCanExtendConstructorFunction.symbols +++ b/tests/baselines/reference/classCanExtendConstructorFunction.symbols @@ -107,15 +107,15 @@ class Sql extends Wagon { } } var db = new Sql(); ->db : Symbol(db, Decl(first.js, 42, 3)) +>db : Symbol(db, Decl(first.js, 42, 3), Decl(first.js, 42, 19)) >Sql : Symbol(Sql, Decl(first.js, 18, 1)) db.numberOxen = db.foonly >db.numberOxen : Symbol(Wagon.numberOxen, Decl(first.js, 4, 28)) ->db : Symbol(db, Decl(first.js, 42, 3)) +>db : Symbol(db, Decl(first.js, 42, 3), Decl(first.js, 42, 19)) >numberOxen : Symbol(Wagon.numberOxen, Decl(first.js, 4, 28)) >db.foonly : Symbol(Sql.foonly, Decl(first.js, 22, 16)) ->db : Symbol(db, Decl(first.js, 42, 3)) +>db : Symbol(db, Decl(first.js, 42, 3), Decl(first.js, 42, 19)) >foonly : Symbol(Sql.foonly, Decl(first.js, 22, 16)) // error, can't extend a TS constructor function diff --git a/tests/baselines/reference/classExtendingPrimitive.types b/tests/baselines/reference/classExtendingPrimitive.types index 99dec6c462b..7c118c092bc 100644 --- a/tests/baselines/reference/classExtendingPrimitive.types +++ b/tests/baselines/reference/classExtendingPrimitive.types @@ -40,7 +40,7 @@ class C7 extends Undefined { } enum E { A } >E : E ->A : E +>A : E.A class C8 extends E { } >C8 : C8 diff --git a/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.types b/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.types index 72149f11a5c..2e11087f368 100644 --- a/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.types +++ b/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.types @@ -25,7 +25,7 @@ enum Enum { >Enum : Enum A ->A : Enum +>A : Enum.A } const ObjLiteral = { diff --git a/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.types b/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.types index 398179b5cdc..b9366a0cd84 100644 --- a/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.types +++ b/tests/baselines/reference/collisionCodeGenEnumWithEnumMemberConflict.types @@ -3,9 +3,9 @@ enum Color { >Color : Color Color, ->Color : Color +>Color : Color.Color Thing = Color ->Thing : Color +>Thing : Color.Color >Color : Color } diff --git a/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.types b/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.types index 527c8930fcb..b629abc18dd 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithEnumMemberConflict.types @@ -6,10 +6,10 @@ module m1 { >e : e m1, ->m1 : e +>m1 : e.m1 m2 = m1 ->m2 : e +>m2 : e.m1 >m1 : e } } diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.types b/tests/baselines/reference/computedPropertyNames47_ES5.types index 7307210cfbe..ab8ab053f6a 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.types +++ b/tests/baselines/reference/computedPropertyNames47_ES5.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames47_ES5.ts === enum E1 { x } >E1 : E1 ->x : E1 +>x : E1.x enum E2 { x } >E2 : E2 ->x : E2 +>x : E2.x var o = { >o : { [E1.x || E2.x]: number; } diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.types b/tests/baselines/reference/computedPropertyNames47_ES6.types index d630d5bba93..a11d09dd121 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.types +++ b/tests/baselines/reference/computedPropertyNames47_ES6.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames47_ES6.ts === enum E1 { x } >E1 : E1 ->x : E1 +>x : E1.x enum E2 { x } >E2 : E2 ->x : E2 +>x : E2.x var o = { >o : { [E1.x || E2.x]: number; } diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index d3e2cbd6538..c036eabf3d7 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -6,7 +6,7 @@ declare function extractIndexer(p: { [n: number]: T }): T; enum E { x } >E : E ->x : E +>x : E.x var a: any; >a : any diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index 9a1f43f3b7d..7775f6c8c7b 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -6,7 +6,7 @@ declare function extractIndexer(p: { [n: number]: T }): T; enum E { x } >E : E ->x : E +>x : E.x var a: any; >a : any diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.types b/tests/baselines/reference/computedPropertyNames7_ES5.types index 55f6448127b..08d75af1cd3 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.types +++ b/tests/baselines/reference/computedPropertyNames7_ES5.types @@ -3,7 +3,7 @@ enum E { >E : E member ->member : E +>member : E.member } var v = { >v : { [E.member]: number; } diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.types b/tests/baselines/reference/computedPropertyNames7_ES6.types index 0ae55d7c1bb..6e4c85ef6f7 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.types +++ b/tests/baselines/reference/computedPropertyNames7_ES6.types @@ -3,7 +3,7 @@ enum E { >E : E member ->member : E +>member : E.member } var v = { >v : { [E.member]: number; } diff --git a/tests/baselines/reference/constDeclarations-ambient-errors.errors.txt b/tests/baselines/reference/constDeclarations-ambient-errors.errors.txt index 979448abf72..2eb6e22cd75 100644 --- a/tests/baselines/reference/constDeclarations-ambient-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-ambient-errors.errors.txt @@ -1,30 +1,30 @@ -tests/cases/compiler/constDeclarations-ambient-errors.ts(2,27): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/constDeclarations-ambient-errors.ts(3,26): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/constDeclarations-ambient-errors.ts(4,20): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal. -tests/cases/compiler/constDeclarations-ambient-errors.ts(4,37): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/constDeclarations-ambient-errors.ts(4,51): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/constDeclarations-ambient-errors.ts(8,22): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/constDeclarations-ambient-errors.ts(2,29): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/constDeclarations-ambient-errors.ts(3,28): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/constDeclarations-ambient-errors.ts(4,20): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. +tests/cases/compiler/constDeclarations-ambient-errors.ts(4,39): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/constDeclarations-ambient-errors.ts(4,53): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/constDeclarations-ambient-errors.ts(8,24): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/constDeclarations-ambient-errors.ts (6 errors) ==== // error: no intialization expected in ambient declarations declare const c1: boolean = true; - ~ + ~~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare const c2: number = 0; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare const c3 = null, c4 :string = "", c5: any = 0; ~~~~ -!!! error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal. - ~ +!!! error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare module M { const c6 = 0; const c7: number = 7; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/constEnumBadPropertyNames.types b/tests/baselines/reference/constEnumBadPropertyNames.types index 05c45ba588e..2a640ed1462 100644 --- a/tests/baselines/reference/constEnumBadPropertyNames.types +++ b/tests/baselines/reference/constEnumBadPropertyNames.types @@ -1,7 +1,7 @@ === tests/cases/compiler/constEnumBadPropertyNames.ts === const enum E { A } >E : E ->A : E +>A : E.A var x = E["B"] >x : any diff --git a/tests/baselines/reference/constEnumErrors.types b/tests/baselines/reference/constEnumErrors.types index 187cc1dfde9..f0ebb60815c 100644 --- a/tests/baselines/reference/constEnumErrors.types +++ b/tests/baselines/reference/constEnumErrors.types @@ -3,7 +3,7 @@ const enum E { >E : E A ->A : E +>A : E.A } module E { @@ -41,7 +41,7 @@ const enum E2 { >E2 : E2 A ->A : E2 +>A : E2.A } var y0 = E2[1] diff --git a/tests/baselines/reference/constEnumExternalModule.types b/tests/baselines/reference/constEnumExternalModule.types index 2bd978a2caf..1076328445e 100644 --- a/tests/baselines/reference/constEnumExternalModule.types +++ b/tests/baselines/reference/constEnumExternalModule.types @@ -13,7 +13,7 @@ const enum E { >E : E V = 100 ->V : E +>V : E.V >100 : 100 } diff --git a/tests/baselines/reference/constEnumMergingWithValues1.types b/tests/baselines/reference/constEnumMergingWithValues1.types index 6a3777b6254..ccbf484c251 100644 --- a/tests/baselines/reference/constEnumMergingWithValues1.types +++ b/tests/baselines/reference/constEnumMergingWithValues1.types @@ -5,7 +5,7 @@ function foo() {} module foo { const enum E { X } >E : E ->X : E +>X : E.X } export = foo diff --git a/tests/baselines/reference/constEnumMergingWithValues2.types b/tests/baselines/reference/constEnumMergingWithValues2.types index aad5bb4cbc4..fa9932acc32 100644 --- a/tests/baselines/reference/constEnumMergingWithValues2.types +++ b/tests/baselines/reference/constEnumMergingWithValues2.types @@ -5,7 +5,7 @@ class foo {} module foo { const enum E { X } >E : E ->X : E +>X : E.X } export = foo diff --git a/tests/baselines/reference/constEnumMergingWithValues3.types b/tests/baselines/reference/constEnumMergingWithValues3.types index 3bb578396d4..5d9b3c16e55 100644 --- a/tests/baselines/reference/constEnumMergingWithValues3.types +++ b/tests/baselines/reference/constEnumMergingWithValues3.types @@ -1,12 +1,12 @@ === tests/cases/compiler/m1.ts === enum foo { A } >foo : foo ->A : foo +>A : foo.A module foo { const enum E { X } >E : E ->X : E +>X : E.X } export = foo diff --git a/tests/baselines/reference/constEnumMergingWithValues4.types b/tests/baselines/reference/constEnumMergingWithValues4.types index 88fa405f85d..3b0a085c70b 100644 --- a/tests/baselines/reference/constEnumMergingWithValues4.types +++ b/tests/baselines/reference/constEnumMergingWithValues4.types @@ -2,7 +2,7 @@ module foo { const enum E { X } >E : E ->X : E +>X : E.X } module foo { diff --git a/tests/baselines/reference/constEnumMergingWithValues5.types b/tests/baselines/reference/constEnumMergingWithValues5.types index efd3304ec9f..e75179d4cde 100644 --- a/tests/baselines/reference/constEnumMergingWithValues5.types +++ b/tests/baselines/reference/constEnumMergingWithValues5.types @@ -2,7 +2,7 @@ module foo { const enum E { X } >E : E ->X : E +>X : E.X } export = foo diff --git a/tests/baselines/reference/constEnumOnlyModuleMerging.types b/tests/baselines/reference/constEnumOnlyModuleMerging.types index 9c75910ece3..8e63afcaa80 100644 --- a/tests/baselines/reference/constEnumOnlyModuleMerging.types +++ b/tests/baselines/reference/constEnumOnlyModuleMerging.types @@ -10,7 +10,7 @@ module Outer { module Outer { export const enum A { X } >A : A ->X : A +>X : A.X } module B { diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 0c4b5c62380..a85f64f95a1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok a15: new (x: T) => T[]; // ok a16: new (x: T) => number[]; // ok a17: new (x: new (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols index 1ad1c3707c5..2aaa5eda84f 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) a15: new (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 41)) +>a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 44)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) >x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 17)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types index 01941d5219b..08a687d8867 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: new (x: T) => T[]; // ok >a15 : new (x: T) => T[] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 9646acd071f..1a9edc159af 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(66,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(70,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => number' is not assignable to type 'new (x: { a: string; b: number; }) => number'. @@ -121,8 +123,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: new (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index d81722fc950..8431b225440 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [constructSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols index e1991673f98..c08d7537f65 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types index 0397a78f678..9296ce8295d 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/constructorFunctions3.symbols b/tests/baselines/reference/constructorFunctions3.symbols index 7c98cd921e0..385ae3d1be2 100644 --- a/tests/baselines/reference/constructorFunctions3.symbols +++ b/tests/baselines/reference/constructorFunctions3.symbols @@ -16,25 +16,25 @@ i; >i : Symbol(i, Decl(a.js, 3, 3)) function StaticToo() { ->StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2)) +>StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2), Decl(a.js, 9, 1)) this.i = 'more complex' >i : Symbol(StaticToo.i, Decl(a.js, 7, 22)) } StaticToo.property = 'yep' >StaticToo.property : Symbol(StaticToo.property, Decl(a.js, 9, 1)) ->StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2)) +>StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2), Decl(a.js, 9, 1)) >property : Symbol(StaticToo.property, Decl(a.js, 9, 1)) var s = new StaticToo(); >s : Symbol(s, Decl(a.js, 11, 3)) ->StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2)) +>StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2), Decl(a.js, 9, 1)) s; >s : Symbol(s, Decl(a.js, 11, 3)) StaticToo; ->StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2)) +>StaticToo : Symbol(StaticToo, Decl(a.js, 5, 2), Decl(a.js, 9, 1)) // Both! function A () { @@ -74,12 +74,12 @@ A.t = function g(m) { >m : Symbol(m, Decl(a.js, 26, 17)) } var a = new A() ->a : Symbol(a, Decl(a.js, 29, 3)) +>a : Symbol(a, Decl(a.js, 29, 3), Decl(a.js, 31, 6)) >A : Symbol(A, Decl(a.js, 13, 10), Decl(a.js, 24, 1)) a.z(3) >a.z : Symbol(A.z, Decl(a.js, 20, 1)) ->a : Symbol(a, Decl(a.js, 29, 3)) +>a : Symbol(a, Decl(a.js, 29, 3), Decl(a.js, 31, 6)) >z : Symbol(A.z, Decl(a.js, 20, 1)) A.t(2) @@ -89,6 +89,6 @@ A.t(2) a.second = 1 >a.second : Symbol(A.second, Decl(a.js, 17, 14)) ->a : Symbol(a, Decl(a.js, 29, 3)) +>a : Symbol(a, Decl(a.js, 29, 3), Decl(a.js, 31, 6)) >second : Symbol(A.second, Decl(a.js, 17, 14)) diff --git a/tests/baselines/reference/constructorFunctionsStrict.symbols b/tests/baselines/reference/constructorFunctionsStrict.symbols index 4c5d47b7a51..3954e2ce1e6 100644 --- a/tests/baselines/reference/constructorFunctionsStrict.symbols +++ b/tests/baselines/reference/constructorFunctionsStrict.symbols @@ -20,18 +20,18 @@ C.prototype.m = function() { >y : Symbol(C.y, Decl(a.js, 4, 28)) } var c = new C(1) ->c : Symbol(c, Decl(a.js, 7, 3)) +>c : Symbol(c, Decl(a.js, 7, 3), Decl(a.js, 7, 16)) >C : Symbol(C, Decl(a.js, 0, 0)) c.x = undefined // should error >c.x : Symbol(C.x, Decl(a.js, 1, 15)) ->c : Symbol(c, Decl(a.js, 7, 3)) +>c : Symbol(c, Decl(a.js, 7, 3), Decl(a.js, 7, 16)) >x : Symbol(C.x, Decl(a.js, 1, 15)) >undefined : Symbol(undefined) c.y = undefined // ok >c.y : Symbol(C.y, Decl(a.js, 4, 28)) ->c : Symbol(c, Decl(a.js, 7, 3)) +>c : Symbol(c, Decl(a.js, 7, 3), Decl(a.js, 7, 16)) >y : Symbol(C.y, Decl(a.js, 4, 28)) >undefined : Symbol(undefined) diff --git a/tests/baselines/reference/contextualSignatureInstantiation.errors.txt b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt new file mode 100644 index 00000000000..6c14ad3c150 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(19,13): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(20,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(21,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. + Types of parameters 'y' and 'y' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts (3 errors) ==== + // TypeScript Spec, section 4.12.2: + // If e is an expression of a function type that contains exactly one generic call signature and no other members, + // and T is a function type with exactly one non - generic call signature and no other members, then any inferences + // made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed + // to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + + declare function foo(cb: (x: number, y: string) => T): T; + declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; + declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; + + declare function g(x: T, y: T): T; + declare function h(x: T, y: U): T[] | U[]; + + var a: number; + var a = bar(1, 1, g); // Should be number + var a = baz(1, 1, g); // Should be number + + var b: number | string; + var b = foo(g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar(1, "one", g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar("one", 1, g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. + var b = baz(b, b, g); // Should be number | string + + var d: number[] | string[]; + var d = foo(h); // Should be number[] | string[] + var d = bar(1, "one", h); // Should be number[] | string[] + var d = bar("one", 1, h); // Should be number[] | string[] + var d = baz(d, d, g); // Should be number[] | string[] + \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstantiation.js b/tests/baselines/reference/contextualSignatureInstantiation.js index 11e19b3262e..d945592bbda 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.js +++ b/tests/baselines/reference/contextualSignatureInstantiation.js @@ -17,9 +17,9 @@ var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b: number | string; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d: number[] | string[]; @@ -39,9 +39,9 @@ var a; var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d; var d = foo(h); // Should be number[] | string[] diff --git a/tests/baselines/reference/contextualSignatureInstantiation.symbols b/tests/baselines/reference/contextualSignatureInstantiation.symbols index c16ffed84b7..742ae58905c 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation.symbols @@ -83,17 +83,17 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >foo : Symbol(foo, Decl(contextualSignatureInstantiation.ts, 0, 0)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types index 0f8c1ed49ba..ae5a4000537 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.types +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -59,23 +59,23 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : string | number -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : string | number ->foo(g) : string | number +>foo(g) : any >foo : (cb: (x: number, y: string) => T) => T >g : (x: T, y: T) => T -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : string | number ->bar(1, "one", g) : string | number +>bar(1, "one", g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >1 : 1 >"one" : "one" >g : (x: T, y: T) => T -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : string | number ->bar("one", 1, g) : string | number +>bar("one", 1, g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >"one" : "one" >1 : 1 diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt new file mode 100644 index 00000000000..fe9c6cf3f14 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/contextualSignatureInstatiationContravariance.ts(8,1): error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. + Types of parameters 'y' and 'e' are incompatible. + Type 'Elephant' is not assignable to type 'Giraffe'. + Property 'y' is missing in type 'Elephant'. + + +==== tests/cases/compiler/contextualSignatureInstatiationContravariance.ts (1 errors) ==== + interface Animal { x } + interface Giraffe extends Animal { y } + interface Elephant extends Animal { y2 } + + var f2: (x: T, y: T) => void; + + var g2: (g: Giraffe, e: Elephant) => void; + g2 = f2; // error because Giraffe and Elephant are disjoint types + ~~ +!!! error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. +!!! error TS2322: Types of parameters 'y' and 'e' are incompatible. +!!! error TS2322: Type 'Elephant' is not assignable to type 'Giraffe'. +!!! error TS2322: Property 'y' is missing in type 'Elephant'. + + var h2: (g1: Giraffe, g2: Giraffe) => void; + h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js index 6e731d61713..6e2de5d2907 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js @@ -6,7 +6,7 @@ interface Elephant extends Animal { y2 } var f2: (x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. @@ -14,6 +14,6 @@ h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the tr //// [contextualSignatureInstatiationContravariance.js] var f2; var g2; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols index 37a0c4adb02..fc11cca8aa6 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols @@ -29,7 +29,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >e : Symbol(e, Decl(contextualSignatureInstatiationContravariance.ts, 6, 20)) >Elephant : Symbol(Elephant, Decl(contextualSignatureInstatiationContravariance.ts, 1, 38)) -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 : Symbol(g2, Decl(contextualSignatureInstatiationContravariance.ts, 6, 3)) >f2 : Symbol(f2, Decl(contextualSignatureInstatiationContravariance.ts, 4, 3)) diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types index d0d281b7d49..0ca89f7016c 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types @@ -18,7 +18,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >g : Giraffe >e : Elephant -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 = f2 : (x: T, y: T) => void >g2 : (g: Giraffe, e: Elephant) => void >f2 : (x: T, y: T) => void diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt index e4ffa209e6f..fb44cb57da7 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt +++ b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(58,5): error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '((a: string, b: number) => string) | ((a: string, b: number) => number)'. - Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => string'. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts (6 errors) ==== @@ -116,8 +116,8 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( commonMethodDifferentReturnType: (a, b) => strOrNumber, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '((a: string, b: number) => string) | ((a: string, b: number) => number)'. -!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => string'. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. !!! related TS6500 tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts:35:5: The expected type comes from property 'commonMethodDifferentReturnType' which is declared here on type 'I11 | I21' }; \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypedSpecialAssignment.symbols b/tests/baselines/reference/contextualTypedSpecialAssignment.symbols index ae22cf020da..01ba1d6ba79 100644 --- a/tests/baselines/reference/contextualTypedSpecialAssignment.symbols +++ b/tests/baselines/reference/contextualTypedSpecialAssignment.symbols @@ -6,12 +6,12 @@ // property assignment var ns = {} ->ns : Symbol(ns, Decl(test.js, 6, 3)) +>ns : Symbol(ns, Decl(test.js, 6, 3), Decl(test.js, 6, 11)) /** @type {DoneStatus} */ ns.x = { >ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) ->ns : Symbol(ns, Decl(test.js, 6, 3)) +>ns : Symbol(ns, Decl(test.js, 6, 3), Decl(test.js, 6, 11)) >x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) status: 'done', @@ -24,7 +24,7 @@ ns.x = { ns.x = { >ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) ->ns : Symbol(ns, Decl(test.js, 6, 3)) +>ns : Symbol(ns, Decl(test.js, 6, 3), Decl(test.js, 6, 11)) >x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) status: 'done', @@ -36,7 +36,7 @@ ns.x = { } ns.x >ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) ->ns : Symbol(ns, Decl(test.js, 6, 3)) +>ns : Symbol(ns, Decl(test.js, 6, 3), Decl(test.js, 6, 11)) >x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) diff --git a/tests/baselines/reference/contextualTypedSpecialAssignment.types b/tests/baselines/reference/contextualTypedSpecialAssignment.types index 31865449ae3..2788df859cf 100644 --- a/tests/baselines/reference/contextualTypedSpecialAssignment.types +++ b/tests/baselines/reference/contextualTypedSpecialAssignment.types @@ -6,14 +6,14 @@ // property assignment var ns = {} ->ns : { x: { status: "done"; m(n: number): void; }; } +>ns : typeof ns >{} : {} /** @type {DoneStatus} */ ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } +>ns : typeof ns >x : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } @@ -29,7 +29,7 @@ ns.x = { ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } +>ns : typeof ns >x : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } @@ -43,7 +43,7 @@ ns.x = { } ns.x >ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } +>ns : typeof ns >x : { status: "done"; m(n: number): void; } diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index 39083598ee2..03141e26185 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -104,7 +104,7 @@ function c(data: string | T): T { >JSON.parse : (text: string, reviver?: (key: any, value: any) => any) => any >JSON : JSON >parse : (text: string, reviver?: (key: any, value: any) => any) => any ->data : string +>data : string | (T & string) } else { return data; diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js new file mode 100644 index 00000000000..500d546971b --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +/*[#|*/() => {/*|]*/ + return fetch('https://typescriptlang.org').then(result => console.log(result)); +} +// ==ASYNC FUNCTION::Convert to async function== + +async () => { + const result = await fetch('https://typescriptlang.org'); + return console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts new file mode 100644 index 00000000000..500d546971b --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +/*[#|*/() => {/*|]*/ + return fetch('https://typescriptlang.org').then(result => console.log(result)); +} +// ==ASYNC FUNCTION::Convert to async function== + +async () => { + const result = await fetch('https://typescriptlang.org'); + return console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js new file mode 100644 index 00000000000..8aec78c6670 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +function /*[#|*/f/*|]*/() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +// ==ASYNC FUNCTION::Convert to async function== + +async function f() { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts new file mode 100644 index 00000000000..8aec78c6670 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +function /*[#|*/f/*|]*/() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +// ==ASYNC FUNCTION::Convert to async function== + +async function f() { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js new file mode 100644 index 00000000000..a92497ca937 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const /*[#|*/foo/*|]*/ = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const foo = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts new file mode 100644 index 00000000000..a92497ca937 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const /*[#|*/foo/*|]*/ = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const foo = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} diff --git a/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types index ede64818ff5..fb107e77093 100644 --- a/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types @@ -7,14 +7,14 @@ enum Hello { >Hello : Hello World ->World : Hello +>World : Hello.World } enum Hello1 { >Hello1 : Hello1 World1 ->World1 : Hello1 +>World1 : Hello1.World1 } class Foo { diff --git a/tests/baselines/reference/declarationEmitConstantNoWidening.js b/tests/baselines/reference/declarationEmitConstantNoWidening.js new file mode 100644 index 00000000000..268f0776543 --- /dev/null +++ b/tests/baselines/reference/declarationEmitConstantNoWidening.js @@ -0,0 +1,24 @@ +//// [declarationEmitConstantNoWidening.ts] +export const FOO = 'FOO'; +export class Bar { + readonly type = FOO; // Should be widening literal "FOO" - so either `typeof "FOO"` or = "FOO" +} + +//// [declarationEmitConstantNoWidening.js] +"use strict"; +exports.__esModule = true; +exports.FOO = 'FOO'; +var Bar = /** @class */ (function () { + function Bar() { + this.type = exports.FOO; // Should be widening literal "FOO" - so either `typeof "FOO"` or = "FOO" + } + return Bar; +}()); +exports.Bar = Bar; + + +//// [declarationEmitConstantNoWidening.d.ts] +export declare const FOO = "FOO"; +export declare class Bar { + readonly type = "FOO"; +} diff --git a/tests/baselines/reference/declarationEmitConstantNoWidening.symbols b/tests/baselines/reference/declarationEmitConstantNoWidening.symbols new file mode 100644 index 00000000000..17ab38272b9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitConstantNoWidening.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/declarationEmitConstantNoWidening.ts === +export const FOO = 'FOO'; +>FOO : Symbol(FOO, Decl(declarationEmitConstantNoWidening.ts, 0, 12)) + +export class Bar { +>Bar : Symbol(Bar, Decl(declarationEmitConstantNoWidening.ts, 0, 25)) + + readonly type = FOO; // Should be widening literal "FOO" - so either `typeof "FOO"` or = "FOO" +>type : Symbol(Bar.type, Decl(declarationEmitConstantNoWidening.ts, 1, 18)) +>FOO : Symbol(FOO, Decl(declarationEmitConstantNoWidening.ts, 0, 12)) +} diff --git a/tests/baselines/reference/declarationEmitConstantNoWidening.types b/tests/baselines/reference/declarationEmitConstantNoWidening.types new file mode 100644 index 00000000000..5a7a11728a5 --- /dev/null +++ b/tests/baselines/reference/declarationEmitConstantNoWidening.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/declarationEmitConstantNoWidening.ts === +export const FOO = 'FOO'; +>FOO : "FOO" +>'FOO' : "FOO" + +export class Bar { +>Bar : Bar + + readonly type = FOO; // Should be widening literal "FOO" - so either `typeof "FOO"` or = "FOO" +>type : "FOO" +>FOO : "FOO" +} diff --git a/tests/baselines/reference/declarationEmitEnumReadonlyProperty.js b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.js new file mode 100644 index 00000000000..75c4ce5139d --- /dev/null +++ b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.js @@ -0,0 +1,36 @@ +//// [declarationEmitEnumReadonlyProperty.ts] +enum E { + A = 'a', + B = 'b' +} + +class C { + readonly type = E.A; +} + +let x: E.A = new C().type; + +//// [declarationEmitEnumReadonlyProperty.js] +var E; +(function (E) { + E["A"] = "a"; + E["B"] = "b"; +})(E || (E = {})); +var C = /** @class */ (function () { + function C() { + this.type = E.A; + } + return C; +}()); +var x = new C().type; + + +//// [declarationEmitEnumReadonlyProperty.d.ts] +declare enum E { + A = "a", + B = "b" +} +declare class C { + readonly type = E.A; +} +declare let x: E.A; diff --git a/tests/baselines/reference/declarationEmitEnumReadonlyProperty.symbols b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.symbols new file mode 100644 index 00000000000..7d1425ade78 --- /dev/null +++ b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts === +enum E { +>E : Symbol(E, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 0)) + + A = 'a', +>A : Symbol(E.A, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 8)) + + B = 'b' +>B : Symbol(E.B, Decl(declarationEmitEnumReadonlyProperty.ts, 1, 12)) +} + +class C { +>C : Symbol(C, Decl(declarationEmitEnumReadonlyProperty.ts, 3, 1)) + + readonly type = E.A; +>type : Symbol(C.type, Decl(declarationEmitEnumReadonlyProperty.ts, 5, 9)) +>E.A : Symbol(E.A, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 8)) +>E : Symbol(E, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 0)) +>A : Symbol(E.A, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 8)) +} + +let x: E.A = new C().type; +>x : Symbol(x, Decl(declarationEmitEnumReadonlyProperty.ts, 9, 3)) +>E : Symbol(E, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 0)) +>A : Symbol(E.A, Decl(declarationEmitEnumReadonlyProperty.ts, 0, 8)) +>new C().type : Symbol(C.type, Decl(declarationEmitEnumReadonlyProperty.ts, 5, 9)) +>C : Symbol(C, Decl(declarationEmitEnumReadonlyProperty.ts, 3, 1)) +>type : Symbol(C.type, Decl(declarationEmitEnumReadonlyProperty.ts, 5, 9)) + diff --git a/tests/baselines/reference/declarationEmitEnumReadonlyProperty.types b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.types new file mode 100644 index 00000000000..eb8f5528cf9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitEnumReadonlyProperty.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts === +enum E { +>E : E + + A = 'a', +>A : E.A +>'a' : "a" + + B = 'b' +>B : E.B +>'b' : "b" +} + +class C { +>C : C + + readonly type = E.A; +>type : E.A +>E.A : E.A +>E : typeof E +>A : E.A +} + +let x: E.A = new C().type; +>x : E.A +>E : any +>new C().type : E.A +>new C() : C +>C : typeof C +>type : E.A + diff --git a/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.js b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.js new file mode 100644 index 00000000000..fcc0722c07e --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts] //// + +//// [Types.ts] +type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; +type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; +export { Suit, Rank }; + +//// [Card.ts] +import { Suit, Rank } from './Types'; +export default (suit: Suit, rank: Rank) => ({suit, rank}); + +//// [index.ts] +export let lazyCard = () => import('./Card').then(a => a.default); +export { Suit, Rank } from './Types'; + + +//// [Types.js] +"use strict"; +exports.__esModule = true; +//// [Card.js] +"use strict"; +exports.__esModule = true; +exports["default"] = (function (suit, rank) { return ({ suit: suit, rank: rank }); }); +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.lazyCard = function () { return Promise.resolve().then(function () { return require('./Card'); }).then(function (a) { return a["default"]; }); }; + + +//// [Types.d.ts] +declare type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; +declare type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; +export { Suit, Rank }; +//// [Card.d.ts] +import { Suit, Rank } from './Types'; +declare const _default: (suit: Suit, rank: Rank) => { + suit: Suit; + rank: Rank; +}; +export default _default; +//// [index.d.ts] +export declare let lazyCard: () => Promise<(suit: import("./Types").Suit, rank: import("./Types").Rank) => { + suit: import("./Types").Suit; + rank: import("./Types").Rank; +}>; +export { Suit, Rank } from './Types'; diff --git a/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.symbols b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.symbols new file mode 100644 index 00000000000..a89d82fff50 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/Types.ts === +type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; +>Suit : Symbol(Suit, Decl(Types.ts, 0, 0)) + +type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; +>Rank : Symbol(Rank, Decl(Types.ts, 0, 55)) + +export { Suit, Rank }; +>Suit : Symbol(Suit, Decl(Types.ts, 2, 8)) +>Rank : Symbol(Rank, Decl(Types.ts, 2, 14)) + +=== tests/cases/compiler/Card.ts === +import { Suit, Rank } from './Types'; +>Suit : Symbol(Suit, Decl(Card.ts, 0, 8)) +>Rank : Symbol(Rank, Decl(Card.ts, 0, 14)) + +export default (suit: Suit, rank: Rank) => ({suit, rank}); +>suit : Symbol(suit, Decl(Card.ts, 1, 16)) +>Suit : Symbol(Suit, Decl(Card.ts, 0, 8)) +>rank : Symbol(rank, Decl(Card.ts, 1, 27)) +>Rank : Symbol(Rank, Decl(Card.ts, 0, 14)) +>suit : Symbol(suit, Decl(Card.ts, 1, 45)) +>rank : Symbol(rank, Decl(Card.ts, 1, 50)) + +=== tests/cases/compiler/index.ts === +export let lazyCard = () => import('./Card').then(a => a.default); +>lazyCard : Symbol(lazyCard, Decl(index.ts, 0, 10)) +>import('./Card').then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>'./Card' : Symbol("tests/cases/compiler/Card", Decl(Card.ts, 0, 0)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(index.ts, 0, 50)) +>a.default : Symbol(default, Decl(Card.ts, 0, 37)) +>a : Symbol(a, Decl(index.ts, 0, 50)) +>default : Symbol(default, Decl(Card.ts, 0, 37)) + +export { Suit, Rank } from './Types'; +>Suit : Symbol(Suit, Decl(index.ts, 1, 8)) +>Rank : Symbol(Rank, Decl(index.ts, 1, 14)) + diff --git a/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types new file mode 100644 index 00000000000..bf9666f3082 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/Types.ts === +type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; +>Suit : Suit + +type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; +>Rank : Rank + +export { Suit, Rank }; +>Suit : any +>Rank : any + +=== tests/cases/compiler/Card.ts === +import { Suit, Rank } from './Types'; +>Suit : any +>Rank : any + +export default (suit: Suit, rank: Rank) => ({suit, rank}); +>(suit: Suit, rank: Rank) => ({suit, rank}) : (suit: Suit, rank: Rank) => { suit: Suit; rank: Rank; } +>suit : Suit +>rank : Rank +>({suit, rank}) : { suit: Suit; rank: Rank; } +>{suit, rank} : { suit: Suit; rank: Rank; } +>suit : Suit +>rank : Rank + +=== tests/cases/compiler/index.ts === +export let lazyCard = () => import('./Card').then(a => a.default); +>lazyCard : () => Promise<(suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; }> +>() => import('./Card').then(a => a.default) : () => Promise<(suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; }> +>import('./Card').then(a => a.default) : Promise<(suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; }> +>import('./Card').then : (onfulfilled?: (value: typeof import("tests/cases/compiler/Card")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>import('./Card') : Promise +>'./Card' : "./Card" +>then : (onfulfilled?: (value: typeof import("tests/cases/compiler/Card")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>a => a.default : (a: typeof import("tests/cases/compiler/Card")) => (suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; } +>a : typeof import("tests/cases/compiler/Card") +>a.default : (suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; } +>a : typeof import("tests/cases/compiler/Card") +>default : (suit: import("tests/cases/compiler/Types").Suit, rank: import("tests/cases/compiler/Types").Rank) => { suit: import("tests/cases/compiler/Types").Suit; rank: import("tests/cases/compiler/Types").Rank; } + +export { Suit, Rank } from './Types'; +>Suit : any +>Rank : any + diff --git a/tests/baselines/reference/declarationEmitNameConflicts3.types b/tests/baselines/reference/declarationEmitNameConflicts3.types index 4963076d574..ea1406674de 100644 --- a/tests/baselines/reference/declarationEmitNameConflicts3.types +++ b/tests/baselines/reference/declarationEmitNameConflicts3.types @@ -41,7 +41,7 @@ module M.P { >D : D f ->f : D +>f : D.f } export var v: M.D; // ok >v : M.D diff --git a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.js b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.js new file mode 100644 index 00000000000..c7e1d1e8ee6 --- /dev/null +++ b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.js @@ -0,0 +1,28 @@ +//// [declarationEmitPrivateReadonlyLiterals.ts] +class Foo { + private static readonly A = "a"; + private readonly B = "b"; + private static readonly C = 42; + private readonly D = 42; +} + + +//// [declarationEmitPrivateReadonlyLiterals.js] +var Foo = /** @class */ (function () { + function Foo() { + this.B = "b"; + this.D = 42; + } + Foo.A = "a"; + Foo.C = 42; + return Foo; +}()); + + +//// [declarationEmitPrivateReadonlyLiterals.d.ts] +declare class Foo { + private static readonly A; + private readonly B; + private static readonly C; + private readonly D; +} diff --git a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.symbols b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.symbols new file mode 100644 index 00000000000..ac3d42abf3a --- /dev/null +++ b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts === +class Foo { +>Foo : Symbol(Foo, Decl(declarationEmitPrivateReadonlyLiterals.ts, 0, 0)) + + private static readonly A = "a"; +>A : Symbol(Foo.A, Decl(declarationEmitPrivateReadonlyLiterals.ts, 0, 11)) + + private readonly B = "b"; +>B : Symbol(Foo.B, Decl(declarationEmitPrivateReadonlyLiterals.ts, 1, 36)) + + private static readonly C = 42; +>C : Symbol(Foo.C, Decl(declarationEmitPrivateReadonlyLiterals.ts, 2, 29)) + + private readonly D = 42; +>D : Symbol(Foo.D, Decl(declarationEmitPrivateReadonlyLiterals.ts, 3, 35)) +} + diff --git a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.types b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.types new file mode 100644 index 00000000000..10fdff00b2e --- /dev/null +++ b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts === +class Foo { +>Foo : Foo + + private static readonly A = "a"; +>A : "a" +>"a" : "a" + + private readonly B = "b"; +>B : "b" +>"b" : "b" + + private static readonly C = 42; +>C : 42 +>42 : 42 + + private readonly D = 42; +>D : 42 +>42 : 42 +} + diff --git a/tests/baselines/reference/declarationEmitWithComposite.js b/tests/baselines/reference/declarationEmitWithComposite.js new file mode 100644 index 00000000000..3ccdf5c1ea1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.js @@ -0,0 +1,17 @@ +//// [test.ts] +interface Foo { + x: number; +} +export default Foo; + + +//// [/foo/out/test.js] +"use strict"; +exports.__esModule = true; + + +//// [/foo/out/test.d.ts] +interface Foo { + x: number; +} +export default Foo; diff --git a/tests/baselines/reference/declarationEmitWithComposite.symbols b/tests/baselines/reference/declarationEmitWithComposite.symbols new file mode 100644 index 00000000000..74f9fba394b --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.symbols @@ -0,0 +1,10 @@ +=== /foo/test.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(test.ts, 0, 0)) + + x: number; +>x : Symbol(Foo.x, Decl(test.ts, 0, 15)) +} +export default Foo; +>Foo : Symbol(Foo, Decl(test.ts, 0, 0)) + diff --git a/tests/baselines/reference/declarationEmitWithComposite.types b/tests/baselines/reference/declarationEmitWithComposite.types new file mode 100644 index 00000000000..489a84bb9f1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitWithComposite.types @@ -0,0 +1,8 @@ +=== /foo/test.ts === +interface Foo { + x: number; +>x : number +} +export default Foo; +>Foo : Foo + diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 920f995ef32..930d5f0c5b9 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -17,10 +17,8 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. - Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. - Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. - Property 'x' is missing in type '{ y: false; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,17): error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. + Property 'x' is missing in type '{ y: boolean; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. @@ -170,11 +168,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): f14([2, ["abc", { x: 0, y: true }]]); f14([2, ["abc", { x: 0 }]]); f14([2, ["abc", { y: false }]]); // Error, no x - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. -!!! error TS2345: Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. -!!! error TS2345: Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ y: false; }'. + ~~~~~~~~~~~~ +!!! error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. +!!! error TS2322: Property 'x' is missing in type '{ y: boolean; }'. module M { export var [a, b] = [1, 2]; diff --git a/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.errors.txt b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.errors.txt new file mode 100644 index 00000000000..30a1cc39aeb --- /dev/null +++ b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts(2,16): error TS1255: A definite assignment assertion '!' is not permitted in this context. +tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts(5,7): error TS1162: An object member cannot be declared optional. + + +==== tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts (2 errors) ==== + const a: string | undefined = 'ff'; + const foo = { a! } + ~ +!!! error TS1255: A definite assignment assertion '!' is not permitted in this context. + + const bar = { + a ? () { } + ~ +!!! error TS1162: An object member cannot be declared optional. + } \ No newline at end of file diff --git a/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.js b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.js new file mode 100644 index 00000000000..c3bfe922374 --- /dev/null +++ b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.js @@ -0,0 +1,23 @@ +//// [definiteAssignmentAssertionsWithObjectShortHand.ts] +const a: string | undefined = 'ff'; +const foo = { a! } + +const bar = { + a ? () { } +} + +//// [definiteAssignmentAssertionsWithObjectShortHand.js] +"use strict"; +var a = 'ff'; +var foo = { a: a }; +var bar = { + a: function () { } +}; + + +//// [definiteAssignmentAssertionsWithObjectShortHand.d.ts] +declare const a: string | undefined; +declare const foo: { + a: string; +}; +declare const bar: {}; diff --git a/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.symbols b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.symbols new file mode 100644 index 00000000000..7b8afc1d657 --- /dev/null +++ b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts === +const a: string | undefined = 'ff'; +>a : Symbol(a, Decl(definiteAssignmentAssertionsWithObjectShortHand.ts, 0, 5)) + +const foo = { a! } +>foo : Symbol(foo, Decl(definiteAssignmentAssertionsWithObjectShortHand.ts, 1, 5)) +>a : Symbol(a, Decl(definiteAssignmentAssertionsWithObjectShortHand.ts, 1, 13)) + +const bar = { +>bar : Symbol(bar, Decl(definiteAssignmentAssertionsWithObjectShortHand.ts, 3, 5)) + + a ? () { } +>a : Symbol(a, Decl(definiteAssignmentAssertionsWithObjectShortHand.ts, 3, 13)) +} diff --git a/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.types b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.types new file mode 100644 index 00000000000..73c3edfdaa5 --- /dev/null +++ b/tests/baselines/reference/definiteAssignmentAssertionsWithObjectShortHand.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts === +const a: string | undefined = 'ff'; +>a : string | undefined +>'ff' : "ff" + +const foo = { a! } +>foo : { a: string; } +>{ a! } : { a: string; } +>a : string + +const bar = { +>bar : {} +>{ a ? () { }} : {} + + a ? () { } +>a : (() => void) | undefined +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5.types b/tests/baselines/reference/destructuringParameterDeclaration1ES5.types index c0288afccec..a346856223a 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5.types @@ -191,7 +191,7 @@ b7([["string"], 1, [[true, false]]]); // Shouldn't be an error // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } >Foo : Foo ->a : Foo +>a : Foo.a function c0({z: {x, y: {j}}}) { } >c0 : ({ z: { x, y: { j } } }: { z: { x: any; y: { j: any; }; }; }) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.types b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.types index d7d682fc048..3797a5da957 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.types +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.types @@ -191,7 +191,7 @@ b7([["string"], 1, [[true, false]]]); // Shouldn't be an error // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } >Foo : Foo ->a : Foo +>a : Foo.a function c0({z: {x, y: {j}}}) { } >c0 : ({ z: { x, y: { j } } }: { z: { x: any; y: { j: any; }; }; }) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES6.types b/tests/baselines/reference/destructuringParameterDeclaration1ES6.types index baa17d8f125..04d282c76b7 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES6.types @@ -174,7 +174,7 @@ b2("string", { x: 200, y: true }); // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) enum Foo { a } >Foo : Foo ->a : Foo +>a : Foo.a function c0({z: {x, y: {j}}}) { } >c0 : ({ z: { x, y: { j } } }: { z: { x: any; y: { j: any; }; }; }) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 6e4b3f1ad08..a3ca44020c2 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -1,38 +1,21 @@ -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,8): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. Types of property 'length' are incompatible. Type '4' is not assignable to type '3'. 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; }'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,16): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,14): error TS2300: Duplicate identifier 'z'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,18): error TS2300: Duplicate identifier 'z'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,4): error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. - Types of property 'z' are incompatible. - Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,6): error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(35,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. Property 'z' is missing in type '{}'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. - Types of property 'z' are incompatible. - Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. - Types of property 'z' are incompatible. - Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. - Types of property 'b' are incompatible. - Type 'boolean' is not assignable to type 'string | number'. -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]]'. -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?]]]'. - Type '[[string]]' is not assignable to type '[[number?]]'. - Type '[string]' is not assignable to type '[number?]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,6): error TS2322: Type 'true' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,6): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,6): error TS2322: Type 'true' is not assignable to type 'string | number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,11): error TS2322: Type 'false' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,13): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -54,9 +37,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( // If the declaration includes a type annotation, the parameter is of that type function a0([a, b, [[c]]]: [number, number, string[][]]) { } a0([1, "string", [["world"]]); // Error - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. ~ !!! error TS1005: ',' expected. a0([1, 2, [["world"]], "string"]); // Error @@ -83,10 +65,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } b1("string", { x: "string", y: true }); // Error - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:19:29: The expected type comes from property 'x' which is declared here on type '{ x: number; y: any; }' // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) function c0({z: {x, y: {j}}}) { } @@ -102,41 +83,29 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( function c6([a, b, [[c = 1]]]) { } c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} } - ~~~~~~~~ -!!! error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'. c1({}); // Error, implied type is {z:number}? ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'. !!! error TS2345: Property 'z' is missing in type '{}'. c1({ z: true }); // Error, implied type is {z:number}? - ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:27:21: The expected type comes from property 'z' which is declared here on type '{ z: number; }' c2({ z: false }); // Error, implied type is {z?: number} - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. -!!! error TS2345: Types of property 'z' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. c3({ b: true }); // Error, implied type is { b: number|string }. - ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. -!!! error TS2345: Types of property 'b' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string | number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:29:20: The expected type comes from property 'b' which is declared here on type '{ b: string | number; }' c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] - ~~~~~~~~~~~~~~~~~~~ -!!! 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 TS2322: Type 'false' is not assignable to type '[[any]]'. 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?]]]'. -!!! error TS2345: Type '[[string]]' is not assignable to type '[[number?]]'. -!!! error TS2345: Type '[string]' is not assignable to type '[number?]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. Initializers (including binding property or element initializers) are diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt index d3d7cc97b51..89c0cad0d3a 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5. a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt index fa08518279e..047ee9e191c 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5i a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt index 238e155e954..38b56187a28 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property 'length' are incompatible. Type '5' is not assignable to type '3'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. - Types of property '2' are incompatible. - Type 'number' is not assignable to type '[[any]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. Property '2' is missing in type '[number, number]'. @@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6. a10([1, 2, [["string"]], false, true]); // Parameter type is any[] a10([1, 2, 3, false, true]); // Parameter type is any[] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '[[any]]'. + ~ +!!! error TS2322: Type 'number' is not assignable to type '[[any]]'. a10([1, 2]); // Parameter type is any[] ~~~~~~ !!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 2af931d352d..46e4f597c21 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -2,9 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -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]]'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,11): error TS2322: Type 'string' is not assignable to type '[[any]]'. 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 '(string | number)[]' is not assignable to parameter of type 'number[]'. @@ -47,10 +45,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? !!! related TS2728 /.ts/lib.es5.d.ts:1298:15: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! 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 TS2322: Type 'string' is not assignable to type '[[any]]'. 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 2afb25502c7..be65d7c37aa 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration5.errors.txt @@ -1,15 +1,9 @@ -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(47,6): error TS2322: 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; }'. - Types of property 'y' are incompatible. - Type 'number' is not assignable to type 'D'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,4): error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,6): error TS2322: Type 'number' is not assignable to type 'D'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,6): error TS2322: Type 'string' is not assignable to type 'D'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts (4 errors) ==== @@ -60,22 +54,19 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts( d3({ y: new SubClass() }); // Error d3({ y: new Class() }); - ~~~~~~~~~~~~~~~~~~ -!!! 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'. + ~ +!!! error TS2322: Type 'Class' is not assignable to type 'D'. +!!! error TS2322: Property 'foo' is missing in type 'Class'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' d3({}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'. !!! error TS2345: Property 'y' is missing in type '{}'. d3({ y: 1 }); - ~~~~~~~~ -!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'D'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'D'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' d3({ y: "world" }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'D'. \ No newline at end of file + ~ +!!! error TS2322: Type 'string' is not assignable to type 'D'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }' \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt index 0b333efe901..bb6b1686fc2 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt @@ -1,11 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(4,5): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(5,15): error TS2322: Type '"c"' is not assignable to type '"a" | "b"'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,6): error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. - Types of property 'method' are incompatible. - Type '"z"' is not assignable to type '"x" | "y"'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,6): error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. - Types of property 'method' are incompatible. - Type '"one"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,8): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,8): error TS2322: Type '"one"' is not assignable to type '"x" | "y"'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts (4 errors) ==== @@ -30,13 +26,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts( test({}); test({ method: 'x', nested: { p: 'a' } }) test({ method: 'z', nested: { p: 'b' } }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. -!!! error TS2345: Types of property 'method' are incompatible. -!!! error TS2345: Type '"z"' is not assignable to type '"x" | "y"'. + ~~~~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }' test({ method: 'one', nested: { p: 'a' } }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. -!!! error TS2345: Types of property 'method' are incompatible. -!!! error TS2345: Type '"one"' is not assignable to type '"x" | "y"'. + ~~~~~~ +!!! error TS2322: Type '"one"' is not assignable to type '"x" | "y"'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }' \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index deb039aa67d..da8ecee52b6 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -5,8 +5,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,42): error TS2322: Type 'string' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== @@ -45,9 +44,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2 } var x = new C1(undefined, [0, undefined, ""]); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; var y = new C1(10, [0, "", true]); diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index e0540240b61..44e013fad0b 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -7,12 +7,13 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'. - Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. - Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. + Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,47): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,51): error TS2322: Type 'false' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (12 errors) ==== type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] @@ -43,7 +44,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); ~~~~~~ -!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'. -!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. -!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. +!!! error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'. +!!! error TS2322: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierEnum.types b/tests/baselines/reference/duplicateIdentifierEnum.types index 1555c13f3a0..4fbe1dac8cc 100644 --- a/tests/baselines/reference/duplicateIdentifierEnum.types +++ b/tests/baselines/reference/duplicateIdentifierEnum.types @@ -4,7 +4,7 @@ enum A { >A : A bar ->bar : A +>bar : A.bar } class A { >A : A @@ -21,7 +21,7 @@ const enum B { >B : B bar ->bar : B +>bar : B.bar } const enum C { @@ -39,7 +39,7 @@ enum D { >D : D bar ->bar : D +>bar : D.bar } class E { >E : E @@ -59,5 +59,5 @@ enum E { >E : E bar ->bar : E +>bar : E.bar } diff --git a/tests/baselines/reference/duplicateLocalVariable4.types b/tests/baselines/reference/duplicateLocalVariable4.types index 951f24a0b9d..57da559f7e8 100644 --- a/tests/baselines/reference/duplicateLocalVariable4.types +++ b/tests/baselines/reference/duplicateLocalVariable4.types @@ -3,7 +3,7 @@ enum E{ >E : E a ->a : E +>a : E.a } var x = E; diff --git a/tests/baselines/reference/duplicatePackage_withErrors.errors.txt b/tests/baselines/reference/duplicatePackage_withErrors.errors.txt index ad24637e983..89cc598606f 100644 --- a/tests/baselines/reference/duplicatePackage_withErrors.errors.txt +++ b/tests/baselines/reference/duplicatePackage_withErrors.errors.txt @@ -1,4 +1,4 @@ -/node_modules/a/node_modules/x/index.d.ts(1,18): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal. +/node_modules/a/node_modules/x/index.d.ts(1,18): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. ==== /src/a.ts (0 errors) ==== @@ -11,7 +11,7 @@ ==== /node_modules/a/node_modules/x/index.d.ts (1 errors) ==== export const x = 1 + 1; ~~~~~ -!!! error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal. +!!! error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. ==== /node_modules/a/node_modules/x/package.json (0 errors) ==== { "name": "x", "version": "1.2.3" } diff --git a/tests/baselines/reference/emptyTuplesTypeAssertion01.errors.txt b/tests/baselines/reference/emptyTuplesTypeAssertion01.errors.txt new file mode 100644 index 00000000000..4b85b821a89 --- /dev/null +++ b/tests/baselines/reference/emptyTuplesTypeAssertion01.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts(2,11): error TS2733: Index '0' is out-of-bounds in tuple of length 0. + + +==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts (1 errors) ==== + let x = <[]>[]; + let y = x[0]; + ~ +!!! error TS2733: Index '0' is out-of-bounds in tuple of length 0. \ No newline at end of file diff --git a/tests/baselines/reference/emptyTuplesTypeAssertion02.errors.txt b/tests/baselines/reference/emptyTuplesTypeAssertion02.errors.txt new file mode 100644 index 00000000000..3969ed0fc2d --- /dev/null +++ b/tests/baselines/reference/emptyTuplesTypeAssertion02.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts(2,11): error TS2733: Index '0' is out-of-bounds in tuple of length 0. + + +==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts (1 errors) ==== + let x = [] as []; + let y = x[0]; + ~ +!!! error TS2733: Index '0' is out-of-bounds in tuple of length 0. \ No newline at end of file diff --git a/tests/baselines/reference/enumAssignability.types b/tests/baselines/reference/enumAssignability.types index 0f6446c2e51..3783a97c5ff 100644 --- a/tests/baselines/reference/enumAssignability.types +++ b/tests/baselines/reference/enumAssignability.types @@ -3,11 +3,11 @@ enum E { A } >E : E ->A : E +>A : E.A enum F { B } >F : F ->B : F +>B : F.B var e = E.A; >e : E diff --git a/tests/baselines/reference/enumAssignabilityInInheritance.types b/tests/baselines/reference/enumAssignabilityInInheritance.types index f6c2d999a2e..2c792b406df 100644 --- a/tests/baselines/reference/enumAssignabilityInInheritance.types +++ b/tests/baselines/reference/enumAssignabilityInInheritance.types @@ -4,7 +4,7 @@ enum E { A } >E : E ->A : E +>A : E.A interface I0 { [x: string]: E; @@ -243,7 +243,7 @@ var r4 = foo12(E.A); enum E2 { A } >E2 : E2 ->A : E2 +>A : E2.A declare function foo13(x: E2): E2; >foo13 : { (x: E2): E2; (x: E): E; } diff --git a/tests/baselines/reference/enumAssignmentCompat4.types b/tests/baselines/reference/enumAssignmentCompat4.types index 8d960245862..7ca5a5603b1 100644 --- a/tests/baselines/reference/enumAssignmentCompat4.types +++ b/tests/baselines/reference/enumAssignmentCompat4.types @@ -6,7 +6,7 @@ namespace M { >MyEnum : MyEnum BAR ->BAR : MyEnum +>BAR : MyEnum.BAR } export var object2 = { >object2 : { foo: MyEnum; } @@ -28,7 +28,7 @@ namespace N { >MyEnum : MyEnum FOO ->FOO : MyEnum +>FOO : MyEnum.FOO }; export var object1 = { diff --git a/tests/baselines/reference/enumBasics.types b/tests/baselines/reference/enumBasics.types index 0ca967cc258..1568212a455 100644 --- a/tests/baselines/reference/enumBasics.types +++ b/tests/baselines/reference/enumBasics.types @@ -162,10 +162,10 @@ enum E9 { >E9 : E9 A, ->A : E9 +>A : E9.A B = A ->B : E9 +>B : E9.A >A : E9 } diff --git a/tests/baselines/reference/enumClassification.types b/tests/baselines/reference/enumClassification.types index 73c8041a6b7..886d5f7342d 100644 --- a/tests/baselines/reference/enumClassification.types +++ b/tests/baselines/reference/enumClassification.types @@ -10,14 +10,14 @@ enum E01 { >E01 : E01 A ->A : E01 +>A : E01.A } enum E02 { >E02 : E02 A = 123 ->A : E02 +>A : E02.A >123 : 123 } @@ -25,7 +25,7 @@ enum E03 { >E03 : E03 A = "hello" ->A : E03 +>A : E03.A >"hello" : "hello" } diff --git a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.types b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.types index b593384ac34..73d1595187c 100644 --- a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.types +++ b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.types @@ -3,7 +3,7 @@ enum Position { >Position : Position IgnoreRulesSpecific = 0, ->IgnoreRulesSpecific : Position +>IgnoreRulesSpecific : Position.IgnoreRulesSpecific >0 : 0 } var x = IgnoreRulesSpecific. diff --git a/tests/baselines/reference/enumConstantMemberWithString.types b/tests/baselines/reference/enumConstantMemberWithString.types index 91bc2f97072..4d20d1c6f0f 100644 --- a/tests/baselines/reference/enumConstantMemberWithString.types +++ b/tests/baselines/reference/enumConstantMemberWithString.types @@ -75,7 +75,7 @@ enum T4 { >T4 : T4 a = "1" ->a : T4 +>a : T4.a >"1" : "1" } @@ -83,7 +83,7 @@ enum T5 { >T5 : T5 a = "1" + "2" ->a : T5 +>a : T5.a >"1" + "2" : string >"1" : "1" >"2" : "2" diff --git a/tests/baselines/reference/enumConstantMemberWithStringEmitDeclaration.types b/tests/baselines/reference/enumConstantMemberWithStringEmitDeclaration.types index b613ec306e4..5baed333def 100644 --- a/tests/baselines/reference/enumConstantMemberWithStringEmitDeclaration.types +++ b/tests/baselines/reference/enumConstantMemberWithStringEmitDeclaration.types @@ -53,7 +53,7 @@ enum T4 { >T4 : T4 a = "1" ->a : T4 +>a : T4.a >"1" : "1" } @@ -61,7 +61,7 @@ enum T5 { >T5 : T5 a = "1" + "2" ->a : T5 +>a : T5.a >"1" + "2" : string >"1" : "1" >"2" : "2" diff --git a/tests/baselines/reference/enumErrors.types b/tests/baselines/reference/enumErrors.types index 8c95ef133ce..a219c862233 100644 --- a/tests/baselines/reference/enumErrors.types +++ b/tests/baselines/reference/enumErrors.types @@ -27,10 +27,10 @@ enum E9 { >E9 : E9 A, ->A : E9 +>A : E9.A B = A ->B : E9 +>B : E9.A >A : E9 } diff --git a/tests/baselines/reference/enumFromExternalModule.types b/tests/baselines/reference/enumFromExternalModule.types index 05555572aa7..b4675348367 100644 --- a/tests/baselines/reference/enumFromExternalModule.types +++ b/tests/baselines/reference/enumFromExternalModule.types @@ -14,5 +14,5 @@ var x = f.Mode.Open; === tests/cases/compiler/enumFromExternalModule_0.ts === export enum Mode { Open } >Mode : Mode ->Open : Mode +>Open : Mode.Open diff --git a/tests/baselines/reference/enumGenericTypeClash.types b/tests/baselines/reference/enumGenericTypeClash.types index bb7521fa222..9e589503c2f 100644 --- a/tests/baselines/reference/enumGenericTypeClash.types +++ b/tests/baselines/reference/enumGenericTypeClash.types @@ -4,5 +4,5 @@ class X { } enum X { MyVal } >X : X ->MyVal : X +>MyVal : X.MyVal diff --git a/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.types b/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.types index a44aeee7f3d..5df80fd39bd 100644 --- a/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.types +++ b/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.types @@ -3,7 +3,7 @@ enum E { A } >E : E ->A : E +>A : E.A interface I { [x: string]: any; @@ -133,7 +133,7 @@ interface I13 { enum E2 { A } >E2 : E2 ->A : E2 +>A : E2.A interface I14 { [x: string]: E2; diff --git a/tests/baselines/reference/enumLiteralUnionNotWidened.js b/tests/baselines/reference/enumLiteralUnionNotWidened.js new file mode 100644 index 00000000000..a58e9332476 --- /dev/null +++ b/tests/baselines/reference/enumLiteralUnionNotWidened.js @@ -0,0 +1,48 @@ +//// [enumLiteralUnionNotWidened.ts] +// repro from #22093 +enum A { one = "one", two = "two" }; +enum B { foo = "foo", bar = "bar" }; + +type C = A | B.foo; +type D = A | "foo"; + +class List +{ + private readonly items: T[] = []; +} + +function asList(arg: T): List { return new List(); } + +// TypeScript incorrectly infers the return type of "asList(x)" to be "List" +// The correct type is "List" +function fn1(x: C): List { return asList(x); } + +// If we use the literal "foo" instead of B.foo, the correct type is inferred +function fn2(x: D): List { return asList(x); } + +//// [enumLiteralUnionNotWidened.js] +// repro from #22093 +var A; +(function (A) { + A["one"] = "one"; + A["two"] = "two"; +})(A || (A = {})); +; +var B; +(function (B) { + B["foo"] = "foo"; + B["bar"] = "bar"; +})(B || (B = {})); +; +var List = /** @class */ (function () { + function List() { + this.items = []; + } + return List; +}()); +function asList(arg) { return new List(); } +// TypeScript incorrectly infers the return type of "asList(x)" to be "List" +// The correct type is "List" +function fn1(x) { return asList(x); } +// If we use the literal "foo" instead of B.foo, the correct type is inferred +function fn2(x) { return asList(x); } diff --git a/tests/baselines/reference/enumLiteralUnionNotWidened.symbols b/tests/baselines/reference/enumLiteralUnionNotWidened.symbols new file mode 100644 index 00000000000..2a2eb67399a --- /dev/null +++ b/tests/baselines/reference/enumLiteralUnionNotWidened.symbols @@ -0,0 +1,61 @@ +=== tests/cases/compiler/enumLiteralUnionNotWidened.ts === +// repro from #22093 +enum A { one = "one", two = "two" }; +>A : Symbol(A, Decl(enumLiteralUnionNotWidened.ts, 0, 0)) +>one : Symbol(A.one, Decl(enumLiteralUnionNotWidened.ts, 1, 8)) +>two : Symbol(A.two, Decl(enumLiteralUnionNotWidened.ts, 1, 21)) + +enum B { foo = "foo", bar = "bar" }; +>B : Symbol(B, Decl(enumLiteralUnionNotWidened.ts, 1, 36)) +>foo : Symbol(B.foo, Decl(enumLiteralUnionNotWidened.ts, 2, 8)) +>bar : Symbol(B.bar, Decl(enumLiteralUnionNotWidened.ts, 2, 21)) + +type C = A | B.foo; +>C : Symbol(C, Decl(enumLiteralUnionNotWidened.ts, 2, 36)) +>A : Symbol(A, Decl(enumLiteralUnionNotWidened.ts, 0, 0)) +>B : Symbol(B, Decl(enumLiteralUnionNotWidened.ts, 1, 36)) +>foo : Symbol(B.foo, Decl(enumLiteralUnionNotWidened.ts, 2, 8)) + +type D = A | "foo"; +>D : Symbol(D, Decl(enumLiteralUnionNotWidened.ts, 4, 19)) +>A : Symbol(A, Decl(enumLiteralUnionNotWidened.ts, 0, 0)) + +class List +>List : Symbol(List, Decl(enumLiteralUnionNotWidened.ts, 5, 19)) +>T : Symbol(T, Decl(enumLiteralUnionNotWidened.ts, 7, 11)) +{ + private readonly items: T[] = []; +>items : Symbol(List.items, Decl(enumLiteralUnionNotWidened.ts, 8, 1)) +>T : Symbol(T, Decl(enumLiteralUnionNotWidened.ts, 7, 11)) +} + +function asList(arg: T): List { return new List(); } +>asList : Symbol(asList, Decl(enumLiteralUnionNotWidened.ts, 10, 1)) +>T : Symbol(T, Decl(enumLiteralUnionNotWidened.ts, 12, 16)) +>arg : Symbol(arg, Decl(enumLiteralUnionNotWidened.ts, 12, 19)) +>T : Symbol(T, Decl(enumLiteralUnionNotWidened.ts, 12, 16)) +>List : Symbol(List, Decl(enumLiteralUnionNotWidened.ts, 5, 19)) +>T : Symbol(T, Decl(enumLiteralUnionNotWidened.ts, 12, 16)) +>List : Symbol(List, Decl(enumLiteralUnionNotWidened.ts, 5, 19)) + +// TypeScript incorrectly infers the return type of "asList(x)" to be "List" +// The correct type is "List" +function fn1(x: C): List { return asList(x); } +>fn1 : Symbol(fn1, Decl(enumLiteralUnionNotWidened.ts, 12, 58)) +>x : Symbol(x, Decl(enumLiteralUnionNotWidened.ts, 16, 13)) +>C : Symbol(C, Decl(enumLiteralUnionNotWidened.ts, 2, 36)) +>List : Symbol(List, Decl(enumLiteralUnionNotWidened.ts, 5, 19)) +>C : Symbol(C, Decl(enumLiteralUnionNotWidened.ts, 2, 36)) +>asList : Symbol(asList, Decl(enumLiteralUnionNotWidened.ts, 10, 1)) +>x : Symbol(x, Decl(enumLiteralUnionNotWidened.ts, 16, 13)) + +// If we use the literal "foo" instead of B.foo, the correct type is inferred +function fn2(x: D): List { return asList(x); } +>fn2 : Symbol(fn2, Decl(enumLiteralUnionNotWidened.ts, 16, 49)) +>x : Symbol(x, Decl(enumLiteralUnionNotWidened.ts, 19, 13)) +>D : Symbol(D, Decl(enumLiteralUnionNotWidened.ts, 4, 19)) +>List : Symbol(List, Decl(enumLiteralUnionNotWidened.ts, 5, 19)) +>D : Symbol(D, Decl(enumLiteralUnionNotWidened.ts, 4, 19)) +>asList : Symbol(asList, Decl(enumLiteralUnionNotWidened.ts, 10, 1)) +>x : Symbol(x, Decl(enumLiteralUnionNotWidened.ts, 19, 13)) + diff --git a/tests/baselines/reference/enumLiteralUnionNotWidened.types b/tests/baselines/reference/enumLiteralUnionNotWidened.types new file mode 100644 index 00000000000..87443fbd549 --- /dev/null +++ b/tests/baselines/reference/enumLiteralUnionNotWidened.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/enumLiteralUnionNotWidened.ts === +// repro from #22093 +enum A { one = "one", two = "two" }; +>A : A +>one : A.one +>"one" : "one" +>two : A.two +>"two" : "two" + +enum B { foo = "foo", bar = "bar" }; +>B : B +>foo : B.foo +>"foo" : "foo" +>bar : B.bar +>"bar" : "bar" + +type C = A | B.foo; +>C : C +>B : any + +type D = A | "foo"; +>D : D + +class List +>List : List +{ + private readonly items: T[] = []; +>items : T[] +>[] : undefined[] +} + +function asList(arg: T): List { return new List(); } +>asList : (arg: T) => List +>arg : T +>new List() : List +>List : typeof List + +// TypeScript incorrectly infers the return type of "asList(x)" to be "List" +// The correct type is "List" +function fn1(x: C): List { return asList(x); } +>fn1 : (x: C) => List +>x : C +>asList(x) : List +>asList : (arg: T) => List +>x : C + +// If we use the literal "foo" instead of B.foo, the correct type is inferred +function fn2(x: D): List { return asList(x); } +>fn2 : (x: D) => List +>x : D +>asList(x) : List +>asList : (arg: T) => List +>x : D + diff --git a/tests/baselines/reference/enumMemberResolution.types b/tests/baselines/reference/enumMemberResolution.types index 0d761573973..e0a53f1d5ff 100644 --- a/tests/baselines/reference/enumMemberResolution.types +++ b/tests/baselines/reference/enumMemberResolution.types @@ -3,7 +3,7 @@ enum Position2 { >Position2 : Position2 IgnoreRulesSpecific = 0 ->IgnoreRulesSpecific : Position2 +>IgnoreRulesSpecific : Position2.IgnoreRulesSpecific >0 : 0 } var x = IgnoreRulesSpecific. // error diff --git a/tests/baselines/reference/enumMergingErrors.types b/tests/baselines/reference/enumMergingErrors.types index 3603f01fb5a..34fa6fe671b 100644 --- a/tests/baselines/reference/enumMergingErrors.types +++ b/tests/baselines/reference/enumMergingErrors.types @@ -64,7 +64,7 @@ module M1 { export enum E1 { A = 0 } >E1 : E1 ->A : E1 +>A : E1.A >0 : 0 } module M1 { @@ -72,14 +72,14 @@ module M1 { export enum E1 { B } >E1 : E1 ->B : E1 +>B : E1.A } module M1 { >M1 : typeof M1 export enum E1 { C } >E1 : E1 ->C : E1 +>C : E1.A } @@ -89,14 +89,14 @@ module M2 { export enum E1 { A } >E1 : E1 ->A : E1 +>A : E1.A } module M2 { >M2 : typeof M2 export enum E1 { B = 0 } >E1 : E1 ->B : E1 +>B : E1.A >0 : 0 } module M2 { @@ -104,7 +104,7 @@ module M2 { export enum E1 { C } >E1 : E1 ->C : E1 +>C : E1.A } diff --git a/tests/baselines/reference/enumOperations.types b/tests/baselines/reference/enumOperations.types index 261b5149ebd..e4afed35b10 100644 --- a/tests/baselines/reference/enumOperations.types +++ b/tests/baselines/reference/enumOperations.types @@ -1,7 +1,7 @@ === tests/cases/compiler/enumOperations.ts === enum Enum { None = 0 } >Enum : Enum ->None : Enum +>None : Enum.None >0 : 0 var enumType: Enum = Enum.None; diff --git a/tests/baselines/reference/enumWithInfinityProperty.types b/tests/baselines/reference/enumWithInfinityProperty.types index 664aa5ea2d5..ea4dc8a1dde 100644 --- a/tests/baselines/reference/enumWithInfinityProperty.types +++ b/tests/baselines/reference/enumWithInfinityProperty.types @@ -3,7 +3,7 @@ enum A { >A : A Infinity = 1 ->Infinity : A +>Infinity : A.Infinity >1 : 1 } diff --git a/tests/baselines/reference/enumWithNaNProperty.types b/tests/baselines/reference/enumWithNaNProperty.types index 710c7554a31..5233d30473a 100644 --- a/tests/baselines/reference/enumWithNaNProperty.types +++ b/tests/baselines/reference/enumWithNaNProperty.types @@ -3,7 +3,7 @@ enum A { >A : A NaN = 1 ->NaN : A +>NaN : A.NaN >1 : 1 } diff --git a/tests/baselines/reference/enumWithNegativeInfinityProperty.types b/tests/baselines/reference/enumWithNegativeInfinityProperty.types index 951f8969769..55a3f3c5633 100644 --- a/tests/baselines/reference/enumWithNegativeInfinityProperty.types +++ b/tests/baselines/reference/enumWithNegativeInfinityProperty.types @@ -3,7 +3,7 @@ enum A { >A : A "-Infinity" = 1 ->"-Infinity" : A +>"-Infinity" : A.-Infinity >1 : 1 } diff --git a/tests/baselines/reference/enumWithQuotedElementName1.types b/tests/baselines/reference/enumWithQuotedElementName1.types index 4e3db0ca482..2452f3882d5 100644 --- a/tests/baselines/reference/enumWithQuotedElementName1.types +++ b/tests/baselines/reference/enumWithQuotedElementName1.types @@ -3,5 +3,5 @@ enum E { >E : E 'fo"o', ->'fo"o' : E +>'fo"o' : E.fo"o } diff --git a/tests/baselines/reference/enumWithQuotedElementName2.types b/tests/baselines/reference/enumWithQuotedElementName2.types index 9b07138e5ab..0c34e07188c 100644 --- a/tests/baselines/reference/enumWithQuotedElementName2.types +++ b/tests/baselines/reference/enumWithQuotedElementName2.types @@ -3,5 +3,5 @@ enum E { >E : E "fo'o", ->"fo'o" : E +>"fo'o" : E.fo'o } diff --git a/tests/baselines/reference/enumWithUnicodeEscape1.types b/tests/baselines/reference/enumWithUnicodeEscape1.types index ee9dbbf5c2a..e989936dd85 100644 --- a/tests/baselines/reference/enumWithUnicodeEscape1.types +++ b/tests/baselines/reference/enumWithUnicodeEscape1.types @@ -3,6 +3,6 @@ enum E { >E : E 'gold \u2730' ->'gold \u2730' : E +>'gold \u2730' : E.gold ✰ } diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations1.types b/tests/baselines/reference/enumsWithMultipleDeclarations1.types index 1df52e22c82..552122bdc20 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations1.types +++ b/tests/baselines/reference/enumsWithMultipleDeclarations1.types @@ -3,19 +3,19 @@ enum E { >E : E A ->A : E +>A : E.A } enum E { >E : E B ->B : E +>B : E.A } enum E { >E : E C ->C : E +>C : E.A } diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations3.types b/tests/baselines/reference/enumsWithMultipleDeclarations3.types index 4f8f0ce5f58..b21e60afd24 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations3.types +++ b/tests/baselines/reference/enumsWithMultipleDeclarations3.types @@ -6,5 +6,5 @@ enum E { >E : E A ->A : E +>A : E.A } diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt b/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt new file mode 100644 index 00000000000..b70d3d744ef --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/errorsWithInvokablesInUnions01.ts(14,12): error TS2322: Type '(x: string) => void' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. + Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. + Types of parameters 'x' and 'scope' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/errorsWithInvokablesInUnions01.ts(16,12): error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. + Type 'typeof ctor' is not assignable to type 'ConstructableA'. + Type 'ctor' is not assignable to type '{ somePropA: any; }'. + Property 'somePropA' is missing in type 'ctor'. + + +==== tests/cases/compiler/errorsWithInvokablesInUnions01.ts (2 errors) ==== + interface ConstructableA { + new(): { somePropA: any }; + } + + interface IDirectiveLinkFn { + (scope: TScope): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} + ~~~~ +!!! error TS2322: Type '(x: string) => void' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. +!!! error TS2322: Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. +!!! error TS2322: Types of parameters 'x' and 'scope' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { + ~~~~ +!!! error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. +!!! error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA'. +!!! error TS2322: Type 'ctor' is not assignable to type '{ somePropA: any; }'. +!!! error TS2322: Property 'somePropA' is missing in type 'ctor'. + someUnaccountedProp: any; + } + \ No newline at end of file diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.js b/tests/baselines/reference/errorsWithInvokablesInUnions01.js new file mode 100644 index 00000000000..47c2df0fc23 --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.js @@ -0,0 +1,30 @@ +//// [errorsWithInvokablesInUnions01.ts] +interface ConstructableA { + new(): { somePropA: any }; +} + +interface IDirectiveLinkFn { + (scope: TScope): void; +} + +interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { + someUnaccountedProp: any; +} + + +//// [errorsWithInvokablesInUnions01.js] +"use strict"; +exports.__esModule = true; +exports.blah = function (x) { }; +exports.ctor = /** @class */ (function () { + function class_1() { + } + return class_1; +}()); diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols b/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols new file mode 100644 index 00000000000..a82cecb7665 --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols @@ -0,0 +1,49 @@ +=== tests/cases/compiler/errorsWithInvokablesInUnions01.ts === +interface ConstructableA { +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) + + new(): { somePropA: any }; +>somePropA : Symbol(somePropA, Decl(errorsWithInvokablesInUnions01.ts, 1, 10)) +} + +interface IDirectiveLinkFn { +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 4, 27)) + + (scope: TScope): void; +>scope : Symbol(scope, Decl(errorsWithInvokablesInUnions01.ts, 5, 5)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 4, 27)) +} + +interface IDirectivePrePost { +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) + + pre?: IDirectiveLinkFn; +>pre : Symbol(IDirectivePrePost.pre, Decl(errorsWithInvokablesInUnions01.ts, 8, 37)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) + + post?: IDirectiveLinkFn; +>post : Symbol(IDirectivePrePost.post, Decl(errorsWithInvokablesInUnions01.ts, 9, 35)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} +>blah : Symbol(blah, Decl(errorsWithInvokablesInUnions01.ts, 13, 10)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) +>x : Symbol(x, Decl(errorsWithInvokablesInUnions01.ts, 13, 90)) + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { +>ctor : Symbol(ctor, Decl(errorsWithInvokablesInUnions01.ts, 15, 10)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) + + someUnaccountedProp: any; +>someUnaccountedProp : Symbol(ctor.someUnaccountedProp, Decl(errorsWithInvokablesInUnions01.ts, 15, 96)) +} + diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.types b/tests/baselines/reference/errorsWithInvokablesInUnions01.types new file mode 100644 index 00000000000..3497a71cad8 --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/errorsWithInvokablesInUnions01.ts === +interface ConstructableA { + new(): { somePropA: any }; +>somePropA : any +} + +interface IDirectiveLinkFn { + (scope: TScope): void; +>scope : TScope +} + +interface IDirectivePrePost { + pre?: IDirectiveLinkFn; +>pre : IDirectiveLinkFn + + post?: IDirectiveLinkFn; +>post : IDirectiveLinkFn +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} +>blah : ConstructableA | IDirectiveLinkFn | IDirectivePrePost +>(x: string) => {} : (x: string) => void +>x : string + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { +>ctor : ConstructableA | IDirectiveLinkFn | IDirectivePrePost +>class { someUnaccountedProp: any;} : typeof ctor + + someUnaccountedProp: any; +>someUnaccountedProp : any +} + diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index 532931fd2b3..523f0673025 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -20,16 +20,16 @@ export module uninstantiated { === tests/cases/compiler/client.ts === export { c } from "server"; ->c : typeof c +>c : typeof import("tests/cases/compiler/server").c export { c as c2 } from "server"; ->c : typeof c ->c2 : typeof c +>c : typeof import("tests/cases/compiler/server").c +>c2 : typeof import("tests/cases/compiler/server").c export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof import("tests/cases/compiler/server").m +>instantiatedModule : typeof import("tests/cases/compiler/server").m export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 57b4845a6fa..cb5fd1d3756 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -20,16 +20,16 @@ export module uninstantiated { === tests/cases/compiler/client.ts === export { c } from "./server"; ->c : typeof c +>c : typeof import("tests/cases/compiler/server").c export { c as c2 } from "./server"; ->c : typeof c ->c2 : typeof c +>c : typeof import("tests/cases/compiler/server").c +>c2 : typeof import("tests/cases/compiler/server").c export { i, m as instantiatedModule } from "./server"; >i : any ->m : typeof instantiatedModule ->instantiatedModule : typeof instantiatedModule +>m : typeof import("tests/cases/compiler/server").m +>instantiatedModule : typeof import("tests/cases/compiler/server").m export { uninstantiated } from "./server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6modulekindWithES5Target5.types b/tests/baselines/reference/es6modulekindWithES5Target5.types index b5e69598788..74f4e8b34a6 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target5.types +++ b/tests/baselines/reference/es6modulekindWithES5Target5.types @@ -3,12 +3,12 @@ export enum E1 { >E1 : E1 value1 ->value1 : E1 +>value1 : E1.value1 } export const enum E2 { >E2 : E2 value1 ->value1 : E2 +>value1 : E2.value1 } diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.types b/tests/baselines/reference/esnextmodulekindWithES5Target5.types index c838a953ef9..bfeec26a519 100644 --- a/tests/baselines/reference/esnextmodulekindWithES5Target5.types +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.types @@ -3,12 +3,12 @@ export enum E1 { >E1 : E1 value1 ->value1 : E1 +>value1 : E1.value1 } export const enum E2 { >E2 : E2 value1 ->value1 : E2 +>value1 : E2.value1 } diff --git a/tests/baselines/reference/everyTypeAssignableToAny.types b/tests/baselines/reference/everyTypeAssignableToAny.types index c38e2bb0f61..574d77bc7e4 100644 --- a/tests/baselines/reference/everyTypeAssignableToAny.types +++ b/tests/baselines/reference/everyTypeAssignableToAny.types @@ -20,7 +20,7 @@ var ai: I; enum E { A } >E : E ->A : E +>A : E.A var ae: E; >ae : E diff --git a/tests/baselines/reference/expandoFunctionContextualTypes.js b/tests/baselines/reference/expandoFunctionContextualTypes.js new file mode 100644 index 00000000000..541adf963e4 --- /dev/null +++ b/tests/baselines/reference/expandoFunctionContextualTypes.js @@ -0,0 +1,22 @@ +//// [expandoFunctionContextualTypes.ts] +interface MyComponentProps { + color: "red" | "blue" +} + +interface StatelessComponent

{ + (): any; + defaultProps?: Partial

; +} + +const MyComponent: StatelessComponent = () => null as any; + +MyComponent.defaultProps = { + color: "red" +}; + + +//// [expandoFunctionContextualTypes.js] +var MyComponent = function () { return null; }; +MyComponent.defaultProps = { + color: "red" +}; diff --git a/tests/baselines/reference/expandoFunctionContextualTypes.symbols b/tests/baselines/reference/expandoFunctionContextualTypes.symbols new file mode 100644 index 00000000000..38c87d1e941 --- /dev/null +++ b/tests/baselines/reference/expandoFunctionContextualTypes.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/expandoFunctionContextualTypes.ts === +interface MyComponentProps { +>MyComponentProps : Symbol(MyComponentProps, Decl(expandoFunctionContextualTypes.ts, 0, 0)) + + color: "red" | "blue" +>color : Symbol(MyComponentProps.color, Decl(expandoFunctionContextualTypes.ts, 0, 28)) +} + +interface StatelessComponent

{ +>StatelessComponent : Symbol(StatelessComponent, Decl(expandoFunctionContextualTypes.ts, 2, 1)) +>P : Symbol(P, Decl(expandoFunctionContextualTypes.ts, 4, 29)) + + (): any; + defaultProps?: Partial

; +>defaultProps : Symbol(StatelessComponent.defaultProps, Decl(expandoFunctionContextualTypes.ts, 5, 12)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(expandoFunctionContextualTypes.ts, 4, 29)) +} + +const MyComponent: StatelessComponent = () => null as any; +>MyComponent : Symbol(MyComponent, Decl(expandoFunctionContextualTypes.ts, 9, 5), Decl(expandoFunctionContextualTypes.ts, 9, 76)) +>StatelessComponent : Symbol(StatelessComponent, Decl(expandoFunctionContextualTypes.ts, 2, 1)) +>MyComponentProps : Symbol(MyComponentProps, Decl(expandoFunctionContextualTypes.ts, 0, 0)) + +MyComponent.defaultProps = { +>MyComponent.defaultProps : Symbol(StatelessComponent.defaultProps, Decl(expandoFunctionContextualTypes.ts, 5, 12)) +>MyComponent : Symbol(MyComponent, Decl(expandoFunctionContextualTypes.ts, 9, 5), Decl(expandoFunctionContextualTypes.ts, 9, 76)) +>defaultProps : Symbol(StatelessComponent.defaultProps, Decl(expandoFunctionContextualTypes.ts, 5, 12)) + + color: "red" +>color : Symbol(color, Decl(expandoFunctionContextualTypes.ts, 11, 28)) + +}; + diff --git a/tests/baselines/reference/expandoFunctionContextualTypes.types b/tests/baselines/reference/expandoFunctionContextualTypes.types new file mode 100644 index 00000000000..e1eca92659c --- /dev/null +++ b/tests/baselines/reference/expandoFunctionContextualTypes.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/expandoFunctionContextualTypes.ts === +interface MyComponentProps { + color: "red" | "blue" +>color : "red" | "blue" +} + +interface StatelessComponent

{ + (): any; + defaultProps?: Partial

; +>defaultProps : Partial

+} + +const MyComponent: StatelessComponent = () => null as any; +>MyComponent : StatelessComponent +>() => null as any : { (): any; defaultProps: { color: "red"; }; } +>null as any : any +>null : null + +MyComponent.defaultProps = { +>MyComponent.defaultProps = { color: "red"} : { color: "red"; } +>MyComponent.defaultProps : Partial +>MyComponent : StatelessComponent +>defaultProps : Partial +>{ color: "red"} : { color: "red"; } + + color: "red" +>color : "red" +>"red" : "red" + +}; + diff --git a/tests/baselines/reference/expandoFunctionContextualTypesJs.symbols b/tests/baselines/reference/expandoFunctionContextualTypesJs.symbols new file mode 100644 index 00000000000..bf0b71f5664 --- /dev/null +++ b/tests/baselines/reference/expandoFunctionContextualTypesJs.symbols @@ -0,0 +1,86 @@ +=== tests/cases/compiler/input.js === +/** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + +/** + * @template P + * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ + + /** + * @type {StatelessComponent} + */ +const MyComponent = () => /* @type {any} */(null); +>MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5), Decl(input.js, 9, 50)) + +MyComponent.defaultProps = { +>MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) +>MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5), Decl(input.js, 9, 50)) +>defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) + + color: "red" +>color : Symbol(color, Decl(input.js, 11, 28)) + +}; + +const MyComponent2 = () => null; +>MyComponent2 : Symbol(MyComponent2, Decl(input.js, 15, 5), Decl(input.js, 15, 32)) + +/** + * @type {MyComponentProps} + */ +MyComponent2.defaultProps = { +>MyComponent2.defaultProps : Symbol(MyComponent2.defaultProps, Decl(input.js, 15, 32)) +>MyComponent2 : Symbol(MyComponent2, Decl(input.js, 15, 5), Decl(input.js, 15, 32)) +>defaultProps : Symbol(MyComponent2.defaultProps, Decl(input.js, 15, 32)) + + color: "red" +>color : Symbol(color, Decl(input.js, 20, 29)) +} + +/** + * @type {StatelessComponent} + */ +const check = MyComponent2; +>check : Symbol(check, Decl(input.js, 27, 5)) +>MyComponent2 : Symbol(MyComponent2, Decl(input.js, 15, 5), Decl(input.js, 15, 32)) + +/** + * + * @param {{ props: MyComponentProps }} p + */ +function expectLiteral(p) {} +>expectLiteral : Symbol(expectLiteral, Decl(input.js, 27, 27)) +>p : Symbol(p, Decl(input.js, 33, 23)) + +function foo() { +>foo : Symbol(foo, Decl(input.js, 33, 28)) + + /** + * @type {MyComponentProps} + */ + this.props = { color: "red" }; +>props : Symbol(foo.props, Decl(input.js, 35, 16)) +>color : Symbol(color, Decl(input.js, 39, 18)) + + expectLiteral(this); +>expectLiteral : Symbol(expectLiteral, Decl(input.js, 27, 27)) +} + +/** + * @type {MyComponentProps} + */ +module.exports = { +>module.exports : Symbol("tests/cases/compiler/input", Decl(input.js, 0, 0)) +>module : Symbol(export=, Decl(input.js, 42, 1)) +>exports : Symbol(export=, Decl(input.js, 42, 1)) + + color: "red" +>color : Symbol(color, Decl(input.js, 47, 18)) +} + +expectLiteral({ props: module.exports }); +>expectLiteral : Symbol(expectLiteral, Decl(input.js, 27, 27)) +>props : Symbol(props, Decl(input.js, 51, 15)) +>module.exports : Symbol("tests/cases/compiler/input", Decl(input.js, 0, 0)) +>module : Symbol(module, Decl(input.js, 42, 1), Decl(input.js, 51, 22)) +>exports : Symbol("tests/cases/compiler/input", Decl(input.js, 0, 0)) + diff --git a/tests/baselines/reference/expandoFunctionContextualTypesJs.types b/tests/baselines/reference/expandoFunctionContextualTypesJs.types new file mode 100644 index 00000000000..081c57c0dac --- /dev/null +++ b/tests/baselines/reference/expandoFunctionContextualTypesJs.types @@ -0,0 +1,109 @@ +=== tests/cases/compiler/input.js === +/** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + +/** + * @template P + * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ + + /** + * @type {StatelessComponent} + */ +const MyComponent = () => /* @type {any} */(null); +>MyComponent : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; } +>() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; } +>(null) : null +>null : null + +MyComponent.defaultProps = { +>MyComponent.defaultProps = { color: "red"} : { color: "red"; } +>MyComponent.defaultProps : Partial<{ color: "red" | "blue"; }> +>MyComponent : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; } +>defaultProps : Partial<{ color: "red" | "blue"; }> +>{ color: "red"} : { color: "red"; } + + color: "red" +>color : "red" +>"red" : "red" + +}; + +const MyComponent2 = () => null; +>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; } +>() => null : { (): any; defaultProps: { color: "red" | "blue"; }; } +>null : null + +/** + * @type {MyComponentProps} + */ +MyComponent2.defaultProps = { +>MyComponent2.defaultProps = { color: "red"} : { color: "red"; } +>MyComponent2.defaultProps : { color: "red" | "blue"; } +>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; } +>defaultProps : { color: "red" | "blue"; } +>{ color: "red"} : { color: "red"; } + + color: "red" +>color : "red" +>"red" : "red" +} + +/** + * @type {StatelessComponent} + */ +const check = MyComponent2; +>check : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; } +>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; } + +/** + * + * @param {{ props: MyComponentProps }} p + */ +function expectLiteral(p) {} +>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void +>p : { props: { color: "red" | "blue"; }; } + +function foo() { +>foo : typeof foo + + /** + * @type {MyComponentProps} + */ + this.props = { color: "red" }; +>this.props = { color: "red" } : { color: "red"; } +>this.props : any +>this : any +>props : any +>{ color: "red" } : { color: "red"; } +>color : "red" +>"red" : "red" + + expectLiteral(this); +>expectLiteral(this) : void +>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void +>this : any +} + +/** + * @type {MyComponentProps} + */ +module.exports = { +>module.exports = { color: "red"} : { color: "red" | "blue"; } +>module.exports : { color: "red" | "blue"; } +>module : { "tests/cases/compiler/input": { color: "red" | "blue"; }; } +>exports : { color: "red" | "blue"; } +>{ color: "red"} : { color: "red"; } + + color: "red" +>color : "red" +>"red" : "red" +} + +expectLiteral({ props: module.exports }); +>expectLiteral({ props: module.exports }) : void +>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void +>{ props: module.exports } : { props: { color: "red" | "blue"; }; } +>props : { color: "red" | "blue"; } +>module.exports : { color: "red" | "blue"; } +>module : { "tests/cases/compiler/input": { color: "red" | "blue"; }; } +>exports : { color: "red" | "blue"; } + diff --git a/tests/baselines/reference/exportCodeGen.types b/tests/baselines/reference/exportCodeGen.types index 782ac5ff499..99c912f9864 100644 --- a/tests/baselines/reference/exportCodeGen.types +++ b/tests/baselines/reference/exportCodeGen.types @@ -66,7 +66,7 @@ module E { export enum Color { Red } >Color : Color ->Red : Color +>Red : Color.Red export function fn() { } >fn : () => void @@ -94,7 +94,7 @@ module F { enum Color { Red } >Color : Color ->Red : Color +>Red : Color.Red function fn() { } >fn : () => void diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt index 20a1c9a7d41..d2f103a91fa 100644 --- a/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt +++ b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt @@ -1,17 +1,14 @@ tests/cases/compiler/b.ts(1,9): error TS2661: Cannot export 'X'. Only local declarations can be exported from a module. -tests/cases/compiler/b.ts(2,17): error TS4060: Return type of exported function has or is using private name 'X'. ==== tests/cases/compiler/a.d.ts (0 errors) ==== declare class X { } -==== tests/cases/compiler/b.ts (2 errors) ==== +==== tests/cases/compiler/b.ts (1 errors) ==== export {X}; ~ !!! error TS2661: Cannot export 'X'. Only local declarations can be exported from a module. export function f() { - ~ -!!! error TS4060: Return type of exported function has or is using private name 'X'. var x: X; return x; } diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js index 9f12241cbd1..6023b7c7f14 100644 --- a/tests/baselines/reference/exportSpecifierForAGlobal.js +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -19,3 +19,8 @@ function f() { return x; } exports.f = f; + + +//// [b.d.ts] +export { X }; +export declare function f(): X; diff --git a/tests/baselines/reference/exportsAndImports1-amd.types b/tests/baselines/reference/exportsAndImports1-amd.types index b63913106fa..fc79a3dcc78 100644 --- a/tests/baselines/reference/exportsAndImports1-amd.types +++ b/tests/baselines/reference/exportsAndImports1-amd.types @@ -61,11 +61,11 @@ export { v, f, C, I, E, D, M, N, T, a }; export { v, f, C, I, E, D, M, N, T, a } from "./t1"; >v : number >f : () => void ->C : typeof C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I : any ->E : typeof E ->D : typeof D ->M : typeof M +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N : any >T : any >a : any diff --git a/tests/baselines/reference/exportsAndImports1-es6.types b/tests/baselines/reference/exportsAndImports1-es6.types index b63913106fa..fc79a3dcc78 100644 --- a/tests/baselines/reference/exportsAndImports1-es6.types +++ b/tests/baselines/reference/exportsAndImports1-es6.types @@ -61,11 +61,11 @@ export { v, f, C, I, E, D, M, N, T, a }; export { v, f, C, I, E, D, M, N, T, a } from "./t1"; >v : number >f : () => void ->C : typeof C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I : any ->E : typeof E ->D : typeof D ->M : typeof M +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N : any >T : any >a : any diff --git a/tests/baselines/reference/exportsAndImports1.types b/tests/baselines/reference/exportsAndImports1.types index b63913106fa..fc79a3dcc78 100644 --- a/tests/baselines/reference/exportsAndImports1.types +++ b/tests/baselines/reference/exportsAndImports1.types @@ -61,11 +61,11 @@ export { v, f, C, I, E, D, M, N, T, a }; export { v, f, C, I, E, D, M, N, T, a } from "./t1"; >v : number >f : () => void ->C : typeof C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I : any ->E : typeof E ->D : typeof D ->M : typeof M +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N : any >T : any >a : any diff --git a/tests/baselines/reference/exportsAndImports3-amd.symbols b/tests/baselines/reference/exportsAndImports3-amd.symbols index edc5d5c2e4e..f71014281c2 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.symbols +++ b/tests/baselines/reference/exportsAndImports3-amd.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/exportsAndImports3-amd.types b/tests/baselines/reference/exportsAndImports3-amd.types index a8357a4db22..8a021f7a009 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.types +++ b/tests/baselines/reference/exportsAndImports3-amd.types @@ -73,16 +73,16 @@ export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, >v : number >f1 : () => void >f : () => void ->C1 : typeof C ->C : typeof C +>C1 : typeof import("tests/cases/conformance/es6/modules/t1").C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I1 : any >I : any ->E1 : typeof E ->E : typeof E ->D1 : typeof D ->D : typeof D ->M1 : typeof M ->M : typeof M +>E1 : typeof import("tests/cases/conformance/es6/modules/t1").E +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D1 : typeof import("tests/cases/conformance/es6/modules/t1").D +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M1 : typeof import("tests/cases/conformance/es6/modules/t1").M +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N1 : any >N : any >T1 : any diff --git a/tests/baselines/reference/exportsAndImports3-es6.symbols b/tests/baselines/reference/exportsAndImports3-es6.symbols index edc5d5c2e4e..f71014281c2 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.symbols +++ b/tests/baselines/reference/exportsAndImports3-es6.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/exportsAndImports3-es6.types b/tests/baselines/reference/exportsAndImports3-es6.types index a8357a4db22..8a021f7a009 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.types +++ b/tests/baselines/reference/exportsAndImports3-es6.types @@ -73,16 +73,16 @@ export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, >v : number >f1 : () => void >f : () => void ->C1 : typeof C ->C : typeof C +>C1 : typeof import("tests/cases/conformance/es6/modules/t1").C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I1 : any >I : any ->E1 : typeof E ->E : typeof E ->D1 : typeof D ->D : typeof D ->M1 : typeof M ->M : typeof M +>E1 : typeof import("tests/cases/conformance/es6/modules/t1").E +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D1 : typeof import("tests/cases/conformance/es6/modules/t1").D +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M1 : typeof import("tests/cases/conformance/es6/modules/t1").M +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N1 : any >N : any >T1 : any diff --git a/tests/baselines/reference/exportsAndImports3.symbols b/tests/baselines/reference/exportsAndImports3.symbols index edc5d5c2e4e..f71014281c2 100644 --- a/tests/baselines/reference/exportsAndImports3.symbols +++ b/tests/baselines/reference/exportsAndImports3.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E1.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E1.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E1.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D1.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D1.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D1.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/exportsAndImports3.types b/tests/baselines/reference/exportsAndImports3.types index a8357a4db22..8a021f7a009 100644 --- a/tests/baselines/reference/exportsAndImports3.types +++ b/tests/baselines/reference/exportsAndImports3.types @@ -73,16 +73,16 @@ export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, >v : number >f1 : () => void >f : () => void ->C1 : typeof C ->C : typeof C +>C1 : typeof import("tests/cases/conformance/es6/modules/t1").C +>C : typeof import("tests/cases/conformance/es6/modules/t1").C >I1 : any >I : any ->E1 : typeof E ->E : typeof E ->D1 : typeof D ->D : typeof D ->M1 : typeof M ->M : typeof M +>E1 : typeof import("tests/cases/conformance/es6/modules/t1").E +>E : typeof import("tests/cases/conformance/es6/modules/t1").E +>D1 : typeof import("tests/cases/conformance/es6/modules/t1").D +>D : typeof import("tests/cases/conformance/es6/modules/t1").D +>M1 : typeof import("tests/cases/conformance/es6/modules/t1").M +>M : typeof import("tests/cases/conformance/es6/modules/t1").M >N1 : any >N : any >T1 : any diff --git a/tests/baselines/reference/externSemantics.errors.txt b/tests/baselines/reference/externSemantics.errors.txt index b58e2a4950c..db6ce0f6acd 100644 --- a/tests/baselines/reference/externSemantics.errors.txt +++ b/tests/baselines/reference/externSemantics.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/externSemantics.ts(1,14): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/externSemantics.ts(3,21): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/externSemantics.ts(1,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/externSemantics.ts(3,22): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/externSemantics.ts (2 errors) ==== declare var x=10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare var v; declare var y:number=3; - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/for-of39.errors.txt b/tests/baselines/reference/for-of39.errors.txt index 62edda40de3..5f084961833 100644 --- a/tests/baselines/reference/for-of39.errors.txt +++ b/tests/baselines/reference/for-of39.errors.txt @@ -1,24 +1,16 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,19): error TS2345: Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'ReadonlyArray<[string, boolean]>'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray<[string, number] | [string, true]>[]): ([string, number] | [string, true])[]; (...items: ([string, number] | [string, true] | ConcatArray<[string, number] | [string, true]>)[]): ([string, number] | [string, true])[]; }' is not assignable to type '{ (...items: ConcatArray<[string, boolean]>[]): [string, boolean][]; (...items: ([string, boolean] | ConcatArray<[string, boolean]>)[]): [string, boolean][]; }'. - Types of parameters 'items' and 'items' are incompatible. - Type 'ConcatArray<[string, boolean]>' is not assignable to type 'ConcatArray<[string, number] | [string, true]>'. - Type '[string, boolean]' is not assignable to type '[string, number] | [string, true]'. - Type '[string, boolean]' is not assignable to type '[string, number]'. - Type 'boolean' is not assignable to type 'number'. + Type '[string, number] | [string, true]' is not assignable to type '[string, boolean]'. + Type '[string, number]' is not assignable to type '[string, boolean]'. + Type 'number' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/for-ofStatements/for-of39.ts (1 errors) ==== var map = new Map([["", true], ["", 0]]); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'ReadonlyArray<[string, boolean]>'. -!!! error TS2345: Types of property 'concat' are incompatible. -!!! error TS2345: Type '{ (...items: ConcatArray<[string, number] | [string, true]>[]): ([string, number] | [string, true])[]; (...items: ([string, number] | [string, true] | ConcatArray<[string, number] | [string, true]>)[]): ([string, number] | [string, true])[]; }' is not assignable to type '{ (...items: ConcatArray<[string, boolean]>[]): [string, boolean][]; (...items: ([string, boolean] | ConcatArray<[string, boolean]>)[]): [string, boolean][]; }'. -!!! error TS2345: Types of parameters 'items' and 'items' are incompatible. -!!! error TS2345: Type 'ConcatArray<[string, boolean]>' is not assignable to type 'ConcatArray<[string, number] | [string, true]>'. -!!! error TS2345: Type '[string, boolean]' is not assignable to type '[string, number] | [string, true]'. -!!! error TS2345: Type '[string, boolean]' is not assignable to type '[string, number]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. +!!! error TS2345: Type '[string, number] | [string, true]' is not assignable to type '[string, boolean]'. +!!! error TS2345: Type '[string, number]' is not assignable to type '[string, boolean]'. +!!! error TS2345: Type 'number' is not assignable to type 'boolean'. for (var [k, v] of map) { k; v; diff --git a/tests/baselines/reference/for-of47.types b/tests/baselines/reference/for-of47.types index 9f98a2c63b4..b235d772e84 100644 --- a/tests/baselines/reference/for-of47.types +++ b/tests/baselines/reference/for-of47.types @@ -14,7 +14,7 @@ var array = [{ x: "", y: true }] enum E { x } >E : E ->x : E +>x : E.x for ({x, y: y = E.x} of array) { >{x, y: y = E.x} : { x: string; y?: E; } diff --git a/tests/baselines/reference/for-of48.types b/tests/baselines/reference/for-of48.types index af93d4968f2..575ea99064f 100644 --- a/tests/baselines/reference/for-of48.types +++ b/tests/baselines/reference/for-of48.types @@ -14,7 +14,7 @@ var array = [{ x: "", y: true }] enum E { x } >E : E ->x : E +>x : E.x for ({x, y = E.x} of array) { >{x, y = E.x} : { x: string; y?: number; } diff --git a/tests/baselines/reference/functionCall18.errors.txt b/tests/baselines/reference/functionCall18.errors.txt new file mode 100644 index 00000000000..99d7415425c --- /dev/null +++ b/tests/baselines/reference/functionCall18.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/functionCall18.ts(4,1): error TS2554: Expected 2 arguments, but got 1. + + +==== tests/cases/compiler/functionCall18.ts (1 errors) ==== + // Repro from #26835 + declare function foo(a: T, b: T); + declare function foo(a: {}); + foo("hello"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 2 arguments, but got 1. + \ No newline at end of file diff --git a/tests/baselines/reference/functionCall18.js b/tests/baselines/reference/functionCall18.js new file mode 100644 index 00000000000..6e059205c62 --- /dev/null +++ b/tests/baselines/reference/functionCall18.js @@ -0,0 +1,9 @@ +//// [functionCall18.ts] +// Repro from #26835 +declare function foo(a: T, b: T); +declare function foo(a: {}); +foo("hello"); + + +//// [functionCall18.js] +foo("hello"); diff --git a/tests/baselines/reference/functionCall18.symbols b/tests/baselines/reference/functionCall18.symbols new file mode 100644 index 00000000000..ebf635d91e9 --- /dev/null +++ b/tests/baselines/reference/functionCall18.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/functionCall18.ts === +// Repro from #26835 +declare function foo(a: T, b: T); +>foo : Symbol(foo, Decl(functionCall18.ts, 0, 0), Decl(functionCall18.ts, 1, 36)) +>T : Symbol(T, Decl(functionCall18.ts, 1, 21)) +>a : Symbol(a, Decl(functionCall18.ts, 1, 24)) +>T : Symbol(T, Decl(functionCall18.ts, 1, 21)) +>b : Symbol(b, Decl(functionCall18.ts, 1, 29)) +>T : Symbol(T, Decl(functionCall18.ts, 1, 21)) + +declare function foo(a: {}); +>foo : Symbol(foo, Decl(functionCall18.ts, 0, 0), Decl(functionCall18.ts, 1, 36)) +>a : Symbol(a, Decl(functionCall18.ts, 2, 21)) + +foo("hello"); +>foo : Symbol(foo, Decl(functionCall18.ts, 0, 0), Decl(functionCall18.ts, 1, 36)) + diff --git a/tests/baselines/reference/functionCall18.types b/tests/baselines/reference/functionCall18.types new file mode 100644 index 00000000000..90fa33f0617 --- /dev/null +++ b/tests/baselines/reference/functionCall18.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/functionCall18.ts === +// Repro from #26835 +declare function foo(a: T, b: T); +>foo : { (a: T, b: T): any; (a: {}): any; } +>a : T +>b : T + +declare function foo(a: {}); +>foo : { (a: T, b: T): any; (a: {}): any; } +>a : {} + +foo("hello"); +>foo("hello") : any +>foo : { (a: T, b: T): any; (a: {}): any; } +>"hello" : "hello" + diff --git a/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt index 6a3a7998f09..d50e0c4b6d6 100644 --- a/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt +++ b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts(11,1): error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. - Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. - Type 'boolean' is not assignable to type 'string'. + Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => number'. + Type 'boolean' is not assignable to type 'number'. ==== tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts (1 errors) ==== @@ -17,5 +17,5 @@ tests/cases/conformance/expressions/contextualTyping/functionExpressionContextua a1 = (foo, bar) => { return true; } // Error ~~ !!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. -!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => number'. +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js new file mode 100644 index 00000000000..1cf35579976 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.js @@ -0,0 +1,113 @@ +//// [functionWithUseStrictAndSimpleParameterList.ts] +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function rest1(a = 1, ...args) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} + + +//// [functionWithUseStrictAndSimpleParameterList.js] +"use strict"; +exports.__esModule = true; +function a(a) { + "use strict"; + if (a === void 0) { a = 10; } +} +exports.foo = 10; +function b(a) { + if (a === void 0) { a = 10; } +} +function container() { + "use strict"; + function f(a) { + if (a === void 0) { a = 10; } + } +} +function rest() { + 'use strict'; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} +function rest1(a) { + 'use strict'; + if (a === void 0) { a = 1; } + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } +} +function paramDefault(param) { + 'use strict'; + if (param === void 0) { param = 1; } +} +function objectBindingPattern(_a) { + 'use strict'; + var foo = _a.foo; +} +function arrayBindingPattern(_a) { + 'use strict'; + var foo = _a[0]; +} +function manyParameter(a, b) { + "use strict"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } +} +function manyPrologue(a, b) { + "foo"; + "use strict"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } +} +function invalidPrologue(a, b) { + "foo"; + if (a === void 0) { a = 10; } + if (b === void 0) { b = 20; } + var c = 1; + "use strict"; +} diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols new file mode 100644 index 00000000000..9c2ad86d974 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.symbols @@ -0,0 +1,91 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts === +function a(a = 10) { +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 0, 0)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 0, 11)) + + "use strict"; +} + +export var foo = 10; +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 4, 10)) + +function b(a = 10) { +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 4, 20)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 5, 11)) +} + +function container() { +>container : Symbol(container, Decl(functionWithUseStrictAndSimpleParameterList.ts, 6, 1)) + + "use strict"; + function f(a = 10) { +>f : Symbol(f, Decl(functionWithUseStrictAndSimpleParameterList.ts, 9, 17)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 10, 15)) + } +} + +function rest(...args: any[]) { +>rest : Symbol(rest, Decl(functionWithUseStrictAndSimpleParameterList.ts, 12, 1)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList.ts, 14, 14)) + + 'use strict'; +} + +function rest1(a = 1, ...args) { +>rest1 : Symbol(rest1, Decl(functionWithUseStrictAndSimpleParameterList.ts, 16, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 15)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList.ts, 18, 21)) + + 'use strict'; +} + +function paramDefault(param = 1) { +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList.ts, 20, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList.ts, 22, 22)) + + 'use strict'; +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 26, 31)) + + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList.ts, 28, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList.ts, 30, 30)) + + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 34, 30)) + + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 36, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 38, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 38, 29)) + + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList.ts, 41, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList.ts, 43, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList.ts, 43, 32)) + + "foo"; + const c = 1; +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList.ts, 45, 9)) + + "use strict"; +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types new file mode 100644 index 00000000000..462086d28ad --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList.types @@ -0,0 +1,119 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts === +function a(a = 10) { +>a : (a?: number) => void +>a : number +>10 : 10 + + "use strict"; +>"use strict" : "use strict" +} + +export var foo = 10; +>foo : number +>10 : 10 + +function b(a = 10) { +>b : (a?: number) => void +>a : number +>10 : 10 +} + +function container() { +>container : () => void + + "use strict"; +>"use strict" : "use strict" + + function f(a = 10) { +>f : (a?: number) => void +>a : number +>10 : 10 + } +} + +function rest(...args: any[]) { +>rest : (...args: any[]) => void +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function rest1(a = 1, ...args) { +>rest1 : (a?: number, ...args: any[]) => void +>a : number +>1 : 1 +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function paramDefault(param = 1) { +>paramDefault : (param?: number) => void +>param : number +>1 : 1 + + 'use strict'; +>'use strict' : "use strict" +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : ({ foo }: any) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : ([foo]: any[]) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "use strict"; +>"use strict" : "use strict" +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + "use strict"; +>"use strict" : "use strict" +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + const c = 1; +>c : 1 +>1 : 1 + + "use strict"; +>"use strict" : "use strict" +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt new file mode 100644 index 00000000000..4f92ac06b2b --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.errors.txt @@ -0,0 +1,131 @@ +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(1,12): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(2,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(15,15): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(16,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,16): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(19,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(20,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(23,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(24,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(27,31): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(28,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(31,30): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(32,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,24): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(35,32): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(36,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,23): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(39,31): error TS1346: This parameter is not allowed with 'use strict' directive. +tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts(41,5): error TS1347: 'use strict' directive cannot be used with non-simple parameter list. + + +==== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts (19 errors) ==== + function a(a = 10) { + ~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:2:5: 'use strict' directive used here. + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:1:12: Non-simple parameter declared here. + } + + export var foo = 10; + function b(a = 10) { + } + + function container() { + "use strict"; + function f(a = 10) { + } + } + + function rest(...args: any[]) { + ~~~~~~~~~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:16:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:15:15: Non-simple parameter declared here. + } + + function rest1(a = 1, ...args) { + ~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. + ~~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:20:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:16: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:19:23: and here. + } + + function paramDefault(param = 1) { + ~~~~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:24:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:23:23: Non-simple parameter declared here. + } + + function objectBindingPattern({foo}: any) { + ~~~~~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:28:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:27:31: Non-simple parameter declared here. + } + + function arrayBindingPattern([foo]: any[]) { + ~~~~~~~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:32:5: 'use strict' directive used here. + 'use strict'; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:31:30: Non-simple parameter declared here. + } + + function manyParameter(a = 10, b = 20) { + ~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. + ~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:36:5: 'use strict' directive used here. + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:24: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:35:32: and here. + } + + function manyPrologue(a = 10, b = 20) { + ~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. + ~~~~~~ +!!! error TS1346: This parameter is not allowed with 'use strict' directive. +!!! related TS1349 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:41:5: 'use strict' directive used here. + "foo"; + "use strict"; + ~~~~~~~~~~~~~ +!!! error TS1347: 'use strict' directive cannot be used with non-simple parameter list. +!!! related TS1348 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:23: Non-simple parameter declared here. +!!! related TS6204 tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts:39:31: and here. + } + + function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; + } + \ No newline at end of file diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js new file mode 100644 index 00000000000..f9e07fc96ea --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.js @@ -0,0 +1,90 @@ +//// [functionWithUseStrictAndSimpleParameterList_es2016.ts] +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function rest1(a = 1, ...args) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} + + +//// [functionWithUseStrictAndSimpleParameterList_es2016.js] +function a(a = 10) { + "use strict"; +} +export var foo = 10; +function b(a = 10) { +} +function container() { + "use strict"; + function f(a = 10) { + } +} +function rest(...args) { + 'use strict'; +} +function rest1(a = 1, ...args) { + 'use strict'; +} +function paramDefault(param = 1) { + 'use strict'; +} +function objectBindingPattern({ foo }) { + 'use strict'; +} +function arrayBindingPattern([foo]) { + 'use strict'; +} +function manyParameter(a = 10, b = 20) { + "use strict"; +} +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols new file mode 100644 index 00000000000..8f3d1366ad2 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.symbols @@ -0,0 +1,91 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts === +function a(a = 10) { +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 0, 0)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 0, 11)) + + "use strict"; +} + +export var foo = 10; +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 4, 10)) + +function b(a = 10) { +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 4, 20)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 5, 11)) +} + +function container() { +>container : Symbol(container, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 6, 1)) + + "use strict"; + function f(a = 10) { +>f : Symbol(f, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 9, 17)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 10, 15)) + } +} + +function rest(...args: any[]) { +>rest : Symbol(rest, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 12, 1)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 14, 14)) + + 'use strict'; +} + +function rest1(a = 1, ...args) { +>rest1 : Symbol(rest1, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 16, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 15)) +>args : Symbol(args, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 18, 21)) + + 'use strict'; +} + +function paramDefault(param = 1) { +>paramDefault : Symbol(paramDefault, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 20, 1)) +>param : Symbol(param, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 22, 22)) + + 'use strict'; +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : Symbol(objectBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 24, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 26, 31)) + + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : Symbol(arrayBindingPattern, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 28, 1)) +>foo : Symbol(foo, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 30, 30)) + + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : Symbol(manyParameter, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 32, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 23)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 34, 30)) + + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : Symbol(manyPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 36, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 38, 22)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 38, 29)) + + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : Symbol(invalidPrologue, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 41, 1)) +>a : Symbol(a, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 43, 25)) +>b : Symbol(b, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 43, 32)) + + "foo"; + const c = 1; +>c : Symbol(c, Decl(functionWithUseStrictAndSimpleParameterList_es2016.ts, 45, 9)) + + "use strict"; +} + diff --git a/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types new file mode 100644 index 00000000000..c5268cd8e48 --- /dev/null +++ b/tests/baselines/reference/functionWithUseStrictAndSimpleParameterList_es2016.types @@ -0,0 +1,119 @@ +=== tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts === +function a(a = 10) { +>a : (a?: number) => void +>a : number +>10 : 10 + + "use strict"; +>"use strict" : "use strict" +} + +export var foo = 10; +>foo : number +>10 : 10 + +function b(a = 10) { +>b : (a?: number) => void +>a : number +>10 : 10 +} + +function container() { +>container : () => void + + "use strict"; +>"use strict" : "use strict" + + function f(a = 10) { +>f : (a?: number) => void +>a : number +>10 : 10 + } +} + +function rest(...args: any[]) { +>rest : (...args: any[]) => void +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function rest1(a = 1, ...args) { +>rest1 : (a?: number, ...args: any[]) => void +>a : number +>1 : 1 +>args : any[] + + 'use strict'; +>'use strict' : "use strict" +} + +function paramDefault(param = 1) { +>paramDefault : (param?: number) => void +>param : number +>1 : 1 + + 'use strict'; +>'use strict' : "use strict" +} + +function objectBindingPattern({foo}: any) { +>objectBindingPattern : ({ foo }: any) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function arrayBindingPattern([foo]: any[]) { +>arrayBindingPattern : ([foo]: any[]) => void +>foo : any + + 'use strict'; +>'use strict' : "use strict" +} + +function manyParameter(a = 10, b = 20) { +>manyParameter : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "use strict"; +>"use strict" : "use strict" +} + +function manyPrologue(a = 10, b = 20) { +>manyPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + "use strict"; +>"use strict" : "use strict" +} + +function invalidPrologue(a = 10, b = 20) { +>invalidPrologue : (a?: number, b?: number) => void +>a : number +>10 : 10 +>b : number +>20 : 20 + + "foo"; +>"foo" : "foo" + + const c = 1; +>c : 1 +>1 : 1 + + "use strict"; +>"use strict" : "use strict" +} + diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt index 75ae76b1dbc..ee15ac0597c 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt @@ -1,9 +1,5 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. - Types of property 'cb' are incompatible. - Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. - Types of property 'cb' are incompatible. - Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,16): error TS2322: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,16): error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts (2 errors) ==== @@ -17,15 +13,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun var r = foo(arg); // {} // more args not allowed var r2 = foo({ cb: (x: T, y: T) => '' }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. -!!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. + ~~ +!!! error TS2322: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: {}) => string; }' var r3 = foo({ cb: (x: string, y: number) => '' }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. -!!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. + ~~ +!!! error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: string) => string; }' function foo2(arg: { cb: (t: T, t2: T) => U }) { return arg.cb(null, null); diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.types index 20d58530615..64acb69d4e6 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.types +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.types @@ -106,11 +106,11 @@ module onlyT { enum E { A } >E : E ->A : E +>A : E.A enum F { A } >F : F ->A : F +>A : F.A function foo3(x: T, a: (x: T) => T, b: (x: T) => T) { >foo3 : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T @@ -250,11 +250,11 @@ module TU { enum E { A } >E : E ->A : E +>A : E.A enum F { A } >F : F ->A : F +>A : F.A function foo3(x: T, a: (x: T) => T, b: (x: U) => U) { >foo3 : (x: T, a: (x: T) => T, b: (x: any) => any) => (x: T) => T diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types index 4379594f6eb..5bd04109723 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types @@ -93,11 +93,11 @@ var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object enum E { A } >E : E ->A : E +>A : E.A enum F { A } >F : F ->A : F +>A : F.A var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number >r6 : (x: number) => number diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt index c1724a8f698..22e19e10d80 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt @@ -1,6 +1,4 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,13): error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'. - Types of property 'baz' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,23): error TS2322: Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ==== @@ -9,10 +7,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj } var r = foo({ bar: 1, baz: '' }); // error - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'. -!!! error TS2345: Types of property 'baz' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts:1:30: The expected type comes from property 'baz' which is declared here on type '{ bar: number; baz: number; }' var r2 = foo({ bar: 1, baz: 1 }); // T = number var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo var r4 = foo({ bar: 1, baz: '' }); // T = Object \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt index cbc57364155..3537744ad39 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt @@ -1,45 +1,30 @@ -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,13): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'. - Types of property 'y' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,21): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,30): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,24): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,24): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,31): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ==== function foo(n: { x: T; y: T }, m: T) { return m; } // these are all errors var x = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }' var x2 = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }' var x3 = foo({ x: 3, y: "" }, 4); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: string; y: string; }' var x4 = foo({ x: "", y: 4 }, ""); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: number; y: number; }' var x5 = foo({ x: "", y: 4 }, ""); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: string; y: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt index ad07374b810..d6cbc5d17b7 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt @@ -1,7 +1,5 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,12): error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'. - Types of property 'y' are incompatible. - Type 'Derived2' is not assignable to type 'Derived'. - Property 'y' is missing in type 'Derived2'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,32): error TS2322: Type 'Derived2' is not assignable to type 'Derived'. + Property 'y' is missing in type 'Derived2'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ==== @@ -23,11 +21,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj } var r1 = f({ x: new Derived(), y: new Derived2() }); // error because neither is supertype of the other - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'Derived2' is not assignable to type 'Derived'. -!!! error TS2345: Property 'y' is missing in type 'Derived2'. + ~ +!!! error TS2322: Type 'Derived2' is not assignable to type 'Derived'. +!!! error TS2322: Property 'y' is missing in type 'Derived2'. +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts:13:39: The expected type comes from property 'y' which is declared here on type '{ x: Derived; y: Derived; }' function f2(a: U) { var r: T; diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index 1136022e2fe..6e6732ebb09 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(12,1): error TS2322: Type '[string, number, boolean, boolean]' is not assignable to type '[string, number]'. Types of property 'length' are incompatible. Type '4' is not assignable to type '2'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(13,20): error TS2733: Index '2' is out-of-bounds in tuple of length 2. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'. Type '{ a: string; }' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,11): error TS2733: Index '3' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(15,20): error TS2733: Index '3' is out-of-bounds in tuple of length 2. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,14): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,17): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,14): error TS2322: Type '{}' is not assignable to type 'string'. @@ -11,7 +14,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup Property '1' is missing in type '[{}]'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (7 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (10 errors) ==== interface I { tuple1: [T, U]; } @@ -29,11 +32,17 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup !!! error TS2322: Types of property 'length' are incompatible. !!! error TS2322: Type '4' is not assignable to type '2'. var e3 = i1.tuple1[2]; // {} + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. i1.tuple1[3] = { a: "string" }; ~~~~~~~~~~~~ !!! error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'. !!! error TS2322: Type '{ a: string; }' is not assignable to type 'number'. + ~ +!!! error TS2733: Index '3' is out-of-bounds in tuple of length 2. var e4 = i1.tuple1[3]; // {} + ~ +!!! error TS2733: Index '3' is out-of-bounds in tuple of length 2. i2.tuple1 = ["foo", 5]; i2.tuple1 = ["foo", "bar"]; i2.tuple1 = [5, "bar"]; diff --git a/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt b/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt index ade053d9344..735900e3ef3 100644 --- a/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt +++ b/tests/baselines/reference/genericConstraintSatisfaction1.errors.txt @@ -1,6 +1,4 @@ -tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'. - Types of property 's' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericConstraintSatisfaction1.ts(6,6): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/genericConstraintSatisfaction1.ts (1 errors) ==== @@ -10,8 +8,7 @@ tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argum var x: I<{s: string}> x.f({s: 1}) - ~~~~~~ -!!! error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'. -!!! error TS2345: Types of property 's' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/genericConstraintSatisfaction1.ts:5:11: The expected type comes from property 's' which is declared here on type '{ s: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/genericRestParameters1.errors.txt b/tests/baselines/reference/genericRestParameters1.errors.txt index 2f314387424..6b6d7f60845 100644 --- a/tests/baselines/reference/genericRestParameters1.errors.txt +++ b/tests/baselines/reference/genericRestParameters1.errors.txt @@ -1,11 +1,19 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(22,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(31,1): error TS2556: Expected 3 arguments, but got 1 or more. -tests/cases/conformance/types/rest/genericRestParameters1.ts(166,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(133,40): error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(134,51): error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. + Type 'Function' provides no match for the signature '(...args: any[]): any'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. Types of parameters 'a' and 'args' are incompatible. Type 'any' is not assignable to type 'never'. -==== tests/cases/conformance/types/rest/genericRestParameters1.ts (3 errors) ==== +==== tests/cases/conformance/types/rest/genericRestParameters1.ts (6 errors) ==== declare let f1: (...x: [number, string, boolean]) => void; declare let f2: (x0: number, x1: string, x2: boolean) => void; @@ -136,17 +144,26 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(166,1): error TS232 const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] - type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; - type T03 = Parameters void>; - type T04 = Parameters void>; + type T03 = ConstructorParameters void>; + type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; - type T06 = Parameters void>; + type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; - type T08 = Parameters void>; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. + type T08 = ConstructorParameters void>; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. type T09 = Parameters; + ~~~~~~~~ +!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Type 'Function' provides no match for the signature '(...args: any[]): any'. type Record1 = { move: [number, 'left' | 'right']; diff --git a/tests/baselines/reference/genericRestParameters1.js b/tests/baselines/reference/genericRestParameters1.js index d41565e4c6a..3d8703213ac 100644 --- a/tests/baselines/reference/genericRestParameters1.js +++ b/tests/baselines/reference/genericRestParameters1.js @@ -125,16 +125,14 @@ declare function f30 any)[]>(x: T, ...args: U): U; const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; type T09 = Parameters; type Record1 = { @@ -327,15 +325,14 @@ declare const g22: (z?: boolean | undefined) => string[]; declare const g23: () => string[]; declare function f30 any)[]>(x: T, ...args: U): U; declare const c30: [(x: number) => string, (x: number) => number]; -declare type Parameters = T extends ((...args: infer U) => any) | (new (...args: infer U) => any) ? U : any[]; declare type T01 = Parameters<(x: number, y: string, z: boolean) => void>; declare type T02 = Parameters<(...args: [number, string, boolean]) => void>; -declare type T03 = Parameters void>; -declare type T04 = Parameters void>; +declare type T03 = ConstructorParameters void>; +declare type T04 = ConstructorParameters void>; declare type T05 = Parameters<(...args: T[]) => void>; -declare type T06 = Parameters void>; +declare type T06 = ConstructorParameters void>; declare type T07 = Parameters<(...args: T) => void>; -declare type T08 = Parameters void>; +declare type T08 = ConstructorParameters void>; declare type T09 = Parameters; declare type Record1 = { move: [number, 'left' | 'right']; diff --git a/tests/baselines/reference/genericRestParameters1.symbols b/tests/baselines/reference/genericRestParameters1.symbols index 87ddbfcf6fe..4b0dae51150 100644 --- a/tests/baselines/reference/genericRestParameters1.symbols +++ b/tests/baselines/reference/genericRestParameters1.symbols @@ -494,160 +494,149 @@ const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: nu >x : Symbol(x, Decl(genericRestParameters1.ts, 124, 32)) >x : Symbol(x, Decl(genericRestParameters1.ts, 124, 32)) -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 126, 16)) ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 126, 16)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 126, 50)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 126, 83)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; ->T01 : Symbol(T01, Decl(genericRestParameters1.ts, 126, 121)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->x : Symbol(x, Decl(genericRestParameters1.ts, 128, 23)) ->y : Symbol(y, Decl(genericRestParameters1.ts, 128, 33)) ->z : Symbol(z, Decl(genericRestParameters1.ts, 128, 44)) +>T01 : Symbol(T01, Decl(genericRestParameters1.ts, 124, 45)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters1.ts, 126, 23)) +>y : Symbol(y, Decl(genericRestParameters1.ts, 126, 33)) +>z : Symbol(z, Decl(genericRestParameters1.ts, 126, 44)) type T02 = Parameters<(...args: [number, string, boolean]) => void>; ->T02 : Symbol(T02, Decl(genericRestParameters1.ts, 128, 66)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 129, 23)) +>T02 : Symbol(T02, Decl(genericRestParameters1.ts, 126, 66)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 127, 23)) -type T03 = Parameters void>; ->T03 : Symbol(T03, Decl(genericRestParameters1.ts, 129, 68)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->x : Symbol(x, Decl(genericRestParameters1.ts, 130, 27)) ->y : Symbol(y, Decl(genericRestParameters1.ts, 130, 37)) ->z : Symbol(z, Decl(genericRestParameters1.ts, 130, 48)) +type T03 = ConstructorParameters void>; +>T03 : Symbol(T03, Decl(genericRestParameters1.ts, 127, 68)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters1.ts, 128, 38)) +>y : Symbol(y, Decl(genericRestParameters1.ts, 128, 48)) +>z : Symbol(z, Decl(genericRestParameters1.ts, 128, 59)) -type T04 = Parameters void>; ->T04 : Symbol(T04, Decl(genericRestParameters1.ts, 130, 70)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 131, 27)) +type T04 = ConstructorParameters void>; +>T04 : Symbol(T04, Decl(genericRestParameters1.ts, 128, 81)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 129, 38)) type T05 = Parameters<(...args: T[]) => void>; ->T05 : Symbol(T05, Decl(genericRestParameters1.ts, 131, 72)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 132, 26)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) +>T05 : Symbol(T05, Decl(genericRestParameters1.ts, 129, 83)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 130, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 130, 26)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 130, 9)) -type T06 = Parameters void>; ->T06 : Symbol(T06, Decl(genericRestParameters1.ts, 132, 49)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 133, 30)) +type T06 = ConstructorParameters void>; +>T06 : Symbol(T06, Decl(genericRestParameters1.ts, 130, 49)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 131, 9)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 131, 41)) type T07 = Parameters<(...args: T) => void>; ->T07 : Symbol(T07, Decl(genericRestParameters1.ts, 133, 52)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 134, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 134, 40)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 134, 9)) +>T07 : Symbol(T07, Decl(genericRestParameters1.ts, 131, 63)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 132, 40)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) -type T08 = Parameters void>; ->T08 : Symbol(T08, Decl(genericRestParameters1.ts, 134, 61)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 135, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 135, 44)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 135, 9)) +type T08 = ConstructorParameters void>; +>T08 : Symbol(T08, Decl(genericRestParameters1.ts, 132, 61)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 133, 55)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) type T09 = Parameters; ->T09 : Symbol(T09, Decl(genericRestParameters1.ts, 135, 65)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) +>T09 : Symbol(T09, Decl(genericRestParameters1.ts, 133, 76)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) type Record1 = { ->Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 136, 32)) +>Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 134, 32)) move: [number, 'left' | 'right']; ->move : Symbol(move, Decl(genericRestParameters1.ts, 138, 16)) +>move : Symbol(move, Decl(genericRestParameters1.ts, 136, 16)) jump: [number, 'up' | 'down']; ->jump : Symbol(jump, Decl(genericRestParameters1.ts, 139, 35)) +>jump : Symbol(jump, Decl(genericRestParameters1.ts, 137, 35)) stop: string; ->stop : Symbol(stop, Decl(genericRestParameters1.ts, 140, 32)) +>stop : Symbol(stop, Decl(genericRestParameters1.ts, 138, 32)) done: []; ->done : Symbol(done, Decl(genericRestParameters1.ts, 141, 15)) +>done : Symbol(done, Decl(genericRestParameters1.ts, 139, 15)) } type EventType = { ->EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 143, 1)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) +>EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 141, 1)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) emit(e: K, ...payload: T[K] extends any[] ? T[K] : [T[K]]): void; ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->e : Symbol(e, Decl(genericRestParameters1.ts, 146, 36)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->payload : Symbol(payload, Decl(genericRestParameters1.ts, 146, 41)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>e : Symbol(e, Decl(genericRestParameters1.ts, 144, 36)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>payload : Symbol(payload, Decl(genericRestParameters1.ts, 144, 41)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) } declare var events: EventType; ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 143, 1)) ->Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 136, 32)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 141, 1)) +>Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 134, 32)) events.emit('move', 10, 'left'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('jump', 20, 'up'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('stop', 'Bye!'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('done'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) // Repro from #25871 declare var ff1: (... args: any[]) => void; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 157, 18)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 155, 18)) declare var ff2: () => void; ->ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 159, 11)) +>ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 157, 11)) declare var ff3: (...args: []) => void; ->ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 160, 11)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 160, 18)) +>ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 158, 11)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 158, 18)) declare var ff4: (a: never) => void; ->ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 161, 11)) ->a : Symbol(a, Decl(genericRestParameters1.ts, 161, 18)) +>ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 159, 11)) +>a : Symbol(a, Decl(genericRestParameters1.ts, 159, 18)) ff1 = ff2; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 159, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 157, 11)) ff1 = ff3; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 160, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 158, 11)) ff1 = ff4; // Error ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 161, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 159, 11)) diff --git a/tests/baselines/reference/genericRestParameters1.types b/tests/baselines/reference/genericRestParameters1.types index 625edcc4d84..497561c8a98 100644 --- a/tests/baselines/reference/genericRestParameters1.types +++ b/tests/baselines/reference/genericRestParameters1.types @@ -664,11 +664,6 @@ const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: nu >x : number >1 : 1 -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Parameters ->args : U ->args : U - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; >T01 : [number, string, boolean] >x : number @@ -679,13 +674,13 @@ type T02 = Parameters<(...args: [number, string, boolean]) => void>; >T02 : [number, string, boolean] >args : [number, string, boolean] -type T03 = Parameters void>; +type T03 = ConstructorParameters void>; >T03 : [number, string, boolean] >x : number >y : string >z : boolean -type T04 = Parameters void>; +type T04 = ConstructorParameters void>; >T04 : [number, string, boolean] >args : [number, string, boolean] @@ -693,7 +688,7 @@ type T05 = Parameters<(...args: T[]) => void>; >T05 : T[] >args : T[] -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; >T06 : [] >args : [] @@ -701,12 +696,12 @@ type T07 = Parameters<(...args: T) => void>; >T07 : T >args : T -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; >T08 : T >args : T type T09 = Parameters; ->T09 : any[] +>T09 : never type Record1 = { >Record1 : Record1 diff --git a/tests/baselines/reference/genericRestParameters2.errors.txt b/tests/baselines/reference/genericRestParameters2.errors.txt new file mode 100644 index 00000000000..d6d3de9f322 --- /dev/null +++ b/tests/baselines/reference/genericRestParameters2.errors.txt @@ -0,0 +1,91 @@ +tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'x' and 'args' are incompatible. + Type 'any[]' is not assignable to type '[string, ...any[]]'. + Property '0' is missing in type 'any[]'. + + +==== tests/cases/conformance/types/rest/genericRestParameters2.ts (1 errors) ==== + declare const t1: [number, string, ...boolean[]]; + declare const t2: [string, ...boolean[]]; + declare const t3: [...boolean[]]; + declare const t4: []; + + declare let f00: (...x: [number, string, boolean]) => void; + declare let f01: (a: number, ...x: [string, boolean]) => void; + declare let f02: (a: number, b: string, ...x: [boolean]) => void; + declare let f03: (a: number, b: string, c: boolean) => void; + declare let f04: (a: number, b: string, c: boolean, ...x: []) => void; + + declare let f10: (...x: [number, string, ...boolean[]]) => void; + declare let f11: (a: number, ...x: [string, ...boolean[]]) => void; + declare let f12: (a: number, b: string, ...x: [...boolean[]]) => void; + declare let f13: (a: number, b: string, ...c: boolean[]) => void; + + declare const ns: [number, string]; + declare const sn: [string, number]; + + f10(42, "hello"); + f10(42, "hello", true); + f10(42, "hello", true, false); + f10(t1[0], t1[1], t1[2], t1[3]); + f10(...t1); + f10(42, ...t2); + f10(42, "hello", ...t3); + f10(42, "hello", true, ...t4); + f10(42, "hello", true, ...t4, false, ...t3); + + f11(42, "hello"); + f11(42, "hello", true); + f11(42, "hello", true, false); + f11(t1[0], t1[1], t1[2], t1[3]); + f11(...t1); + f11(42, ...t2); + f11(42, "hello", ...t3); + f11(42, "hello", true, ...t4); + f11(42, "hello", true, ...t4, false, ...t3); + + f12(42, "hello"); + f12(42, "hello", true); + f12(42, "hello", true, false); + f12(t1[0], t1[1], t1[2], t1[3]); + f12(...t1); + f12(42, ...t2); + f12(42, "hello", ...t3); + f12(42, "hello", true, ...t4); + f12(42, "hello", true, ...t4, false, ...t3); + + f13(42, "hello"); + f13(42, "hello", true); + f13(42, "hello", true, false); + f13(t1[0], t1[1], t1[2], t1[3]); + f13(...t1); + f13(42, ...t2); + f13(42, "hello", ...t3); + f13(42, "hello", true, ...t4); + f13(42, "hello", true, ...t4, false, ...t3); + + declare const f20: (...args: T) => T; + + f20(...t1); + f20(42, ...t2); + f20(42, "hello", ...t3); + f20(42, "hello", ...t2, true); + + type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; + type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; + type T03 = ConstructorParameters void>; + type T04 = ConstructorParameters void>; + type T05 = Parameters<(x: string, ...args: T) => void>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'x' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type '[string, ...any[]]'. +!!! error TS2344: Property '0' is missing in type 'any[]'. + type T06 = T05<[number, ...boolean[]]>; + + type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; + + type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>; + type T11 = P1<(...z: number[]) => void>; + type T12 = P1<(x: number, y: number) => void>; + \ No newline at end of file diff --git a/tests/baselines/reference/genericRestParameters2.js b/tests/baselines/reference/genericRestParameters2.js index 143a4a62f52..3c00a7c2a3a 100644 --- a/tests/baselines/reference/genericRestParameters2.js +++ b/tests/baselines/reference/genericRestParameters2.js @@ -65,12 +65,10 @@ f20(42, ...t2); f20(42, "hello", ...t3); f20(42, "hello", ...t2, true); -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(x: string, ...args: T) => void>; type T06 = T05<[number, ...boolean[]]>; @@ -142,11 +140,10 @@ declare let f13: (a: number, b: string, ...c: boolean[]) => void; declare const ns: [number, string]; declare const sn: [string, number]; declare const f20: (...args: T) => T; -declare type Parameters = T extends ((...args: infer U) => any) | (new (...args: infer U) => any) ? U : any[]; declare type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; declare type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -declare type T03 = Parameters void>; -declare type T04 = Parameters void>; +declare type T03 = ConstructorParameters void>; +declare type T04 = ConstructorParameters void>; declare type T05 = Parameters<(x: string, ...args: T) => void>; declare type T06 = T05<[number, ...boolean[]]>; declare type P1 = T extends (head: infer A, ...tail: infer B) => any ? { diff --git a/tests/baselines/reference/genericRestParameters2.symbols b/tests/baselines/reference/genericRestParameters2.symbols index 164d08d132e..1dd27d4f890 100644 --- a/tests/baselines/reference/genericRestParameters2.symbols +++ b/tests/baselines/reference/genericRestParameters2.symbols @@ -245,82 +245,71 @@ f20(42, "hello", ...t2, true); >f20 : Symbol(f20, Decl(genericRestParameters2.ts, 59, 13)) >t2 : Symbol(t2, Decl(genericRestParameters2.ts, 1, 13)) -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 66, 16)) ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 66, 16)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 66, 50)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 66, 83)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; ->T01 : Symbol(T01, Decl(genericRestParameters2.ts, 66, 121)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 68, 23)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 68, 33)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 68, 44)) +>T01 : Symbol(T01, Decl(genericRestParameters2.ts, 64, 30)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 66, 23)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 66, 33)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 66, 44)) type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; ->T02 : Symbol(T02, Decl(genericRestParameters2.ts, 68, 71)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 69, 23)) +>T02 : Symbol(T02, Decl(genericRestParameters2.ts, 66, 71)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 67, 23)) -type T03 = Parameters void>; ->T03 : Symbol(T03, Decl(genericRestParameters2.ts, 69, 73)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 70, 27)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 70, 37)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 70, 48)) +type T03 = ConstructorParameters void>; +>T03 : Symbol(T03, Decl(genericRestParameters2.ts, 67, 73)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 68, 38)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 68, 48)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 68, 59)) -type T04 = Parameters void>; ->T04 : Symbol(T04, Decl(genericRestParameters2.ts, 70, 75)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 71, 27)) +type T04 = ConstructorParameters void>; +>T04 : Symbol(T04, Decl(genericRestParameters2.ts, 68, 86)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 69, 38)) type T05 = Parameters<(x: string, ...args: T) => void>; ->T05 : Symbol(T05, Decl(genericRestParameters2.ts, 71, 77)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 72, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 72, 40)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 72, 50)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 72, 9)) +>T05 : Symbol(T05, Decl(genericRestParameters2.ts, 69, 88)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 70, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 70, 40)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 70, 50)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 70, 9)) type T06 = T05<[number, ...boolean[]]>; ->T06 : Symbol(T06, Decl(genericRestParameters2.ts, 72, 72)) ->T05 : Symbol(T05, Decl(genericRestParameters2.ts, 71, 77)) +>T06 : Symbol(T06, Decl(genericRestParameters2.ts, 70, 72)) +>T05 : Symbol(T05, Decl(genericRestParameters2.ts, 69, 88)) type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 75, 8)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 73, 8)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 75, 8)) ->head : Symbol(head, Decl(genericRestParameters2.ts, 75, 41)) ->A : Symbol(A, Decl(genericRestParameters2.ts, 75, 52)) ->tail : Symbol(tail, Decl(genericRestParameters2.ts, 75, 55)) ->B : Symbol(B, Decl(genericRestParameters2.ts, 75, 70)) ->head : Symbol(head, Decl(genericRestParameters2.ts, 75, 84)) ->A : Symbol(A, Decl(genericRestParameters2.ts, 75, 52)) ->tail : Symbol(tail, Decl(genericRestParameters2.ts, 75, 93)) ->B : Symbol(B, Decl(genericRestParameters2.ts, 75, 70)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 73, 8)) +>head : Symbol(head, Decl(genericRestParameters2.ts, 73, 41)) +>A : Symbol(A, Decl(genericRestParameters2.ts, 73, 52)) +>tail : Symbol(tail, Decl(genericRestParameters2.ts, 73, 55)) +>B : Symbol(B, Decl(genericRestParameters2.ts, 73, 70)) +>head : Symbol(head, Decl(genericRestParameters2.ts, 73, 84)) +>A : Symbol(A, Decl(genericRestParameters2.ts, 73, 52)) +>tail : Symbol(tail, Decl(genericRestParameters2.ts, 73, 93)) +>B : Symbol(B, Decl(genericRestParameters2.ts, 73, 70)) type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>; ->T10 : Symbol(T10, Decl(genericRestParameters2.ts, 75, 112)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 77, 15)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 77, 25)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 77, 36)) +>T10 : Symbol(T10, Decl(genericRestParameters2.ts, 73, 112)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 75, 15)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 75, 25)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 75, 36)) type T11 = P1<(...z: number[]) => void>; ->T11 : Symbol(T11, Decl(genericRestParameters2.ts, 77, 63)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 78, 15)) +>T11 : Symbol(T11, Decl(genericRestParameters2.ts, 75, 63)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 76, 15)) type T12 = P1<(x: number, y: number) => void>; ->T12 : Symbol(T12, Decl(genericRestParameters2.ts, 78, 40)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 79, 15)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 79, 25)) +>T12 : Symbol(T12, Decl(genericRestParameters2.ts, 76, 40)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 77, 15)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 77, 25)) diff --git a/tests/baselines/reference/genericRestParameters2.types b/tests/baselines/reference/genericRestParameters2.types index 3c0a7c62877..103b0a0a62f 100644 --- a/tests/baselines/reference/genericRestParameters2.types +++ b/tests/baselines/reference/genericRestParameters2.types @@ -416,11 +416,6 @@ f20(42, "hello", ...t2, true); >t2 : [string, ...boolean[]] >true : true -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Parameters ->args : U ->args : U - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; >T01 : [number, string, ...boolean[]] >x : number @@ -431,13 +426,13 @@ type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; >T02 : [number, string, ...boolean[]] >args : [number, string, ...boolean[]] -type T03 = Parameters void>; +type T03 = ConstructorParameters void>; >T03 : [number, string, ...boolean[]] >x : number >y : string >z : boolean[] -type T04 = Parameters void>; +type T04 = ConstructorParameters void>; >T04 : [number, string, ...boolean[]] >args : [number, string, ...boolean[]] diff --git a/tests/baselines/reference/genericRestTypes.js b/tests/baselines/reference/genericRestTypes.js index f932032af56..5abf8113f38 100644 --- a/tests/baselines/reference/genericRestTypes.js +++ b/tests/baselines/reference/genericRestTypes.js @@ -2,7 +2,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; diff --git a/tests/baselines/reference/genericRestTypes.symbols b/tests/baselines/reference/genericRestTypes.symbols index 77bc400b5db..c8ab347609c 100644 --- a/tests/baselines/reference/genericRestTypes.symbols +++ b/tests/baselines/reference/genericRestTypes.symbols @@ -2,54 +2,45 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) ->args : Symbol(args, Decl(genericRestTypes.ts, 3, 27)) ->T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) ->args : Symbol(args, Decl(genericRestTypes.ts, 3, 64)) ->U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) ->U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) - // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) ->args : Symbol(args, Decl(genericRestTypes.ts, 5, 31)) ->T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) ->head : Symbol(head, Decl(genericRestTypes.ts, 5, 61)) ->tail : Symbol(tail, Decl(genericRestTypes.ts, 5, 71)) ->U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) ->U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>T : Symbol(T, Decl(genericRestTypes.ts, 4, 10)) +>args : Symbol(args, Decl(genericRestTypes.ts, 4, 31)) +>T : Symbol(T, Decl(genericRestTypes.ts, 4, 10)) +>head : Symbol(head, Decl(genericRestTypes.ts, 4, 61)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 4, 71)) +>U : Symbol(U, Decl(genericRestTypes.ts, 4, 86)) +>U : Symbol(U, Decl(genericRestTypes.ts, 4, 86)) type MyFunctionType = (foo: number, bar: string) => boolean; ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) ->foo : Symbol(foo, Decl(genericRestTypes.ts, 7, 23)) ->bar : Symbol(bar, Decl(genericRestTypes.ts, 7, 35)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) +>foo : Symbol(foo, Decl(genericRestTypes.ts, 6, 23)) +>bar : Symbol(bar, Decl(genericRestTypes.ts, 6, 35)) type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean ->Explicit : Symbol(Explicit, Decl(genericRestTypes.ts, 7, 60)) ->args : Symbol(args, Decl(genericRestTypes.ts, 9, 17)) ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>Explicit : Symbol(Explicit, Decl(genericRestTypes.ts, 6, 60)) +>args : Symbol(args, Decl(genericRestTypes.ts, 8, 17)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) >ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) type Bind1 any> = (...args: Tail>) => ReturnType; ->Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) ->head : Symbol(head, Decl(genericRestTypes.ts, 11, 22)) ->tail : Symbol(tail, Decl(genericRestTypes.ts, 11, 32)) ->args : Symbol(args, Decl(genericRestTypes.ts, 11, 60)) ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 8, 90)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) +>head : Symbol(head, Decl(genericRestTypes.ts, 10, 22)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 10, 32)) +>args : Symbol(args, Decl(genericRestTypes.ts, 10, 60)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) >ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) type Generic = Bind1; // (bar: string) => boolean ->Generic : Symbol(Generic, Decl(genericRestTypes.ts, 11, 107)) ->Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>Generic : Symbol(Generic, Decl(genericRestTypes.ts, 10, 107)) +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 8, 90)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) diff --git a/tests/baselines/reference/genericRestTypes.types b/tests/baselines/reference/genericRestTypes.types index 6fb482799dd..b2fb37871bd 100644 --- a/tests/baselines/reference/genericRestTypes.types +++ b/tests/baselines/reference/genericRestTypes.types @@ -2,11 +2,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; ->Parameters : Parameters ->args : any[] ->args : U - // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; >Tail : Tail diff --git a/tests/baselines/reference/inOperatorWithInvalidOperands.types b/tests/baselines/reference/inOperatorWithInvalidOperands.types index f5c8ff8fb88..d85ec6d7a3d 100644 --- a/tests/baselines/reference/inOperatorWithInvalidOperands.types +++ b/tests/baselines/reference/inOperatorWithInvalidOperands.types @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts === enum E { a } >E : E ->a : E +>a : E.a var x: any; >x : any diff --git a/tests/baselines/reference/indexedAccessRelation.errors.txt b/tests/baselines/reference/indexedAccessRelation.errors.txt index 84e65df856d..14dbee4d4c1 100644 --- a/tests/baselines/reference/indexedAccessRelation.errors.txt +++ b/tests/baselines/reference/indexedAccessRelation.errors.txt @@ -1,10 +1,8 @@ -tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick, "a">'. - Types of property 'a' are incompatible. - Type 'T' is not assignable to type 'S["a"] & T'. - Type 'Foo' is not assignable to type 'S["a"] & T'. +tests/cases/compiler/indexedAccessRelation.ts(16,25): error TS2322: Type 'T' is not assignable to type 'S["a"] & T'. + Type 'Foo' is not assignable to type 'S["a"] & T'. + Type 'Foo' is not assignable to type 'S["a"]'. + Type 'T' is not assignable to type 'S["a"]'. Type 'Foo' is not assignable to type 'S["a"]'. - Type 'T' is not assignable to type 'S["a"]'. - Type 'Foo' is not assignable to type 'S["a"]'. ==== tests/cases/compiler/indexedAccessRelation.ts (1 errors) ==== @@ -24,14 +22,13 @@ tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of { foo(a: T) { this.setState({ a: a }); - ~~~~~~~~ -!!! error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick, "a">'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'T' is not assignable to type 'S["a"] & T'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"] & T'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. -!!! error TS2345: Type 'T' is not assignable to type 'S["a"]'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. + ~ +!!! error TS2322: Type 'T' is not assignable to type 'S["a"] & T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"] & T'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'. +!!! error TS2322: Type 'T' is not assignable to type 'S["a"]'. +!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'. +!!! related TS6500 tests/cases/compiler/indexedAccessRelation.ts:8:5: The expected type comes from property 'a' which is declared here on type 'Pick, "a">' } } \ No newline at end of file diff --git a/tests/baselines/reference/indexerWithTuple.errors.txt b/tests/baselines/reference/indexerWithTuple.errors.txt new file mode 100644 index 00000000000..4e931a3ad6e --- /dev/null +++ b/tests/baselines/reference/indexerWithTuple.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/types/tuple/indexerWithTuple.ts(11,25): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/tuple/indexerWithTuple.ts(17,27): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/tuple/indexerWithTuple.ts(20,30): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/tuple/indexerWithTuple.ts(28,30): error TS2733: Index '2' is out-of-bounds in tuple of length 2. + + +==== tests/cases/conformance/types/tuple/indexerWithTuple.ts (4 errors) ==== + var strNumTuple: [string, number] = ["foo", 10]; + var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]]; + var unionTuple1: [number, string| number] = [10, "foo"]; + var unionTuple2: [boolean, string| number] = [true, "foo"]; + + // no error + var idx0 = 0; + var idx1 = 1; + var ele10 = strNumTuple[0]; // string + var ele11 = strNumTuple[1]; // number + var ele12 = strNumTuple[2]; // string | number + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var ele13 = strNumTuple[idx0]; // string | number + var ele14 = strNumTuple[idx1]; // string | number + var ele15 = strNumTuple["0"]; // string + var ele16 = strNumTuple["1"]; // number + var strNumTuple1 = numTupleTuple[1]; //[string, number]; + var ele17 = numTupleTuple[2]; // number | [string, number] + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var eleUnion10 = unionTuple1[0]; // number + var eleUnion11 = unionTuple1[1]; // string | number + var eleUnion12 = unionTuple1[2]; // string | number + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var eleUnion13 = unionTuple1[idx0]; // string | number + var eleUnion14 = unionTuple1[idx1]; // string | number + var eleUnion15 = unionTuple1["0"]; // number + var eleUnion16 = unionTuple1["1"]; // string | number + + var eleUnion20 = unionTuple2[0]; // boolean + var eleUnion21 = unionTuple2[1]; // string | number + var eleUnion22 = unionTuple2[2]; // string | number | boolean + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + var eleUnion23 = unionTuple2[idx0]; // string | number | boolean + var eleUnion24 = unionTuple2[idx1]; // string | number | boolean + var eleUnion25 = unionTuple2["0"]; // boolean + var eleUnion26 = unionTuple2["1"]; // string | number \ No newline at end of file diff --git a/tests/baselines/reference/inferThisType.js b/tests/baselines/reference/inferThisType.js new file mode 100644 index 00000000000..68018970847 --- /dev/null +++ b/tests/baselines/reference/inferThisType.js @@ -0,0 +1,15 @@ +//// [inferThisType.ts] +declare function f(g: (this: T) => void): T +declare function h(this: number): void; +f(h) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +type r1 = Check<(this: number) => void>; // should be string + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +type r2 = This<(this: number) => void>; // should be number + + +//// [inferThisType.js] +f(h); diff --git a/tests/baselines/reference/inferThisType.symbols b/tests/baselines/reference/inferThisType.symbols new file mode 100644 index 00000000000..8e4b56c67a0 --- /dev/null +++ b/tests/baselines/reference/inferThisType.symbols @@ -0,0 +1,45 @@ +=== tests/cases/conformance/types/thisType/inferThisType.ts === +declare function f(g: (this: T) => void): T +>f : Symbol(f, Decl(inferThisType.ts, 0, 0)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) +>g : Symbol(g, Decl(inferThisType.ts, 0, 22)) +>this : Symbol(this, Decl(inferThisType.ts, 0, 26)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) + +declare function h(this: number): void; +>h : Symbol(h, Decl(inferThisType.ts, 0, 46)) +>this : Symbol(this, Decl(inferThisType.ts, 1, 19)) + +f(h) +>f : Symbol(f, Decl(inferThisType.ts, 0, 0)) +>h : Symbol(h, Decl(inferThisType.ts, 0, 46)) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +>Check : Symbol(Check, Decl(inferThisType.ts, 2, 4)) +>T : Symbol(T, Decl(inferThisType.ts, 5, 11)) +>T : Symbol(T, Decl(inferThisType.ts, 5, 11)) +>this : Symbol(this, Decl(inferThisType.ts, 5, 27)) +>U : Symbol(U, Decl(inferThisType.ts, 5, 38)) +>args : Symbol(args, Decl(inferThisType.ts, 5, 41)) + +type r1 = Check<(this: number) => void>; // should be string +>r1 : Symbol(r1, Decl(inferThisType.ts, 5, 84)) +>Check : Symbol(Check, Decl(inferThisType.ts, 2, 4)) +>this : Symbol(this, Decl(inferThisType.ts, 6, 17)) + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +>This : Symbol(This, Decl(inferThisType.ts, 6, 40)) +>T : Symbol(T, Decl(inferThisType.ts, 8, 10)) +>T : Symbol(T, Decl(inferThisType.ts, 8, 10)) +>this : Symbol(this, Decl(inferThisType.ts, 8, 27)) +>U : Symbol(U, Decl(inferThisType.ts, 8, 38)) +>args : Symbol(args, Decl(inferThisType.ts, 8, 41)) +>U : Symbol(U, Decl(inferThisType.ts, 8, 38)) + +type r2 = This<(this: number) => void>; // should be number +>r2 : Symbol(r2, Decl(inferThisType.ts, 8, 79)) +>This : Symbol(This, Decl(inferThisType.ts, 6, 40)) +>this : Symbol(this, Decl(inferThisType.ts, 9, 16)) + diff --git a/tests/baselines/reference/inferThisType.types b/tests/baselines/reference/inferThisType.types new file mode 100644 index 00000000000..3676c7bf3da --- /dev/null +++ b/tests/baselines/reference/inferThisType.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/thisType/inferThisType.ts === +declare function f(g: (this: T) => void): T +>f : (g: (this: T) => void) => T +>g : (this: T) => void +>this : T + +declare function h(this: number): void; +>h : (this: number) => void +>this : number + +f(h) +>f(h) : number +>f : (g: (this: T) => void) => T +>h : (this: number) => void + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +>Check : Check +>this : U +>args : any[] + +type r1 = Check<(this: number) => void>; // should be string +>r1 : string +>this : number + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +>This : This +>this : U +>args : any[] + +type r2 = This<(this: number) => void>; // should be number +>r2 : number +>this : number + diff --git a/tests/baselines/reference/inferringClassStaticMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassStaticMembersFromAssignments.symbols index 1c82d05c019..a643fbfba9e 100644 --- a/tests/baselines/reference/inferringClassStaticMembersFromAssignments.symbols +++ b/tests/baselines/reference/inferringClassStaticMembersFromAssignments.symbols @@ -1,67 +1,67 @@ === tests/cases/conformance/salsa/a.js === export class C1 { } ->C1 : Symbol(C1, Decl(a.js, 0, 0)) +>C1 : Symbol(C1, Decl(a.js, 0, 0), Decl(a.js, 0, 19)) C1.staticProp = 0; >C1.staticProp : Symbol(C1.staticProp, Decl(a.js, 0, 19)) ->C1 : Symbol(C1, Decl(a.js, 0, 0)) +>C1 : Symbol(C1, Decl(a.js, 0, 0), Decl(a.js, 0, 19)) >staticProp : Symbol(C1.staticProp, Decl(a.js, 0, 19)) export function F1() { } ->F1 : Symbol(F1, Decl(a.js, 1, 18)) +>F1 : Symbol(F1, Decl(a.js, 1, 18), Decl(a.js, 3, 24)) F1.staticProp = 0; >F1.staticProp : Symbol(F1.staticProp, Decl(a.js, 3, 24)) ->F1 : Symbol(F1, Decl(a.js, 1, 18)) +>F1 : Symbol(F1, Decl(a.js, 1, 18), Decl(a.js, 3, 24)) >staticProp : Symbol(F1.staticProp, Decl(a.js, 3, 24)) export var C2 = class { }; ->C2 : Symbol(C2, Decl(a.js, 6, 10)) +>C2 : Symbol(C2, Decl(a.js, 6, 10), Decl(a.js, 6, 26)) C2.staticProp = 0; >C2.staticProp : Symbol(C2.staticProp, Decl(a.js, 6, 26)) ->C2 : Symbol(C2, Decl(a.js, 6, 10)) +>C2 : Symbol(C2, Decl(a.js, 6, 10), Decl(a.js, 6, 26)) >staticProp : Symbol(C2.staticProp, Decl(a.js, 6, 26)) export let F2 = function () { }; ->F2 : Symbol(F2, Decl(a.js, 9, 10)) +>F2 : Symbol(F2, Decl(a.js, 9, 10), Decl(a.js, 9, 32)) F2.staticProp = 0; >F2.staticProp : Symbol(F2.staticProp, Decl(a.js, 9, 32)) ->F2 : Symbol(F2, Decl(a.js, 9, 10)) +>F2 : Symbol(F2, Decl(a.js, 9, 10), Decl(a.js, 9, 32)) >staticProp : Symbol(F2.staticProp, Decl(a.js, 9, 32)) === tests/cases/conformance/salsa/global.js === class C3 { } ->C3 : Symbol(C3, Decl(global.js, 0, 0)) +>C3 : Symbol(C3, Decl(global.js, 0, 0), Decl(global.js, 0, 12)) C3.staticProp = 0; >C3.staticProp : Symbol(C3.staticProp, Decl(global.js, 0, 12)) ->C3 : Symbol(C3, Decl(global.js, 0, 0)) +>C3 : Symbol(C3, Decl(global.js, 0, 0), Decl(global.js, 0, 12)) >staticProp : Symbol(C3.staticProp, Decl(global.js, 0, 12)) function F3() { } ->F3 : Symbol(F3, Decl(global.js, 1, 18)) +>F3 : Symbol(F3, Decl(global.js, 1, 18), Decl(global.js, 3, 17)) F3.staticProp = 0; >F3.staticProp : Symbol(F3.staticProp, Decl(global.js, 3, 17)) ->F3 : Symbol(F3, Decl(global.js, 1, 18)) +>F3 : Symbol(F3, Decl(global.js, 1, 18), Decl(global.js, 3, 17)) >staticProp : Symbol(F3.staticProp, Decl(global.js, 3, 17)) var C4 = class { }; ->C4 : Symbol(C4, Decl(global.js, 6, 3)) +>C4 : Symbol(C4, Decl(global.js, 6, 3), Decl(global.js, 6, 19)) C4.staticProp = 0; >C4.staticProp : Symbol(C4.staticProp, Decl(global.js, 6, 19)) ->C4 : Symbol(C4, Decl(global.js, 6, 3)) +>C4 : Symbol(C4, Decl(global.js, 6, 3), Decl(global.js, 6, 19)) >staticProp : Symbol(C4.staticProp, Decl(global.js, 6, 19)) let F4 = function () { }; ->F4 : Symbol(F4, Decl(global.js, 9, 3)) +>F4 : Symbol(F4, Decl(global.js, 9, 3), Decl(global.js, 9, 25)) F4.staticProp = 0; >F4.staticProp : Symbol(F4.staticProp, Decl(global.js, 9, 25)) ->F4 : Symbol(F4, Decl(global.js, 9, 3)) +>F4 : Symbol(F4, Decl(global.js, 9, 3), Decl(global.js, 9, 25)) >staticProp : Symbol(F4.staticProp, Decl(global.js, 9, 25)) === tests/cases/conformance/salsa/b.ts === @@ -74,57 +74,57 @@ var n: number; var n = a.C1.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >a.C1.staticProp : Symbol(a.C1.staticProp, Decl(a.js, 0, 19)) ->a.C1 : Symbol(a.C1, Decl(a.js, 0, 0)) +>a.C1 : Symbol(a.C1, Decl(a.js, 0, 0), Decl(a.js, 0, 19)) >a : Symbol(a, Decl(b.ts, 0, 6)) ->C1 : Symbol(a.C1, Decl(a.js, 0, 0)) +>C1 : Symbol(a.C1, Decl(a.js, 0, 0), Decl(a.js, 0, 19)) >staticProp : Symbol(a.C1.staticProp, Decl(a.js, 0, 19)) var n = a.C2.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >a.C2.staticProp : Symbol(a.C2.staticProp, Decl(a.js, 6, 26)) ->a.C2 : Symbol(a.C2, Decl(a.js, 6, 10)) +>a.C2 : Symbol(a.C2, Decl(a.js, 6, 10), Decl(a.js, 6, 26)) >a : Symbol(a, Decl(b.ts, 0, 6)) ->C2 : Symbol(a.C2, Decl(a.js, 6, 10)) +>C2 : Symbol(a.C2, Decl(a.js, 6, 10), Decl(a.js, 6, 26)) >staticProp : Symbol(a.C2.staticProp, Decl(a.js, 6, 26)) var n = a.F1.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >a.F1.staticProp : Symbol(a.F1.staticProp, Decl(a.js, 3, 24)) ->a.F1 : Symbol(a.F1, Decl(a.js, 1, 18)) +>a.F1 : Symbol(a.F1, Decl(a.js, 1, 18), Decl(a.js, 3, 24)) >a : Symbol(a, Decl(b.ts, 0, 6)) ->F1 : Symbol(a.F1, Decl(a.js, 1, 18)) +>F1 : Symbol(a.F1, Decl(a.js, 1, 18), Decl(a.js, 3, 24)) >staticProp : Symbol(a.F1.staticProp, Decl(a.js, 3, 24)) var n = a.F2.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >a.F2.staticProp : Symbol(a.F2.staticProp, Decl(a.js, 9, 32)) ->a.F2 : Symbol(a.F2, Decl(a.js, 9, 10)) +>a.F2 : Symbol(a.F2, Decl(a.js, 9, 10), Decl(a.js, 9, 32)) >a : Symbol(a, Decl(b.ts, 0, 6)) ->F2 : Symbol(a.F2, Decl(a.js, 9, 10)) +>F2 : Symbol(a.F2, Decl(a.js, 9, 10), Decl(a.js, 9, 32)) >staticProp : Symbol(a.F2.staticProp, Decl(a.js, 9, 32)) var n = C3.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >C3.staticProp : Symbol(C3.staticProp, Decl(global.js, 0, 12)) ->C3 : Symbol(C3, Decl(global.js, 0, 0)) +>C3 : Symbol(C3, Decl(global.js, 0, 0), Decl(global.js, 0, 12)) >staticProp : Symbol(C3.staticProp, Decl(global.js, 0, 12)) var n = C4.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >C4.staticProp : Symbol(C4.staticProp, Decl(global.js, 6, 19)) ->C4 : Symbol(C4, Decl(global.js, 6, 3)) +>C4 : Symbol(C4, Decl(global.js, 6, 3), Decl(global.js, 6, 19)) >staticProp : Symbol(C4.staticProp, Decl(global.js, 6, 19)) var n = F3.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >F3.staticProp : Symbol(F3.staticProp, Decl(global.js, 3, 17)) ->F3 : Symbol(F3, Decl(global.js, 1, 18)) +>F3 : Symbol(F3, Decl(global.js, 1, 18), Decl(global.js, 3, 17)) >staticProp : Symbol(F3.staticProp, Decl(global.js, 3, 17)) var n = F4.staticProp; >n : Symbol(n, Decl(b.ts, 1, 3), Decl(b.ts, 3, 3), Decl(b.ts, 4, 3), Decl(b.ts, 5, 3), Decl(b.ts, 6, 3) ... and 4 more) >F4.staticProp : Symbol(F4.staticProp, Decl(global.js, 9, 25)) ->F4 : Symbol(F4, Decl(global.js, 9, 3)) +>F4 : Symbol(F4, Decl(global.js, 9, 3), Decl(global.js, 9, 25)) >staticProp : Symbol(F4.staticProp, Decl(global.js, 9, 25)) diff --git a/tests/baselines/reference/inferringClassStaticMembersFromAssignments.types b/tests/baselines/reference/inferringClassStaticMembersFromAssignments.types index 69dff49724b..c38c61dc2f2 100644 --- a/tests/baselines/reference/inferringClassStaticMembersFromAssignments.types +++ b/tests/baselines/reference/inferringClassStaticMembersFromAssignments.types @@ -10,12 +10,12 @@ C1.staticProp = 0; >0 : 0 export function F1() { } ->F1 : { (): void; staticProp: number; } +>F1 : typeof F1 F1.staticProp = 0; >F1.staticProp = 0 : 0 >F1.staticProp : number ->F1 : { (): void; staticProp: number; } +>F1 : typeof F1 >staticProp : number >0 : 0 @@ -53,12 +53,12 @@ C3.staticProp = 0; >0 : 0 function F3() { } ->F3 : { (): void; staticProp: number; } +>F3 : typeof F3 F3.staticProp = 0; >F3.staticProp = 0 : 0 >F3.staticProp : number ->F3 : { (): void; staticProp: number; } +>F3 : typeof F3 >staticProp : number >0 : 0 @@ -110,9 +110,9 @@ var n = a.C2.staticProp; var n = a.F1.staticProp; >n : number >a.F1.staticProp : number ->a.F1 : { (): void; staticProp: number; } +>a.F1 : typeof a.F1 >a : typeof a ->F1 : { (): void; staticProp: number; } +>F1 : typeof a.F1 >staticProp : number var n = a.F2.staticProp; @@ -139,7 +139,7 @@ var n = C4.staticProp; var n = F3.staticProp; >n : number >F3.staticProp : number ->F3 : { (): void; staticProp: number; } +>F3 : typeof F3 >staticProp : number var n = F4.staticProp; diff --git a/tests/baselines/reference/infiniteConstraints.errors.txt b/tests/baselines/reference/infiniteConstraints.errors.txt index 387b0daac68..71034e87edf 100644 --- a/tests/baselines/reference/infiniteConstraints.errors.txt +++ b/tests/baselines/reference/infiniteConstraints.errors.txt @@ -1,11 +1,15 @@ +error TS2321: Excessive stack depth comparing types 'Extract], Record<"val", string>>["val"]' and 'Extract>], Record<"val", string>>["val"]'. tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude]'. -tests/cases/compiler/infiniteConstraints.ts(31,42): error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'. - Types of property 'main' are incompatible. - Type 'Record<"val", "dup">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(27,37): error TS2322: Type 'Record<"val", "test">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(27,58): error TS2322: Type 'Record<"val", "test2">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(29,45): error TS2322: Type 'Record<"val", "test">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'. -==== tests/cases/compiler/infiniteConstraints.ts (3 errors) ==== +!!! error TS2321: Excessive stack depth comparing types 'Extract], Record<"val", string>>["val"]' and 'Extract>], Record<"val", string>>["val"]'. +==== tests/cases/compiler/infiniteConstraints.ts (7 errors) ==== // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint type T1], { val: string }>["val"] }> = B; @@ -35,14 +39,25 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c >(vals: T): void; const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2")}); + ~~~~ +!!! error TS2322: Type 'Record<"val", "test">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:27:37: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }' + ~~~~~~~~~ +!!! error TS2322: Type 'Record<"val", "test2">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:27:58: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }' const shouldBeNoError = ensureNoDuplicates({main: value("test")}); + ~~~~ +!!! error TS2322: Type 'Record<"val", "test">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:29:45: The expected type comes from property 'main' which is declared here on type '{ main: never; }' const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'. -!!! error TS2345: Types of property 'main' are incompatible. -!!! error TS2345: Type 'Record<"val", "dup">' is not assignable to type 'never'. + ~~~~ +!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:43: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }' + ~~~~~~~~~ +!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. +!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:63: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }' // Repro from #26448 diff --git a/tests/baselines/reference/infiniteConstraints.types b/tests/baselines/reference/infiniteConstraints.types index e23e138c820..7e357fbb01e 100644 --- a/tests/baselines/reference/infiniteConstraints.types +++ b/tests/baselines/reference/infiniteConstraints.types @@ -39,7 +39,7 @@ declare function value(val: V): Value; >val : V declare function ensureNoDuplicates< ->ensureNoDuplicates : >["val"] extends Extract], Record<"val", string>>["val"] ? never : any; }>(vals: T) => void +>ensureNoDuplicates : (vals: T) => void T extends { [K in keyof T]: Extract["val"] extends Extract], Value>["val"] @@ -50,9 +50,9 @@ declare function ensureNoDuplicates< >vals : T const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2")}); ->noError : void ->ensureNoDuplicates({main: value("test"), alternate: value("test2")}) : void ->ensureNoDuplicates : >["val"] extends Extract], Record<"val", string>>["val"] ? never : any; }>(vals: T) => void +>noError : any +>ensureNoDuplicates({main: value("test"), alternate: value("test2")}) : any +>ensureNoDuplicates : (vals: T) => void >{main: value("test"), alternate: value("test2")} : { main: Record<"val", "test">; alternate: Record<"val", "test2">; } >main : Record<"val", "test"> >value("test") : Record<"val", "test"> @@ -64,9 +64,9 @@ const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2 >"test2" : "test2" const shouldBeNoError = ensureNoDuplicates({main: value("test")}); ->shouldBeNoError : void ->ensureNoDuplicates({main: value("test")}) : void ->ensureNoDuplicates : >["val"] extends Extract], Record<"val", string>>["val"] ? never : any; }>(vals: T) => void +>shouldBeNoError : any +>ensureNoDuplicates({main: value("test")}) : any +>ensureNoDuplicates : (vals: T) => void >{main: value("test")} : { main: Record<"val", "test">; } >main : Record<"val", "test"> >value("test") : Record<"val", "test"> @@ -76,7 +76,7 @@ const shouldBeNoError = ensureNoDuplicates({main: value("test")}); const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")}); >shouldBeError : any >ensureNoDuplicates({main: value("dup"), alternate: value("dup")}) : any ->ensureNoDuplicates : >["val"] extends Extract], Record<"val", string>>["val"] ? never : any; }>(vals: T) => void +>ensureNoDuplicates : (vals: T) => void >{main: value("dup"), alternate: value("dup")} : { main: Record<"val", "dup">; alternate: Record<"val", "dup">; } >main : Record<"val", "dup"> >value("dup") : Record<"val", "dup"> diff --git a/tests/baselines/reference/initializersInDeclarations.errors.txt b/tests/baselines/reference/initializersInDeclarations.errors.txt index 34a7b67e5d5..d7f2847286b 100644 --- a/tests/baselines/reference/initializersInDeclarations.errors.txt +++ b/tests/baselines/reference/initializersInDeclarations.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/externalModules/file1.d.ts(4,9): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/file1.d.ts(5,16): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/file1.d.ts(6,16): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/externalModules/file1.d.ts(11,15): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/externalModules/file1.d.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/externalModules/file1.d.ts(11,17): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/externalModules/file1.d.ts(12,17): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/file1.d.ts(15,2): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/externalModules/file1.d.ts(17,16): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/externalModules/file1.d.ts(17,18): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/conformance/externalModules/file1.d.ts (7 errors) ==== @@ -25,10 +25,10 @@ tests/cases/conformance/externalModules/file1.d.ts(17,16): error TS1039: Initial } declare var x = []; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare var y = {}; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare module M1 { @@ -37,6 +37,6 @@ tests/cases/conformance/externalModules/file1.d.ts(17,16): error TS1039: Initial !!! error TS1036: Statements are not allowed in ambient contexts. export var v1 = () => false; - ~ + ~~~~~~~~~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types index 6df43d9e39a..28fddbce52a 100644 --- a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types +++ b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types @@ -15,7 +15,7 @@ module M { } enum E { A } >E : E ->A : E +>A : E.A interface Foo { a: number; @@ -70,7 +70,7 @@ interface Foo { var a: Foo = { >a : Foo ->{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: true; d: {}; e: null; f: number[]; g: {}; h: (x: number) => number; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E; } +>{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: true; d: {}; e: null; f: number[]; g: {}; h: (x: number) => number; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E.A; } a: 1, >a : number @@ -136,7 +136,7 @@ var a: Foo = { >{} : {} o: E.A ->o : E +>o : E.A >E.A : E >E : typeof E >A : E diff --git a/tests/baselines/reference/invalidBooleanAssignments.types b/tests/baselines/reference/invalidBooleanAssignments.types index 1b91002ffba..439d93e5408 100644 --- a/tests/baselines/reference/invalidBooleanAssignments.types +++ b/tests/baselines/reference/invalidBooleanAssignments.types @@ -22,7 +22,7 @@ var d: typeof undefined = x; enum E { A } >E : E ->A : E +>A : E.A var e: E = x; >e : E diff --git a/tests/baselines/reference/invalidStringAssignments.types b/tests/baselines/reference/invalidStringAssignments.types index 4f749b6528d..66510d029c9 100644 --- a/tests/baselines/reference/invalidStringAssignments.types +++ b/tests/baselines/reference/invalidStringAssignments.types @@ -71,7 +71,7 @@ i = x; enum E { A } >E : E ->A : E +>A : E.A var j: E = x; >j : E diff --git a/tests/baselines/reference/invalidUndefinedAssignments.types b/tests/baselines/reference/invalidUndefinedAssignments.types index fdb8e160be0..ab19dd824e1 100644 --- a/tests/baselines/reference/invalidUndefinedAssignments.types +++ b/tests/baselines/reference/invalidUndefinedAssignments.types @@ -5,7 +5,7 @@ var x: typeof undefined; enum E { A } >E : E ->A : E +>A : E.A E = x; >E = x : any diff --git a/tests/baselines/reference/invalidUndefinedValues.types b/tests/baselines/reference/invalidUndefinedValues.types index f93b3a4c244..3cb51ebeb29 100644 --- a/tests/baselines/reference/invalidUndefinedValues.types +++ b/tests/baselines/reference/invalidUndefinedValues.types @@ -91,7 +91,7 @@ x = f; enum E { A } >E : E ->A : E +>A : E.A x = E; >x = E : typeof E diff --git a/tests/baselines/reference/invalidVoidAssignments.types b/tests/baselines/reference/invalidVoidAssignments.types index 02c80b7f942..0711f912f3e 100644 --- a/tests/baselines/reference/invalidVoidAssignments.types +++ b/tests/baselines/reference/invalidVoidAssignments.types @@ -70,7 +70,7 @@ i = x; enum E { A } >E : E ->A : E +>A : E.A x = E; >x = E : typeof E diff --git a/tests/baselines/reference/invalidVoidValues.types b/tests/baselines/reference/invalidVoidValues.types index 9f0988cf35f..ab539e61d4f 100644 --- a/tests/baselines/reference/invalidVoidValues.types +++ b/tests/baselines/reference/invalidVoidValues.types @@ -19,7 +19,7 @@ x = true; enum E { A } >E : E ->A : E +>A : E.A x = E; >x = E : typeof E diff --git a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt index 5142b665d71..bf9c8065cea 100644 --- a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt +++ b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt @@ -8,9 +8,7 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(3,7): error TS2322: Typ Type 'Constraint>>' is not assignable to type 'Constraint>'. Types of property 'underlying' are incompatible. Type 'Constraint>' is not assignable to type 'Constraint'. -tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype; }'. - Property 'foo' is incompatible with index signature. - Type 'Num' is not assignable to type 'Runtype'. +tests/cases/compiler/invariantGenericErrorElaboration.ts(4,19): error TS2322: Type 'Num' is not assignable to type 'Runtype'. ==== tests/cases/compiler/invariantGenericErrorElaboration.ts (2 errors) ==== @@ -29,10 +27,9 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Ar !!! error TS2322: Types of property 'underlying' are incompatible. !!! error TS2322: Type 'Constraint>' is not assignable to type 'Constraint'. const Foo = Obj({ foo: Num }) - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype; }'. -!!! error TS2345: Property 'foo' is incompatible with index signature. -!!! error TS2345: Type 'Num' is not assignable to type 'Runtype'. + ~~~ +!!! error TS2322: Type 'Num' is not assignable to type 'Runtype'. +!!! related TS6501 tests/cases/compiler/invariantGenericErrorElaboration.ts:17:34: The expected type comes from this index signature. interface Runtype { constraint: Constraint diff --git a/tests/baselines/reference/isolatedModulesAmbientConstEnum.types b/tests/baselines/reference/isolatedModulesAmbientConstEnum.types index ea849088d50..8b714d98f6e 100644 --- a/tests/baselines/reference/isolatedModulesAmbientConstEnum.types +++ b/tests/baselines/reference/isolatedModulesAmbientConstEnum.types @@ -1,7 +1,7 @@ === tests/cases/compiler/file1.ts === declare const enum E { X = 1} >E : E ->X : E +>X : E.X >1 : 1 export var y; diff --git a/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types index 1ac53071e4c..0c5f566fee9 100644 --- a/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types +++ b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types @@ -1,7 +1,7 @@ === tests/cases/compiler/file1.ts === const enum E { X = 100 }; >E : E ->X : E +>X : E.X >100 : 100 var e = E.X; diff --git a/tests/baselines/reference/isolatedModulesReExportType.types b/tests/baselines/reference/isolatedModulesReExportType.types index 5c857a16952..55c4cdfb7b7 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.types +++ b/tests/baselines/reference/isolatedModulesReExportType.types @@ -8,7 +8,7 @@ export import T2 = require("./exportEqualsT"); // OK, has a value side export { C } from "./exportValue"; ->C : typeof C +>C : typeof import("/exportValue").C // OK, even though the namespace it exports is only types. import * as NS from "./exportT"; diff --git a/tests/baselines/reference/iterableArrayPattern28.errors.txt b/tests/baselines/reference/iterableArrayPattern28.errors.txt index 7ca750cd81f..ecc9f0a02c5 100644 --- a/tests/baselines/reference/iterableArrayPattern28.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern28.errors.txt @@ -1,11 +1,8 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,32): error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'ReadonlyArray<[string, number]>'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray<[string, number] | [string, boolean]>[]): ([string, number] | [string, boolean])[]; (...items: ([string, number] | [string, boolean] | ConcatArray<[string, number] | [string, boolean]>)[]): ([string, number] | [string, boolean])[]; }' is not assignable to type '{ (...items: ConcatArray<[string, number]>[]): [string, number][]; (...items: ([string, number] | ConcatArray<[string, number]>)[]): [string, number][]; }'. - Type '([string, number] | [string, boolean])[]' is not assignable to type '[string, number][]'. - Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'. - Type '[string, boolean]' is not assignable to type '[string, number]'. - Type 'boolean' is not assignable to type 'number'. + Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'. + Type '[string, boolean]' is not assignable to type '[string, number]'. + Type 'boolean' is not assignable to type 'number'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (2 errors) ==== @@ -15,9 +12,6 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,32): error takeFirstTwoEntries(...new Map([["", 0], ["hello", true]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'ReadonlyArray<[string, number]>'. -!!! error TS2345: Types of property 'concat' are incompatible. -!!! error TS2345: Type '{ (...items: ConcatArray<[string, number] | [string, boolean]>[]): ([string, number] | [string, boolean])[]; (...items: ([string, number] | [string, boolean] | ConcatArray<[string, number] | [string, boolean]>)[]): ([string, number] | [string, boolean])[]; }' is not assignable to type '{ (...items: ConcatArray<[string, number]>[]): [string, number][]; (...items: ([string, number] | ConcatArray<[string, number]>)[]): [string, number][]; }'. -!!! error TS2345: Type '([string, number] | [string, boolean])[]' is not assignable to type '[string, number][]'. -!!! error TS2345: Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'. -!!! error TS2345: Type '[string, boolean]' is not assignable to type '[string, number]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2345: Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'. +!!! error TS2345: Type '[string, boolean]' is not assignable to type '[string, number]'. +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.types b/tests/baselines/reference/jsContainerMergeJsContainer.types index 73e61aded0d..75d2152c571 100644 --- a/tests/baselines/reference/jsContainerMergeJsContainer.types +++ b/tests/baselines/reference/jsContainerMergeJsContainer.types @@ -6,18 +6,18 @@ const a = {}; a.d = function() {}; >a.d = function() {} : { (): void; prototype: {}; } ->a.d : { (): void; prototype: {}; } +>a.d : typeof a.d >a : typeof a ->d : { (): void; prototype: {}; } +>d : typeof a.d >function() {} : { (): void; prototype: {}; } === tests/cases/conformance/salsa/b.js === a.d.prototype = {}; >a.d.prototype = {} : {} >a.d.prototype : {} ->a.d : { (): void; prototype: {}; } +>a.d : typeof a.d >a : typeof a ->d : { (): void; prototype: {}; } +>d : typeof a.d >prototype : {} >{} : {} diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols index 231d9fa60b2..9d9f2164845 100644 --- a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols @@ -1,10 +1,10 @@ === tests/cases/conformance/salsa/a.js === var variable = {}; ->variable : Symbol(variable, Decl(a.js, 0, 3)) +>variable : Symbol(variable, Decl(a.js, 0, 3), Decl(a.js, 0, 18)) variable.a = 0; >variable.a : Symbol(variable.a, Decl(a.js, 0, 18)) ->variable : Symbol(variable, Decl(a.js, 0, 3)) +>variable : Symbol(variable, Decl(a.js, 0, 3), Decl(a.js, 0, 18)) >a : Symbol(variable.a, Decl(a.js, 0, 18)) class C { @@ -27,7 +27,7 @@ class C { } var obj = { ->obj : Symbol(obj, Decl(a.js, 11, 3)) +>obj : Symbol(obj, Decl(a.js, 11, 3), Decl(a.js, 13, 2)) property: {} >property : Symbol(property, Decl(a.js, 11, 11)) @@ -36,7 +36,7 @@ var obj = { obj.property.a = 0; >obj.property : Symbol(property, Decl(a.js, 11, 11)) ->obj : Symbol(obj, Decl(a.js, 11, 3)) +>obj : Symbol(obj, Decl(a.js, 11, 3), Decl(a.js, 13, 2)) >property : Symbol(property, Decl(a.js, 11, 11)) var arr = [{}]; @@ -52,7 +52,7 @@ function getObj() { === tests/cases/conformance/salsa/b.ts === variable.a = 1; >variable.a : Symbol(variable.a, Decl(a.js, 0, 18)) ->variable : Symbol(variable, Decl(a.js, 0, 3)) +>variable : Symbol(variable, Decl(a.js, 0, 3), Decl(a.js, 0, 18)) >a : Symbol(variable.a, Decl(a.js, 0, 18)) (new C()).member.a = 1; @@ -67,7 +67,7 @@ variable.a = 1; obj.property.a = 1; >obj.property : Symbol(property, Decl(a.js, 11, 11)) ->obj : Symbol(obj, Decl(a.js, 11, 3)) +>obj : Symbol(obj, Decl(a.js, 11, 3), Decl(a.js, 13, 2)) >property : Symbol(property, Decl(a.js, 11, 11)) arr[0].a = 1; diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types index c30a5e99b2a..996165537bc 100644 --- a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types @@ -1,12 +1,12 @@ === tests/cases/conformance/salsa/a.js === var variable = {}; ->variable : { a: number; } +>variable : typeof variable >{} : {} variable.a = 0; >variable.a = 0 : 0 >variable.a : number ->variable : { a: number; } +>variable : typeof variable >a : number >0 : 0 @@ -72,7 +72,7 @@ function getObj() { variable.a = 1; >variable.a = 1 : 1 >variable.a : number ->variable : { a: number; } +>variable : typeof variable >a : number >1 : 1 diff --git a/tests/baselines/reference/jsdocAccessEnumType.types b/tests/baselines/reference/jsdocAccessEnumType.types index a08c2b4e179..7ceabb3c7b7 100644 --- a/tests/baselines/reference/jsdocAccessEnumType.types +++ b/tests/baselines/reference/jsdocAccessEnumType.types @@ -1,7 +1,7 @@ === /a.ts === export enum E { A } >E : E ->A : E +>A : E.A === /b.js === import { E } from "./a"; diff --git a/tests/baselines/reference/jsdocTemplateClass.symbols b/tests/baselines/reference/jsdocTemplateClass.symbols index a2da2f051cd..ee2fc5a6fb9 100644 --- a/tests/baselines/reference/jsdocTemplateClass.symbols +++ b/tests/baselines/reference/jsdocTemplateClass.symbols @@ -38,7 +38,7 @@ class Foo { } } var f = new Foo(1) ->f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3)) +>f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3), Decl(templateTagOnClasses.js, 23, 22)) >Foo : Symbol(Foo, Decl(templateTagOnClasses.js, 0, 0)) var g = new Foo(false) @@ -47,7 +47,7 @@ var g = new Foo(false) f.a = g.a >f.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) ->f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3)) +>f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3), Decl(templateTagOnClasses.js, 23, 22)) >a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) >g.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) >g : Symbol(g, Decl(templateTagOnClasses.js, 23, 3)) diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols b/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols index 6a8a948cba8..d176aba903e 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols @@ -45,16 +45,16 @@ Zet.prototype.add = function(v, id) { >u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) } var z = new Zet(1) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3), Decl(templateTagOnConstructorFunctions.js, 21, 18)) >Zet : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) z.t = 2 >z.t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3), Decl(templateTagOnConstructorFunctions.js, 21, 18)) >t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) z.u = false >z.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3), Decl(templateTagOnConstructorFunctions.js, 21, 18)) >u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols b/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols index 703e23c5af8..ca12425262b 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols @@ -41,17 +41,17 @@ Zet.prototype.add = function(v, o) { >u : Symbol(Zet.u, Decl(templateTagWithNestedTypeLiteral.js, 4, 17), Decl(templateTagWithNestedTypeLiteral.js, 14, 36)) } var z = new Zet(1) ->z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3)) +>z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3), Decl(templateTagWithNestedTypeLiteral.js, 18, 18)) >Zet : Symbol(Zet, Decl(templateTagWithNestedTypeLiteral.js, 0, 0)) z.t = 2 >z.t : Symbol(Zet.t, Decl(templateTagWithNestedTypeLiteral.js, 6, 10)) ->z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3)) +>z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3), Decl(templateTagWithNestedTypeLiteral.js, 18, 18)) >t : Symbol(Zet.t, Decl(templateTagWithNestedTypeLiteral.js, 6, 10)) z.u = false >z.u : Symbol(Zet.u, Decl(templateTagWithNestedTypeLiteral.js, 4, 17), Decl(templateTagWithNestedTypeLiteral.js, 14, 36)) ->z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3)) +>z : Symbol(z, Decl(templateTagWithNestedTypeLiteral.js, 18, 3), Decl(templateTagWithNestedTypeLiteral.js, 18, 18)) >u : Symbol(Zet.u, Decl(templateTagWithNestedTypeLiteral.js, 4, 17), Decl(templateTagWithNestedTypeLiteral.js, 14, 36)) // lookup in typedef should not crash the compiler, even when the type is unknown diff --git a/tests/baselines/reference/jsdocTemplateTag4.symbols b/tests/baselines/reference/jsdocTemplateTag4.symbols new file mode 100644 index 00000000000..02ce7221fc2 --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag4.symbols @@ -0,0 +1,113 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { +>Multimap : Symbol(Multimap, Decl(a.js, 0, 0)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap._map, Decl(a.js, 6, 21)) +>this : Symbol(Multimap, Decl(a.js, 0, 0)) +>_map : Symbol(Multimap._map, Decl(a.js, 6, 21)) + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap.prototype.get = function (key) { +>Multimap.prototype : Symbol(Multimap.get, Decl(a.js, 9, 2)) +>Multimap : Symbol(Multimap, Decl(a.js, 0, 0)) +>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>get : Symbol(Multimap.get, Decl(a.js, 9, 2)) +>key : Symbol(key, Decl(a.js, 15, 35)) + + return this._map[key + '']; +>this._map : Symbol(Multimap._map, Decl(a.js, 6, 21)) +>this : Symbol(Multimap, Decl(a.js, 0, 0)) +>_map : Symbol(Multimap._map, Decl(a.js, 6, 21)) +>key : Symbol(key, Decl(a.js, 15, 35)) +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { +>Multimap2 : Symbol(Multimap2, Decl(a.js, 25, 3)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap2._map, Decl(a.js, 25, 28)) +>this : Symbol(Multimap2, Decl(a.js, 25, 15)) +>_map : Symbol(Multimap2._map, Decl(a.js, 25, 28)) + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap2.prototype.get = function (key) { +>Multimap2.prototype : Symbol(Multimap2.get, Decl(a.js, 28, 2)) +>Multimap2 : Symbol(Multimap2, Decl(a.js, 25, 3)) +>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>get : Symbol(Multimap2.get, Decl(a.js, 28, 2)) +>key : Symbol(key, Decl(a.js, 34, 36)) + + return this._map[key + '']; +>this._map : Symbol(Multimap2._map, Decl(a.js, 25, 28)) +>this : Symbol(Multimap2, Decl(a.js, 25, 15)) +>_map : Symbol(Multimap2._map, Decl(a.js, 25, 28)) +>key : Symbol(key, Decl(a.js, 34, 36)) +} + +var Ns = {}; +>Ns : Symbol(Ns, Decl(a.js, 38, 3), Decl(a.js, 38, 12)) + +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { +>Ns.Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 38, 12)) +>Ns : Symbol(Ns, Decl(a.js, 38, 3), Decl(a.js, 38, 12)) +>Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 38, 12)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap3._map, Decl(a.js, 45, 27)) +>this : Symbol(Multimap3, Decl(a.js, 45, 14)) +>_map : Symbol(Multimap3._map, Decl(a.js, 45, 27)) + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Ns.Multimap3.prototype.get = function (key) { +>Ns.Multimap3.prototype : Symbol(Ns.Multimap3.get, Decl(a.js, 48, 2)) +>Ns.Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 38, 12)) +>Ns : Symbol(Ns, Decl(a.js, 38, 3), Decl(a.js, 38, 12)) +>Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 38, 12)) +>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>get : Symbol(Ns.Multimap3.get, Decl(a.js, 48, 2)) +>key : Symbol(key, Decl(a.js, 54, 39)) + + return this._map[key + '']; +>this._map : Symbol(Multimap3._map, Decl(a.js, 45, 27)) +>this : Symbol(Multimap3, Decl(a.js, 45, 14)) +>_map : Symbol(Multimap3._map, Decl(a.js, 45, 27)) +>key : Symbol(key, Decl(a.js, 54, 39)) +} + diff --git a/tests/baselines/reference/jsdocTemplateTag4.types b/tests/baselines/reference/jsdocTemplateTag4.types new file mode 100644 index 00000000000..6df18d4b98a --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag4.types @@ -0,0 +1,141 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { +>Multimap : typeof Multimap + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap +>_map : { [x: string]: V; } +>{} : {} + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap.prototype.get = function (key) { +>Multimap.prototype.get = function (key) { return this._map[key + ''];} : (key: K) => V +>Multimap.prototype.get : any +>Multimap.prototype : any +>Multimap : typeof Multimap +>prototype : any +>get : any +>function (key) { return this._map[key + ''];} : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : V +>this._map : { [x: string]: V; } +>this : Multimap +>_map : { [x: string]: V; } +>key + '' : string +>key : K +>'' : "" +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { +>Multimap2 : typeof Multimap2 +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap2 + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap2 +>_map : { [x: string]: V; } +>{} : {} + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap2.prototype.get = function (key) { +>Multimap2.prototype.get = function (key) { return this._map[key + ''];} : (key: K) => V +>Multimap2.prototype.get : any +>Multimap2.prototype : any +>Multimap2 : typeof Multimap2 +>prototype : any +>get : any +>function (key) { return this._map[key + ''];} : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : V +>this._map : { [x: string]: V; } +>this : Multimap2 +>_map : { [x: string]: V; } +>key + '' : string +>key : K +>'' : "" +} + +var Ns = {}; +>Ns : typeof Ns +>{} : {} + +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { +>Ns.Multimap3 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap3 +>Ns.Multimap3 : typeof Multimap3 +>Ns : typeof Ns +>Multimap3 : typeof Multimap3 +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap3 + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap3 +>_map : { [x: string]: V; } +>{} : {} + +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Ns.Multimap3.prototype.get = function (key) { +>Ns.Multimap3.prototype.get = function (key) { return this._map[key + ''];} : (key: K) => V +>Ns.Multimap3.prototype.get : any +>Ns.Multimap3.prototype : any +>Ns.Multimap3 : typeof Multimap3 +>Ns : typeof Ns +>Multimap3 : typeof Multimap3 +>prototype : any +>get : any +>function (key) { return this._map[key + ''];} : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : V +>this._map : { [x: string]: V; } +>this : Multimap3 +>_map : { [x: string]: V; } +>key + '' : string +>key : K +>'' : "" +} + diff --git a/tests/baselines/reference/jsdocTemplateTag5.errors.txt b/tests/baselines/reference/jsdocTemplateTag5.errors.txt new file mode 100644 index 00000000000..e24cd0926b6 --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag5.errors.txt @@ -0,0 +1,77 @@ +tests/cases/conformance/jsdoc/a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. +tests/cases/conformance/jsdoc/a.js(39,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. +tests/cases/conformance/jsdoc/a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + + +==== tests/cases/conformance/jsdoc/a.js (3 errors) ==== + /** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ + function Multimap() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; + }; + + Multimap.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { + return this._map[key + '']; + ~~~~ +!!! error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + } + } + + /** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ + var Multimap2 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; + }; + + Multimap2.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get: function(key) { + return this._map[key + '']; + ~~~~ +!!! error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. + } + } + + var Ns = {}; + /** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ + Ns.Multimap3 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; + }; + + Ns.Multimap3.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { + return this._map[key + '']; + ~~~~ +!!! error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocTemplateTag5.symbols b/tests/baselines/reference/jsdocTemplateTag5.symbols new file mode 100644 index 00000000000..249e92ab257 --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag5.symbols @@ -0,0 +1,114 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { +>Multimap : Symbol(Multimap, Decl(a.js, 0, 0), Decl(a.js, 9, 2)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap._map, Decl(a.js, 6, 21)) +>_map : Symbol(Multimap._map, Decl(a.js, 6, 21)) + +}; + +Multimap.prototype = { +>Multimap.prototype : Symbol(Multimap.prototype, Decl(a.js, 9, 2)) +>Multimap : Symbol(Multimap, Decl(a.js, 0, 0), Decl(a.js, 9, 2)) +>prototype : Symbol(Multimap.prototype, Decl(a.js, 9, 2)) + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { +>get : Symbol(get, Decl(a.js, 11, 22)) +>key : Symbol(key, Decl(a.js, 16, 8)) + + return this._map[key + '']; +>this : Symbol(__object, Decl(a.js, 11, 20)) +>key : Symbol(key, Decl(a.js, 16, 8)) + } +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { +>Multimap2 : Symbol(Multimap2, Decl(a.js, 27, 3), Decl(a.js, 30, 2)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap2._map, Decl(a.js, 27, 28)) +>_map : Symbol(Multimap2._map, Decl(a.js, 27, 28)) + +}; + +Multimap2.prototype = { +>Multimap2.prototype : Symbol(Multimap2.prototype, Decl(a.js, 30, 2)) +>Multimap2 : Symbol(Multimap2, Decl(a.js, 27, 3), Decl(a.js, 30, 2)) +>prototype : Symbol(Multimap2.prototype, Decl(a.js, 30, 2)) + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get: function(key) { +>get : Symbol(get, Decl(a.js, 32, 23)) +>key : Symbol(key, Decl(a.js, 37, 18)) + + return this._map[key + '']; +>this : Symbol(__object, Decl(a.js, 32, 21)) +>key : Symbol(key, Decl(a.js, 37, 18)) + } +} + +var Ns = {}; +>Ns : Symbol(Ns, Decl(a.js, 42, 3), Decl(a.js, 42, 12), Decl(a.js, 52, 2)) + +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { +>Ns.Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 42, 12), Decl(a.js, 54, 3)) +>Ns : Symbol(Ns, Decl(a.js, 42, 3), Decl(a.js, 42, 12), Decl(a.js, 52, 2)) +>Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 42, 12), Decl(a.js, 54, 3)) + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map : Symbol(Multimap3._map, Decl(a.js, 49, 27)) +>_map : Symbol(Multimap3._map, Decl(a.js, 49, 27)) + +}; + +Ns.Multimap3.prototype = { +>Ns.Multimap3.prototype : Symbol(Ns.Multimap3.prototype, Decl(a.js, 52, 2)) +>Ns.Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 42, 12), Decl(a.js, 54, 3)) +>Ns : Symbol(Ns, Decl(a.js, 42, 3), Decl(a.js, 42, 12), Decl(a.js, 52, 2)) +>Multimap3 : Symbol(Ns.Multimap3, Decl(a.js, 42, 12), Decl(a.js, 54, 3)) +>prototype : Symbol(Ns.Multimap3.prototype, Decl(a.js, 52, 2)) + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { +>get : Symbol(get, Decl(a.js, 54, 26)) +>key : Symbol(key, Decl(a.js, 59, 8)) + + return this._map[key + '']; +>this : Symbol(__object, Decl(a.js, 54, 24)) +>key : Symbol(key, Decl(a.js, 59, 8)) + } +} + + diff --git a/tests/baselines/reference/jsdocTemplateTag5.types b/tests/baselines/reference/jsdocTemplateTag5.types new file mode 100644 index 00000000000..c5b8752d2b6 --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag5.types @@ -0,0 +1,149 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { +>Multimap : typeof Multimap + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap & { get(key: K): V; } +>_map : { [x: string]: V; } +>{} : {} + +}; + +Multimap.prototype = { +>Multimap.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } +>Multimap.prototype : { get(key: K): V; } +>Multimap : typeof Multimap +>prototype : { get(key: K): V; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { +>get : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : any +>this._map : any +>this : { get(key: K): V; } +>_map : any +>key + '' : string +>key : K +>'' : "" + } +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { +>Multimap2 : typeof Multimap2 +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap2 + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap2 & { get: (key: K) => V; } +>_map : { [x: string]: V; } +>{} : {} + +}; + +Multimap2.prototype = { +>Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } +>Multimap2.prototype : { get: (key: K) => V; } +>Multimap2 : typeof Multimap2 +>prototype : { get: (key: K) => V; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get: function(key) { +>get : (key: K) => V +>function(key) { return this._map[key + '']; } : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : any +>this._map : any +>this : { get: (key: K) => V; } +>_map : any +>key + '' : string +>key : K +>'' : "" + } +} + +var Ns = {}; +>Ns : typeof Ns +>{} : {} + +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { +>Ns.Multimap3 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap3 +>Ns.Multimap3 : typeof Multimap3 +>Ns : typeof Ns +>Multimap3 : typeof Multimap3 +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap3 + + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +>this._map = {} : {} +>this._map : { [x: string]: V; } +>this : Multimap3 & { get(key: K): V; } +>_map : { [x: string]: V; } +>{} : {} + +}; + +Ns.Multimap3.prototype = { +>Ns.Multimap3.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } +>Ns.Multimap3.prototype : { get(key: K): V; } +>Ns.Multimap3 : typeof Multimap3 +>Ns : typeof Ns +>Multimap3 : typeof Multimap3 +>prototype : { get(key: K): V; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } + + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { +>get : (key: K) => V +>key : K + + return this._map[key + '']; +>this._map[key + ''] : any +>this._map : any +>this : { get(key: K): V; } +>_map : any +>key + '' : string +>key : K +>'' : "" + } +} + + diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment.symbols b/tests/baselines/reference/jsdocTypeFromChainedAssignment.symbols index c2d14050ee1..dbf21cf0925 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment.symbols +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment.symbols @@ -45,17 +45,17 @@ A.s = A.t = function g(m) { >this : Symbol(A, Decl(a.js, 0, 0), Decl(a.js, 8, 1)) } var a = new A() ->a : Symbol(a, Decl(a.js, 13, 3)) +>a : Symbol(a, Decl(a.js, 13, 3), Decl(a.js, 17, 22)) >A : Symbol(A, Decl(a.js, 0, 0), Decl(a.js, 8, 1)) a.y('no') // error >a.y : Symbol(A.y, Decl(a.js, 4, 1)) ->a : Symbol(a, Decl(a.js, 13, 3)) +>a : Symbol(a, Decl(a.js, 13, 3), Decl(a.js, 17, 22)) >y : Symbol(A.y, Decl(a.js, 4, 1)) a.z('not really') // error >a.z : Symbol(A.z, Decl(a.js, 6, 15)) ->a : Symbol(a, Decl(a.js, 13, 3)) +>a : Symbol(a, Decl(a.js, 13, 3), Decl(a.js, 17, 22)) >z : Symbol(A.z, Decl(a.js, 6, 15)) A.s('still no') // error @@ -70,6 +70,6 @@ A.t('not here either') // error a.first = 10 // error: '10' isn't assignable to '1' >a.first : Symbol(A.first, Decl(a.js, 1, 14)) ->a : Symbol(a, Decl(a.js, 13, 3)) +>a : Symbol(a, Decl(a.js, 13, 3), Decl(a.js, 17, 22)) >first : Symbol(A.first, Decl(a.js, 1, 14)) diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt index 14cfbd1ceab..dd5cbe050a9 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt @@ -8,9 +8,12 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(25,18): error tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(26,18): error TS2538: Type 'void' cannot be used as an index type. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(27,18): error TS2538: Type 'undefined' cannot be used as an index type. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(28,18): error TS2538: Type '{ x: string; }' cannot be used as an index type. +tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(29,18): error TS2537: Type 'Shape' has no matching index signature for type 'number'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(29,18): error TS2537: Type 'Shape' has no matching index signature for type 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(30,18): error TS2538: Type 'string & number' cannot be used as an index type. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(31,18): error TS2537: Type 'Shape' has no matching index signature for type 'string'. +tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(31,18): error TS2538: Type 'false' cannot be used as an index type. +tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(31,18): error TS2538: Type 'true' cannot be used as an index type. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(35,21): error TS2537: Type 'string[]' has no matching index signature for type 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(36,21): error TS2538: Type 'boolean' cannot be used as an index type. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(41,31): error TS2538: Type 'boolean' cannot be used as an index type. @@ -60,7 +63,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error Type 'T' is not assignable to type 'U'. -==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (33 errors) ==== +==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (36 errors) ==== class Shape { name: string; width: number; @@ -111,6 +114,8 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error !!! error TS2538: Type '{ x: string; }' cannot be used as an index type. type T20 = Shape[string | number]; // Error ~~~~~~~~~~~~~~~ +!!! error TS2537: Type 'Shape' has no matching index signature for type 'number'. + ~~~~~~~~~~~~~~~ !!! error TS2537: Type 'Shape' has no matching index signature for type 'string'. type T21 = Shape[string & number]; // Error ~~~~~~~~~~~~~~~ @@ -118,6 +123,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error type T22 = Shape[string | boolean]; // Error ~~~~~~~~~~~~~~~~ !!! error TS2537: Type 'Shape' has no matching index signature for type 'string'. + ~~~~~~~~~~~~~~~~ +!!! error TS2538: Type 'false' cannot be used as an index type. + ~~~~~~~~~~~~~~~~ +!!! error TS2538: Type 'true' cannot be used as an index type. type T30 = string[]["length"]; type T31 = string[][number]; diff --git a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt index 2b4a694975b..5e12521ad60 100644 --- a/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt +++ b/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt @@ -1,13 +1,12 @@ -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 'string' is not assignable to type 'number'. +tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. + Types of parameters 'num' and 'str' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'. +tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'. -==== tests/cases/compiler/lastPropertyInLiteralWins.ts (3 errors) ==== +==== tests/cases/compiler/lastPropertyInLiteralWins.ts (4 errors) ==== interface Thing { thunk: (str: string) => void; } @@ -15,20 +14,19 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate thing.thunk("str"); } test({ // Should error, as last one wins, and is wrong type - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ thunk: (str: string) => {}, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. +!!! error TS2322: Types of parameters 'num' and 'str' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing' thunk: (num: number) => {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2300: Duplicate identifier 'thunk'. + ~~~~~ +!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'. +!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing' }); - ~ -!!! 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 'string' is not assignable to type 'number'. test({ // Should be OK. Last 'thunk' is of correct type thunk: (num: number) => {}, diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 354ede66365..d84dc46ef73 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -126,7 +126,7 @@ var rb5 = a5 || a2; // void || boolean is void | boolean >a2 : boolean var rb6 = a6 || a2; // enum || boolean is E | boolean ->rb6 : boolean | E +>rb6 : boolean | E.b | E.c >a6 || a2 : boolean | E.b | E.c >a6 : E >a2 : boolean @@ -246,7 +246,7 @@ var rd5 = a5 || a4; // void || string is void | string >a4 : string var rd6 = a6 || a4; // enum || string is enum | string ->rd6 : string | E +>rd6 : string | E.b | E.c >a6 || a4 : string | E.b | E.c >a6 : E >a4 : string @@ -306,7 +306,7 @@ var re5 = a5 || a5; // void || void is void >a5 : void var re6 = a6 || a5; // enum || void is enum | void ->re6 : void | E +>re6 : void | E.b | E.c >a6 || a5 : void | E.b | E.c >a6 : E >a5 : void @@ -426,7 +426,7 @@ var rh5 = a5 || a7; // void || object is void | object >a7 : { a: string; } var rh6 = a6 || a7; // enum || object is enum | object ->rh6 : E | { a: string; } +>rh6 : E.b | E.c | { a: string; } >a6 || a7 : E.b | E.c | { a: string; } >a6 : E >a7 : { a: string; } @@ -486,7 +486,7 @@ var ri5 = a5 || a8; // void || array is void | array >a8 : string[] var ri6 = a6 || a8; // enum || array is enum | array ->ri6 : E | string[] +>ri6 : E.b | E.c | string[] >a6 || a8 : E.b | E.c | string[] >a6 : E >a8 : string[] @@ -546,7 +546,7 @@ var rj5 = a5 || null; // void || null is void >null : null var rj6 = a6 || null; // enum || null is E ->rj6 : E +>rj6 : E.b | E.c >a6 || null : E.b | E.c >a6 : E >null : null @@ -606,7 +606,7 @@ var rf5 = a5 || undefined; // void || undefined is void >undefined : undefined var rf6 = a6 || undefined; // enum || undefined is E ->rf6 : E +>rf6 : E.b | E.c >a6 || undefined : E.b | E.c >a6 : E >undefined : undefined diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 99d8f9c7ad1..6d78b229fa4 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -27,14 +27,10 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(77,59): error TS2345: A Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(83,58): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'. Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,15): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. - Types of property 'a' are incompatible. - Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,17): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(106,17): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,12): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. - Types of property 'a' are incompatible. - Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,14): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(128,16): error TS2322: Type 'string' is not assignable to type 'number | undefined'. @@ -196,10 +192,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: setState(foo, { }); setState(foo, foo); setState(foo, { a: undefined }); // Error - ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'undefined' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick' setState(foo, { c: true }); // Error ~~~~~~~ !!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. @@ -221,10 +216,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: c.setState({ }); c.setState(foo); c.setState({ a: undefined }); // Error - ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'undefined' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick' c.setState({ c: true }); // Error ~~~~~~~ !!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. diff --git a/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt b/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt index 28bc188f7b6..41edb0f6924 100644 --- a/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeInferenceErrors.errors.txt @@ -1,9 +1,4 @@ -tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'. - Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'. - Types of property 'computed' are incompatible. - Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'. - Types of property 'baz' are incompatible. - Type 'number' is not assignable to type '() => {}'. +tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(16,9): error TS2322: Type 'number' is not assignable to type '() => {}'. ==== tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts (1 errors) ==== @@ -16,29 +11,16 @@ tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS declare function foo(options: { props: P, computed: ComputedOf } & ThisType

): void; foo({ - ~ props: { x: 10, y: 20 }, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ computed: { - ~~~~~~~~~~~~~~~ bar(): number { - ~~~~~~~~~~~~~~~~~~~~~~~ let z = this.bar; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 42; - ~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ baz: 42 - ~~~~~~~~~~~~~~~ + ~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => {}'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts:16:9: The expected type comes from property 'baz' which is declared here on type 'ComputedOf<{ bar: number; baz: {}; }>' } - ~~~~~ }); - ~ -!!! error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'. -!!! error TS2345: Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'. -!!! error TS2345: Types of property 'computed' are incompatible. -!!! error TS2345: Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'. -!!! error TS2345: Types of property 'baz' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type '() => {}'. \ No newline at end of file diff --git a/tests/baselines/reference/mergeWithImportedType.types b/tests/baselines/reference/mergeWithImportedType.types index ff647809287..7ba671ce468 100644 --- a/tests/baselines/reference/mergeWithImportedType.types +++ b/tests/baselines/reference/mergeWithImportedType.types @@ -1,7 +1,7 @@ === tests/cases/compiler/f1.ts === export enum E {X} >E : E ->X : E +>X : E.X === tests/cases/compiler/f2.ts === import {E} from "./f1"; diff --git a/tests/baselines/reference/mergedDeclarations2.types b/tests/baselines/reference/mergedDeclarations2.types index 15b548fa724..5d82d475d85 100644 --- a/tests/baselines/reference/mergedDeclarations2.types +++ b/tests/baselines/reference/mergedDeclarations2.types @@ -3,13 +3,13 @@ enum Foo { >Foo : Foo b ->b : Foo +>b : Foo.b } enum Foo { >Foo : Foo a = b ->a : Foo +>a : Foo.b >b : Foo } diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.types b/tests/baselines/reference/mergedEnumDeclarationCodeGen.types index 84e6a8237e5..1449ddcad6c 100644 --- a/tests/baselines/reference/mergedEnumDeclarationCodeGen.types +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.types @@ -3,16 +3,16 @@ enum E { >E : E a, ->a : E +>a : E.a b = a ->b : E +>b : E.a >a : E } enum E { >E : E c = a ->c : E +>c : E.a >a : E } diff --git a/tests/baselines/reference/missingRequiredDeclare.d.errors.txt b/tests/baselines/reference/missingRequiredDeclare.d.errors.txt index dc713c86d89..a673c948a48 100644 --- a/tests/baselines/reference/missingRequiredDeclare.d.errors.txt +++ b/tests/baselines/reference/missingRequiredDeclare.d.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/missingRequiredDeclare.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. -tests/cases/compiler/missingRequiredDeclare.d.ts(1,7): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/missingRequiredDeclare.d.ts(1,9): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/missingRequiredDeclare.d.ts (2 errors) ==== var x = 1; ~~~ !!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/moduleCodeGenTest5.types b/tests/baselines/reference/moduleCodeGenTest5.types index b49c0c895d2..c0d806d9398 100644 --- a/tests/baselines/reference/moduleCodeGenTest5.types +++ b/tests/baselines/reference/moduleCodeGenTest5.types @@ -36,7 +36,7 @@ class C2{ export enum E1 {A=0} >E1 : E1 ->A : E1 +>A : E1.A >0 : 0 var u = E1.A; @@ -47,7 +47,7 @@ var u = E1.A; enum E2 {B=0} >E2 : E2 ->B : E2 +>B : E2.B >0 : 0 var v = E2.B; diff --git a/tests/baselines/reference/moduleExportAlias5.symbols b/tests/baselines/reference/moduleExportAlias5.symbols index cc9cd7212f4..35e27b4a642 100644 --- a/tests/baselines/reference/moduleExportAlias5.symbols +++ b/tests/baselines/reference/moduleExportAlias5.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/salsa/bug24754.js === // #24754 const webpack = function (){ ->webpack : Symbol(webpack, Decl(bug24754.js, 1, 5)) +>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5), Decl(bug24754.js, 4, 23)) } exports = module.exports = webpack; >exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0)) >module.exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0)) >module : Symbol(export=, Decl(bug24754.js, 3, 9)) >exports : Symbol(export=, Decl(bug24754.js, 3, 9)) ->webpack : Symbol(webpack, Decl(bug24754.js, 1, 5)) +>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5), Decl(bug24754.js, 4, 23)) exports.version = 1001; >exports.version : Symbol(version, Decl(bug24754.js, 3, 35)) @@ -17,6 +17,6 @@ exports.version = 1001; webpack.WebpackOptionsDefaulter = 1111; >webpack.WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23)) ->webpack : Symbol(webpack, Decl(bug24754.js, 1, 5)) +>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5), Decl(bug24754.js, 4, 23)) >WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23)) diff --git a/tests/baselines/reference/moduleExportAssignment2.symbols b/tests/baselines/reference/moduleExportAssignment2.symbols index 25e80647d89..eaafdbefb1f 100644 --- a/tests/baselines/reference/moduleExportAssignment2.symbols +++ b/tests/baselines/reference/moduleExportAssignment2.symbols @@ -9,7 +9,7 @@ var npm = module.exports = function (tree) { module.exports.asReadInstalled = function (tree) { >module.exports.asReadInstalled : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) >module.exports : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) ->module : Symbol(module, Decl(npm.js, 0, 9)) +>module : Symbol(module, Decl(npm.js, 0, 9), Decl(npm.js, 3, 13)) >exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) >asReadInstalled : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) >tree : Symbol(tree, Decl(npm.js, 2, 43)) @@ -20,7 +20,7 @@ module.exports.asReadInstalled = function (tree) { module.exports(tree) >module.exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) ->module : Symbol(module, Decl(npm.js, 3, 13)) +>module : Symbol(module, Decl(npm.js, 0, 9), Decl(npm.js, 3, 13)) >exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) >tree : Symbol(tree, Decl(npm.js, 2, 43)) } diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols index 61ff2fffe8a..1dd9bed92e6 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols @@ -49,27 +49,27 @@ module.exports.bothBefore = 'string' A.justExport = 4 >A.justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) ->A : Symbol(A, Decl(mod1.js, 5, 18)) +>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36)) >justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) A.bothBefore = 2 >A.bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) ->A : Symbol(A, Decl(mod1.js, 5, 18)) +>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36)) >bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) A.bothAfter = 3 >A.bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) ->A : Symbol(A, Decl(mod1.js, 5, 18)) +>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36)) >bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports = A >module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 4, 15)) >exports : Symbol(export=, Decl(mod1.js, 4, 15)) ->A : Symbol(A, Decl(mod1.js, 5, 18)) +>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36)) function A() { ->A : Symbol(A, Decl(mod1.js, 5, 18)) +>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36)) this.p = 1 >p : Symbol(A.p, Decl(mod1.js, 6, 14)) diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types index 1e1f0be5101..fbcc5fa6c43 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types @@ -4,7 +4,7 @@ No type information for this code.export * from "./c"; No type information for this code. No type information for this code.=== tests/cases/compiler/b.ts === export {Animals} from "./c"; ->Animals : typeof Animals +>Animals : typeof import("tests/cases/compiler/c").Animals === tests/cases/compiler/c.ts === export enum Animals { diff --git a/tests/baselines/reference/narrowUnknownByTypeofObject.js b/tests/baselines/reference/narrowUnknownByTypeofObject.js new file mode 100644 index 00000000000..076d91e0df8 --- /dev/null +++ b/tests/baselines/reference/narrowUnknownByTypeofObject.js @@ -0,0 +1,14 @@ +//// [narrowUnknownByTypeofObject.ts] +function foo(x: unknown) { + if (typeof x === "object") { + x + } +} + + +//// [narrowUnknownByTypeofObject.js] +function foo(x) { + if (typeof x === "object") { + x; + } +} diff --git a/tests/baselines/reference/narrowUnknownByTypeofObject.symbols b/tests/baselines/reference/narrowUnknownByTypeofObject.symbols new file mode 100644 index 00000000000..ee3ec77ec04 --- /dev/null +++ b/tests/baselines/reference/narrowUnknownByTypeofObject.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/narrowUnknownByTypeofObject.ts === +function foo(x: unknown) { +>foo : Symbol(foo, Decl(narrowUnknownByTypeofObject.ts, 0, 0)) +>x : Symbol(x, Decl(narrowUnknownByTypeofObject.ts, 0, 13)) + + if (typeof x === "object") { +>x : Symbol(x, Decl(narrowUnknownByTypeofObject.ts, 0, 13)) + + x +>x : Symbol(x, Decl(narrowUnknownByTypeofObject.ts, 0, 13)) + } +} + diff --git a/tests/baselines/reference/narrowUnknownByTypeofObject.types b/tests/baselines/reference/narrowUnknownByTypeofObject.types new file mode 100644 index 00000000000..98225861d1e --- /dev/null +++ b/tests/baselines/reference/narrowUnknownByTypeofObject.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/narrowUnknownByTypeofObject.ts === +function foo(x: unknown) { +>foo : (x: unknown) => void +>x : unknown + + if (typeof x === "object") { +>typeof x === "object" : boolean +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"object" : "object" + + x +>x : object | null + } +} + diff --git a/tests/baselines/reference/narrowingByTypeofInSwitch.js b/tests/baselines/reference/narrowingByTypeofInSwitch.js new file mode 100644 index 00000000000..95ec120a85d --- /dev/null +++ b/tests/baselines/reference/narrowingByTypeofInSwitch.js @@ -0,0 +1,472 @@ +//// [narrowingByTypeofInSwitch.ts] +function assertNever(x: never) { + return x; +} + +function assertNumber(x: number) { + return x; +} + +function assertBoolean(x: boolean) { + return x; +} + +function assertString(x: string) { + return x; +} + +function assertSymbol(x: symbol) { + return x; +} + +function assertFunction(x: Function) { + return x; +} + +function assertObject(x: object) { + return x; +} + +function assertUndefined(x: undefined) { + return x; +} + +function assertAll(x: Basic) { + return x; +} + +function assertStringOrNumber(x: string | number) { + return x; +} + +function assertBooleanOrObject(x: boolean | object) { + return x; +} + +type Basic = number | boolean | string | symbol | object | Function | undefined; + +function testUnion(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertObject(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertNever(x); +} + +function testExtendsUnion(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertAll(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertAll(x); +} + +function testAny(x: any) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertObject(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertAll(x); // is any +} + +function a1(x: string | object | undefined) { + return x; +} + +function testUnionExplicitDefault(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + default: a1(x); return; + } +} + +function testUnionImplicitDefault(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + } + return a1(x); +} + +function testExtendsExplicitDefault(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + default: assertAll(x); return; + + } +} + +function testExtendsImplicitDefault(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + } + return assertAll(x); +} + +type L = (x: number) => string; +type R = { x: string, y: number } + +function exhaustiveChecks(x: number | string | L | R): string { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return x(42); + case 'object': return x.x; + } +} + +function exhaustiveChecksGenerics(x: T): string { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return (x as L)(42); // Can't narrow generic + case 'object': return (x as R).x; // Can't narrow generic + } +} + +function multipleGeneric(xy: X | Y): [X, string] | [Y, number] { + switch (typeof xy) { + case 'function': return [xy, xy(42)]; + case 'object': return [xy, xy.y]; + default: return assertNever(xy); + } +} + +function multipleGenericFuse(xy: X | Y): [X, number] | [Y, string] | [(X | Y)] { + switch (typeof xy) { + case 'function': return [xy, 1]; + case 'object': return [xy, 'two']; + case 'number': return [xy] + } +} + +function multipleGenericExhaustive(xy: X | Y): [X, string] | [Y, number] { + switch (typeof xy) { + case 'object': return [xy, xy.y]; + case 'function': return [xy, xy(42)]; + } +} + +function switchOrdering(x: string | number | boolean) { + switch (typeof x) { + case 'string': return assertString(x); + case 'number': return assertNumber(x); + case 'boolean': return assertBoolean(x); + case 'number': return assertNever(x); + } +} + +function switchOrderingWithDefault(x: string | number | boolean) { + function local(y: string | number | boolean) { + return x; + } + switch (typeof x) { + case 'string': + case 'number': + default: return local(x) + case 'string': return assertNever(x); + case 'number': return assertNever(x); + } +} + +function fallThroughTest(x: string | number | boolean | object) { + switch (typeof x) { + case 'number': + assertNumber(x) + case 'string': + assertStringOrNumber(x) + break; + default: + assertObject(x); + case 'number': + case 'boolean': + assertBooleanOrObject(x); + break; + } +} + + +//// [narrowingByTypeofInSwitch.js] +function assertNever(x) { + return x; +} +function assertNumber(x) { + return x; +} +function assertBoolean(x) { + return x; +} +function assertString(x) { + return x; +} +function assertSymbol(x) { + return x; +} +function assertFunction(x) { + return x; +} +function assertObject(x) { + return x; +} +function assertUndefined(x) { + return x; +} +function assertAll(x) { + return x; +} +function assertStringOrNumber(x) { + return x; +} +function assertBooleanOrObject(x) { + return x; +} +function testUnion(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertFunction(x); + return; + case 'symbol': + assertSymbol(x); + return; + case 'object': + assertObject(x); + return; + case 'string': + assertString(x); + return; + case 'undefined': + assertUndefined(x); + return; + } + assertNever(x); +} +function testExtendsUnion(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertAll(x); + return; + case 'symbol': + assertSymbol(x); + return; + case 'object': + assertAll(x); + return; + case 'string': + assertString(x); + return; + case 'undefined': + assertUndefined(x); + return; + } + assertAll(x); +} +function testAny(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertFunction(x); + return; + case 'symbol': + assertSymbol(x); + return; + case 'object': + assertObject(x); + return; + case 'string': + assertString(x); + return; + case 'undefined': + assertUndefined(x); + return; + } + assertAll(x); // is any +} +function a1(x) { + return x; +} +function testUnionExplicitDefault(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertFunction(x); + return; + case 'symbol': + assertSymbol(x); + return; + default: + a1(x); + return; + } +} +function testUnionImplicitDefault(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertFunction(x); + return; + case 'symbol': + assertSymbol(x); + return; + } + return a1(x); +} +function testExtendsExplicitDefault(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertAll(x); + return; + case 'symbol': + assertSymbol(x); + return; + default: + assertAll(x); + return; + } +} +function testExtendsImplicitDefault(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + return; + case 'boolean': + assertBoolean(x); + return; + case 'function': + assertAll(x); + return; + case 'symbol': + assertSymbol(x); + return; + } + return assertAll(x); +} +function exhaustiveChecks(x) { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return x(42); + case 'object': return x.x; + } +} +function exhaustiveChecksGenerics(x) { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return x(42); // Can't narrow generic + case 'object': return x.x; // Can't narrow generic + } +} +function multipleGeneric(xy) { + switch (typeof xy) { + case 'function': return [xy, xy(42)]; + case 'object': return [xy, xy.y]; + default: return assertNever(xy); + } +} +function multipleGenericFuse(xy) { + switch (typeof xy) { + case 'function': return [xy, 1]; + case 'object': return [xy, 'two']; + case 'number': return [xy]; + } +} +function multipleGenericExhaustive(xy) { + switch (typeof xy) { + case 'object': return [xy, xy.y]; + case 'function': return [xy, xy(42)]; + } +} +function switchOrdering(x) { + switch (typeof x) { + case 'string': return assertString(x); + case 'number': return assertNumber(x); + case 'boolean': return assertBoolean(x); + case 'number': return assertNever(x); + } +} +function switchOrderingWithDefault(x) { + function local(y) { + return x; + } + switch (typeof x) { + case 'string': + case 'number': + default: return local(x); + case 'string': return assertNever(x); + case 'number': return assertNever(x); + } +} +function fallThroughTest(x) { + switch (typeof x) { + case 'number': + assertNumber(x); + case 'string': + assertStringOrNumber(x); + break; + default: + assertObject(x); + case 'number': + case 'boolean': + assertBooleanOrObject(x); + break; + } +} diff --git a/tests/baselines/reference/narrowingByTypeofInSwitch.symbols b/tests/baselines/reference/narrowingByTypeofInSwitch.symbols new file mode 100644 index 00000000000..80246251815 --- /dev/null +++ b/tests/baselines/reference/narrowingByTypeofInSwitch.symbols @@ -0,0 +1,591 @@ +=== tests/cases/compiler/narrowingByTypeofInSwitch.ts === +function assertNever(x: never) { +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 0, 21)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 0, 21)) +} + +function assertNumber(x: number) { +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 4, 22)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 4, 22)) +} + +function assertBoolean(x: boolean) { +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 8, 23)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 8, 23)) +} + +function assertString(x: string) { +>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 12, 22)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 12, 22)) +} + +function assertSymbol(x: symbol) { +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 16, 22)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 16, 22)) +} + +function assertFunction(x: Function) { +>assertFunction : Symbol(assertFunction, Decl(narrowingByTypeofInSwitch.ts, 18, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 20, 24)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 20, 24)) +} + +function assertObject(x: object) { +>assertObject : Symbol(assertObject, Decl(narrowingByTypeofInSwitch.ts, 22, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 24, 22)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 24, 22)) +} + +function assertUndefined(x: undefined) { +>assertUndefined : Symbol(assertUndefined, Decl(narrowingByTypeofInSwitch.ts, 26, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 28, 25)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 28, 25)) +} + +function assertAll(x: Basic) { +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 32, 19)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 32, 19)) +} + +function assertStringOrNumber(x: string | number) { +>assertStringOrNumber : Symbol(assertStringOrNumber, Decl(narrowingByTypeofInSwitch.ts, 34, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 36, 30)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 36, 30)) +} + +function assertBooleanOrObject(x: boolean | object) { +>assertBooleanOrObject : Symbol(assertBooleanOrObject, Decl(narrowingByTypeofInSwitch.ts, 38, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 40, 31)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 40, 31)) +} + +type Basic = number | boolean | string | symbol | object | Function | undefined; +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +function testUnion(x: Basic) { +>testUnion : Symbol(testUnion, Decl(narrowingByTypeofInSwitch.ts, 44, 80)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'function': assertFunction(x); return; +>assertFunction : Symbol(assertFunction, Decl(narrowingByTypeofInSwitch.ts, 18, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'object': assertObject(x); return; +>assertObject : Symbol(assertObject, Decl(narrowingByTypeofInSwitch.ts, 22, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'string': assertString(x); return; +>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + + case 'undefined': assertUndefined(x); return; +>assertUndefined : Symbol(assertUndefined, Decl(narrowingByTypeofInSwitch.ts, 26, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) + } + assertNever(x); +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 46, 19)) +} + +function testExtendsUnion(x: T) { +>testExtendsUnion : Symbol(testExtendsUnion, Decl(narrowingByTypeofInSwitch.ts, 57, 1)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 59, 26)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 59, 26)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'function': assertAll(x); return; +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'object': assertAll(x); return; +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'string': assertString(x); return; +>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + + case 'undefined': assertUndefined(x); return; +>assertUndefined : Symbol(assertUndefined, Decl(narrowingByTypeofInSwitch.ts, 26, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) + } + assertAll(x); +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 59, 43)) +} + +function testAny(x: any) { +>testAny : Symbol(testAny, Decl(narrowingByTypeofInSwitch.ts, 70, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'function': assertFunction(x); return; +>assertFunction : Symbol(assertFunction, Decl(narrowingByTypeofInSwitch.ts, 18, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'object': assertObject(x); return; +>assertObject : Symbol(assertObject, Decl(narrowingByTypeofInSwitch.ts, 22, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'string': assertString(x); return; +>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + + case 'undefined': assertUndefined(x); return; +>assertUndefined : Symbol(assertUndefined, Decl(narrowingByTypeofInSwitch.ts, 26, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) + } + assertAll(x); // is any +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 72, 17)) +} + +function a1(x: string | object | undefined) { +>a1 : Symbol(a1, Decl(narrowingByTypeofInSwitch.ts, 83, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 85, 12)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 85, 12)) +} + +function testUnionExplicitDefault(x: Basic) { +>testUnionExplicitDefault : Symbol(testUnionExplicitDefault, Decl(narrowingByTypeofInSwitch.ts, 87, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + + case 'function': assertFunction(x); return; +>assertFunction : Symbol(assertFunction, Decl(narrowingByTypeofInSwitch.ts, 18, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + + default: a1(x); return; +>a1 : Symbol(a1, Decl(narrowingByTypeofInSwitch.ts, 83, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 89, 34)) + } +} + +function testUnionImplicitDefault(x: Basic) { +>testUnionImplicitDefault : Symbol(testUnionImplicitDefault, Decl(narrowingByTypeofInSwitch.ts, 97, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) + + case 'function': assertFunction(x); return; +>assertFunction : Symbol(assertFunction, Decl(narrowingByTypeofInSwitch.ts, 18, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) + } + return a1(x); +>a1 : Symbol(a1, Decl(narrowingByTypeofInSwitch.ts, 83, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 99, 34)) +} + +function testExtendsExplicitDefault(x: T) { +>testExtendsExplicitDefault : Symbol(testExtendsExplicitDefault, Decl(narrowingByTypeofInSwitch.ts, 107, 1)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 109, 36)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 109, 36)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + case 'function': assertAll(x); return; +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + default: assertAll(x); return; +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 109, 53)) + + } +} + +function testExtendsImplicitDefault(x: T) { +>testExtendsImplicitDefault : Symbol(testExtendsImplicitDefault, Decl(narrowingByTypeofInSwitch.ts, 118, 1)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 120, 36)) +>Basic : Symbol(Basic, Decl(narrowingByTypeofInSwitch.ts, 42, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 120, 36)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) + + case 'number': assertNumber(x); return; +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) + + case 'boolean': assertBoolean(x); return; +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) + + case 'function': assertAll(x); return; +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) + + case 'symbol': assertSymbol(x); return; +>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) + } + return assertAll(x); +>assertAll : Symbol(assertAll, Decl(narrowingByTypeofInSwitch.ts, 30, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 120, 53)) +} + +type L = (x: number) => string; +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 130, 10)) + +type R = { x: string, y: number } +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 131, 10)) +>y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 131, 21)) + +function exhaustiveChecks(x: number | string | L | R): string { +>exhaustiveChecks : Symbol(exhaustiveChecks, Decl(narrowingByTypeofInSwitch.ts, 131, 33)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) + + case 'number': return x.toString(2); +>x.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + + case 'string': return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) + + case 'function': return x(42); +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) + + case 'object': return x.x; +>x.x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 131, 10)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 133, 26)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 131, 10)) + } +} + +function exhaustiveChecksGenerics(x: T): string { +>exhaustiveChecksGenerics : Symbol(exhaustiveChecksGenerics, Decl(narrowingByTypeofInSwitch.ts, 140, 1)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 142, 34)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) +>T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 142, 34)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) + + case 'number': return x.toString(2); +>x.toString : Symbol(toString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 2 more) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) +>toString : Symbol(toString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 2 more) + + case 'string': return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) + + case 'function': return (x as L)(42); // Can't narrow generic +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) + + case 'object': return (x as R).x; // Can't narrow generic +>(x as R).x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 131, 10)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 142, 69)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 131, 10)) + } +} + +function multipleGeneric(xy: X | Y): [X, string] | [Y, number] { +>multipleGeneric : Symbol(multipleGeneric, Decl(narrowingByTypeofInSwitch.ts, 149, 1)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 151, 25)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 151, 37)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 151, 25)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 151, 37)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 151, 25)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 151, 37)) + + switch (typeof xy) { +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) + + case 'function': return [xy, xy(42)]; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) + + case 'object': return [xy, xy.y]; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) +>xy.y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 131, 21)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) +>y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 131, 21)) + + default: return assertNever(xy); +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 151, 51)) + } +} + +function multipleGenericFuse(xy: X | Y): [X, number] | [Y, string] | [(X | Y)] { +>multipleGenericFuse : Symbol(multipleGenericFuse, Decl(narrowingByTypeofInSwitch.ts, 157, 1)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 159, 29)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 159, 50)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 159, 73)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 159, 29)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 159, 50)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 159, 29)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 159, 50)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 159, 29)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 159, 50)) + + switch (typeof xy) { +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 159, 73)) + + case 'function': return [xy, 1]; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 159, 73)) + + case 'object': return [xy, 'two']; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 159, 73)) + + case 'number': return [xy] +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 159, 73)) + } +} + +function multipleGenericExhaustive(xy: X | Y): [X, string] | [Y, number] { +>multipleGenericExhaustive : Symbol(multipleGenericExhaustive, Decl(narrowingByTypeofInSwitch.ts, 165, 1)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 167, 35)) +>L : Symbol(L, Decl(narrowingByTypeofInSwitch.ts, 128, 1)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 167, 47)) +>R : Symbol(R, Decl(narrowingByTypeofInSwitch.ts, 130, 31)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 167, 35)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 167, 47)) +>X : Symbol(X, Decl(narrowingByTypeofInSwitch.ts, 167, 35)) +>Y : Symbol(Y, Decl(narrowingByTypeofInSwitch.ts, 167, 47)) + + switch (typeof xy) { +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) + + case 'object': return [xy, xy.y]; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) +>xy.y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 131, 21)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) +>y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 131, 21)) + + case 'function': return [xy, xy(42)]; +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) +>xy : Symbol(xy, Decl(narrowingByTypeofInSwitch.ts, 167, 61)) + } +} + +function switchOrdering(x: string | number | boolean) { +>switchOrdering : Symbol(switchOrdering, Decl(narrowingByTypeofInSwitch.ts, 172, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + + case 'string': return assertString(x); +>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + + case 'number': return assertNumber(x); +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + + case 'boolean': return assertBoolean(x); +>assertBoolean : Symbol(assertBoolean, Decl(narrowingByTypeofInSwitch.ts, 6, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + + case 'number': return assertNever(x); +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 174, 24)) + } +} + +function switchOrderingWithDefault(x: string | number | boolean) { +>switchOrderingWithDefault : Symbol(switchOrderingWithDefault, Decl(narrowingByTypeofInSwitch.ts, 181, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + + function local(y: string | number | boolean) { +>local : Symbol(local, Decl(narrowingByTypeofInSwitch.ts, 183, 66)) +>y : Symbol(y, Decl(narrowingByTypeofInSwitch.ts, 184, 19)) + + return x; +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + } + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + + case 'string': + case 'number': + default: return local(x) +>local : Symbol(local, Decl(narrowingByTypeofInSwitch.ts, 183, 66)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + + case 'string': return assertNever(x); +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + + case 'number': return assertNever(x); +>assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 183, 35)) + } +} + +function fallThroughTest(x: string | number | boolean | object) { +>fallThroughTest : Symbol(fallThroughTest, Decl(narrowingByTypeofInSwitch.ts, 194, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + switch (typeof x) { +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + case 'number': + assertNumber(x) +>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + case 'string': + assertStringOrNumber(x) +>assertStringOrNumber : Symbol(assertStringOrNumber, Decl(narrowingByTypeofInSwitch.ts, 34, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + break; + default: + assertObject(x); +>assertObject : Symbol(assertObject, Decl(narrowingByTypeofInSwitch.ts, 22, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + case 'number': + case 'boolean': + assertBooleanOrObject(x); +>assertBooleanOrObject : Symbol(assertBooleanOrObject, Decl(narrowingByTypeofInSwitch.ts, 38, 1)) +>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 196, 25)) + + break; + } +} + diff --git a/tests/baselines/reference/narrowingByTypeofInSwitch.types b/tests/baselines/reference/narrowingByTypeofInSwitch.types new file mode 100644 index 00000000000..000eea75f79 --- /dev/null +++ b/tests/baselines/reference/narrowingByTypeofInSwitch.types @@ -0,0 +1,708 @@ +=== tests/cases/compiler/narrowingByTypeofInSwitch.ts === +function assertNever(x: never) { +>assertNever : (x: never) => never +>x : never + + return x; +>x : never +} + +function assertNumber(x: number) { +>assertNumber : (x: number) => number +>x : number + + return x; +>x : number +} + +function assertBoolean(x: boolean) { +>assertBoolean : (x: boolean) => boolean +>x : boolean + + return x; +>x : boolean +} + +function assertString(x: string) { +>assertString : (x: string) => string +>x : string + + return x; +>x : string +} + +function assertSymbol(x: symbol) { +>assertSymbol : (x: symbol) => symbol +>x : symbol + + return x; +>x : symbol +} + +function assertFunction(x: Function) { +>assertFunction : (x: Function) => Function +>x : Function + + return x; +>x : Function +} + +function assertObject(x: object) { +>assertObject : (x: object) => object +>x : object + + return x; +>x : object +} + +function assertUndefined(x: undefined) { +>assertUndefined : (x: undefined) => undefined +>x : undefined + + return x; +>x : undefined +} + +function assertAll(x: Basic) { +>assertAll : (x: Basic) => Basic +>x : Basic + + return x; +>x : Basic +} + +function assertStringOrNumber(x: string | number) { +>assertStringOrNumber : (x: string | number) => string | number +>x : string | number + + return x; +>x : string | number +} + +function assertBooleanOrObject(x: boolean | object) { +>assertBooleanOrObject : (x: boolean | object) => boolean | object +>x : boolean | object + + return x; +>x : boolean | object +} + +type Basic = number | boolean | string | symbol | object | Function | undefined; +>Basic : Basic + +function testUnion(x: Basic) { +>testUnion : (x: Basic) => void +>x : Basic + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : Basic + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : boolean + + case 'function': assertFunction(x); return; +>'function' : "function" +>assertFunction(x) : Function +>assertFunction : (x: Function) => Function +>x : Function + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : symbol + + case 'object': assertObject(x); return; +>'object' : "object" +>assertObject(x) : object +>assertObject : (x: object) => object +>x : object + + case 'string': assertString(x); return; +>'string' : "string" +>assertString(x) : string +>assertString : (x: string) => string +>x : string + + case 'undefined': assertUndefined(x); return; +>'undefined' : "undefined" +>assertUndefined(x) : undefined +>assertUndefined : (x: undefined) => undefined +>x : undefined + } + assertNever(x); +>assertNever(x) : never +>assertNever : (x: never) => never +>x : never +} + +function testExtendsUnion(x: T) { +>testExtendsUnion : (x: T) => void +>x : T + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : T + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : T & number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : (T & false) | (T & true) + + case 'function': assertAll(x); return; +>'function' : "function" +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : T & symbol + + case 'object': assertAll(x); return; +>'object' : "object" +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T + + case 'string': assertString(x); return; +>'string' : "string" +>assertString(x) : string +>assertString : (x: string) => string +>x : T & string + + case 'undefined': assertUndefined(x); return; +>'undefined' : "undefined" +>assertUndefined(x) : undefined +>assertUndefined : (x: undefined) => undefined +>x : T & undefined + } + assertAll(x); +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T +} + +function testAny(x: any) { +>testAny : (x: any) => void +>x : any + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : any + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : boolean + + case 'function': assertFunction(x); return; +>'function' : "function" +>assertFunction(x) : Function +>assertFunction : (x: Function) => Function +>x : any + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : symbol + + case 'object': assertObject(x); return; +>'object' : "object" +>assertObject(x) : object +>assertObject : (x: object) => object +>x : any + + case 'string': assertString(x); return; +>'string' : "string" +>assertString(x) : string +>assertString : (x: string) => string +>x : string + + case 'undefined': assertUndefined(x); return; +>'undefined' : "undefined" +>assertUndefined(x) : undefined +>assertUndefined : (x: undefined) => undefined +>x : undefined + } + assertAll(x); // is any +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : any +} + +function a1(x: string | object | undefined) { +>a1 : (x: string | object | undefined) => string | object | undefined +>x : string | object | undefined + + return x; +>x : string | object | undefined +} + +function testUnionExplicitDefault(x: Basic) { +>testUnionExplicitDefault : (x: Basic) => void +>x : Basic + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : Basic + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : boolean + + case 'function': assertFunction(x); return; +>'function' : "function" +>assertFunction(x) : Function +>assertFunction : (x: Function) => Function +>x : Function + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : symbol + + default: a1(x); return; +>a1(x) : string | object | undefined +>a1 : (x: string | object | undefined) => string | object | undefined +>x : string | object | undefined + } +} + +function testUnionImplicitDefault(x: Basic) { +>testUnionImplicitDefault : (x: Basic) => string | object | undefined +>x : Basic + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : Basic + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : boolean + + case 'function': assertFunction(x); return; +>'function' : "function" +>assertFunction(x) : Function +>assertFunction : (x: Function) => Function +>x : Function + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : symbol + } + return a1(x); +>a1(x) : string | object | undefined +>a1 : (x: string | object | undefined) => string | object | undefined +>x : string | object | undefined +} + +function testExtendsExplicitDefault(x: T) { +>testExtendsExplicitDefault : (x: T) => void +>x : T + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : T + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : T & number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : (T & false) | (T & true) + + case 'function': assertAll(x); return; +>'function' : "function" +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : T & symbol + + default: assertAll(x); return; +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T + + } +} + +function testExtendsImplicitDefault(x: T) { +>testExtendsImplicitDefault : (x: T) => string | number | boolean | symbol | object | undefined +>x : T + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : T + + case 'number': assertNumber(x); return; +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : T & number + + case 'boolean': assertBoolean(x); return; +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : (T & false) | (T & true) + + case 'function': assertAll(x); return; +>'function' : "function" +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T + + case 'symbol': assertSymbol(x); return; +>'symbol' : "symbol" +>assertSymbol(x) : symbol +>assertSymbol : (x: symbol) => symbol +>x : T & symbol + } + return assertAll(x); +>assertAll(x) : Basic +>assertAll : (x: Basic) => Basic +>x : T +} + +type L = (x: number) => string; +>L : L +>x : number + +type R = { x: string, y: number } +>R : R +>x : string +>y : number + +function exhaustiveChecks(x: number | string | L | R): string { +>exhaustiveChecks : (x: string | number | R | L) => string +>x : string | number | R | L + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : string | number | R | L + + case 'number': return x.toString(2); +>'number' : "number" +>x.toString(2) : string +>x.toString : (radix?: number | undefined) => string +>x : number +>toString : (radix?: number | undefined) => string +>2 : 2 + + case 'string': return x; +>'string' : "string" +>x : string + + case 'function': return x(42); +>'function' : "function" +>x(42) : string +>x : L +>42 : 42 + + case 'object': return x.x; +>'object' : "object" +>x.x : string +>x : R +>x : string + } +} + +function exhaustiveChecksGenerics(x: T): string { +>exhaustiveChecksGenerics : (x: T) => string +>x : T + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : T + + case 'number': return x.toString(2); +>'number' : "number" +>x.toString(2) : string +>x.toString : ((radix?: number | undefined) => string) | ((() => string) & ((radix?: number | undefined) => string)) | ((() => string) & ((radix?: number | undefined) => string)) | ((() => string) & ((radix?: number | undefined) => string)) +>x : T & number +>toString : ((radix?: number | undefined) => string) | ((() => string) & ((radix?: number | undefined) => string)) | ((() => string) & ((radix?: number | undefined) => string)) | ((() => string) & ((radix?: number | undefined) => string)) +>2 : 2 + + case 'string': return x; +>'string' : "string" +>x : T & string + + case 'function': return (x as L)(42); // Can't narrow generic +>'function' : "function" +>(x as L)(42) : string +>(x as L) : L +>x as L : L +>x : T +>42 : 42 + + case 'object': return (x as R).x; // Can't narrow generic +>'object' : "object" +>(x as R).x : string +>(x as R) : R +>x as R : R +>x : T +>x : string + } +} + +function multipleGeneric(xy: X | Y): [X, string] | [Y, number] { +>multipleGeneric : (xy: X | Y) => [X, string] | [Y, number] +>xy : X | Y + + switch (typeof xy) { +>typeof xy : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>xy : X | Y + + case 'function': return [xy, xy(42)]; +>'function' : "function" +>[xy, xy(42)] : [X, string] +>xy : X +>xy(42) : string +>xy : X +>42 : 42 + + case 'object': return [xy, xy.y]; +>'object' : "object" +>[xy, xy.y] : [Y, number] +>xy : Y +>xy.y : number +>xy : Y +>y : number + + default: return assertNever(xy); +>assertNever(xy) : never +>assertNever : (x: never) => never +>xy : never + } +} + +function multipleGenericFuse(xy: X | Y): [X, number] | [Y, string] | [(X | Y)] { +>multipleGenericFuse : (xy: X | Y) => [X, number] | [Y, string] | [X | Y] +>xy : X | Y + + switch (typeof xy) { +>typeof xy : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>xy : X | Y + + case 'function': return [xy, 1]; +>'function' : "function" +>[xy, 1] : [X, number] +>xy : X +>1 : 1 + + case 'object': return [xy, 'two']; +>'object' : "object" +>[xy, 'two'] : [Y, string] +>xy : Y +>'two' : "two" + + case 'number': return [xy] +>'number' : "number" +>[xy] : [X | Y] +>xy : X | Y + } +} + +function multipleGenericExhaustive(xy: X | Y): [X, string] | [Y, number] { +>multipleGenericExhaustive : (xy: X | Y) => [X, string] | [Y, number] +>xy : X | Y + + switch (typeof xy) { +>typeof xy : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>xy : X | Y + + case 'object': return [xy, xy.y]; +>'object' : "object" +>[xy, xy.y] : [Y, number] +>xy : Y +>xy.y : number +>xy : Y +>y : number + + case 'function': return [xy, xy(42)]; +>'function' : "function" +>[xy, xy(42)] : [X, string] +>xy : X +>xy(42) : string +>xy : X +>42 : 42 + } +} + +function switchOrdering(x: string | number | boolean) { +>switchOrdering : (x: string | number | boolean) => string | number | boolean +>x : string | number | boolean + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : string | number | boolean + + case 'string': return assertString(x); +>'string' : "string" +>assertString(x) : string +>assertString : (x: string) => string +>x : string + + case 'number': return assertNumber(x); +>'number' : "number" +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'boolean': return assertBoolean(x); +>'boolean' : "boolean" +>assertBoolean(x) : boolean +>assertBoolean : (x: boolean) => boolean +>x : boolean + + case 'number': return assertNever(x); +>'number' : "number" +>assertNever(x) : never +>assertNever : (x: never) => never +>x : never + } +} + +function switchOrderingWithDefault(x: string | number | boolean) { +>switchOrderingWithDefault : (x: string | number | boolean) => string | number | boolean +>x : string | number | boolean + + function local(y: string | number | boolean) { +>local : (y: string | number | boolean) => string | number | boolean +>y : string | number | boolean + + return x; +>x : string | number | boolean + } + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : string | number | boolean + + case 'string': +>'string' : "string" + + case 'number': +>'number' : "number" + + default: return local(x) +>local(x) : string | number | boolean +>local : (y: string | number | boolean) => string | number | boolean +>x : string | number | boolean + + case 'string': return assertNever(x); +>'string' : "string" +>assertNever(x) : never +>assertNever : (x: never) => never +>x : never + + case 'number': return assertNever(x); +>'number' : "number" +>assertNever(x) : never +>assertNever : (x: never) => never +>x : never + } +} + +function fallThroughTest(x: string | number | boolean | object) { +>fallThroughTest : (x: string | number | boolean | object) => void +>x : string | number | boolean | object + + switch (typeof x) { +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : string | number | boolean | object + + case 'number': +>'number' : "number" + + assertNumber(x) +>assertNumber(x) : number +>assertNumber : (x: number) => number +>x : number + + case 'string': +>'string' : "string" + + assertStringOrNumber(x) +>assertStringOrNumber(x) : string | number +>assertStringOrNumber : (x: string | number) => string | number +>x : string | number + + break; + default: + assertObject(x); +>assertObject(x) : object +>assertObject : (x: object) => object +>x : object + + case 'number': +>'number' : "number" + + case 'boolean': +>'boolean' : "boolean" + + assertBooleanOrObject(x); +>assertBooleanOrObject(x) : boolean | object +>assertBooleanOrObject : (x: boolean | object) => boolean | object +>x : boolean | object + + break; + } +} + diff --git a/tests/baselines/reference/noImplicitAnyIndexing.types b/tests/baselines/reference/noImplicitAnyIndexing.types index 702c763c7a8..2bd27cb0c0b 100644 --- a/tests/baselines/reference/noImplicitAnyIndexing.types +++ b/tests/baselines/reference/noImplicitAnyIndexing.types @@ -3,7 +3,7 @@ enum MyEmusEnum { >MyEmusEnum : MyEmusEnum emu ->emu : MyEmusEnum +>emu : MyEmusEnum.emu } // Should be okay; should be a string. diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types index fe34cdbc130..fe10152e90c 100644 --- a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types @@ -3,7 +3,7 @@ enum MyEmusEnum { >MyEmusEnum : MyEmusEnum emu ->emu : MyEmusEnum +>emu : MyEmusEnum.emu } // Should be okay; should be a string. diff --git a/tests/baselines/reference/nonExportedElementsOfMergedModules.types b/tests/baselines/reference/nonExportedElementsOfMergedModules.types index e0a11ecb6de..cd929474fac 100644 --- a/tests/baselines/reference/nonExportedElementsOfMergedModules.types +++ b/tests/baselines/reference/nonExportedElementsOfMergedModules.types @@ -4,7 +4,7 @@ module One { enum A { X } >A : A ->X : A +>X : A.X module B { >B : typeof B @@ -19,7 +19,7 @@ module One { enum A { Y } >A : A ->Y : A +>Y : A.Y module B { >B : typeof B diff --git a/tests/baselines/reference/nullAssignableToEveryType.types b/tests/baselines/reference/nullAssignableToEveryType.types index 1dd8cf400e7..e39c5121b2c 100644 --- a/tests/baselines/reference/nullAssignableToEveryType.types +++ b/tests/baselines/reference/nullAssignableToEveryType.types @@ -17,7 +17,7 @@ var ai: I; enum E { A } >E : E ->A : E +>A : E.A var ae: E; >ae : E diff --git a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types index f598b4d7782..8139c9bcd76 100644 --- a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types +++ b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types @@ -219,7 +219,7 @@ var r12 = true ? null : c2; enum E { A } >E : E ->A : E +>A : E.A var r13 = true ? E : null; >r13 : typeof E diff --git a/tests/baselines/reference/numberAssignableToEnum.types b/tests/baselines/reference/numberAssignableToEnum.types index 44fa0ed042e..8b70b7f0e68 100644 --- a/tests/baselines/reference/numberAssignableToEnum.types +++ b/tests/baselines/reference/numberAssignableToEnum.types @@ -1,7 +1,7 @@ === tests/cases/conformance/types/typeRelationships/assignmentCompatibility/numberAssignableToEnum.ts === enum E { A } >E : E ->A : E +>A : E.A var n: number; >n : number diff --git a/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt b/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt index 0d064af3935..6ced1a767de 100644 --- a/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt +++ b/tests/baselines/reference/objectLitTargetTypeCallSite.errors.txt @@ -1,6 +1,4 @@ -tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'. - Types of property 'a' are incompatible. - Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,10): error TS2322: Type 'true' is not assignable to type 'number'. ==== tests/cases/compiler/objectLitTargetTypeCallSite.ts (1 errors) ==== @@ -9,7 +7,6 @@ tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument } process({a:true,b:"y"}); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file + ~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/objectLitTargetTypeCallSite.ts:1:23: The expected type comes from property 'a' which is declared here on type '{ a: number; b: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.js b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.js new file mode 100644 index 00000000000..5c5e5feccd8 --- /dev/null +++ b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.js @@ -0,0 +1,29 @@ +//// [objectLiteralComputedNameNoDeclarationError.ts] +const Foo = { + BANANA: 'banana' as 'banana', +} + +export const Baa = { + [Foo.BANANA]: 1 +}; + +//// [objectLiteralComputedNameNoDeclarationError.js] +"use strict"; +exports.__esModule = true; +var _a; +var Foo = { + BANANA: 'banana' +}; +exports.Baa = (_a = {}, + _a[Foo.BANANA] = 1, + _a); + + +//// [objectLiteralComputedNameNoDeclarationError.d.ts] +declare const Foo: { + BANANA: "banana"; +}; +export declare const Baa: { + [Foo.BANANA]: number; +}; +export {}; diff --git a/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.symbols b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.symbols new file mode 100644 index 00000000000..dce3f633b10 --- /dev/null +++ b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts === +const Foo = { +>Foo : Symbol(Foo, Decl(objectLiteralComputedNameNoDeclarationError.ts, 0, 5)) + + BANANA: 'banana' as 'banana', +>BANANA : Symbol(BANANA, Decl(objectLiteralComputedNameNoDeclarationError.ts, 0, 13)) +} + +export const Baa = { +>Baa : Symbol(Baa, Decl(objectLiteralComputedNameNoDeclarationError.ts, 4, 12)) + + [Foo.BANANA]: 1 +>[Foo.BANANA] : Symbol([Foo.BANANA], Decl(objectLiteralComputedNameNoDeclarationError.ts, 4, 20)) +>Foo.BANANA : Symbol(BANANA, Decl(objectLiteralComputedNameNoDeclarationError.ts, 0, 13)) +>Foo : Symbol(Foo, Decl(objectLiteralComputedNameNoDeclarationError.ts, 0, 5)) +>BANANA : Symbol(BANANA, Decl(objectLiteralComputedNameNoDeclarationError.ts, 0, 13)) + +}; diff --git a/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.types b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.types new file mode 100644 index 00000000000..17ef7ff584d --- /dev/null +++ b/tests/baselines/reference/objectLiteralComputedNameNoDeclarationError.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts === +const Foo = { +>Foo : { BANANA: "banana"; } +>{ BANANA: 'banana' as 'banana',} : { BANANA: "banana"; } + + BANANA: 'banana' as 'banana', +>BANANA : "banana" +>'banana' as 'banana' : "banana" +>'banana' : "banana" +} + +export const Baa = { +>Baa : { [Foo.BANANA]: number; } +>{ [Foo.BANANA]: 1} : { [Foo.BANANA]: number; } + + [Foo.BANANA]: 1 +>[Foo.BANANA] : number +>Foo.BANANA : "banana" +>Foo : { BANANA: "banana"; } +>BANANA : "banana" +>1 : 1 + +}; diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 0117d2c0c8c..9fa7176779f 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -4,12 +4,9 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS Property 'doStuff' is missing in type '{ value: string; }'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'what' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. - Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2322: Type '(s: string) => string' is not assignable to type '() => string'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. ==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts (6 errors) ==== @@ -33,14 +30,14 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) - ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. + ~~~~~~~~ +!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' f2({ toString: (s: string) => s }) - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. + ~~~~~~~~ +!!! error TS2322: Type '(s: string) => string' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' f2({ value: '', toString: (s) => s.uhhh }) - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'. \ No newline at end of file + ~~~~~~~~ +!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2' \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index e36842e4f69..7a425857bd6 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -2,9 +2,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,81): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,87): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. - Types of property 'id' are incompatible. - Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,13): error TS2322: Type 'number' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (4 errors) ==== @@ -25,9 +23,8 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:6:43: The expected type comes from property 'id' which is declared here on type '{ id: string; name: number; }' function bar(obj: { name: string; id: boolean }) { } bar({ name, id }); // error - ~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. -!!! error TS2345: Types of property 'id' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'boolean'. + ~~ +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:7:35: The expected type comes from property 'id' which is declared here on type '{ name: string; id: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 92225755c71..1af05906873 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -18,15 +18,9 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339 tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(82,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (20 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -138,23 +132,4 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322 f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - - // excess property checks - type A = { a: string, b: string }; - type Extra = { a: string, b: string, extra: string }; - const extra1: A = { a: "a", b: "b", extra: "extra" }; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. - const extra2 = { a: "a", b: "b", extra: "extra" }; - const a1: A = { ...extra1 }; // error spans should be here - const a2: A = { ...extra2 }; // not on the symbol declarations above - ~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. - const extra3: Extra = { a: "a", b: "b", extra: "extra" }; - const a3: A = { ...extra3 }; // same here - ~~ -!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. -!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 63ae8914385..35d8cdf9830 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -73,16 +73,6 @@ let overlapConflict: { id:string, a: string } = f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - -// excess property checks -type A = { a: string, b: string }; -type Extra = { a: string, b: string, extra: string }; -const extra1: A = { a: "a", b: "b", extra: "extra" }; -const extra2 = { a: "a", b: "b", extra: "extra" }; -const a1: A = { ...extra1 }; // error spans should be here -const a2: A = { ...extra2 }; // not on the symbol declarations above -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; -const a3: A = { ...extra3 }; // same here //// [objectSpreadNegative.js] @@ -167,9 +157,3 @@ var exclusive = f({ a: 1, b: 'yes' }, { c: 'no', d: false }); var overlap = f({ a: 1 }, { a: 2, b: 'extra' }); var overlapConflict = f({ a: 1 }, { a: 'mismatch' }); var overwriteId = f({ a: 1, id: true }, { c: 1, d: 'no' }); -var extra1 = { a: "a", b: "b", extra: "extra" }; -var extra2 = { a: "a", b: "b", extra: "extra" }; -var a1 = __assign({}, extra1); // error spans should be here -var a2 = __assign({}, extra2); // not on the symbol declarations above -var extra3 = { a: "a", b: "b", extra: "extra" }; -var a3 = __assign({}, extra3); // same here diff --git a/tests/baselines/reference/objectSpreadNegative.symbols b/tests/baselines/reference/objectSpreadNegative.symbols index 21af20facbb..4bff16d9be6 100644 --- a/tests/baselines/reference/objectSpreadNegative.symbols +++ b/tests/baselines/reference/objectSpreadNegative.symbols @@ -243,50 +243,3 @@ let overwriteId: { id: string, a: number, c: number, d: string } = >c : Symbol(c, Decl(objectSpreadNegative.ts, 73, 27)) >d : Symbol(d, Decl(objectSpreadNegative.ts, 73, 33)) -// excess property checks -type A = { a: string, b: string }; ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 76, 10)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 76, 21)) - -type Extra = { a: string, b: string, extra: string }; ->Extra : Symbol(Extra, Decl(objectSpreadNegative.ts, 76, 34)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 77, 14)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 77, 25)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 77, 36)) - -const extra1: A = { a: "a", b: "b", extra: "extra" }; ->extra1 : Symbol(extra1, Decl(objectSpreadNegative.ts, 78, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 78, 19)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 78, 27)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 78, 35)) - -const extra2 = { a: "a", b: "b", extra: "extra" }; ->extra2 : Symbol(extra2, Decl(objectSpreadNegative.ts, 79, 5)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 79, 16)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 79, 24)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 79, 32)) - -const a1: A = { ...extra1 }; // error spans should be here ->a1 : Symbol(a1, Decl(objectSpreadNegative.ts, 80, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra1 : Symbol(extra1, Decl(objectSpreadNegative.ts, 78, 5)) - -const a2: A = { ...extra2 }; // not on the symbol declarations above ->a2 : Symbol(a2, Decl(objectSpreadNegative.ts, 81, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra2 : Symbol(extra2, Decl(objectSpreadNegative.ts, 79, 5)) - -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; ->extra3 : Symbol(extra3, Decl(objectSpreadNegative.ts, 82, 5)) ->Extra : Symbol(Extra, Decl(objectSpreadNegative.ts, 76, 34)) ->a : Symbol(a, Decl(objectSpreadNegative.ts, 82, 23)) ->b : Symbol(b, Decl(objectSpreadNegative.ts, 82, 31)) ->extra : Symbol(extra, Decl(objectSpreadNegative.ts, 82, 39)) - -const a3: A = { ...extra3 }; // same here ->a3 : Symbol(a3, Decl(objectSpreadNegative.ts, 83, 5)) ->A : Symbol(A, Decl(objectSpreadNegative.ts, 73, 44)) ->extra3 : Symbol(extra3, Decl(objectSpreadNegative.ts, 82, 5)) - diff --git a/tests/baselines/reference/objectSpreadNegative.types b/tests/baselines/reference/objectSpreadNegative.types index 0d0eab1c35d..26fd5642d23 100644 --- a/tests/baselines/reference/objectSpreadNegative.types +++ b/tests/baselines/reference/objectSpreadNegative.types @@ -325,60 +325,3 @@ let overwriteId: { id: string, a: number, c: number, d: string } = >d : string >'no' : "no" -// excess property checks -type A = { a: string, b: string }; ->A : A ->a : string ->b : string - -type Extra = { a: string, b: string, extra: string }; ->Extra : Extra ->a : string ->b : string ->extra : string - -const extra1: A = { a: "a", b: "b", extra: "extra" }; ->extra1 : A ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const extra2 = { a: "a", b: "b", extra: "extra" }; ->extra2 : { a: string; b: string; extra: string; } ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const a1: A = { ...extra1 }; // error spans should be here ->a1 : A ->{ ...extra1 } : { a: string; b: string; } ->extra1 : A - -const a2: A = { ...extra2 }; // not on the symbol declarations above ->a2 : A ->{ ...extra2 } : { a: string; b: string; extra: string; } ->extra2 : { a: string; b: string; extra: string; } - -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; ->extra3 : Extra ->{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } ->a : string ->"a" : "a" ->b : string ->"b" : "b" ->extra : string ->"extra" : "extra" - -const a3: A = { ...extra3 }; // same here ->a3 : A ->{ ...extra3 } : { a: string; b: string; extra: string; } ->extra3 : Extra - diff --git a/tests/baselines/reference/objectTypesIdentity2.types b/tests/baselines/reference/objectTypesIdentity2.types index 3877fade0db..aa61a461507 100644 --- a/tests/baselines/reference/objectTypesIdentity2.types +++ b/tests/baselines/reference/objectTypesIdentity2.types @@ -33,7 +33,7 @@ var a: { foo: RegExp; } enum E { A } >E : E ->A : E +>A : E.A var b = { foo: E.A }; >b : { foo: E; } diff --git a/tests/baselines/reference/operatorAddNullUndefined.errors.txt b/tests/baselines/reference/operatorAddNullUndefined.errors.txt index c6a74080394..acd65de3417 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.errors.txt +++ b/tests/baselines/reference/operatorAddNullUndefined.errors.txt @@ -6,10 +6,10 @@ tests/cases/compiler/operatorAddNullUndefined.ts(6,10): error TS2365: Operator ' tests/cases/compiler/operatorAddNullUndefined.ts(7,10): error TS2365: Operator '+' cannot be applied to types '1' and 'undefined'. tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2365: Operator '+' cannot be applied to types 'null' and '1'. tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and '1'. -tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2365: Operator '+' cannot be applied to types 'null' and 'E'. -tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'. -tests/cases/compiler/operatorAddNullUndefined.ts(16,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(17,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2365: Operator '+' cannot be applied to types 'null' and 'E.x'. +tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.x'. +tests/cases/compiler/operatorAddNullUndefined.ts(16,11): error TS2365: Operator '+' cannot be applied to types 'E.x' and 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(17,11): error TS2365: Operator '+' cannot be applied to types 'E.x' and 'undefined'. ==== tests/cases/compiler/operatorAddNullUndefined.ts (12 errors) ==== @@ -44,13 +44,13 @@ tests/cases/compiler/operatorAddNullUndefined.ts(17,11): error TS2365: Operator var x12 = undefined + "test"; var x13 = null + E.x ~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E'. +!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E.x'. var x14 = undefined + E.x ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'. +!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.x'. var x15 = E.x + null ~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'null'. +!!! error TS2365: Operator '+' cannot be applied to types 'E.x' and 'null'. var x16 = E.x + undefined ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'. \ No newline at end of file +!!! error TS2365: Operator '+' cannot be applied to types 'E.x' and 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/operatorAddNullUndefined.types b/tests/baselines/reference/operatorAddNullUndefined.types index 63b389f70f4..c24acd2a7ec 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.types +++ b/tests/baselines/reference/operatorAddNullUndefined.types @@ -1,7 +1,7 @@ === tests/cases/compiler/operatorAddNullUndefined.ts === enum E { x } >E : E ->x : E +>x : E.x var x1 = null + null; >x1 : any diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index f78f691d6eb..9ecf802f043 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,6): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,16): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (3 errors) ==== function foo([x,y,z]?: [string, number, boolean]) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -13,6 +13,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): er foo(["", 0, false]); foo([false, 0, ""]); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt index f8b1aa73b2a..80f93ca8b64 100644 --- a/tests/baselines/reference/optionalBindingParameters2.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. - Types of property 'x' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,7): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,23): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (3 errors) ==== function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -14,7 +13,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): er foo({ x: "", y: 0, z: false }); foo({ x: false, y: 0, z: "" }); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt index d8e1c3c4aa6..5401ef79f2b 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,6): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,16): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (2 errors) ==== function foo([x, y, z] ?: [string, number, boolean]); function foo(...rest: any[]) { @@ -11,6 +11,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1. foo(["", 0, false]); foo([false, 0, ""]); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt index acc5c3721bb..86913394da6 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt @@ -1,9 +1,8 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. - Types of property 'x' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,7): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,23): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (2 errors) ==== function foo({ x, y, z }?: { x: string; y: number; z: boolean }); function foo(...rest: any[]) { @@ -12,7 +11,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2. foo({ x: "", y: 0, z: false }); foo({ x: false, y: 0, z: "" }); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. -!!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }' \ No newline at end of file diff --git a/tests/baselines/reference/overloadResolutionTest1.errors.txt b/tests/baselines/reference/overloadResolutionTest1.errors.txt index b36684db501..53ee7873472 100644 --- a/tests/baselines/reference/overloadResolutionTest1.errors.txt +++ b/tests/baselines/reference/overloadResolutionTest1.errors.txt @@ -2,12 +2,8 @@ tests/cases/compiler/overloadResolutionTest1.ts(7,16): error TS2345: Argument of Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'boolean'. -tests/cases/compiler/overloadResolutionTest1.ts(18,15): error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'boolean'. -tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'. - Types of property 'a' are incompatible. - Type 'boolean' is not assignable to type 'string'. +tests/cases/compiler/overloadResolutionTest1.ts(18,16): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/compiler/overloadResolutionTest1.ts(24,15): error TS2322: Type 'true' is not assignable to type 'string'. ==== tests/cases/compiler/overloadResolutionTest1.ts (3 errors) ==== @@ -34,17 +30,15 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument o var x2 = foo2({a:0}); // works var x3 = foo2({a:true}); // works var x4 = foo2({a:"s"}); // error - ~~~~~~~ -!!! error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:13:20: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }' function foo4(bar:{a:number;}):number; function foo4(bar:{a:string;}):string; function foo4(bar:{a:any;}):any{ return bar }; var x = foo4({a:true}); // error - ~~~~~~~~ -!!! error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'. -!!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string'. +!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:22:20: The expected type comes from property 'a' which is declared here on type '{ a: string; }' \ No newline at end of file diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.types b/tests/baselines/reference/overrideBaseIntersectionMethod.types index 57d06fe648f..3ca80a06a1a 100644 --- a/tests/baselines/reference/overrideBaseIntersectionMethod.types +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.types @@ -78,9 +78,9 @@ class Foo extends WithLocation(Point) { return super.getLocation() >super.getLocation() : [number, number] ->super.getLocation : () => [number, number] +>super.getLocation : (() => [number, number]) & (() => [number, number]) >super : WithLocation.(Anonymous class) & Point ->getLocation : () => [number, number] +>getLocation : (() => [number, number]) & (() => [number, number]) } whereAmI() { >whereAmI : () => [number, number] diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt index 94f4175f5e5..73f4f27d08b 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt @@ -55,4 +55,6 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29 class Foo { constructor(public x = 12, public y = x) {} } + + function f8(foo1: string, bar = foo1) { } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.js b/tests/baselines/reference/parameterInitializersForwardReferencing1.js index bb3a4c87e69..bd2b62e4216 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.js +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.js @@ -34,6 +34,8 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } //// [parameterInitializersForwardReferencing1.js] @@ -81,3 +83,6 @@ var Foo = /** @class */ (function () { } return Foo; }()); +function f8(foo1, bar) { + if (bar === void 0) { bar = foo1; } +} diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols b/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols index 10f94a2bd64..74b00fe04b8 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.symbols @@ -84,3 +84,9 @@ class Foo { >x : Symbol(x, Decl(parameterInitializersForwardReferencing1.ts, 33, 16)) } +function f8(foo1: string, bar = foo1) { } +>f8 : Symbol(f8, Decl(parameterInitializersForwardReferencing1.ts, 34, 1)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1.ts, 36, 12)) +>bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1.ts, 36, 25)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1.ts, 36, 12)) + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.types b/tests/baselines/reference/parameterInitializersForwardReferencing1.types index d6eee6a9c30..2b80bfe87e0 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.types +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.types @@ -92,3 +92,9 @@ class Foo { >x : number } +function f8(foo1: string, bar = foo1) { } +>f8 : (foo1: string, bar?: string) => void +>foo1 : string +>bar : string +>foo1 : string + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt index d84519e406e..ce4368081f1 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt @@ -1,21 +1,31 @@ +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(3,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(8,27): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(13,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(21,18): error TS2372: Parameter 'a' cannot be referenced in its initializer. tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(25,22): error TS2372: Parameter 'async' cannot be referenced in its initializer. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(29,15): error TS2448: Block-scoped variable 'foo' used before its declaration. -==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts (2 errors) ==== +==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts (6 errors) ==== let foo: string = ""; function f1 (bar = foo) { // unexpected compiler error; works at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. var foo: number = 2; return bar; // returns 1 } function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. var foo: number = 2; return bar(); // returns 1 } function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. return bar; } @@ -36,10 +46,15 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t } function f7({[foo]: bar}: any[]) { + ~~~ +!!! error TS2448: Block-scoped variable 'foo' used before its declaration. +!!! related TS2728 tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts:30:9: 'foo' is declared here. let foo: number = 2; } class Foo { constructor(public x = 12, public y = x) {} } + + function f8(foo1: string, bar = foo1) { } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js index a5b00cfeb44..ecabb8ceba9 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.js @@ -34,6 +34,8 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } //// [parameterInitializersForwardReferencing1_es6.js] @@ -67,3 +69,4 @@ class Foo { this.y = y; } } +function f8(foo1, bar = foo1) { } diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols index 3d678a021ba..b44c91e8afd 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols @@ -5,7 +5,7 @@ let foo: string = ""; function f1 (bar = foo) { // unexpected compiler error; works at runtime >f1 : Symbol(f1, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 21)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 2, 13)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 3, 7)) var foo: number = 2; >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 3, 7)) @@ -18,7 +18,7 @@ function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at >f2 : Symbol(f2, Decl(parameterInitializersForwardReferencing1_es6.ts, 5, 1)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 13)) >baz : Symbol(baz, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 20)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 8, 7)) >baz : Symbol(baz, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 20)) var foo: number = 2; @@ -31,7 +31,7 @@ function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime >f3 : Symbol(f3, Decl(parameterInitializersForwardReferencing1_es6.ts, 10, 1)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 13)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 23)) >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 23)) return bar; @@ -42,7 +42,7 @@ function f4 (foo, bar = foo) { >f4 : Symbol(f4, Decl(parameterInitializersForwardReferencing1_es6.ts, 14, 1)) >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 13)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 17)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 13)) return bar >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 16, 17)) @@ -68,7 +68,7 @@ function f6 (async = async) { function f7({[foo]: bar}: any[]) { >f7 : Symbol(f7, Decl(parameterInitializersForwardReferencing1_es6.ts, 26, 1)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 29, 7)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 28, 13)) let foo: number = 2; @@ -84,3 +84,9 @@ class Foo { >x : Symbol(x, Decl(parameterInitializersForwardReferencing1_es6.ts, 33, 16)) } +function f8(foo1: string, bar = foo1) { } +>f8 : Symbol(f8, Decl(parameterInitializersForwardReferencing1_es6.ts, 34, 1)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 12)) +>bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 25)) +>foo1 : Symbol(foo1, Decl(parameterInitializersForwardReferencing1_es6.ts, 36, 12)) + diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types index ca8ae55557e..a58d19c5755 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types @@ -4,54 +4,54 @@ let foo: string = ""; >"" : "" function f1 (bar = foo) { // unexpected compiler error; works at runtime ->f1 : (bar?: string) => string ->bar : string ->foo : string +>f1 : (bar?: number) => number +>bar : number +>foo : number var foo: number = 2; >foo : number >2 : 2 return bar; // returns 1 ->bar : string +>bar : number } function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime ->f2 : (bar?: (baz?: string) => string) => string ->bar : (baz?: string) => string ->(baz = foo) => baz : (baz?: string) => string ->baz : string ->foo : string ->baz : string +>f2 : (bar?: (baz?: number) => number) => number +>bar : (baz?: number) => number +>(baz = foo) => baz : (baz?: number) => number +>baz : number +>foo : number +>baz : number var foo: number = 2; >foo : number >2 : 2 return bar(); // returns 1 ->bar() : string ->bar : (baz?: string) => string +>bar() : number +>bar : (baz?: number) => number } function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime ->f3 : (bar?: string, foo?: number) => string ->bar : string ->foo : string +>f3 : (bar?: number, foo?: number) => number +>bar : number +>foo : number >foo : number >2 : 2 return bar; ->bar : string +>bar : number } function f4 (foo, bar = foo) { ->f4 : (foo: any, bar?: string) => string +>f4 : (foo: any, bar?: any) => any +>foo : any +>bar : any >foo : any ->bar : string ->foo : string return bar ->bar : string +>bar : any } function f5 (a = a) { @@ -74,7 +74,7 @@ function f6 (async = async) { function f7({[foo]: bar}: any[]) { >f7 : ({ [foo]: bar }: any[]) => void ->foo : string +>foo : number >bar : any let foo: number = 2; @@ -92,3 +92,9 @@ class Foo { >x : number } +function f8(foo1: string, bar = foo1) { } +>f8 : (foo1: string, bar?: string) => void +>foo1 : string +>bar : string +>foo1 : string + diff --git a/tests/baselines/reference/parameterListAsTupleType.errors.txt b/tests/baselines/reference/parameterListAsTupleType.errors.txt new file mode 100644 index 00000000000..021138ec2ba --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/parameterListAsTupleType.ts(8,17): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/parameterListAsTupleType.ts(16,23): error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any[]) => any'. + Type 'typeof C' provides no match for the signature '(...args: any[]): any'. + + +==== tests/cases/compiler/parameterListAsTupleType.ts (2 errors) ==== + function foo(a: number, b: string) { + return true; + } + type Foops = Parameters; + + const x = (a: number) => 5; + type Xps = Parameters; + const a: Xps = ['should-not-work']; // works, but shouldn't + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + function t(...args: Xps) {} // should work + + class C { + constructor(a: number, b: string) { + } + } + + type Cps = Parameters; // should not work + ~~~~~~~~ +!!! error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Type 'typeof C' provides no match for the signature '(...args: any[]): any'. + type Ccps = ConstructorParameters; // should be [number, string] + + class D { + constructor(a: number, ...rest: string[]) { + } + } + type Dcps = ConstructorParameters; // should be [number, ...string[]] + \ No newline at end of file diff --git a/tests/baselines/reference/parameterListAsTupleType.js b/tests/baselines/reference/parameterListAsTupleType.js new file mode 100644 index 00000000000..0c831e36edb --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.js @@ -0,0 +1,52 @@ +//// [parameterListAsTupleType.ts] +function foo(a: number, b: string) { + return true; +} +type Foops = Parameters; + +const x = (a: number) => 5; +type Xps = Parameters; +const a: Xps = ['should-not-work']; // works, but shouldn't +function t(...args: Xps) {} // should work + +class C { + constructor(a: number, b: string) { + } +} + +type Cps = Parameters; // should not work +type Ccps = ConstructorParameters; // should be [number, string] + +class D { + constructor(a: number, ...rest: string[]) { + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] + + +//// [parameterListAsTupleType.js] +function foo(a, b) { + return true; +} +var x = function (a) { return 5; }; +var a = ['should-not-work']; // works, but shouldn't +function t() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} // should work +var C = /** @class */ (function () { + function C(a, b) { + } + return C; +}()); +var D = /** @class */ (function () { + function D(a) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return D; +}()); diff --git a/tests/baselines/reference/parameterListAsTupleType.symbols b/tests/baselines/reference/parameterListAsTupleType.symbols new file mode 100644 index 00000000000..fc09e66c180 --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.symbols @@ -0,0 +1,63 @@ +=== tests/cases/compiler/parameterListAsTupleType.ts === +function foo(a: number, b: string) { +>foo : Symbol(foo, Decl(parameterListAsTupleType.ts, 0, 0)) +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 0, 13)) +>b : Symbol(b, Decl(parameterListAsTupleType.ts, 0, 23)) + + return true; +} +type Foops = Parameters; +>Foops : Symbol(Foops, Decl(parameterListAsTupleType.ts, 2, 1)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(parameterListAsTupleType.ts, 0, 0)) + +const x = (a: number) => 5; +>x : Symbol(x, Decl(parameterListAsTupleType.ts, 5, 5)) +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 5, 11)) + +type Xps = Parameters; +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(parameterListAsTupleType.ts, 5, 5)) + +const a: Xps = ['should-not-work']; // works, but shouldn't +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 7, 5)) +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) + +function t(...args: Xps) {} // should work +>t : Symbol(t, Decl(parameterListAsTupleType.ts, 7, 35)) +>args : Symbol(args, Decl(parameterListAsTupleType.ts, 8, 11)) +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) + +class C { +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + + constructor(a: number, b: string) { +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 11, 16)) +>b : Symbol(b, Decl(parameterListAsTupleType.ts, 11, 26)) + } +} + +type Cps = Parameters; // should not work +>Cps : Symbol(Cps, Decl(parameterListAsTupleType.ts, 13, 1)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + +type Ccps = ConstructorParameters; // should be [number, string] +>Ccps : Symbol(Ccps, Decl(parameterListAsTupleType.ts, 15, 32)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + +class D { +>D : Symbol(D, Decl(parameterListAsTupleType.ts, 16, 44)) + + constructor(a: number, ...rest: string[]) { +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 19, 16)) +>rest : Symbol(rest, Decl(parameterListAsTupleType.ts, 19, 26)) + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] +>Dcps : Symbol(Dcps, Decl(parameterListAsTupleType.ts, 21, 1)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>D : Symbol(D, Decl(parameterListAsTupleType.ts, 16, 44)) + diff --git a/tests/baselines/reference/parameterListAsTupleType.types b/tests/baselines/reference/parameterListAsTupleType.types new file mode 100644 index 00000000000..3bb861f5a1d --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.types @@ -0,0 +1,61 @@ +=== tests/cases/compiler/parameterListAsTupleType.ts === +function foo(a: number, b: string) { +>foo : (a: number, b: string) => boolean +>a : number +>b : string + + return true; +>true : true +} +type Foops = Parameters; +>Foops : [number, string] +>foo : (a: number, b: string) => boolean + +const x = (a: number) => 5; +>x : (a: number) => number +>(a: number) => 5 : (a: number) => number +>a : number +>5 : 5 + +type Xps = Parameters; +>Xps : [number] +>x : (a: number) => number + +const a: Xps = ['should-not-work']; // works, but shouldn't +>a : [number] +>['should-not-work'] : [string] +>'should-not-work' : "should-not-work" + +function t(...args: Xps) {} // should work +>t : (a: number) => void +>args : [number] + +class C { +>C : C + + constructor(a: number, b: string) { +>a : number +>b : string + } +} + +type Cps = Parameters; // should not work +>Cps : never +>C : typeof C + +type Ccps = ConstructorParameters; // should be [number, string] +>Ccps : [number, string] +>C : typeof C + +class D { +>D : D + + constructor(a: number, ...rest: string[]) { +>a : number +>rest : string[] + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] +>Dcps : [number, ...string[]] +>D : typeof D + diff --git a/tests/baselines/reference/parseEntityNameWithReservedWord.types b/tests/baselines/reference/parseEntityNameWithReservedWord.types index 551125c55ac..e3024dae16e 100644 --- a/tests/baselines/reference/parseEntityNameWithReservedWord.types +++ b/tests/baselines/reference/parseEntityNameWithReservedWord.types @@ -1,7 +1,7 @@ === tests/cases/compiler/parseEntityNameWithReservedWord.ts === enum Bool { false } >Bool : Bool ->false : Bool +>false : Bool.false const x: Bool.false = Bool.false; >x : Bool diff --git a/tests/baselines/reference/parserComputedPropertyName16.types b/tests/baselines/reference/parserComputedPropertyName16.types index b6440d89f0f..0ccd4470d9d 100644 --- a/tests/baselines/reference/parserComputedPropertyName16.types +++ b/tests/baselines/reference/parserComputedPropertyName16.types @@ -3,7 +3,7 @@ enum E { >E : E [e] = 1 ->[e] : E +>[e] : E.__computed >e : any >1 : 1 } diff --git a/tests/baselines/reference/parserES5ComputedPropertyName6.types b/tests/baselines/reference/parserES5ComputedPropertyName6.types index cbfa5ec1f8d..61d9fa24b9a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName6.types +++ b/tests/baselines/reference/parserES5ComputedPropertyName6.types @@ -3,7 +3,7 @@ enum E { >E : E [e] = 1 ->[e] : E +>[e] : E.__computed >e : any >1 : 1 } diff --git a/tests/baselines/reference/parserEnum5.types b/tests/baselines/reference/parserEnum5.types index 5d9e30c0932..c49a62333e0 100644 --- a/tests/baselines/reference/parserEnum5.types +++ b/tests/baselines/reference/parserEnum5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts === enum E2 { a, } >E2 : E2 ->a : E2 +>a : E2.a enum E3 { a: 1, } >E3 : E3 diff --git a/tests/baselines/reference/parserEnumDeclaration3.d.types b/tests/baselines/reference/parserEnumDeclaration3.d.types index 4b741ec38ef..090556475ea 100644 --- a/tests/baselines/reference/parserEnumDeclaration3.d.types +++ b/tests/baselines/reference/parserEnumDeclaration3.d.types @@ -3,6 +3,6 @@ enum E { >E : E A = 1 ->A : E +>A : E.A >1 : 1 } diff --git a/tests/baselines/reference/parserEnumDeclaration3.types b/tests/baselines/reference/parserEnumDeclaration3.types index 027f837229f..de3e32fcbcf 100644 --- a/tests/baselines/reference/parserEnumDeclaration3.types +++ b/tests/baselines/reference/parserEnumDeclaration3.types @@ -3,6 +3,6 @@ declare enum E { >E : E A = 1 ->A : E +>A : E.A >1 : 1 } diff --git a/tests/baselines/reference/parserInterfaceKeywordInEnum.types b/tests/baselines/reference/parserInterfaceKeywordInEnum.types index aa71126883d..f648c3d2796 100644 --- a/tests/baselines/reference/parserInterfaceKeywordInEnum.types +++ b/tests/baselines/reference/parserInterfaceKeywordInEnum.types @@ -3,6 +3,6 @@ enum Bar { >Bar : Bar interface, ->interface : Bar +>interface : Bar.interface } diff --git a/tests/baselines/reference/parserInterfaceKeywordInEnum1.types b/tests/baselines/reference/parserInterfaceKeywordInEnum1.types index 57c4ef2ebec..687e01b4654 100644 --- a/tests/baselines/reference/parserInterfaceKeywordInEnum1.types +++ b/tests/baselines/reference/parserInterfaceKeywordInEnum1.types @@ -6,6 +6,6 @@ enum Bar { >Bar : Bar interface, ->interface : Bar +>interface : Bar.interface } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.errors.txt b/tests/baselines/reference/parserModifierOnStatementInBlock2.errors.txt index d863bf7143e..c990b08efc1 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.errors.txt +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts(2,4): error TS1184: Modifiers cannot appear here. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts(2,18): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts(2,20): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts (2 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStateme declare var x = this; ~~~~~~~ !!! error TS1184: Modifiers cannot appear here. - ~ + ~~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserVariableStatement1.d.errors.txt b/tests/baselines/reference/parserVariableStatement1.d.errors.txt index de0bef5288c..eb6f799df74 100644 --- a/tests/baselines/reference/parserVariableStatement1.d.errors.txt +++ b/tests/baselines/reference/parserVariableStatement1.d.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. -tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts(1,7): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts(1,9): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts (2 errors) ==== var v = 1; ~~~ !!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - ~ + ~ !!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/preserveConstEnums.types b/tests/baselines/reference/preserveConstEnums.types index 9f2d30a3604..ded9ca90d74 100644 --- a/tests/baselines/reference/preserveConstEnums.types +++ b/tests/baselines/reference/preserveConstEnums.types @@ -3,8 +3,8 @@ const enum E { >E : E Value = 1, Value2 = Value ->Value : E +>Value : E.Value >1 : 1 ->Value2 : E +>Value2 : E.Value >Value : E } diff --git a/tests/baselines/reference/primtiveTypesAreIdentical.types b/tests/baselines/reference/primtiveTypesAreIdentical.types index f84a6257b8c..43b9f2e785a 100644 --- a/tests/baselines/reference/primtiveTypesAreIdentical.types +++ b/tests/baselines/reference/primtiveTypesAreIdentical.types @@ -67,7 +67,7 @@ function foo5(x: any) { } enum E { A } >E : E ->A : E +>A : E.A function foo6(x: E); >foo6 : { (x: E): any; (x: E): any; } diff --git a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.errors.txt b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.errors.txt new file mode 100644 index 00000000000..ee17bd087a1 --- /dev/null +++ b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/salsa/bug24658.js(1,10): error TS2440: Import declaration conflicts with local declaration of 'hurk'. + + +==== tests/cases/conformance/salsa/mod1.js (0 errors) ==== + export var hurk = {} +==== tests/cases/conformance/salsa/bug24658.js (1 errors) ==== + import { hurk } from './mod1' + ~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'hurk'. + hurk.expando = 4 + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.symbols b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.symbols index f8d01ae6981..453816e38cf 100644 --- a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.symbols +++ b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.symbols @@ -4,8 +4,10 @@ export var hurk = {} === tests/cases/conformance/salsa/bug24658.js === import { hurk } from './mod1' ->hurk : Symbol(hurk, Decl(bug24658.js, 0, 8)) +>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8), Decl(bug24658.js, 0, 29)) hurk.expando = 4 ->hurk : Symbol(hurk, Decl(bug24658.js, 0, 8)) +>hurk.expando : Symbol(hurk.expando, Decl(bug24658.js, 0, 29)) +>hurk : Symbol(hurk, Decl(bug24658.js, 0, 8), Decl(bug24658.js, 0, 29)) +>expando : Symbol(hurk.expando, Decl(bug24658.js, 0, 29)) diff --git a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types index 8df4f984574..53930f09a65 100644 --- a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types +++ b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types @@ -5,12 +5,12 @@ export var hurk = {} === tests/cases/conformance/salsa/bug24658.js === import { hurk } from './mod1' ->hurk : {} +>hurk : typeof hurk hurk.expando = 4 >hurk.expando = 4 : 4 ->hurk.expando : any ->hurk : {} ->expando : any +>hurk.expando : number +>hurk : typeof hurk +>expando : number >4 : 4 diff --git a/tests/baselines/reference/reachabilityChecks1.errors.txt b/tests/baselines/reference/reachabilityChecks1.errors.txt index 041d10bfecd..97fd5302d45 100644 --- a/tests/baselines/reference/reachabilityChecks1.errors.txt +++ b/tests/baselines/reference/reachabilityChecks1.errors.txt @@ -3,11 +3,9 @@ tests/cases/compiler/reachabilityChecks1.ts(6,5): error TS7027: Unreachable code tests/cases/compiler/reachabilityChecks1.ts(18,5): error TS7027: Unreachable code detected. tests/cases/compiler/reachabilityChecks1.ts(30,5): error TS7027: Unreachable code detected. tests/cases/compiler/reachabilityChecks1.ts(47,5): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(60,5): error TS7027: Unreachable code detected. -tests/cases/compiler/reachabilityChecks1.ts(69,5): error TS7027: Unreachable code detected. -==== tests/cases/compiler/reachabilityChecks1.ts (7 errors) ==== +==== tests/cases/compiler/reachabilityChecks1.ts (5 errors) ==== while (true); var x = 1; ~~~~~~~~~~ @@ -83,12 +81,8 @@ tests/cases/compiler/reachabilityChecks1.ts(69,5): error TS7027: Unreachable cod do { } while (true); enum E { - ~~~~~~~~ X = 1 - ~~~~~~~~~~~~~ } - ~~~~~ -!!! error TS7027: Unreachable code detected. } function f4() { @@ -96,12 +90,8 @@ tests/cases/compiler/reachabilityChecks1.ts(69,5): error TS7027: Unreachable cod throw new Error(); } const enum E { - ~~~~~~~~~~~~~~ X = 1 - ~~~~~~~~~~~~~ } - ~~~~~ -!!! error TS7027: Unreachable code detected. } \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks1.types b/tests/baselines/reference/reachabilityChecks1.types index 1f74c302c64..6d054748ab9 100644 --- a/tests/baselines/reference/reachabilityChecks1.types +++ b/tests/baselines/reference/reachabilityChecks1.types @@ -61,7 +61,7 @@ module A4 { module A { const enum E { X } >E : E ->X : E +>X : E.X } } @@ -112,7 +112,7 @@ function f3() { >E : E X = 1 ->X : E +>X : E.X >1 : 1 } } @@ -131,7 +131,7 @@ function f4() { >E : E X = 1 ->X : E +>X : E.X >1 : 1 } } diff --git a/tests/baselines/reference/reachabilityChecks2.types b/tests/baselines/reference/reachabilityChecks2.types index 6268ca5012e..351f2c27adc 100644 --- a/tests/baselines/reference/reachabilityChecks2.types +++ b/tests/baselines/reference/reachabilityChecks2.types @@ -4,7 +4,7 @@ while (true) { } const enum E { X } >E : E ->X : E +>X : E.X module A4 { >A4 : typeof A4 @@ -15,7 +15,7 @@ module A4 { module A { const enum E { X } >E : E ->X : E +>X : E.X } } diff --git a/tests/baselines/reference/recursiveTypeRelations.types b/tests/baselines/reference/recursiveTypeRelations.types index 893986d2dab..3ca21ccd8e5 100644 --- a/tests/baselines/reference/recursiveTypeRelations.types +++ b/tests/baselines/reference/recursiveTypeRelations.types @@ -58,9 +58,9 @@ export function css(styles: S, ...classNam >"string" : "string" return styles[arg]; ->styles[arg] : S[keyof S] +>styles[arg] : S[keyof S & string] >styles : S ->arg : keyof S +>arg : keyof S & string } if (typeof arg == "object") { >typeof arg == "object" : boolean diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types index 37204b21d09..8d84e2a9d35 100644 --- a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types @@ -9,10 +9,10 @@ export class ThingB { } === tests/cases/compiler/Things.ts === export {ThingA} from "./ThingA"; ->ThingA : typeof ThingA +>ThingA : typeof import("tests/cases/compiler/ThingA").ThingA export {ThingB} from "./ThingB"; ->ThingB : typeof ThingB +>ThingB : typeof import("tests/cases/compiler/ThingB").ThingB === tests/cases/compiler/Test.ts === import * as things from "./Things"; diff --git a/tests/baselines/reference/requireOfJsonFileInJsFile.errors.txt b/tests/baselines/reference/requireOfJsonFileInJsFile.errors.txt new file mode 100644 index 00000000000..dcc976a1b5b --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileInJsFile.errors.txt @@ -0,0 +1,38 @@ +/user.js(2,7): error TS2339: Property 'b' does not exist on type '{ "a": number; }'. +/user.js(5,7): error TS2322: Type '{ "a": number; }' is not assignable to type '{ b: number; }'. + Property 'b' is missing in type '{ "a": number; }'. +/user.js(9,7): error TS2339: Property 'b' does not exist on type '{ "a": number; }'. +/user.js(12,7): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. + Property 'b' is missing in type '{ a: number; }'. + + +==== /user.js (4 errors) ==== + const json0 = require("./json.json"); + json0.b; // Error (good) + ~ +!!! error TS2339: Property 'b' does not exist on type '{ "a": number; }'. + + /** @type {{ b: number }} */ + const json1 = require("./json.json"); // No error (bad) + ~~~~~ +!!! error TS2322: Type '{ "a": number; }' is not assignable to type '{ b: number; }'. +!!! error TS2322: Property 'b' is missing in type '{ "a": number; }'. + json1.b; // No error (OK since that's the type annotation) + + const js0 = require("./js.js"); + json0.b; // Error (good) + ~ +!!! error TS2339: Property 'b' does not exist on type '{ "a": number; }'. + + /** @type {{ b: number }} */ + const js1 = require("./js.js"); // Error (good) + ~~~ +!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: number; }'. + js1.b; +==== /json.json (0 errors) ==== + { "a": 0 } + +==== /js.js (0 errors) ==== + module.exports = { a: 0 }; + \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileInJsFile.symbols b/tests/baselines/reference/requireOfJsonFileInJsFile.symbols new file mode 100644 index 00000000000..2a1e9b6ebd3 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileInJsFile.symbols @@ -0,0 +1,50 @@ +=== /user.js === +const json0 = require("./json.json"); +>json0 : Symbol(json0, Decl(user.js, 0, 5)) +>require : Symbol(require) +>"./json.json" : Symbol("/json", Decl(json.json, 0, 0)) + +json0.b; // Error (good) +>json0 : Symbol(json0, Decl(user.js, 0, 5)) + +/** @type {{ b: number }} */ +const json1 = require("./json.json"); // No error (bad) +>json1 : Symbol(json1, Decl(user.js, 4, 5)) +>require : Symbol(require) +>"./json.json" : Symbol("/json", Decl(json.json, 0, 0)) + +json1.b; // No error (OK since that's the type annotation) +>json1.b : Symbol(b, Decl(user.js, 3, 12)) +>json1 : Symbol(json1, Decl(user.js, 4, 5)) +>b : Symbol(b, Decl(user.js, 3, 12)) + +const js0 = require("./js.js"); +>js0 : Symbol(js0, Decl(user.js, 7, 5)) +>require : Symbol(require) +>"./js.js" : Symbol("/js", Decl(js.js, 0, 0)) + +json0.b; // Error (good) +>json0 : Symbol(json0, Decl(user.js, 0, 5)) + +/** @type {{ b: number }} */ +const js1 = require("./js.js"); // Error (good) +>js1 : Symbol(js1, Decl(user.js, 11, 5)) +>require : Symbol(require) +>"./js.js" : Symbol("/js", Decl(js.js, 0, 0)) + +js1.b; +>js1.b : Symbol(b, Decl(user.js, 10, 12)) +>js1 : Symbol(js1, Decl(user.js, 11, 5)) +>b : Symbol(b, Decl(user.js, 10, 12)) + +=== /json.json === +{ "a": 0 } +>"a" : Symbol("a", Decl(json.json, 0, 1)) + +=== /js.js === +module.exports = { a: 0 }; +>module.exports : Symbol("/js", Decl(js.js, 0, 0)) +>module : Symbol(export=, Decl(js.js, 0, 0)) +>exports : Symbol(export=, Decl(js.js, 0, 0)) +>a : Symbol(a, Decl(js.js, 0, 18)) + diff --git a/tests/baselines/reference/requireOfJsonFileInJsFile.types b/tests/baselines/reference/requireOfJsonFileInJsFile.types new file mode 100644 index 00000000000..b069c87c395 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileInJsFile.types @@ -0,0 +1,63 @@ +=== /user.js === +const json0 = require("./json.json"); +>json0 : { "a": number; } +>require("./json.json") : { "a": number; } +>require : any +>"./json.json" : "./json.json" + +json0.b; // Error (good) +>json0.b : any +>json0 : { "a": number; } +>b : any + +/** @type {{ b: number }} */ +const json1 = require("./json.json"); // No error (bad) +>json1 : { b: number; } +>require("./json.json") : { "a": number; } +>require : any +>"./json.json" : "./json.json" + +json1.b; // No error (OK since that's the type annotation) +>json1.b : number +>json1 : { b: number; } +>b : number + +const js0 = require("./js.js"); +>js0 : { a: number; } +>require("./js.js") : { a: number; } +>require : any +>"./js.js" : "./js.js" + +json0.b; // Error (good) +>json0.b : any +>json0 : { "a": number; } +>b : any + +/** @type {{ b: number }} */ +const js1 = require("./js.js"); // Error (good) +>js1 : { b: number; } +>require("./js.js") : { a: number; } +>require : any +>"./js.js" : "./js.js" + +js1.b; +>js1.b : number +>js1 : { b: number; } +>b : number + +=== /json.json === +{ "a": 0 } +>{ "a": 0 } : { "a": number; } +>"a" : number +>0 : 0 + +=== /js.js === +module.exports = { a: 0 }; +>module.exports = { a: 0 } : { a: number; } +>module.exports : { a: number; } +>module : { "/js": { a: number; }; } +>exports : { a: number; } +>{ a: 0 } : { a: number; } +>a : number +>0 : 0 + diff --git a/tests/baselines/reference/requireOfJsonFileTypes.types b/tests/baselines/reference/requireOfJsonFileTypes.types index d9cd38cd58f..d4587696fc7 100644 --- a/tests/baselines/reference/requireOfJsonFileTypes.types +++ b/tests/baselines/reference/requireOfJsonFileTypes.types @@ -6,10 +6,10 @@ import c = require('./c.json'); >c : (string | null)[] import d = require('./d.json'); ->d : "dConfig" +>d : string import e = require('./e.json'); ->e : -10 +>e : number import f = require('./f.json'); >f : number[] @@ -64,14 +64,14 @@ const stringOrNumberOrNull: string | number | null = c[0]; >0 : 0 stringLiteral = d; ->stringLiteral = d : "dConfig" +>stringLiteral = d : string >stringLiteral : string ->d : "dConfig" +>d : string numberLiteral = e; ->numberLiteral = e : -10 +>numberLiteral = e : number >numberLiteral : number ->e : -10 +>e : number numberLiteral = f[0]; >numberLiteral = f[0] : number diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmd.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmd.errors.txt deleted file mode 100644 index eab6745285b..00000000000 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmd.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. - - -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. -==== tests/cases/compiler/file1.ts (0 errors) ==== - import * as b from './b.json'; - -==== tests/cases/compiler/b.json (0 errors) ==== - { - "a": true, - "b": "hello" - } \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.js b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.js new file mode 100644 index 00000000000..f6aa6d997be --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.ts] //// + +//// [file1.ts] +import * as b from './b.json'; + +//// [b.json] +{ + "a": true, + "b": "hello" +} + +//// [out/output.js] +define("b", [], { + "a": true, + "b": "hello" +}); +define("file1", ["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; +}); diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.symbols b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.symbols new file mode 100644 index 00000000000..827f2e674e6 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === +import * as b from './b.json'; +>b : Symbol(b, Decl(file1.ts, 0, 6)) + +=== tests/cases/compiler/b.json === +{ + "a": true, +>"a" : Symbol("a", Decl(b.json, 0, 1)) + + "b": "hello" +>"b" : Symbol("b", Decl(b.json, 1, 14)) +} diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.types b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.types new file mode 100644 index 00000000000..9e5cc29d342 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === +import * as b from './b.json'; +>b : { "a": boolean; "b": string; } + +=== tests/cases/compiler/b.json === +{ +>{ "a": true, "b": "hello"} : { "a": boolean; "b": string; } + + "a": true, +>"a" : boolean +>true : true + + "b": "hello" +>"b" : string +>"hello" : "hello" +} diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEs2015.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEs2015.errors.txt deleted file mode 100644 index eab6745285b..00000000000 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEs2015.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. - - -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. -==== tests/cases/compiler/file1.ts (0 errors) ==== - import * as b from './b.json'; - -==== tests/cases/compiler/b.json (0 errors) ==== - { - "a": true, - "b": "hello" - } \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEsNext.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEsNext.errors.txt deleted file mode 100644 index b9c37651205..00000000000 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitEsNext.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. - - -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. -==== tests/cases/compiler/file1.ts (0 errors) ==== - import * as b from './b.json'; - -==== tests/cases/compiler/b.json (0 errors) ==== - { - "a": true, - "b": "hello" - } \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt index 8a40ac52e90..6772461f487 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt @@ -1,8 +1,8 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. tests/cases/compiler/file1.ts(1,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. ==== tests/cases/compiler/file1.ts (1 errors) ==== import * as b from './b.json'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt index eab6745285b..8b570387ce7 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt @@ -1,7 +1,7 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. ==== tests/cases/compiler/file1.ts (0 errors) ==== import * as b from './b.json'; diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt index eab6745285b..8b570387ce7 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt @@ -1,7 +1,7 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'. +!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. ==== tests/cases/compiler/file1.ts (0 errors) ==== import * as b from './b.json'; diff --git a/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.js b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.js new file mode 100644 index 00000000000..b9ae124f1ef --- /dev/null +++ b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.js @@ -0,0 +1,14 @@ +//// [scannerNonAsciiHorizontalWhitespace.ts] +//// [scannerNonAsciiHorizontalWhitespace.ts] +"  function f() {}" + +//// [scannerNonAsciiHorizontalWhitespace.js] +"  function f() {}" + + + +//// [scannerNonAsciiHorizontalWhitespace.js] +//// [scannerNonAsciiHorizontalWhitespace.ts] +"  function f() {}"; +//// [scannerNonAsciiHorizontalWhitespace.js] +"  function f() {}"; diff --git a/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.symbols b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.symbols new file mode 100644 index 00000000000..8a7fdec1d33 --- /dev/null +++ b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/scanner/ecmascript5/scannerNonAsciiHorizontalWhitespace.ts === +//// [scannerNonAsciiHorizontalWhitespace.ts] +No type information for this code."  function f() {}" +No type information for this code. +No type information for this code.//// [scannerNonAsciiHorizontalWhitespace.js] +No type information for this code."  function f() {}" +No type information for this code. +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.types b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.types new file mode 100644 index 00000000000..5d68e59d73b --- /dev/null +++ b/tests/baselines/reference/scannerNonAsciiHorizontalWhitespace.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/scanner/ecmascript5/scannerNonAsciiHorizontalWhitespace.ts === +//// [scannerNonAsciiHorizontalWhitespace.ts] +"  function f() {}" +>"  function f() {}" : "  function f() {}" + +//// [scannerNonAsciiHorizontalWhitespace.js] +"  function f() {}" +>"  function f() {}" : "  function f() {}" + + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.js.map index 0dff86fd1d4..1f97726f1a7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatement.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatement.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatement.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrD,IAAA,mBAAW,CAAY;AACvB,IAAA,mBAAW,EAAE,qBAAa,CAAY;AACxC,IAAA,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,CAA+C;AAC/E,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatement.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatement.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrD,IAAA,mBAAW,CAAY;AACvB,IAAA,mBAAW,EAAE,qBAAa,CAAY;AACxC,IAAA,8CAA0E,EAAxE,eAAW,EAAE,iBAA2D,CAAC;AAC/E,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.sourcemap.txt index c00af2dfdbc..5ff8c099993 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.sourcemap.txt @@ -181,15 +181,15 @@ sourceFile:sourceMapValidationDestructuringVariableStatement.ts 4 > 5 > name: nameC 6 > , -7 > skill: skillC -8 > } = { name: "Edger", skill: "cutting edges" }; +7 > skill: skillC } = { name: "Edger", skill: "cutting edges" } +8 > ; 1->Emitted(6, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(6, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(6, 51) Source(13, 79) + SourceIndex(0) 4 >Emitted(6, 53) Source(13, 7) + SourceIndex(0) 5 >Emitted(6, 68) Source(13, 18) + SourceIndex(0) 6 >Emitted(6, 70) Source(13, 20) + SourceIndex(0) -7 >Emitted(6, 87) Source(13, 33) + SourceIndex(0) +7 >Emitted(6, 87) Source(13, 79) + SourceIndex(0) 8 >Emitted(6, 88) Source(13, 80) + SourceIndex(0) --- >>>if (nameA == nameB) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.js.map index 5b9c754af1b..76680cf4481 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatement1.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatement1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatement1.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACvD,IAAA,CAAS,EAAI,mBAAW,CAAY;AACpC,IAAA,CAAS,EAAI,mBAAW,EAAE,qBAAa,CAAY;AACnD,IAAA,CAAS,EAAE,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,CAA+C;AAEpF,IAAA,mBAAW,EAAa,CAAC,GAAG,KAAK,CAAC;AAClC,IAAA,mBAAW,EAAE,qBAAa,EAAa,CAAC,GAAG,QAAQ,CAAC;AACtD,IAAA,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,EAAgD,CAAC,GAAG,KAAK,CAAC;AAE1F,IAAI,CAAC,GAAG,KAAK,EAAI,mBAAW,EAAa,EAAE,GAAE,OAAO,CAAC;AACrD,IAAI,CAAC,GAAG,KAAK,EAAI,mBAAW,EAAE,qBAAa,EAAa,EAAE,GAAG,OAAO,CAAC;AACrE,IAAI,CAAC,GAAG,KAAK,EAAE,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,EAAgD,EAAE,GAAG,KAAK,CAAC;AACtG,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatement1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatement1.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACvD,IAAA,CAAS,EAAI,mBAAW,CAAY;AACpC,IAAA,CAAS,EAAI,mBAAW,EAAE,qBAAa,CAAY;AACnD,IAAA,CAAS,EAAE,8CAA0E,EAAxE,eAAW,EAAE,iBAA2D,CAAC;AAEpF,IAAA,mBAAW,EAAa,CAAC,GAAG,KAAK,CAAC;AAClC,IAAA,mBAAW,EAAE,qBAAa,EAAa,CAAC,GAAG,QAAQ,CAAC;AACtD,IAAA,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,EAAgD,CAAC,GAAG,KAAK,CAAC;AAE1F,IAAI,CAAC,GAAG,KAAK,EAAI,mBAAW,EAAa,EAAE,GAAE,OAAO,CAAC;AACrD,IAAI,CAAC,GAAG,KAAK,EAAI,mBAAW,EAAE,qBAAa,EAAa,EAAE,GAAG,OAAO,CAAC;AACrE,IAAI,CAAC,GAAG,KAAK,EAAE,8CAA0E,EAAxE,eAAW,EAAE,iBAAa,EAAgD,EAAE,GAAG,KAAK,CAAC;AACtG,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.sourcemap.txt index 16a63b61c34..bddfdd1c4d2 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.sourcemap.txt @@ -197,8 +197,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatement1.ts 6 > 7 > name: nameC 8 > , -9 > skill: skillC -10> } = { name: "Edger", skill: "cutting edges" }; +9 > skill: skillC } = { name: "Edger", skill: "cutting edges" } +10> ; 1->Emitted(6, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(6, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(6, 6) Source(13, 14) + SourceIndex(0) @@ -207,7 +207,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatement1.ts 6 >Emitted(6, 56) Source(13, 18) + SourceIndex(0) 7 >Emitted(6, 71) Source(13, 29) + SourceIndex(0) 8 >Emitted(6, 73) Source(13, 31) + SourceIndex(0) -9 >Emitted(6, 90) Source(13, 44) + SourceIndex(0) +9 >Emitted(6, 90) Source(13, 90) + SourceIndex(0) 10>Emitted(6, 91) Source(13, 91) + SourceIndex(0) --- >>>var nameA = robotA.name, a = hello; diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js.map index 919575fe393..d619484eefe 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern.ts"],"names":[],"mappings":"AAIA,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAGxC,IAAA,iBAAK,CAAW;AAClB,IAAA,mBAAO,CAAW;AAClB,IAAA,oBAAQ,EAAE,kBAAM,EAAE,mBAAO,CAAW;AAEpC,IAAA,6CAAQ,CAAoC;AAC7C,IAAA,oCAA0D,EAAzD,eAAO,EAAE,aAAK,EAAE,cAAM,CAAoC;AAE1D,IAAA,oBAAQ,EAAE,4BAAa,CAAW;AAEvC,IAAI,KAAK,IAAI,MAAM,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACxB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern.ts"],"names":[],"mappings":"AAIA,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAGxC,IAAA,iBAAK,CAAW;AAClB,IAAA,mBAAO,CAAW;AAClB,IAAA,oBAAQ,EAAE,kBAAM,EAAE,mBAAO,CAAW;AAEpC,IAAA,6CAAQ,CAAoC;AAC7C,IAAA,oCAA0D,EAAzD,eAAO,EAAE,aAAK,EAAE,cAAyC,CAAC;AAE1D,IAAA,oBAAQ,EAAE,4BAAa,CAAW;AAEvC,IAAI,KAAK,IAAI,MAAM,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACxB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.sourcemap.txt index da763a77037..308e55de910 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.sourcemap.txt @@ -188,8 +188,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern. 6 > , 7 > nameC 8 > , -9 > skillC -10> ] = [3, "edging", "Trimming edges"]; +9 > skillC] = [3, "edging", "Trimming edges"] +10> ; 1->Emitted(7, 1) Source(14, 5) + SourceIndex(0) 2 >Emitted(7, 5) Source(14, 5) + SourceIndex(0) 3 >Emitted(7, 41) Source(14, 63) + SourceIndex(0) @@ -198,7 +198,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern. 6 >Emitted(7, 60) Source(14, 15) + SourceIndex(0) 7 >Emitted(7, 73) Source(14, 20) + SourceIndex(0) 8 >Emitted(7, 75) Source(14, 22) + SourceIndex(0) -9 >Emitted(7, 89) Source(14, 28) + SourceIndex(0) +9 >Emitted(7, 89) Source(14, 63) + SourceIndex(0) 10>Emitted(7, 90) Source(14, 64) + SourceIndex(0) --- >>>var numberA3 = robotA[0], robotAInfo = robotA.slice(1); diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js.map index f33092aef99..59de11c1256 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.ts"],"names":[],"mappings":"AAIA,IAAI,WAAW,GAAsB,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/D,IAAI,WAAW,GAAsB,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElE,IAAA,uBAAM,CAAgB;AACxB,IAAA,uBAAM,CAAgB;AACtB,IAAA,uBAAM,EAAE,mBAAgC,EAA/B,qBAAa,EAAE,uBAAe,CAAiB;AAExD,IAAA,6CAAM,CAAsC;AAC7C,IAAA,sCAA+E,EAA9E,eAAO,EAAE,UAAgC,EAA/B,qBAAa,EAAE,uBAAe,CAAuC;AAE/E,IAAA,sCAAkB,CAAgB;AAEvC,IAAI,MAAM,IAAI,MAAM,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.ts"],"names":[],"mappings":"AAIA,IAAI,WAAW,GAAsB,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/D,IAAI,WAAW,GAAsB,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElE,IAAA,uBAAM,CAAgB;AACxB,IAAA,uBAAM,CAAgB;AACtB,IAAA,uBAAM,EAAE,mBAAgC,EAA/B,qBAAa,EAAE,uBAAgB,CAAgB;AAExD,IAAA,6CAAM,CAAsC;AAC7C,IAAA,sCAA+E,EAA9E,eAAO,EAAE,UAAgC,EAA/B,qBAAa,EAAE,uBAAqD,CAAC;AAE/E,IAAA,sCAAkB,CAAgB;AAEvC,IAAI,MAAM,IAAI,MAAM,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.sourcemap.txt index d445ea559c9..12f78509a8e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.sourcemap.txt @@ -155,8 +155,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern2 6 > 7 > primarySkillA 8 > , -9 > secondarySkillA -10> ]] = multiRobotA; +9 > secondarySkillA] +10> ] = multiRobotA; 1->Emitted(5, 1) Source(10, 6) + SourceIndex(0) 2 >Emitted(5, 5) Source(10, 6) + SourceIndex(0) 3 >Emitted(5, 28) Source(10, 12) + SourceIndex(0) @@ -165,7 +165,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern2 6 >Emitted(5, 51) Source(10, 15) + SourceIndex(0) 7 >Emitted(5, 72) Source(10, 28) + SourceIndex(0) 8 >Emitted(5, 74) Source(10, 30) + SourceIndex(0) -9 >Emitted(5, 97) Source(10, 45) + SourceIndex(0) +9 >Emitted(5, 97) Source(10, 46) + SourceIndex(0) 10>Emitted(5, 98) Source(10, 62) + SourceIndex(0) --- >>>var nameMC = ["roomba", ["vaccum", "mopping"]][0]; @@ -209,8 +209,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern2 8 > 9 > primarySkillC 10> , -11> secondarySkillC -12> ]] = ["roomba", ["vaccum", "mopping"]]; +11> secondarySkillC]] = ["roomba", ["vaccum", "mopping"]] +12> ; 1->Emitted(7, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(7, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(7, 43) Source(13, 84) + SourceIndex(0) @@ -221,7 +221,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern2 8 >Emitted(7, 74) Source(13, 16) + SourceIndex(0) 9 >Emitted(7, 95) Source(13, 29) + SourceIndex(0) 10>Emitted(7, 97) Source(13, 31) + SourceIndex(0) -11>Emitted(7, 120) Source(13, 46) + SourceIndex(0) +11>Emitted(7, 120) Source(13, 84) + SourceIndex(0) 12>Emitted(7, 121) Source(13, 85) + SourceIndex(0) --- >>>var multiRobotAInfo = multiRobotA.slice(0); diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map index 456a64e7f34..96ea969b41a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts"],"names":[],"mappings":"AAAK,IAAA,aAAC,CAAW;AACb,IAAA,WAAe,EAAd,SAAC,EAAE,SAAC,CAAW"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts"],"names":[],"mappings":"AAAK,IAAA,aAAC,CAAW;AACb,IAAA,WAAe,EAAd,SAAC,EAAE,SAAW,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt index 2603b53c456..834b62af310 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt @@ -40,15 +40,15 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern5 4 > 5 > y 6 > , -7 > z -8 > ] = [1, 2]; +7 > z] = [1, 2] +8 > ; 1->Emitted(2, 1) Source(2, 5) + SourceIndex(0) 2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(2, 16) Source(2, 20) + SourceIndex(0) 4 >Emitted(2, 18) Source(2, 6) + SourceIndex(0) 5 >Emitted(2, 27) Source(2, 7) + SourceIndex(0) 6 >Emitted(2, 29) Source(2, 9) + SourceIndex(0) -7 >Emitted(2, 38) Source(2, 10) + SourceIndex(0) +7 >Emitted(2, 38) Source(2, 20) + SourceIndex(0) 8 >Emitted(2, 39) Source(2, 21) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map index 94422f76145..0b43806d517 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts"],"names":[],"mappings":"AAAI,IAAA,WAAoB,EAAnB,UAAM,EAAN,2BAAM,EAAE,SAAC,CAAW"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts"],"names":[],"mappings":"AAAI,IAAA,WAAoB,EAAnB,UAAM,EAAN,2BAAM,EAAE,SAAW,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt index 2a088a1dc82..db14204bda7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt @@ -28,8 +28,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern7 6 > 7 > x = 20 8 > , -9 > j -10> ] = [1, 2]; +9 > j] = [1, 2] +10> ; 1 >Emitted(1, 1) Source(1, 5) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 16) Source(1, 25) + SourceIndex(0) @@ -38,7 +38,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern7 6 >Emitted(1, 30) Source(1, 6) + SourceIndex(0) 7 >Emitted(1, 57) Source(1, 12) + SourceIndex(0) 8 >Emitted(1, 59) Source(1, 14) + SourceIndex(0) -9 >Emitted(1, 68) Source(1, 15) + SourceIndex(0) +9 >Emitted(1, 68) Source(1, 25) + SourceIndex(0) 10>Emitted(1, 69) Source(1, 26) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js.map index a35c7f2596f..ec1321b8a91 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAIA,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAExC,IAAA,cAAgB,EAAhB,qCAAgB,CAAW;AAC7B,IAAA,cAAY,EAAZ,iCAAY,CAAW;AACvB,IAAA,cAAa,EAAb,kCAAa,EAAE,cAAiB,EAAjB,sCAAiB,EAAE,cAAmB,EAAnB,wCAAmB,CAAW;AAEhE,IAAA,uCAAa,EAAb,kCAAa,CAAoC;AAClD,IAAA,oCAAsF,EAArF,UAAY,EAAZ,iCAAY,EAAE,UAAgB,EAAhB,qCAAgB,EAAE,UAAkB,EAAlB,uCAAkB,CAAoC;AAEtF,IAAA,cAAa,EAAb,kCAAa,EAAE,4BAAa,CAAW;AAE5C,IAAI,KAAK,IAAI,MAAM,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACxB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAIA,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,IAAI,MAAM,GAAU,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAExC,IAAA,cAAgB,EAAhB,qCAAgB,CAAW;AAC7B,IAAA,cAAY,EAAZ,iCAAY,CAAW;AACvB,IAAA,cAAa,EAAb,kCAAa,EAAE,cAAiB,EAAjB,sCAAiB,EAAE,cAAmB,EAAnB,wCAAmB,CAAW;AAEhE,IAAA,uCAAa,EAAb,kCAAa,CAAoC;AAClD,IAAA,oCAAsF,EAArF,UAAY,EAAZ,iCAAY,EAAE,UAAgB,EAAhB,qCAAgB,EAAE,UAAkB,EAAlB,uCAAqD,CAAC;AAEtF,IAAA,cAAa,EAAb,kCAAa,EAAE,4BAAa,CAAW;AAE5C,IAAI,KAAK,IAAI,MAAM,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACxB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.sourcemap.txt index dfa51e18e6e..32db2f848c0 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.sourcemap.txt @@ -235,8 +235,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 12> , 13> skillC = "noSkill" 14> -15> skillC = "noSkill" -16> ] = [3, "edging", "Trimming edges"]; +15> skillC = "noSkill"] = [3, "edging", "Trimming edges"] +16> ; 1->Emitted(7, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(7, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(7, 41) Source(13, 91) + SourceIndex(0) @@ -251,7 +251,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 12>Emitted(7, 141) Source(13, 38) + SourceIndex(0) 13>Emitted(7, 151) Source(13, 56) + SourceIndex(0) 14>Emitted(7, 153) Source(13, 38) + SourceIndex(0) -15>Emitted(7, 192) Source(13, 56) + SourceIndex(0) +15>Emitted(7, 192) Source(13, 91) + SourceIndex(0) 16>Emitted(7, 193) Source(13, 92) + SourceIndex(0) --- >>>var _l = robotA[0], numberA3 = _l === void 0 ? -1 : _l, robotAInfo = robotA.slice(1); diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js.map index 844b6f3169f..1a6d2dd6a67 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts"],"names":[],"mappings":"AAIA,IAAI,WAAW,GAAsB,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/D,IAAI,WAAW,GAAsB,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElE,IAAA,mBAA+B,EAA/B,oDAA+B,CAAgB;AACjD,IAAA,mBAAiB,EAAjB,sCAAiB,CAAiB;AAClC,IAAA,mBAAiB,EAAjB,sCAAiB,EAAE,mBAAiF,EAAjF,gDAAiF,EAAhF,UAAyB,EAAzB,8CAAyB,EAAE,UAA2B,EAA3B,gDAA2B,CAA0C;AAEpH,IAAA,yCAAiB,EAAjB,sCAAiB,CAAuC;AACzD,IAAA,sCAA2I,EAA1I,UAAkB,EAAlB,uCAAkB,EAAE,UAAiF,EAAjF,gDAAiF,EAAhF,UAAyB,EAAzB,8CAAyB,EAAE,UAA2B,EAA3B,gDAA2B,CAAgE;AAEhJ,IAAI,MAAM,IAAI,MAAM,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts"],"names":[],"mappings":"AAIA,IAAI,WAAW,GAAsB,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/D,IAAI,WAAW,GAAsB,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElE,IAAA,mBAA+B,EAA/B,oDAA+B,CAAgB;AACjD,IAAA,mBAAiB,EAAjB,sCAAiB,CAAiB;AAClC,IAAA,mBAAiB,EAAjB,sCAAiB,EAAE,mBAAiF,EAAjF,gDAAiF,EAAhF,UAAyB,EAAzB,8CAAyB,EAAE,UAA2B,EAA3B,gDAAqD,CAAgB;AAEpH,IAAA,yCAAiB,EAAjB,sCAAiB,CAAuC;AACzD,IAAA,sCAA2I,EAA1I,UAAkB,EAAlB,uCAAkB,EAAE,UAAiF,EAAjF,gDAAiF,EAAhF,UAAyB,EAAzB,8CAAyB,EAAE,UAA2B,EAA3B,gDAA0F,CAAC;AAEhJ,IAAI,MAAM,IAAI,MAAM,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.sourcemap.txt index 99d2e65cfe7..6cf78caf44a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.sourcemap.txt @@ -183,8 +183,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 14> , 15> secondarySkillA = "noSkill" 16> -17> secondarySkillA = "noSkill" -18> ] = ["noSkill", "noSkill"]] = multiRobotA; +17> secondarySkillA = "noSkill"] = ["noSkill", "noSkill"] +18> ] = multiRobotA; 1->Emitted(5, 1) Source(10, 6) + SourceIndex(0) 2 >Emitted(5, 5) Source(10, 6) + SourceIndex(0) 3 >Emitted(5, 24) Source(10, 23) + SourceIndex(0) @@ -201,7 +201,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 14>Emitted(5, 197) Source(10, 53) + SourceIndex(0) 15>Emitted(5, 207) Source(10, 80) + SourceIndex(0) 16>Emitted(5, 209) Source(10, 53) + SourceIndex(0) -17>Emitted(5, 257) Source(10, 80) + SourceIndex(0) +17>Emitted(5, 257) Source(10, 106) + SourceIndex(0) 18>Emitted(5, 258) Source(10, 122) + SourceIndex(0) --- >>>var _h = ["roomba", ["vaccum", "mopping"]][0], nameMC = _h === void 0 ? "noName" : _h; @@ -267,8 +267,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 16> , 17> secondarySkillC = "noSkill" 18> -19> secondarySkillC = "noSkill" -20> ] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; +19> secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]] +20> ; 1->Emitted(7, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(7, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(7, 43) Source(13, 144) + SourceIndex(0) @@ -287,7 +287,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPatternD 16>Emitted(7, 220) Source(13, 54) + SourceIndex(0) 17>Emitted(7, 230) Source(13, 81) + SourceIndex(0) 18>Emitted(7, 232) Source(13, 54) + SourceIndex(0) -19>Emitted(7, 280) Source(13, 81) + SourceIndex(0) +19>Emitted(7, 280) Source(13, 144) + SourceIndex(0) 20>Emitted(7, 281) Source(13, 145) + SourceIndex(0) --- >>>if (nameMB == nameMA) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.js.map index 4c0852ad1d2..5ce5dc6ff54 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementDefaultValues.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementDefaultValues.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrD,IAAA,gBAAwB,EAAxB,uCAAwB,CAAY;AACpC,IAAA,gBAAwB,EAAxB,uCAAwB,EAAE,iBAAoC,EAApC,kDAAoC,CAAY;AAC5E,IAAA,8CAA8G,EAA5G,YAAwB,EAAxB,uCAAwB,EAAE,aAAoC,EAApC,kDAAoC,CAA+C;AACnH,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementDefaultValues.ts"],"names":[],"mappings":"AAOA,IAAI,KAAK,GAAG,OAAO,CAAC;AACpB,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrD,IAAA,gBAAwB,EAAxB,uCAAwB,CAAY;AACpC,IAAA,gBAAwB,EAAxB,uCAAwB,EAAE,iBAAoC,EAApC,kDAAoC,CAAY;AAC5E,IAAA,8CAA8G,EAA5G,YAAwB,EAAxB,uCAAwB,EAAE,aAAoC,EAApC,kDAAkF,CAAC;AACnH,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.sourcemap.txt index c426313b33c..fe0843d56a9 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.sourcemap.txt @@ -208,8 +208,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementDefaultValues.ts 8 > , 9 > skill: skillC = "" 10> -11> skill: skillC = "" -12> } = { name: "Edger", skill: "cutting edges" }; +11> skill: skillC = "" } = { name: "Edger", skill: "cutting edges" } +12> ; 1->Emitted(6, 1) Source(13, 5) + SourceIndex(0) 2 >Emitted(6, 5) Source(13, 5) + SourceIndex(0) 3 >Emitted(6, 51) Source(13, 115) + SourceIndex(0) @@ -220,7 +220,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementDefaultValues.ts 8 >Emitted(6, 108) Source(13, 33) + SourceIndex(0) 9 >Emitted(6, 121) Source(13, 69) + SourceIndex(0) 10>Emitted(6, 123) Source(13, 33) + SourceIndex(0) -11>Emitted(6, 173) Source(13, 69) + SourceIndex(0) +11>Emitted(6, 173) Source(13, 115) + SourceIndex(0) 12>Emitted(6, 174) Source(13, 116) + SourceIndex(0) --- >>>if (nameA == nameB) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js.map index ed0fe05cb3c..6294c6af22b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.ts"],"names":[],"mappings":"AAUA,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACxF,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;AAExF,IAAA,kBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,CAAc;AAChE,IAAA,mBAAW,EAAE,kBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,CAAc;AAC/E,IAAA,mFAAsJ,EAApJ,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,CAAsF;AAE3J,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.ts"],"names":[],"mappings":"AAUA,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACxF,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;AAExF,IAAA,kBAAoD,EAA1C,qBAAiB,EAAE,yBAAuB,CAAY;AAChE,IAAA,mBAAW,EAAE,kBAAoD,EAA1C,qBAAiB,EAAE,yBAAuB,CAAY;AAC/E,IAAA,mFAAsJ,EAApJ,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAA0G,CAAC;AAE3J,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.sourcemap.txt index 1779c517c68..0e8c1c437a2 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.sourcemap.txt @@ -174,15 +174,15 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 4 > 5 > primary: primaryA 6 > , -7 > secondary: secondaryA -8 > } } = robotA; +7 > secondary: secondaryA } +8 > } = robotA; 1 >Emitted(3, 1) Source(14, 7) + SourceIndex(0) 2 >Emitted(3, 5) Source(14, 7) + SourceIndex(0) 3 >Emitted(3, 23) Source(14, 59) + SourceIndex(0) 4 >Emitted(3, 25) Source(14, 17) + SourceIndex(0) 5 >Emitted(3, 46) Source(14, 34) + SourceIndex(0) 6 >Emitted(3, 48) Source(14, 36) + SourceIndex(0) -7 >Emitted(3, 73) Source(14, 57) + SourceIndex(0) +7 >Emitted(3, 73) Source(14, 59) + SourceIndex(0) 8 >Emitted(3, 74) Source(14, 71) + SourceIndex(0) --- >>>var nameB = robotB.name, _b = robotB.skills, primaryB = _b.primary, secondaryB = _b.secondary; @@ -206,8 +206,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 6 > 7 > primary: primaryB 8 > , -9 > secondary: secondaryB -10> } } = robotB; +9 > secondary: secondaryB } +10> } = robotB; 1->Emitted(4, 1) Source(15, 7) + SourceIndex(0) 2 >Emitted(4, 5) Source(15, 7) + SourceIndex(0) 3 >Emitted(4, 24) Source(15, 18) + SourceIndex(0) @@ -216,7 +216,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 6 >Emitted(4, 46) Source(15, 30) + SourceIndex(0) 7 >Emitted(4, 67) Source(15, 47) + SourceIndex(0) 8 >Emitted(4, 69) Source(15, 49) + SourceIndex(0) -9 >Emitted(4, 94) Source(15, 70) + SourceIndex(0) +9 >Emitted(4, 94) Source(15, 72) + SourceIndex(0) 10>Emitted(4, 95) Source(15, 84) + SourceIndex(0) --- >>>var _c = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }, nameC = _c.name, _d = _c.skills, primaryB = _d.primary, secondaryB = _d.secondary; @@ -243,8 +243,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 8 > 9 > primary: primaryB 10> , -11> secondary: secondaryB -12> } } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }; +11> secondary: secondaryB } } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } +12> ; 1->Emitted(5, 1) Source(16, 5) + SourceIndex(0) 2 >Emitted(5, 5) Source(16, 5) + SourceIndex(0) 3 >Emitted(5, 88) Source(16, 155) + SourceIndex(0) @@ -255,7 +255,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 8 >Emitted(5, 123) Source(16, 30) + SourceIndex(0) 9 >Emitted(5, 144) Source(16, 47) + SourceIndex(0) 10>Emitted(5, 146) Source(16, 49) + SourceIndex(0) -11>Emitted(5, 171) Source(16, 70) + SourceIndex(0) +11>Emitted(5, 171) Source(16, 155) + SourceIndex(0) 12>Emitted(5, 172) Source(16, 156) + SourceIndex(0) --- >>>if (nameB == nameB) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js.map index 73e04a6e433..d718d679cd7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.ts"],"names":[],"mappings":"AAUA,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACxF,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;AAG1F,IAAA,kBAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAAiC,CAE9B;AAEP,IAAA,gBAA+B,EAA/B,8CAA+B,EAC/B,kBAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAAiC,CAE9B;AACP,IAAA,mFAMqF,EALrF,YAA+B,EAA/B,8CAA+B,EAC/B,cAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAAiC,CAEiD;AAE1F,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.ts"],"names":[],"mappings":"AAUA,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACxF,IAAI,MAAM,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;AAG1F,IAAA,kBAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAC4C,CACzC;AAEP,IAAA,gBAA+B,EAA/B,8CAA+B,EAC/B,kBAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAC4C,CACzC;AACP,IAAA,mFAMqF,EALrF,YAA+B,EAA/B,8CAA+B,EAC/B,cAGgD,EAHhD,sEAGgD,EAF5C,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAiC,EAAjC,2CAEiF,CAAC;AAE1F,IAAI,KAAK,IAAI,KAAK,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB;KACI;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACtB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.sourcemap.txt index 1051abf21b6..6b119b8d222 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.sourcemap.txt @@ -195,9 +195,9 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP > 11> secondary: secondaryA = "noSkill" 12> -13> secondary: secondaryA = "noSkill" +13> secondary: secondaryA = "noSkill" + > } = { primary: "noSkill", secondary: "noSkill" } 14> - > } = { primary: "noSkill", secondary: "noSkill" } > } = robotA; 1->Emitted(3, 1) Source(15, 5) + SourceIndex(0) 2 >Emitted(3, 5) Source(15, 5) + SourceIndex(0) @@ -211,7 +211,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 10>Emitted(3, 157) Source(17, 9) + SourceIndex(0) 11>Emitted(3, 174) Source(17, 42) + SourceIndex(0) 12>Emitted(3, 176) Source(17, 9) + SourceIndex(0) -13>Emitted(3, 219) Source(17, 42) + SourceIndex(0) +13>Emitted(3, 219) Source(18, 53) + SourceIndex(0) 14>Emitted(3, 220) Source(19, 12) + SourceIndex(0) --- >>>var _e = robotB.name, nameB = _e === void 0 ? "noNameSpecified" : _e, _f = robotB.skills, _g = _f === void 0 ? { primary: "noSkill", secondary: "noSkill" } : _f, _h = _g.primary, primaryB = _h === void 0 ? "noSkill" : _h, _j = _g.secondary, secondaryB = _j === void 0 ? "noSkill" : _j; @@ -260,9 +260,9 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP > 15> secondary: secondaryB = "noSkill" 16> -17> secondary: secondaryB = "noSkill" +17> secondary: secondaryB = "noSkill" + > } = { primary: "noSkill", secondary: "noSkill" } 18> - > } = { primary: "noSkill", secondary: "noSkill" } > } = robotB; 1->Emitted(4, 1) Source(21, 5) + SourceIndex(0) 2 >Emitted(4, 5) Source(21, 5) + SourceIndex(0) @@ -280,7 +280,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 14>Emitted(4, 223) Source(24, 9) + SourceIndex(0) 15>Emitted(4, 240) Source(24, 42) + SourceIndex(0) 16>Emitted(4, 242) Source(24, 9) + SourceIndex(0) -17>Emitted(4, 285) Source(24, 42) + SourceIndex(0) +17>Emitted(4, 285) Source(25, 53) + SourceIndex(0) 18>Emitted(4, 286) Source(26, 12) + SourceIndex(0) --- >>>var _k = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }, _l = _k.name, nameC = _l === void 0 ? "noNameSpecified" : _l, _m = _k.skills, _o = _m === void 0 ? { primary: "noSkill", secondary: "noSkill" } : _m, _p = _o.primary, primaryB = _p === void 0 ? "noSkill" : _p, _q = _o.secondary, secondaryB = _q === void 0 ? "noSkill" : _q; @@ -337,10 +337,10 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP > 17> secondary: secondaryB = "noSkill" 18> -19> secondary: secondaryB = "noSkill" -20> - > } = { primary: "noSkill", secondary: "noSkill" } - > } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }; +19> secondary: secondaryB = "noSkill" + > } = { primary: "noSkill", secondary: "noSkill" } + > } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } +20> ; 1->Emitted(5, 1) Source(27, 5) + SourceIndex(0) 2 >Emitted(5, 5) Source(27, 5) + SourceIndex(0) 3 >Emitted(5, 88) Source(33, 90) + SourceIndex(0) @@ -359,7 +359,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementNestedObjectBindingP 16>Emitted(5, 300) Source(31, 9) + SourceIndex(0) 17>Emitted(5, 317) Source(31, 42) + SourceIndex(0) 18>Emitted(5, 319) Source(31, 9) + SourceIndex(0) -19>Emitted(5, 362) Source(31, 42) + SourceIndex(0) +19>Emitted(5, 362) Source(33, 90) + SourceIndex(0) 20>Emitted(5, 363) Source(33, 91) + SourceIndex(0) --- >>>if (nameB == nameB) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map index eb36a3b9022..b7086032ef0 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAsB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt index 2390f91a8b1..d3d28db4017 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt @@ -40,15 +40,15 @@ sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern 4 > 5 > a 6 > , -7 > b -8 > } = { a: 30, b: 40 }; +7 > b } = { a: 30, b: 40 } +8 > ; 1->Emitted(2, 1) Source(2, 5) + SourceIndex(0) 2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(2, 26) Source(2, 32) + SourceIndex(0) 4 >Emitted(2, 28) Source(2, 7) + SourceIndex(0) 5 >Emitted(2, 36) Source(2, 8) + SourceIndex(0) 6 >Emitted(2, 38) Source(2, 10) + SourceIndex(0) -7 >Emitted(2, 46) Source(2, 11) + SourceIndex(0) +7 >Emitted(2, 46) Source(2, 32) + SourceIndex(0) 8 >Emitted(2, 47) Source(2, 33) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map index 2b6cd16157d..261e0ec708e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts"],"names":[],"mappings":"AAAI,IAAA,uBACwB,EADvB,SAAO,EAAP,4BAAO,EACP,QAAC,CAAuB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts"],"names":[],"mappings":"AAAI,IAAA,uBACwB,EADvB,SAAO,EAAP,4BAAO,EACP,QAAuB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt index 68d24cb1b32..064a9f6fe58 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt @@ -30,8 +30,8 @@ sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern 7 > x = 500 8 > , > -9 > y -10> } = { x: 20, y: "hi" }; +9 > y} = { x: 20, y: "hi" } +10> ; 1 >Emitted(1, 1) Source(1, 5) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 28) Source(2, 29) + SourceIndex(0) @@ -40,7 +40,7 @@ sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern 6 >Emitted(1, 41) Source(1, 6) + SourceIndex(0) 7 >Emitted(1, 69) Source(1, 13) + SourceIndex(0) 8 >Emitted(1, 71) Source(2, 6) + SourceIndex(0) -9 >Emitted(1, 79) Source(2, 7) + SourceIndex(0) +9 >Emitted(1, 79) Source(2, 29) + SourceIndex(0) 10>Emitted(1, 80) Source(2, 30) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/spreadExcessProperty.js b/tests/baselines/reference/spreadExcessProperty.js new file mode 100644 index 00000000000..c5bf845224c --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.js @@ -0,0 +1,20 @@ +//// [spreadExcessProperty.ts] +type A = { a: string, b: string }; +const extra1 = { a: "a", b: "b", extra: "extra" }; +const a1: A = { ...extra1 }; // spread should not give excess property errors + + +//// [spreadExcessProperty.js] +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var extra1 = { a: "a", b: "b", extra: "extra" }; +var a1 = __assign({}, extra1); // spread should not give excess property errors diff --git a/tests/baselines/reference/spreadExcessProperty.symbols b/tests/baselines/reference/spreadExcessProperty.symbols new file mode 100644 index 00000000000..bc4ef206643 --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/types/spread/spreadExcessProperty.ts === +type A = { a: string, b: string }; +>A : Symbol(A, Decl(spreadExcessProperty.ts, 0, 0)) +>a : Symbol(a, Decl(spreadExcessProperty.ts, 0, 10)) +>b : Symbol(b, Decl(spreadExcessProperty.ts, 0, 21)) + +const extra1 = { a: "a", b: "b", extra: "extra" }; +>extra1 : Symbol(extra1, Decl(spreadExcessProperty.ts, 1, 5)) +>a : Symbol(a, Decl(spreadExcessProperty.ts, 1, 16)) +>b : Symbol(b, Decl(spreadExcessProperty.ts, 1, 24)) +>extra : Symbol(extra, Decl(spreadExcessProperty.ts, 1, 32)) + +const a1: A = { ...extra1 }; // spread should not give excess property errors +>a1 : Symbol(a1, Decl(spreadExcessProperty.ts, 2, 5)) +>A : Symbol(A, Decl(spreadExcessProperty.ts, 0, 0)) +>extra1 : Symbol(extra1, Decl(spreadExcessProperty.ts, 1, 5)) + diff --git a/tests/baselines/reference/spreadExcessProperty.types b/tests/baselines/reference/spreadExcessProperty.types new file mode 100644 index 00000000000..015c7cc85aa --- /dev/null +++ b/tests/baselines/reference/spreadExcessProperty.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/types/spread/spreadExcessProperty.ts === +type A = { a: string, b: string }; +>A : A +>a : string +>b : string + +const extra1 = { a: "a", b: "b", extra: "extra" }; +>extra1 : { a: string; b: string; extra: string; } +>{ a: "a", b: "b", extra: "extra" } : { a: string; b: string; extra: string; } +>a : string +>"a" : "a" +>b : string +>"b" : "b" +>extra : string +>"extra" : "extra" + +const a1: A = { ...extra1 }; // spread should not give excess property errors +>a1 : A +>{ ...extra1 } : { a: string; b: string; extra: string; } +>extra1 : { a: string; b: string; extra: string; } + diff --git a/tests/baselines/reference/strictModeEnumMemberNameReserved.types b/tests/baselines/reference/strictModeEnumMemberNameReserved.types index 557dfcccc67..ed19db7b4bc 100644 --- a/tests/baselines/reference/strictModeEnumMemberNameReserved.types +++ b/tests/baselines/reference/strictModeEnumMemberNameReserved.types @@ -6,7 +6,7 @@ enum E { >E : E static ->static : E +>static : E.static } const x1: E.static = E.static; diff --git a/tests/baselines/reference/strictTypeofUnionNarrowing.js b/tests/baselines/reference/strictTypeofUnionNarrowing.js new file mode 100644 index 00000000000..93b9c7d4330 --- /dev/null +++ b/tests/baselines/reference/strictTypeofUnionNarrowing.js @@ -0,0 +1,32 @@ +//// [strictTypeofUnionNarrowing.ts] +function stringify1(anything: { toString(): string } | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify2(anything: {} | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify3(anything: unknown | undefined): string { // should simplify to just `unknown` which should narrow fine + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify4(anything: { toString?(): string } | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + + +//// [strictTypeofUnionNarrowing.js] +"use strict"; +function stringify1(anything) { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} +function stringify2(anything) { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} +function stringify3(anything) { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} +function stringify4(anything) { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} diff --git a/tests/baselines/reference/strictTypeofUnionNarrowing.symbols b/tests/baselines/reference/strictTypeofUnionNarrowing.symbols new file mode 100644 index 00000000000..83a602eeaf1 --- /dev/null +++ b/tests/baselines/reference/strictTypeofUnionNarrowing.symbols @@ -0,0 +1,47 @@ +=== tests/cases/compiler/strictTypeofUnionNarrowing.ts === +function stringify1(anything: { toString(): string } | undefined): string { +>stringify1 : Symbol(stringify1, Decl(strictTypeofUnionNarrowing.ts, 0, 0)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 0, 20)) +>toString : Symbol(toString, Decl(strictTypeofUnionNarrowing.ts, 0, 31)) + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 0, 20)) +>anything.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 0, 20)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +} + +function stringify2(anything: {} | undefined): string { +>stringify2 : Symbol(stringify2, Decl(strictTypeofUnionNarrowing.ts, 2, 1)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 4, 20)) + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 4, 20)) +>anything.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 4, 20)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +} + +function stringify3(anything: unknown | undefined): string { // should simplify to just `unknown` which should narrow fine +>stringify3 : Symbol(stringify3, Decl(strictTypeofUnionNarrowing.ts, 6, 1)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 8, 20)) + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 8, 20)) +>anything.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 8, 20)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +} + +function stringify4(anything: { toString?(): string } | undefined): string { +>stringify4 : Symbol(stringify4, Decl(strictTypeofUnionNarrowing.ts, 10, 1)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 12, 20)) +>toString : Symbol(toString, Decl(strictTypeofUnionNarrowing.ts, 12, 31)) + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 12, 20)) +>anything.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>anything : Symbol(anything, Decl(strictTypeofUnionNarrowing.ts, 12, 20)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +} + diff --git a/tests/baselines/reference/strictTypeofUnionNarrowing.types b/tests/baselines/reference/strictTypeofUnionNarrowing.types new file mode 100644 index 00000000000..3039ece15d6 --- /dev/null +++ b/tests/baselines/reference/strictTypeofUnionNarrowing.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/strictTypeofUnionNarrowing.ts === +function stringify1(anything: { toString(): string } | undefined): string { +>stringify1 : (anything: { toString(): string; } | undefined) => string +>anything : { toString(): string; } | undefined +>toString : () => string + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>typeof anything === "string" ? anything.toUpperCase() : "" : string +>typeof anything === "string" : boolean +>typeof anything : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>anything : { toString(): string; } | undefined +>"string" : "string" +>anything.toUpperCase() : string +>anything.toUpperCase : () => string +>anything : { toString(): string; } & string +>toUpperCase : () => string +>"" : "" +} + +function stringify2(anything: {} | undefined): string { +>stringify2 : (anything: {} | undefined) => string +>anything : {} | undefined + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>typeof anything === "string" ? anything.toUpperCase() : "" : string +>typeof anything === "string" : boolean +>typeof anything : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>anything : {} | undefined +>"string" : "string" +>anything.toUpperCase() : string +>anything.toUpperCase : () => string +>anything : string & {} +>toUpperCase : () => string +>"" : "" +} + +function stringify3(anything: unknown | undefined): string { // should simplify to just `unknown` which should narrow fine +>stringify3 : (anything: unknown) => string +>anything : unknown + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>typeof anything === "string" ? anything.toUpperCase() : "" : string +>typeof anything === "string" : boolean +>typeof anything : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>anything : unknown +>"string" : "string" +>anything.toUpperCase() : string +>anything.toUpperCase : () => string +>anything : string +>toUpperCase : () => string +>"" : "" +} + +function stringify4(anything: { toString?(): string } | undefined): string { +>stringify4 : (anything: {} | undefined) => string +>anything : {} | undefined +>toString : (() => string) | undefined + + return typeof anything === "string" ? anything.toUpperCase() : ""; +>typeof anything === "string" ? anything.toUpperCase() : "" : string +>typeof anything === "string" : boolean +>typeof anything : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>anything : {} | undefined +>"string" : "string" +>anything.toUpperCase() : string +>anything.toUpperCase : () => string +>anything : {} & string +>toUpperCase : () => string +>"" : "" +} + diff --git a/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.types b/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.types index d95dc856575..be2231fdfb3 100644 --- a/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.types +++ b/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.types @@ -279,7 +279,7 @@ function f13(x: any) { } enum E { A } >E : E ->A : E +>A : E.A function f14(x: 'a'); >f14 : { (x: "a"): any; (x: E): any; } diff --git a/tests/baselines/reference/subtypesOfAny.types b/tests/baselines/reference/subtypesOfAny.types index cdb9469b6a4..903997a7bbc 100644 --- a/tests/baselines/reference/subtypesOfAny.types +++ b/tests/baselines/reference/subtypesOfAny.types @@ -129,7 +129,7 @@ interface I13 { enum E { A } >E : E ->A : E +>A : E.A interface I14 { [x: string]: any; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.types b/tests/baselines/reference/subtypesOfTypeParameter.types index 590f827d2b3..02d4d527786 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.types +++ b/tests/baselines/reference/subtypesOfTypeParameter.types @@ -49,7 +49,7 @@ class C2 { foo: T; } enum E { A } >E : E ->A : E +>A : E.A function f() { } >f : typeof f diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types index 270840b06a9..daf700b06f2 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types @@ -142,7 +142,7 @@ class C2 { foo: T; } enum E { A } >E : E ->A : E +>A : E.A function f() { } >f : typeof f diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 52b763cdaff..c8ac07429f3 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -737,20 +737,20 @@ var r14arg2 = (x: { a: string; b: number }) => null; >null : null var r14 = foo14(r14arg1); // any ->r14 : (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: (x: { a: string; b: number; }) => Object): (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : ((x: { a: string; b: number; }) => Object)[] +>r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : ((x: { a: string; b: number; }) => Object)[] +>r14b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index e169885b87f..4a0b3416e56 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -381,14 +381,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index 8021e2105fb..0d2ff802911 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -653,20 +653,20 @@ var r14arg2: new (x: { a: string; b: number }) => Object; >b : number var r14 = foo14(r14arg1); // any ->r14 : new (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : new (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: new (x: { a: string; b: number; }) => Object): new (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : (new (x: { a: string; b: number; }) => Object)[] +>r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : (new (x: { a: string; b: number; }) => Object)[] +>r14b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 412f7b2f73b..6c9881d1228 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -343,14 +343,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index d3f47955ffc..de10469def0 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [subtypingWithConstructSignatures5.js] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols index cbb55d20155..2daf0631a09 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(subtypingWithConstructSignatures5.ts, 45, 67)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 17)) ->a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 21)) ->T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 27)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) +>x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 20)) +>a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 24)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) +>b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 30)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) } diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.types b/tests/baselines/reference/subtypingWithConstructSignatures5.types index a7adde7a480..d86cfe1c51d 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.types b/tests/baselines/reference/systemModuleAmbientDeclarations.types index 83a1bb857c7..9fcea7b874e 100644 --- a/tests/baselines/reference/systemModuleAmbientDeclarations.types +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.types @@ -10,7 +10,7 @@ declare class C {} declare enum E {X = 1}; >E : E ->X : E +>X : E.X >1 : 1 export var promise = Promise; @@ -44,7 +44,7 @@ export declare var v: number; === tests/cases/compiler/file5.ts === export declare enum E {X = 1} >E : E ->X : E +>X : E.X >1 : 1 === tests/cases/compiler/file6.ts === diff --git a/tests/baselines/reference/systemModuleConstEnums.types b/tests/baselines/reference/systemModuleConstEnums.types index cbfb339c3e3..9c214416018 100644 --- a/tests/baselines/reference/systemModuleConstEnums.types +++ b/tests/baselines/reference/systemModuleConstEnums.types @@ -5,7 +5,7 @@ declare function use(a: any); const enum TopLevelConstEnum { X } >TopLevelConstEnum : TopLevelConstEnum ->X : TopLevelConstEnum +>X : TopLevelConstEnum.X export function foo() { >foo : () => void @@ -30,5 +30,5 @@ export function foo() { module M { export const enum NonTopLevelConstEnum { X } >NonTopLevelConstEnum : NonTopLevelConstEnum ->X : NonTopLevelConstEnum +>X : NonTopLevelConstEnum.X } diff --git a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types index 55c37d31a80..8b62ffe063f 100644 --- a/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types +++ b/tests/baselines/reference/systemModuleConstEnumsSeparateCompilation.types @@ -5,7 +5,7 @@ declare function use(a: any); const enum TopLevelConstEnum { X } >TopLevelConstEnum : TopLevelConstEnum ->X : TopLevelConstEnum +>X : TopLevelConstEnum.X export function foo() { >foo : () => void @@ -30,5 +30,5 @@ export function foo() { module M { export const enum NonTopLevelConstEnum { X } >NonTopLevelConstEnum : NonTopLevelConstEnum ->X : NonTopLevelConstEnum +>X : NonTopLevelConstEnum.X } diff --git a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types index 61edb6db4b0..b96402770fd 100644 --- a/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types +++ b/tests/baselines/reference/systemModuleNonTopLevelModuleMembers.types @@ -11,7 +11,7 @@ export function TopLevelFunction(): void {} export enum TopLevelEnum {E} >TopLevelEnum : TopLevelEnum ->E : TopLevelEnum +>E : TopLevelEnum.E export module TopLevelModule2 { >TopLevelModule2 : typeof TopLevelModule2 @@ -28,5 +28,5 @@ export module TopLevelModule2 { export enum NonTopLevelEnum {E} >NonTopLevelEnum : NonTopLevelEnum ->E : NonTopLevelEnum +>E : NonTopLevelEnum.E } diff --git a/tests/baselines/reference/systemNamespaceAliasEmit.symbols b/tests/baselines/reference/systemNamespaceAliasEmit.symbols index 89ac66a624d..7e9c2434586 100644 --- a/tests/baselines/reference/systemNamespaceAliasEmit.symbols +++ b/tests/baselines/reference/systemNamespaceAliasEmit.symbols @@ -10,10 +10,10 @@ enum AnEnum { >AnEnum : Symbol(AnEnum, Decl(systemNamespaceAliasEmit.ts, 2, 1)) ONE, ->ONE : Symbol(BarEnum.ONE, Decl(systemNamespaceAliasEmit.ts, 4, 13)) +>ONE : Symbol(AnEnum.ONE, Decl(systemNamespaceAliasEmit.ts, 4, 13)) TWO ->TWO : Symbol(BarEnum.TWO, Decl(systemNamespaceAliasEmit.ts, 5, 8)) +>TWO : Symbol(AnEnum.TWO, Decl(systemNamespaceAliasEmit.ts, 5, 8)) } export {ns, AnEnum, ns as FooBar, AnEnum as BarEnum}; diff --git a/tests/baselines/reference/targetTypeTest1.errors.txt b/tests/baselines/reference/targetTypeTest1.errors.txt index 63d061d66b7..a0b05690a3b 100644 --- a/tests/baselines/reference/targetTypeTest1.errors.txt +++ b/tests/baselines/reference/targetTypeTest1.errors.txt @@ -1,13 +1,11 @@ tests/cases/compiler/targetTypeTest1.ts(1,15): error TS2300: Duplicate identifier 'Point'. -tests/cases/compiler/targetTypeTest1.ts(6,43): error TS2304: Cannot find name 'Point'. -tests/cases/compiler/targetTypeTest1.ts(7,22): error TS2304: Cannot find name 'Point'. tests/cases/compiler/targetTypeTest1.ts(14,10): error TS2300: Duplicate identifier 'Point'. tests/cases/compiler/targetTypeTest1.ts(19,18): error TS2384: Overload signatures must all be ambient or non-ambient. tests/cases/compiler/targetTypeTest1.ts(53,15): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifier 'C'. -==== tests/cases/compiler/targetTypeTest1.ts (7 errors) ==== +==== tests/cases/compiler/targetTypeTest1.ts (5 errors) ==== declare class Point ~~~~~ !!! error TS2300: Duplicate identifier 'Point'. @@ -16,11 +14,7 @@ tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifi public x: number; public y: number; public add(dx: number, dy: number): Point; - ~~~~~ -!!! error TS2304: Cannot find name 'Point'. static origin: Point; - ~~~~~ -!!! error TS2304: Cannot find name 'Point'. } diff --git a/tests/baselines/reference/targetTypeTest1.symbols b/tests/baselines/reference/targetTypeTest1.symbols index 7596de0d69f..e8b5292603f 100644 --- a/tests/baselines/reference/targetTypeTest1.symbols +++ b/tests/baselines/reference/targetTypeTest1.symbols @@ -16,9 +16,11 @@ declare class Point >add : Symbol(Point.add, Decl(targetTypeTest1.ts, 4, 23)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 5, 17)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 5, 28)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) static origin: Point; >origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 5, 48)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) } @@ -26,7 +28,7 @@ declare class Point // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >x : Symbol(x, Decl(targetTypeTest1.ts, 13, 15)) >y : Symbol(y, Decl(targetTypeTest1.ts, 13, 17)) @@ -56,22 +58,22 @@ var x = EF1(1,2); // Point.origin declared as type Point Point.origin = new Point(0, 0); >Point.origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) // Point.prototype declared as type Point // this inferred as Point because of obj.prop assignment // dx, dy, and return type inferred using target typing Point.prototype.add = function(dx, dy) { >Point.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 30, 31)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 30, 34)) return new Point(this.x + dx, this.y + dy); ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 30, 31)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 30, 34)) @@ -85,7 +87,7 @@ var f : number = 5; // dx, dy, and return type of add inferred using target typing Point.prototype = { >Point.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) x: 0, @@ -100,7 +102,7 @@ Point.prototype = { >dy : Symbol(dy, Decl(targetTypeTest1.ts, 42, 21)) return new Point(this.x + dx, this.y + dy); ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 42, 18)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 42, 21)) } diff --git a/tests/baselines/reference/targetTypeTest1.types b/tests/baselines/reference/targetTypeTest1.types index 0cd418c1241..fcf994b941a 100644 --- a/tests/baselines/reference/targetTypeTest1.types +++ b/tests/baselines/reference/targetTypeTest1.types @@ -26,7 +26,7 @@ declare class Point // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >x : any >y : any @@ -69,10 +69,10 @@ var x = EF1(1,2); Point.origin = new Point(0, 0); >Point.origin = new Point(0, 0) : any >Point.origin : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >origin : any >new Point(0, 0) : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >0 : 0 >0 : 0 @@ -83,7 +83,7 @@ Point.prototype.add = function(dx, dy) { >Point.prototype.add = function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any >Point.prototype.add : any >Point.prototype : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >prototype : any >add : any >function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any @@ -92,7 +92,7 @@ Point.prototype.add = function(dx, dy) { return new Point(this.x + dx, this.y + dy); >new Point(this.x + dx, this.y + dy) : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >this.x + dx : any >this.x : any >this : any @@ -116,7 +116,7 @@ var f : number = 5; Point.prototype = { >Point.prototype = { x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; } >Point.prototype : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >prototype : any >{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; } @@ -136,7 +136,7 @@ Point.prototype = { return new Point(this.x + dx, this.y + dy); >new Point(this.x + dx, this.y + dy) : any ->Point : { (x: any, y: any): void; origin: any; } +>Point : typeof Point >this.x + dx : any >this.x : any >this : any diff --git a/tests/baselines/reference/tsxDefaultImports.types b/tests/baselines/reference/tsxDefaultImports.types index 08c00256e0e..a798e88fd89 100644 --- a/tests/baselines/reference/tsxDefaultImports.types +++ b/tests/baselines/reference/tsxDefaultImports.types @@ -3,7 +3,7 @@ enum SomeEnum { >SomeEnum : SomeEnum one, ->one : SomeEnum +>one : SomeEnum.one } export default class SomeClass { >SomeClass : SomeClass diff --git a/tests/baselines/reference/tupleLengthCheck.errors.txt b/tests/baselines/reference/tupleLengthCheck.errors.txt new file mode 100644 index 00000000000..f90adbf3525 --- /dev/null +++ b/tests/baselines/reference/tupleLengthCheck.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/types/tuple/tupleLengthCheck.ts(5,14): error TS2733: Index '2' is out-of-bounds in tuple of length 2. +tests/cases/conformance/types/tuple/tupleLengthCheck.ts(6,14): error TS2733: Index '1000' is out-of-bounds in tuple of length 2. + + +==== tests/cases/conformance/types/tuple/tupleLengthCheck.ts (2 errors) ==== + declare const a: [number, string] + declare const rest: [number, string, ...boolean[]] + + const a1 = a[1] + const a2 = a[2] + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. + const a3 = a[1000] + ~~~~ +!!! error TS2733: Index '1000' is out-of-bounds in tuple of length 2. + + const a4 = rest[1] + const a5 = rest[2] + const a6 = rest[3] + const a7 = rest[1000] + \ No newline at end of file diff --git a/tests/baselines/reference/tupleLengthCheck.js b/tests/baselines/reference/tupleLengthCheck.js new file mode 100644 index 00000000000..23e97c47593 --- /dev/null +++ b/tests/baselines/reference/tupleLengthCheck.js @@ -0,0 +1,22 @@ +//// [tupleLengthCheck.ts] +declare const a: [number, string] +declare const rest: [number, string, ...boolean[]] + +const a1 = a[1] +const a2 = a[2] +const a3 = a[1000] + +const a4 = rest[1] +const a5 = rest[2] +const a6 = rest[3] +const a7 = rest[1000] + + +//// [tupleLengthCheck.js] +var a1 = a[1]; +var a2 = a[2]; +var a3 = a[1000]; +var a4 = rest[1]; +var a5 = rest[2]; +var a6 = rest[3]; +var a7 = rest[1000]; diff --git a/tests/baselines/reference/tupleLengthCheck.symbols b/tests/baselines/reference/tupleLengthCheck.symbols new file mode 100644 index 00000000000..ffa524e3ca4 --- /dev/null +++ b/tests/baselines/reference/tupleLengthCheck.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/types/tuple/tupleLengthCheck.ts === +declare const a: [number, string] +>a : Symbol(a, Decl(tupleLengthCheck.ts, 0, 13)) + +declare const rest: [number, string, ...boolean[]] +>rest : Symbol(rest, Decl(tupleLengthCheck.ts, 1, 13)) + +const a1 = a[1] +>a1 : Symbol(a1, Decl(tupleLengthCheck.ts, 3, 5)) +>a : Symbol(a, Decl(tupleLengthCheck.ts, 0, 13)) +>1 : Symbol(1) + +const a2 = a[2] +>a2 : Symbol(a2, Decl(tupleLengthCheck.ts, 4, 5)) +>a : Symbol(a, Decl(tupleLengthCheck.ts, 0, 13)) + +const a3 = a[1000] +>a3 : Symbol(a3, Decl(tupleLengthCheck.ts, 5, 5)) +>a : Symbol(a, Decl(tupleLengthCheck.ts, 0, 13)) + +const a4 = rest[1] +>a4 : Symbol(a4, Decl(tupleLengthCheck.ts, 7, 5)) +>rest : Symbol(rest, Decl(tupleLengthCheck.ts, 1, 13)) +>1 : Symbol(1) + +const a5 = rest[2] +>a5 : Symbol(a5, Decl(tupleLengthCheck.ts, 8, 5)) +>rest : Symbol(rest, Decl(tupleLengthCheck.ts, 1, 13)) + +const a6 = rest[3] +>a6 : Symbol(a6, Decl(tupleLengthCheck.ts, 9, 5)) +>rest : Symbol(rest, Decl(tupleLengthCheck.ts, 1, 13)) + +const a7 = rest[1000] +>a7 : Symbol(a7, Decl(tupleLengthCheck.ts, 10, 5)) +>rest : Symbol(rest, Decl(tupleLengthCheck.ts, 1, 13)) + diff --git a/tests/baselines/reference/tupleLengthCheck.types b/tests/baselines/reference/tupleLengthCheck.types new file mode 100644 index 00000000000..be4372c669c --- /dev/null +++ b/tests/baselines/reference/tupleLengthCheck.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/tuple/tupleLengthCheck.ts === +declare const a: [number, string] +>a : [number, string] + +declare const rest: [number, string, ...boolean[]] +>rest : [number, string, ...boolean[]] + +const a1 = a[1] +>a1 : string +>a[1] : string +>a : [number, string] +>1 : 1 + +const a2 = a[2] +>a2 : string | number +>a[2] : string | number +>a : [number, string] +>2 : 2 + +const a3 = a[1000] +>a3 : string | number +>a[1000] : string | number +>a : [number, string] +>1000 : 1000 + +const a4 = rest[1] +>a4 : string +>rest[1] : string +>rest : [number, string, ...boolean[]] +>1 : 1 + +const a5 = rest[2] +>a5 : boolean +>rest[2] : boolean +>rest : [number, string, ...boolean[]] +>2 : 2 + +const a6 = rest[3] +>a6 : boolean +>rest[3] : boolean +>rest : [number, string, ...boolean[]] +>3 : 3 + +const a7 = rest[1000] +>a7 : boolean +>rest[1000] : boolean +>rest : [number, string, ...boolean[]] +>1000 : 1000 + diff --git a/tests/baselines/reference/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index 87e17e14d3c..4543eb202da 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/tupleTypes.ts(11,12): error TS2733: Index '2' is out-of-bounds in tuple of length 2. tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type '[]' is not assignable to type '[number, string]'. Property '0' is missing in type '[]'. tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]'. @@ -7,24 +8,21 @@ tests/cases/compiler/tupleTypes.ts(17,15): error TS2322: Type 'number' is not as tests/cases/compiler/tupleTypes.ts(18,1): error TS2322: Type '[number, string, number]' is not assignable to type '[number, string]'. Types of property 'length' are incompatible. Type '3' is not assignable to type '2'. +tests/cases/compiler/tupleTypes.ts(35,14): error TS2733: Index '2' is out-of-bounds in tuple of length 2. tests/cases/compiler/tupleTypes.ts(41,1): error TS2322: Type '[]' is not assignable to type '[number, string]'. tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. - Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]'. - Types of property 'pop' are incompatible. - Type '() => number | {}' is not assignable to type '() => number'. - Type 'number | {}' is not assignable to type 'number'. - Type '{}' is not assignable to type 'number'. + Type 'number | {}' is not assignable to type 'number'. + Type '{}' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(50,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. Type 'number' is not assignable to type 'string'. tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'. Type '{}' is not assignable to type 'string'. -==== tests/cases/compiler/tupleTypes.ts (10 errors) ==== +==== tests/cases/compiler/tupleTypes.ts (12 errors) ==== var v1: []; // Error var v2: [number]; var v3: [number, string]; @@ -36,6 +34,8 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n var t1 = t[1]; // string var t1: string; var t2 = t[2]; // number|string + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. var t2: number|string; t = []; // Error @@ -74,6 +74,8 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n var tt1 = tt[1]; var tt1: string; var tt2 = tt[2]; + ~ +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2. var tt2: number | string; tt = tuple2(1, undefined); @@ -90,18 +92,14 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n a = a1; // Error ~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. a = a2; a = a3; // Error ~ !!! error TS2322: Type '[number, {}]' is not assignable to type 'number[]'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => number | {}' is not assignable to type '() => number'. -!!! error TS2322: Type 'number | {}' is not assignable to type 'number'. -!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! error TS2322: Type 'number | {}' is not assignable to type 'number'. +!!! error TS2322: Type '{}' is not assignable to type 'number'. a1 = a2; // Error ~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. diff --git a/tests/baselines/reference/typeAliases.types b/tests/baselines/reference/typeAliases.types index 06dc8d4f327..8790c043adf 100644 --- a/tests/baselines/reference/typeAliases.types +++ b/tests/baselines/reference/typeAliases.types @@ -161,7 +161,7 @@ type Meters = number enum E { x = 10 } >E : E ->x : E +>x : E.x >10 : 10 declare function f15(a: string): boolean; diff --git a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.types b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.types index cb032dc0021..380e1eb686b 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.types +++ b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.types @@ -57,11 +57,11 @@ foo({ enum E1 { X } >E1 : E1 ->X : E1 +>X : E1.X enum E2 { X } >E2 : E2 ->X : E2 +>X : E2.X // Check that we infer from both a.r and b before fixing T in a.w @@ -129,10 +129,10 @@ var v2 = f1({ w: x => x, r: () => E1.X }, E1.X); >v2 : E1 >f1({ w: x => x, r: () => E1.X }, E1.X) : E1 >f1 : (a: { w: (x: T) => U; r: () => T; }, b: T) => U ->{ w: x => x, r: () => E1.X } : { w: (x: E1) => E1; r: () => E1; } ->w : (x: E1) => E1 ->x => x : (x: E1) => E1 ->x : E1 +>{ w: x => x, r: () => E1.X } : { w: (x: E1.X) => E1; r: () => E1; } +>w : (x: E1.X) => E1 +>x => x : (x: E1.X) => E1 +>x : E1.X >x : E1 >r : () => E1 >() => E1.X : () => E1 diff --git a/tests/baselines/reference/typeFromContextualThisType.symbols b/tests/baselines/reference/typeFromContextualThisType.symbols new file mode 100644 index 00000000000..c243123491d --- /dev/null +++ b/tests/baselines/reference/typeFromContextualThisType.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/salsa/bug25926.js === +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { +>o1 : Symbol(o1, Decl(bug25926.js, 1, 5)) + + a() { +>a : Symbol(a, Decl(bug25926.js, 1, 12)) + + this.b = n => n; +>this.b : Symbol(b, Decl(bug25926.js, 0, 23)) +>this : Symbol(__type, Decl(bug25926.js, 0, 11)) +>b : Symbol(b, Decl(bug25926.js, 2, 9)) +>n : Symbol(n, Decl(bug25926.js, 3, 16)) +>n : Symbol(n, Decl(bug25926.js, 3, 16)) + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { +>o2 : Symbol(o2, Decl(bug25926.js, 8, 5)) + + d() { +>d : Symbol(d, Decl(bug25926.js, 8, 12)) + + this.e = this.f = m => this.g || m; +>this.e : Symbol(e, Decl(bug25926.js, 7, 23)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>e : Symbol(e, Decl(bug25926.js, 9, 9)) +>this.f : Symbol(f, Decl(bug25926.js, 7, 46)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>f : Symbol(f, Decl(bug25926.js, 10, 16)) +>m : Symbol(m, Decl(bug25926.js, 10, 25)) +>this.g : Symbol(g, Decl(bug25926.js, 7, 69)) +>this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>g : Symbol(g, Decl(bug25926.js, 7, 69)) +>m : Symbol(m, Decl(bug25926.js, 10, 25)) + } +}; + + diff --git a/tests/baselines/reference/typeFromContextualThisType.types b/tests/baselines/reference/typeFromContextualThisType.types new file mode 100644 index 00000000000..fc6e3961800 --- /dev/null +++ b/tests/baselines/reference/typeFromContextualThisType.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/salsa/bug25926.js === +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { +>o1 : { a(): void; } +>{ a() { this.b = n => n; }} : { a(): void; } + + a() { +>a : () => void + + this.b = n => n; +>this.b = n => n : (n: number) => number +>this.b : ((n: number) => number) | undefined +>this : { a(): void; } +>b : ((n: number) => number) | undefined +>n => n : (n: number) => number +>n : number +>n : number + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { +>o2 : { d(): void; g?: number | undefined; } +>{ d() { this.e = this.f = m => this.g || m; }} : { d(): void; } + + d() { +>d : () => void + + this.e = this.f = m => this.g || m; +>this.e = this.f = m => this.g || m : (m: number) => number +>this.e : ((n: number) => number) | undefined +>this : { d(): void; g?: number | undefined; } +>e : ((n: number) => number) | undefined +>this.f = m => this.g || m : (m: number) => number +>this.f : ((n: number) => number) | undefined +>this : { d(): void; g?: number | undefined; } +>f : ((n: number) => number) | undefined +>m => this.g || m : (m: number) => number +>m : number +>this.g || m : number +>this.g : number | undefined +>this : { d(): void; g?: number | undefined; } +>g : number | undefined +>m : number + } +}; + + diff --git a/tests/baselines/reference/typeFromJSInitializer.symbols b/tests/baselines/reference/typeFromJSInitializer.symbols index d2212ccd367..d7453d1f1e1 100644 --- a/tests/baselines/reference/typeFromJSInitializer.symbols +++ b/tests/baselines/reference/typeFromJSInitializer.symbols @@ -14,74 +14,74 @@ function A () { >empty : Symbol(A.empty, Decl(a.js, 3, 31)) } var a = new A() ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >A : Symbol(A, Decl(a.js, 0, 0)) a.unknown = 1 >a.unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) a.unknown = true >a.unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) a.unknown = {} >a.unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) a.unknown = 'hi' >a.unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknown : Symbol(A.unknown, Decl(a.js, 0, 15)) a.unknowable = 1 >a.unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) a.unknowable = true >a.unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) a.unknowable = {} >a.unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) a.unknowable = 'hi' >a.unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >unknowable : Symbol(A.unknowable, Decl(a.js, 2, 23)) a.empty.push(1) >a.empty.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) >a.empty : Symbol(A.empty, Decl(a.js, 3, 31)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >empty : Symbol(A.empty, Decl(a.js, 3, 31)) >push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) a.empty.push(true) >a.empty.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) >a.empty : Symbol(A.empty, Decl(a.js, 3, 31)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >empty : Symbol(A.empty, Decl(a.js, 3, 31)) >push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) a.empty.push({}) >a.empty.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) >a.empty : Symbol(A.empty, Decl(a.js, 3, 31)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >empty : Symbol(A.empty, Decl(a.js, 3, 31)) >push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) a.empty.push('hi') >a.empty.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) >a.empty : Symbol(A.empty, Decl(a.js, 3, 31)) ->a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 8, 16)) +>a : Symbol(a, Decl(a.js, 6, 3), Decl(a.js, 6, 15)) >empty : Symbol(A.empty, Decl(a.js, 3, 31)) >push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment17.symbols b/tests/baselines/reference/typeFromPropertyAssignment17.symbols index 6708c25796e..165d3a04f8d 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment17.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment17.symbols @@ -41,17 +41,17 @@ module.exports = minimatch >module.exports : Symbol("tests/cases/conformance/salsa/minimatch", Decl(minimatch.js, 0, 0)) >module : Symbol(export=, Decl(minimatch.js, 0, 0)) >exports : Symbol(export=, Decl(minimatch.js, 0, 0)) ->minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1)) +>minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1), Decl(minimatch.js, 1, 26)) minimatch.M = M >minimatch.M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) ->minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1)) +>minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1), Decl(minimatch.js, 1, 26)) >M : Symbol(minimatch.M, Decl(minimatch.js, 1, 26)) >M : Symbol(M, Decl(minimatch.js, 13, 1), Decl(minimatch.js, 8, 1)) minimatch.filter = filter >minimatch.filter : Symbol(minimatch.filter, Decl(minimatch.js, 2, 15)) ->minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1)) +>minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1), Decl(minimatch.js, 1, 26)) >filter : Symbol(minimatch.filter, Decl(minimatch.js, 2, 15)) >filter : Symbol(filter, Decl(minimatch.js, 3, 25)) @@ -59,10 +59,10 @@ function filter() { >filter : Symbol(filter, Decl(minimatch.js, 3, 25)) return minimatch() ->minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1)) +>minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1), Decl(minimatch.js, 1, 26)) } function minimatch() { ->minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1)) +>minimatch : Symbol(minimatch, Decl(minimatch.js, 6, 1), Decl(minimatch.js, 1, 26)) } M.defaults = function (def) { >M.defaults : Symbol(M.defaults, Decl(minimatch.js, 8, 1)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment17.types b/tests/baselines/reference/typeFromPropertyAssignment17.types index 448880f4c89..8d32ac016b3 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment17.types +++ b/tests/baselines/reference/typeFromPropertyAssignment17.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/use.js === /// var mini = require('./minimatch') ->mini : { (): void; M: typeof M; filter: () => void; } ->require('./minimatch') : { (): void; M: typeof M; filter: () => void; } +>mini : typeof minimatch +>require('./minimatch') : typeof minimatch >require : any >'./minimatch' : "./minimatch" @@ -10,7 +10,7 @@ mini.M.defaults() >mini.M.defaults() : any >mini.M.defaults : (def: any) => any >mini.M : typeof M ->mini : { (): void; M: typeof M; filter: () => void; } +>mini : typeof minimatch >M : typeof M >defaults : (def: any) => any @@ -18,7 +18,7 @@ var m = new mini.M() >m : M >new mini.M() : M >mini.M : typeof M ->mini : { (): void; M: typeof M; filter: () => void; } +>mini : typeof minimatch >M : typeof M m.m() @@ -30,7 +30,7 @@ m.m() mini.filter() >mini.filter() : void >mini.filter : () => void ->mini : { (): void; M: typeof M; filter: () => void; } +>mini : typeof minimatch >filter : () => void === tests/cases/conformance/salsa/types.d.ts === @@ -43,23 +43,23 @@ declare var module: any; === tests/cases/conformance/salsa/minimatch.js === /// module.exports = minimatch ->module.exports = minimatch : { (): void; M: typeof M; filter: () => void; } ->module.exports : { (): void; M: typeof M; filter: () => void; } ->module : { "tests/cases/conformance/salsa/minimatch": { (): void; M: typeof M; filter: () => void; }; } ->exports : { (): void; M: typeof M; filter: () => void; } ->minimatch : { (): void; M: typeof M; filter: () => void; } +>module.exports = minimatch : typeof minimatch +>module.exports : typeof minimatch +>module : { "tests/cases/conformance/salsa/minimatch": typeof minimatch; } +>exports : typeof minimatch +>minimatch : typeof minimatch minimatch.M = M >minimatch.M = M : typeof M >minimatch.M : typeof M ->minimatch : { (): void; M: typeof M; filter: () => void; } +>minimatch : typeof minimatch >M : typeof M >M : typeof M minimatch.filter = filter >minimatch.filter = filter : () => void >minimatch.filter : () => void ->minimatch : { (): void; M: typeof M; filter: () => void; } +>minimatch : typeof minimatch >filter : () => void >filter : () => void @@ -68,10 +68,10 @@ function filter() { return minimatch() >minimatch() : void ->minimatch : { (): void; M: typeof M; filter: () => void; } +>minimatch : typeof minimatch } function minimatch() { ->minimatch : { (): void; M: typeof M; filter: () => void; } +>minimatch : typeof minimatch } M.defaults = function (def) { >M.defaults = function (def) { return def} : (def: any) => any diff --git a/tests/baselines/reference/typeFromPropertyAssignment18.symbols b/tests/baselines/reference/typeFromPropertyAssignment18.symbols index cb74bd66d39..1a7e1c292af 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment18.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment18.symbols @@ -1,46 +1,46 @@ === tests/cases/conformance/salsa/a.js === var GLOBSTAR = m.GLOBSTAR = {} ->GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3)) ->m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) ->m : Symbol(m, Decl(a.js, 0, 30)) ->GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) +>GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3), Decl(a.js, 2, 1)) +>m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) +>m : Symbol(m, Decl(a.js, 0, 30), Decl(a.js, 3, 14)) +>GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) function m() { ->m : Symbol(m, Decl(a.js, 0, 30)) +>m : Symbol(m, Decl(a.js, 0, 30), Decl(a.js, 3, 14)) } GLOBSTAR.p = 1 >GLOBSTAR.p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) ->GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3)) +>GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3), Decl(a.js, 2, 1)) >p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) m.GLOBSTAR.q = 2 >m.GLOBSTAR.q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) ->m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) ->m : Symbol(m, Decl(a.js, 0, 30)) ->GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) +>m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) +>m : Symbol(m, Decl(a.js, 0, 30), Decl(a.js, 3, 14)) +>GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) >q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) GLOBSTAR.p >GLOBSTAR.p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) ->GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3)) +>GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3), Decl(a.js, 2, 1)) >p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) GLOBSTAR.q >GLOBSTAR.q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) ->GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3)) +>GLOBSTAR : Symbol(GLOBSTAR, Decl(a.js, 0, 3), Decl(a.js, 2, 1)) >q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) m.GLOBSTAR.p >m.GLOBSTAR.p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) ->m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) ->m : Symbol(m, Decl(a.js, 0, 30)) ->GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) +>m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) +>m : Symbol(m, Decl(a.js, 0, 30), Decl(a.js, 3, 14)) +>GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) >p : Symbol(GLOBSTAR.p, Decl(a.js, 2, 1)) m.GLOBSTAR.q >m.GLOBSTAR.q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) ->m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) ->m : Symbol(m, Decl(a.js, 0, 30)) ->GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14)) +>m.GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) +>m : Symbol(m, Decl(a.js, 0, 30), Decl(a.js, 3, 14)) +>GLOBSTAR : Symbol(m.GLOBSTAR, Decl(a.js, 0, 14), Decl(a.js, 4, 2)) >q : Symbol(m.GLOBSTAR.q, Decl(a.js, 3, 14)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment18.types b/tests/baselines/reference/typeFromPropertyAssignment18.types index 6973115a0f8..1058ae610b3 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment18.types +++ b/tests/baselines/reference/typeFromPropertyAssignment18.types @@ -1,52 +1,52 @@ === tests/cases/conformance/salsa/a.js === var GLOBSTAR = m.GLOBSTAR = {} ->GLOBSTAR : { q: number; p: number; } ->m.GLOBSTAR = {} : { q: number; p: number; } ->m.GLOBSTAR : { q: number; p: number; } ->m : { (): void; GLOBSTAR: { q: number; p: number; }; } ->GLOBSTAR : { q: number; p: number; } +>GLOBSTAR : typeof m.GLOBSTAR +>m.GLOBSTAR = {} : typeof m.GLOBSTAR +>m.GLOBSTAR : typeof m.GLOBSTAR +>m : typeof m +>GLOBSTAR : typeof m.GLOBSTAR >{} : {} function m() { ->m : { (): void; GLOBSTAR: { q: number; p: number; }; } +>m : typeof m } GLOBSTAR.p = 1 >GLOBSTAR.p = 1 : 1 >GLOBSTAR.p : number ->GLOBSTAR : { q: number; p: number; } +>GLOBSTAR : typeof m.GLOBSTAR >p : number >1 : 1 m.GLOBSTAR.q = 2 >m.GLOBSTAR.q = 2 : 2 >m.GLOBSTAR.q : number ->m.GLOBSTAR : { q: number; p: number; } ->m : { (): void; GLOBSTAR: { q: number; p: number; }; } ->GLOBSTAR : { q: number; p: number; } +>m.GLOBSTAR : typeof m.GLOBSTAR +>m : typeof m +>GLOBSTAR : typeof m.GLOBSTAR >q : number >2 : 2 GLOBSTAR.p >GLOBSTAR.p : number ->GLOBSTAR : { q: number; p: number; } +>GLOBSTAR : typeof m.GLOBSTAR >p : number GLOBSTAR.q >GLOBSTAR.q : number ->GLOBSTAR : { q: number; p: number; } +>GLOBSTAR : typeof m.GLOBSTAR >q : number m.GLOBSTAR.p >m.GLOBSTAR.p : number ->m.GLOBSTAR : { q: number; p: number; } ->m : { (): void; GLOBSTAR: { q: number; p: number; }; } ->GLOBSTAR : { q: number; p: number; } +>m.GLOBSTAR : typeof m.GLOBSTAR +>m : typeof m +>GLOBSTAR : typeof m.GLOBSTAR >p : number m.GLOBSTAR.q >m.GLOBSTAR.q : number ->m.GLOBSTAR : { q: number; p: number; } ->m : { (): void; GLOBSTAR: { q: number; p: number; }; } ->GLOBSTAR : { q: number; p: number; } +>m.GLOBSTAR : typeof m.GLOBSTAR +>m : typeof m +>GLOBSTAR : typeof m.GLOBSTAR >q : number diff --git a/tests/baselines/reference/typeFromPropertyAssignment22.symbols b/tests/baselines/reference/typeFromPropertyAssignment22.symbols index 7288d7f6e26..fbdfb304f2c 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment22.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment22.symbols @@ -28,14 +28,14 @@ Installer.prototype.loadArgMetadata = function (next) { } } var i = new Installer() ->i : Symbol(i, Decl(npm-install.js, 10, 3)) +>i : Symbol(i, Decl(npm-install.js, 10, 3), Decl(npm-install.js, 10, 23)) >Installer : Symbol(Installer, Decl(npm-install.js, 0, 0)) i.newProperty = i.args // ok, number ==> number | undefined >i.newProperty : Symbol(Installer.newProperty, Decl(npm-install.js, 6, 24)) ->i : Symbol(i, Decl(npm-install.js, 10, 3)) +>i : Symbol(i, Decl(npm-install.js, 10, 3), Decl(npm-install.js, 10, 23)) >newProperty : Symbol(Installer.newProperty, Decl(npm-install.js, 6, 24)) >i.args : Symbol(Installer.args, Decl(npm-install.js, 0, 23), Decl(npm-install.js, 5, 15)) ->i : Symbol(i, Decl(npm-install.js, 10, 3)) +>i : Symbol(i, Decl(npm-install.js, 10, 3), Decl(npm-install.js, 10, 23)) >args : Symbol(Installer.args, Decl(npm-install.js, 0, 23), Decl(npm-install.js, 5, 15)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment29.symbols b/tests/baselines/reference/typeFromPropertyAssignment29.symbols index 2e51e26304b..8be54d3d87c 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment29.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment29.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/salsa/typeFromPropertyAssignment29.ts === function ExpandoDecl(n: number) { ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 0, 21)) return n.toString(); @@ -10,12 +10,12 @@ function ExpandoDecl(n: number) { } ExpandoDecl.prop = 2 >ExpandoDecl.prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1)) ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1)) ExpandoDecl.m = function(n: number) { >ExpandoDecl.m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20)) ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 4, 25)) @@ -25,17 +25,17 @@ ExpandoDecl.m = function(n: number) { var n = ExpandoDecl.prop + ExpandoDecl.m(12) + ExpandoDecl(101).length >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 17, 3), Decl(typeFromPropertyAssignment29.ts, 45, 3), Decl(typeFromPropertyAssignment29.ts, 63, 3), Decl(typeFromPropertyAssignment29.ts, 73, 3) ... and 1 more) >ExpandoDecl.prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1)) ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >prop : Symbol(ExpandoDecl.prop, Decl(typeFromPropertyAssignment29.ts, 2, 1)) >ExpandoDecl.m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20)) ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >m : Symbol(ExpandoDecl.m, Decl(typeFromPropertyAssignment29.ts, 3, 20)) >ExpandoDecl(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 3, 20)) +>ExpandoDecl : Symbol(ExpandoDecl, Decl(typeFromPropertyAssignment29.ts, 0, 0), Decl(typeFromPropertyAssignment29.ts, 2, 1)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) const ExpandoExpr = function (n: number) { ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 9, 30)) return n.toString(); @@ -45,19 +45,19 @@ const ExpandoExpr = function (n: number) { } ExpandoExpr.prop = { x: 2 } >ExpandoExpr.prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) >x : Symbol(x, Decl(typeFromPropertyAssignment29.ts, 12, 20)) ExpandoExpr.prop = { y: "" } >ExpandoExpr.prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) >y : Symbol(y, Decl(typeFromPropertyAssignment29.ts, 13, 20)) ExpandoExpr.m = function(n: number) { >ExpandoExpr.m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 13, 28)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 13, 28)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 14, 25)) @@ -68,18 +68,18 @@ var n = (ExpandoExpr.prop.x || 0) + ExpandoExpr.m(12) + ExpandoExpr(101).length >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 17, 3), Decl(typeFromPropertyAssignment29.ts, 45, 3), Decl(typeFromPropertyAssignment29.ts, 63, 3), Decl(typeFromPropertyAssignment29.ts, 73, 3) ... and 1 more) >ExpandoExpr.prop.x : Symbol(x, Decl(typeFromPropertyAssignment29.ts, 12, 20)) >ExpandoExpr.prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >prop : Symbol(ExpandoExpr.prop, Decl(typeFromPropertyAssignment29.ts, 11, 1), Decl(typeFromPropertyAssignment29.ts, 12, 27)) >x : Symbol(x, Decl(typeFromPropertyAssignment29.ts, 12, 20)) >ExpandoExpr.m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 13, 28)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >m : Symbol(ExpandoExpr.m, Decl(typeFromPropertyAssignment29.ts, 13, 28)) >ExpandoExpr(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 13, 28)) +>ExpandoExpr : Symbol(ExpandoExpr, Decl(typeFromPropertyAssignment29.ts, 9, 5), Decl(typeFromPropertyAssignment29.ts, 11, 1)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) const ExpandoArrow = (n: number) => n.toString(); ->ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 20, 21)) +>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 19, 49)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 19, 22)) >n.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 19, 22)) @@ -87,12 +87,12 @@ const ExpandoArrow = (n: number) => n.toString(); ExpandoArrow.prop = 2 >ExpandoArrow.prop : Symbol(ExpandoArrow.prop, Decl(typeFromPropertyAssignment29.ts, 19, 49)) ->ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 20, 21)) +>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 19, 49)) >prop : Symbol(ExpandoArrow.prop, Decl(typeFromPropertyAssignment29.ts, 19, 49)) ExpandoArrow.m = function(n: number) { >ExpandoArrow.m : Symbol(ExpandoArrow.m, Decl(typeFromPropertyAssignment29.ts, 20, 21)) ->ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 20, 21)) +>ExpandoArrow : Symbol(ExpandoArrow, Decl(typeFromPropertyAssignment29.ts, 19, 5), Decl(typeFromPropertyAssignment29.ts, 19, 49)) >m : Symbol(ExpandoArrow.m, Decl(typeFromPropertyAssignment29.ts, 20, 21)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 21, 26)) @@ -102,7 +102,7 @@ ExpandoArrow.m = function(n: number) { } function ExpandoNested(n: number) { ->ExpandoNested : Symbol(ExpandoNested, Decl(typeFromPropertyAssignment29.ts, 24, 1)) +>ExpandoNested : Symbol(ExpandoNested, Decl(typeFromPropertyAssignment29.ts, 24, 1), Decl(typeFromPropertyAssignment29.ts, 32, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 26, 23)) const nested = function (m: number) { @@ -125,11 +125,11 @@ function ExpandoNested(n: number) { } ExpandoNested.also = -1; >ExpandoNested.also : Symbol(ExpandoNested.also, Decl(typeFromPropertyAssignment29.ts, 32, 1)) ->ExpandoNested : Symbol(ExpandoNested, Decl(typeFromPropertyAssignment29.ts, 24, 1)) +>ExpandoNested : Symbol(ExpandoNested, Decl(typeFromPropertyAssignment29.ts, 24, 1), Decl(typeFromPropertyAssignment29.ts, 32, 1)) >also : Symbol(ExpandoNested.also, Decl(typeFromPropertyAssignment29.ts, 32, 1)) function ExpandoMerge(n: number) { ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 35, 22)) return n * 100; @@ -137,17 +137,17 @@ function ExpandoMerge(n: number) { } ExpandoMerge.p1 = 111 >ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment29.ts, 37, 1)) ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) >p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment29.ts, 37, 1)) namespace ExpandoMerge { ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) export var p2 = 222; >p2 : Symbol(p2, Decl(typeFromPropertyAssignment29.ts, 40, 14)) } namespace ExpandoMerge { ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) export var p3 = 333; >p3 : Symbol(p3, Decl(typeFromPropertyAssignment29.ts, 43, 14)) @@ -155,15 +155,15 @@ namespace ExpandoMerge { var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge(1); >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 17, 3), Decl(typeFromPropertyAssignment29.ts, 45, 3), Decl(typeFromPropertyAssignment29.ts, 63, 3), Decl(typeFromPropertyAssignment29.ts, 73, 3) ... and 1 more) >ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment29.ts, 37, 1)) ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) >p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment29.ts, 37, 1)) >ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment29.ts, 40, 14)) ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) >p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment29.ts, 40, 14)) >ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment29.ts, 43, 14)) ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) >p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment29.ts, 43, 14)) ->ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment29.ts, 33, 24), Decl(typeFromPropertyAssignment29.ts, 37, 1), Decl(typeFromPropertyAssignment29.ts, 38, 21), Decl(typeFromPropertyAssignment29.ts, 41, 1)) namespace Ns { >Ns : Symbol(Ns, Decl(typeFromPropertyAssignment29.ts, 45, 78)) @@ -186,7 +186,7 @@ namespace Ns { // Should not work in Typescript -- must be const var ExpandoExpr2 = function (n: number) { ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 56, 29)) return n.toString(); @@ -195,10 +195,10 @@ var ExpandoExpr2 = function (n: number) { >toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) } ExpandoExpr2.prop = 2 ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) ExpandoExpr2.m = function(n: number) { ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 60, 26)) return n + 1; @@ -206,10 +206,10 @@ ExpandoExpr2.m = function(n: number) { } var n = ExpandoExpr2.prop + ExpandoExpr2.m(12) + ExpandoExpr2(101).length >n : Symbol(n, Decl(typeFromPropertyAssignment29.ts, 7, 3), Decl(typeFromPropertyAssignment29.ts, 17, 3), Decl(typeFromPropertyAssignment29.ts, 45, 3), Decl(typeFromPropertyAssignment29.ts, 63, 3), Decl(typeFromPropertyAssignment29.ts, 73, 3) ... and 1 more) ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) >ExpandoExpr2(101).length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 59, 21)) +>ExpandoExpr2 : Symbol(ExpandoExpr2, Decl(typeFromPropertyAssignment29.ts, 56, 3), Decl(typeFromPropertyAssignment29.ts, 58, 1)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) // Should not work in typescript -- classes already have statics diff --git a/tests/baselines/reference/typeFromPropertyAssignment29.types b/tests/baselines/reference/typeFromPropertyAssignment29.types index 1421ec885c5..28a6700f482 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment29.types +++ b/tests/baselines/reference/typeFromPropertyAssignment29.types @@ -144,7 +144,7 @@ ExpandoArrow.m = function(n: number) { } function ExpandoNested(n: number) { ->ExpandoNested : { (n: number): { (m: number): number; total: number; }; also: number; } +>ExpandoNested : typeof ExpandoNested >n : number const nested = function (m: number) { @@ -173,7 +173,7 @@ function ExpandoNested(n: number) { ExpandoNested.also = -1; >ExpandoNested.also = -1 : -1 >ExpandoNested.also : number ->ExpandoNested : { (n: number): { (m: number): number; total: number; }; also: number; } +>ExpandoNested : typeof ExpandoNested >also : number >-1 : -1 >1 : 1 diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt new file mode 100644 index 00000000000..6055e89ffec --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts(25,1): error TS2322: Type 'false' is not assignable to type 'number'. + + +==== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + namespace ExpandoMerge { + export var p2 = 222; + } + ExpandoMerge.p4 = 44444; // ok + ExpandoMerge.p6 = 66666; // ok + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + ExpandoMerge.p5 = 555555; // ok + ExpandoMerge.p7 = 777777; // ok + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.js b/tests/baselines/reference/typeFromPropertyAssignment31.js new file mode 100644 index 00000000000..e5c9bda9550 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.js @@ -0,0 +1,56 @@ +//// [typeFromPropertyAssignment31.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +namespace ExpandoMerge { + export var p2 = 222; +} +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + +//// [typeFromPropertyAssignment31.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.symbols b/tests/baselines/reference/typeFromPropertyAssignment31.symbols new file mode 100644 index 00000000000..5a20510a739 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.symbols @@ -0,0 +1,116 @@ +=== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 4, 26)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +} +ExpandoMerge.p4 = 44444; // ok +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) + +ExpandoMerge.p6 = 66666; // ok +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) + +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +} +ExpandoMerge.p5 = 555555; // ok +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) + +ExpandoMerge.p7 = 777777; // ok +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(typeFromPropertyAssignment31.ts, 25, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p1 : Symbol(ExpandoMerge.p1, Decl(typeFromPropertyAssignment31.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p2 : Symbol(ExpandoMerge.p2, Decl(typeFromPropertyAssignment31.ts, 8, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p3 : Symbol(ExpandoMerge.p3, Decl(typeFromPropertyAssignment31.ts, 14, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p4 : Symbol(ExpandoMerge.p4, Decl(typeFromPropertyAssignment31.ts, 9, 1), Decl(typeFromPropertyAssignment31.ts, 15, 14)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p5 : Symbol(ExpandoMerge.p5, Decl(typeFromPropertyAssignment31.ts, 16, 14), Decl(typeFromPropertyAssignment31.ts, 21, 1)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p6 : Symbol(ExpandoMerge.p6, Decl(typeFromPropertyAssignment31.ts, 10, 24), Decl(typeFromPropertyAssignment31.ts, 17, 14)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p7 : Symbol(ExpandoMerge.p7, Decl(typeFromPropertyAssignment31.ts, 18, 14), Decl(typeFromPropertyAssignment31.ts, 22, 25)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p8 : Symbol(ExpandoMerge.p8, Decl(typeFromPropertyAssignment31.ts, 11, 24), Decl(typeFromPropertyAssignment31.ts, 19, 14)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>p9 : Symbol(ExpandoMerge.p9, Decl(typeFromPropertyAssignment31.ts, 20, 14), Decl(typeFromPropertyAssignment31.ts, 23, 25)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) +>m : Symbol(ExpandoMerge.m, Decl(typeFromPropertyAssignment31.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(typeFromPropertyAssignment31.ts, 0, 0), Decl(typeFromPropertyAssignment31.ts, 2, 1), Decl(typeFromPropertyAssignment31.ts, 6, 1), Decl(typeFromPropertyAssignment31.ts, 12, 24)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignment31.types b/tests/baselines/reference/typeFromPropertyAssignment31.types new file mode 100644 index 00000000000..e302d58d507 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment31.types @@ -0,0 +1,156 @@ +=== tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} +ExpandoMerge.p4 = 44444; // ok +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p6 = 66666; // ok +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +ExpandoMerge.p5 = 555555; // ok +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p7 = 777777; // ok +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt new file mode 100644 index 00000000000..bd8d4b003d8 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/salsa/expando.ts(12,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/expando.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/ns.ts(1,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. +tests/cases/conformance/salsa/ns.ts(10,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + + +==== tests/cases/conformance/salsa/expando.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + ExpandoMerge.p4 = 44444; + ExpandoMerge.p5 = 555555; + ExpandoMerge.p6 = 66666; + ExpandoMerge.p7 = 777777; + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +==== tests/cases/conformance/salsa/ns.ts (2 errors) ==== + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p2 = 222; + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.js b/tests/baselines/reference/typeFromPropertyAssignment32.js new file mode 100644 index 00000000000..d805f678358 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts] //// + +//// [expando.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +//// [ns.ts] +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +//// [expando.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +//// [ns.js] +var ExpandoMerge; +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.symbols b/tests/baselines/reference/typeFromPropertyAssignment32.symbols new file mode 100644 index 00000000000..0daec198f71 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>n : Symbol(n, Decl(expando.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(expando.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>n : Symbol(n, Decl(expando.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(expando.ts, 4, 26)) +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(expando.ts, 13, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(ns.ts, 1, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(expando.ts, 6, 1), Decl(ns.ts, 2, 14)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(expando.ts, 7, 24), Decl(ns.ts, 3, 14)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(expando.ts, 8, 25), Decl(ns.ts, 4, 14)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(expando.ts, 9, 24), Decl(ns.ts, 5, 14)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(expando.ts, 10, 25), Decl(ns.ts, 6, 14)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(expando.ts, 11, 24), Decl(ns.ts, 7, 14)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1), Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(ns.ts, 10, 14)) +} + diff --git a/tests/baselines/reference/typeFromPropertyAssignment32.types b/tests/baselines/reference/typeFromPropertyAssignment32.types new file mode 100644 index 00000000000..3ed7612d9c0 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment32.types @@ -0,0 +1,158 @@ +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} + diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt new file mode 100644 index 00000000000..a4617c3d26a --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/salsa/expando.ts(12,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/expando.ts(13,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/salsa/ns.ts(1,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. +tests/cases/conformance/salsa/ns.ts(10,11): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + + +==== tests/cases/conformance/salsa/ns.ts (2 errors) ==== + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; + } + namespace ExpandoMerge { + ~~~~~~~~~~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. + export var p2 = 222; + } + + +==== tests/cases/conformance/salsa/expando.ts (2 errors) ==== + function ExpandoMerge(n: number) { + return n; + } + ExpandoMerge.p1 = 111 + ExpandoMerge.m = function(n: number) { + return n + 1; + } + ExpandoMerge.p4 = 44444; + ExpandoMerge.p5 = 555555; + ExpandoMerge.p6 = 66666; + ExpandoMerge.p7 = 777777; + ExpandoMerge.p8 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + ExpandoMerge.p9 = false; // type error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'number'. + var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.js b/tests/baselines/reference/typeFromPropertyAssignment33.js new file mode 100644 index 00000000000..fa431a0f273 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts] //// + +//// [ns.ts] +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +//// [expando.ts] +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + + + +//// [ns.js] +var ExpandoMerge; +(function (ExpandoMerge) { + ExpandoMerge.p3 = 333; + ExpandoMerge.p4 = 4; + ExpandoMerge.p5 = 5; + ExpandoMerge.p6 = 6; + ExpandoMerge.p7 = 7; + ExpandoMerge.p8 = 6; + ExpandoMerge.p9 = 7; +})(ExpandoMerge || (ExpandoMerge = {})); +(function (ExpandoMerge) { + ExpandoMerge.p2 = 222; +})(ExpandoMerge || (ExpandoMerge = {})); +//// [expando.js] +function ExpandoMerge(n) { + return n; +} +ExpandoMerge.p1 = 111; +ExpandoMerge.m = function (n) { + return n + 1; +}; +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.symbols b/tests/baselines/reference/typeFromPropertyAssignment33.symbols new file mode 100644 index 00000000000..2bdaebbbfdd --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) + + export var p3 = 333; +>p3 : Symbol(p3, Decl(ns.ts, 1, 14)) + + export var p4 = 4; +>p4 : Symbol(p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) + + export var p5 = 5; +>p5 : Symbol(p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) + + export let p6 = 6; +>p6 : Symbol(p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) + + export let p7 = 7; +>p7 : Symbol(p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) + + export var p8 = 6; +>p8 : Symbol(p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) + + export let p9 = 7; +>p9 : Symbol(p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +} +namespace ExpandoMerge { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) + + export var p2 = 222; +>p2 : Symbol(p2, Decl(ns.ts, 10, 14)) +} + + +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>n : Symbol(n, Decl(expando.ts, 0, 22)) + + return n; +>n : Symbol(n, Decl(expando.ts, 0, 22)) +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>n : Symbol(n, Decl(expando.ts, 4, 26)) + + return n + 1; +>n : Symbol(n, Decl(expando.ts, 4, 26)) +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : Symbol(n, Decl(expando.ts, 13, 3)) +>ExpandoMerge.p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p1 : Symbol(ExpandoMerge.p1, Decl(expando.ts, 2, 1)) +>ExpandoMerge.p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p2 : Symbol(ExpandoMerge.p2, Decl(ns.ts, 10, 14)) +>ExpandoMerge.p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p3 : Symbol(ExpandoMerge.p3, Decl(ns.ts, 1, 14)) +>ExpandoMerge.p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p4 : Symbol(ExpandoMerge.p4, Decl(ns.ts, 2, 14), Decl(expando.ts, 6, 1)) +>ExpandoMerge.p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p5 : Symbol(ExpandoMerge.p5, Decl(ns.ts, 3, 14), Decl(expando.ts, 7, 24)) +>ExpandoMerge.p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p6 : Symbol(ExpandoMerge.p6, Decl(ns.ts, 4, 14), Decl(expando.ts, 8, 25)) +>ExpandoMerge.p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p7 : Symbol(ExpandoMerge.p7, Decl(ns.ts, 5, 14), Decl(expando.ts, 9, 24)) +>ExpandoMerge.p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p8 : Symbol(ExpandoMerge.p8, Decl(ns.ts, 6, 14), Decl(expando.ts, 10, 25)) +>ExpandoMerge.p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>p9 : Symbol(ExpandoMerge.p9, Decl(ns.ts, 7, 14), Decl(expando.ts, 11, 24)) +>ExpandoMerge.m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) +>m : Symbol(ExpandoMerge.m, Decl(expando.ts, 3, 21)) +>ExpandoMerge : Symbol(ExpandoMerge, Decl(ns.ts, 0, 0), Decl(ns.ts, 8, 1), Decl(expando.ts, 0, 0), Decl(expando.ts, 2, 1)) + + diff --git a/tests/baselines/reference/typeFromPropertyAssignment33.types b/tests/baselines/reference/typeFromPropertyAssignment33.types new file mode 100644 index 00000000000..1416b798467 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment33.types @@ -0,0 +1,160 @@ +=== tests/cases/conformance/salsa/ns.ts === +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p3 = 333; +>p3 : number +>333 : 333 + + export var p4 = 4; +>p4 : number +>4 : 4 + + export var p5 = 5; +>p5 : number +>5 : 5 + + export let p6 = 6; +>p6 : number +>6 : 6 + + export let p7 = 7; +>p7 : number +>7 : 7 + + export var p8 = 6; +>p8 : number +>6 : 6 + + export let p9 = 7; +>p9 : number +>7 : 7 +} +namespace ExpandoMerge { +>ExpandoMerge : typeof ExpandoMerge + + export var p2 = 222; +>p2 : number +>222 : 222 +} + + +=== tests/cases/conformance/salsa/expando.ts === +function ExpandoMerge(n: number) { +>ExpandoMerge : typeof ExpandoMerge +>n : number + + return n; +>n : number +} +ExpandoMerge.p1 = 111 +>ExpandoMerge.p1 = 111 : 111 +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>111 : 111 + +ExpandoMerge.m = function(n: number) { +>ExpandoMerge.m = function(n: number) { return n + 1;} : (n: number) => number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>function(n: number) { return n + 1;} : (n: number) => number +>n : number + + return n + 1; +>n + 1 : number +>n : number +>1 : 1 +} +ExpandoMerge.p4 = 44444; +>ExpandoMerge.p4 = 44444 : 44444 +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>44444 : 44444 + +ExpandoMerge.p5 = 555555; +>ExpandoMerge.p5 = 555555 : 555555 +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>555555 : 555555 + +ExpandoMerge.p6 = 66666; +>ExpandoMerge.p6 = 66666 : 66666 +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>66666 : 66666 + +ExpandoMerge.p7 = 777777; +>ExpandoMerge.p7 = 777777 : 777777 +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>777777 : 777777 + +ExpandoMerge.p8 = false; // type error +>ExpandoMerge.p8 = false : false +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>false : false + +ExpandoMerge.p9 = false; // type error +>ExpandoMerge.p9 = false : false +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>false : false + +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); +>n : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 : number +>ExpandoMerge.p1 + ExpandoMerge.p2 : number +>ExpandoMerge.p1 : number +>ExpandoMerge : typeof ExpandoMerge +>p1 : number +>ExpandoMerge.p2 : number +>ExpandoMerge : typeof ExpandoMerge +>p2 : number +>ExpandoMerge.p3 : number +>ExpandoMerge : typeof ExpandoMerge +>p3 : number +>ExpandoMerge.p4 : number +>ExpandoMerge : typeof ExpandoMerge +>p4 : number +>ExpandoMerge.p5 : number +>ExpandoMerge : typeof ExpandoMerge +>p5 : number +>ExpandoMerge.p6 : number +>ExpandoMerge : typeof ExpandoMerge +>p6 : number +>ExpandoMerge.p7 : number +>ExpandoMerge : typeof ExpandoMerge +>p7 : number +>ExpandoMerge.p8 : number +>ExpandoMerge : typeof ExpandoMerge +>p8 : number +>ExpandoMerge.p9 : number +>ExpandoMerge : typeof ExpandoMerge +>p9 : number +>ExpandoMerge.m(12) : number +>ExpandoMerge.m : (n: number) => number +>ExpandoMerge : typeof ExpandoMerge +>m : (n: number) => number +>12 : 12 +>ExpandoMerge(1001) : number +>ExpandoMerge : typeof ExpandoMerge +>1001 : 1001 + + diff --git a/tests/baselines/reference/typeFromPropertyAssignment34.symbols b/tests/baselines/reference/typeFromPropertyAssignment34.symbols new file mode 100644 index 00000000000..fb9984c1a87 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment34.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/salsa/file1.js === +var N = {}; +>N : Symbol(N, Decl(file1.js, 0, 3), Decl(file1.js, 0, 11), Decl(file2.js, 0, 0)) + +N.commands = {}; +>N.commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) +>N : Symbol(N, Decl(file1.js, 0, 3), Decl(file1.js, 0, 11), Decl(file2.js, 0, 0)) +>commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) + +=== tests/cases/conformance/salsa/file2.js === +N.commands.a = 111; +>N.commands.a : Symbol(N.commands.a, Decl(file2.js, 0, 0)) +>N.commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) +>N : Symbol(N, Decl(file1.js, 0, 3), Decl(file1.js, 0, 11), Decl(file2.js, 0, 0)) +>commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) +>a : Symbol(N.commands.a, Decl(file2.js, 0, 0)) + +N.commands.b = function () { }; +>N.commands.b : Symbol(N.commands.b, Decl(file2.js, 0, 19)) +>N.commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) +>N : Symbol(N, Decl(file1.js, 0, 3), Decl(file1.js, 0, 11), Decl(file2.js, 0, 0)) +>commands : Symbol(N.commands, Decl(file1.js, 0, 11), Decl(file2.js, 0, 2)) +>b : Symbol(N.commands.b, Decl(file2.js, 0, 19)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignment34.types b/tests/baselines/reference/typeFromPropertyAssignment34.types new file mode 100644 index 00000000000..ee59c928322 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment34.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/salsa/file1.js === +var N = {}; +>N : typeof N +>{} : {} + +N.commands = {}; +>N.commands = {} : typeof N.commands +>N.commands : typeof N.commands +>N : typeof N +>commands : typeof N.commands +>{} : {} + +=== tests/cases/conformance/salsa/file2.js === +N.commands.a = 111; +>N.commands.a = 111 : 111 +>N.commands.a : number +>N.commands : typeof N.commands +>N : typeof N +>commands : typeof N.commands +>a : number +>111 : 111 + +N.commands.b = function () { }; +>N.commands.b = function () { } : () => void +>N.commands.b : () => void +>N.commands : typeof N.commands +>N : typeof N +>commands : typeof N.commands +>b : () => void +>function () { } : () => void + diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types index 4787c07d758..6510b73d44d 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types @@ -14,7 +14,7 @@ if (typeof a === "number") { let c: number = a; >c : number ->a : number +>a : number & {} } if (typeof a === "string") { >typeof a === "string" : boolean @@ -24,7 +24,7 @@ if (typeof a === "string") { let c: string = a; >c : string ->a : string +>a : string & {} } if (typeof a === "boolean") { >typeof a === "boolean" : boolean @@ -34,7 +34,7 @@ if (typeof a === "boolean") { let c: boolean = a; >c : boolean ->a : boolean +>a : (false & {}) | (true & {}) } if (typeof b === "number") { @@ -45,7 +45,7 @@ if (typeof b === "number") { let c: number = b; >c : number ->b : number +>b : { toString(): string; } & number } if (typeof b === "string") { >typeof b === "string" : boolean @@ -55,7 +55,7 @@ if (typeof b === "string") { let c: string = b; >c : string ->b : string +>b : { toString(): string; } & string } if (typeof b === "boolean") { >typeof b === "boolean" : boolean @@ -65,6 +65,6 @@ if (typeof b === "boolean") { let c: boolean = b; >c : boolean ->b : boolean +>b : ({ toString(): string; } & false) | ({ toString(): string; } & true) } diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index a28dab04490..00777ac0eae 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -134,7 +134,7 @@ function test5(a: boolean | void) { } else { a; ->a : boolean | void +>a : undefined } } @@ -151,15 +151,15 @@ function test6(a: boolean | void) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" ->a : boolean | void +>a : undefined >"boolean" : "boolean" a; ->a : boolean +>a : never } else { a; ->a : void +>a : undefined } } else { @@ -184,7 +184,7 @@ function test7(a: boolean | void) { >"boolean" : "boolean" a; ->a : boolean | void +>a : boolean } else { a; @@ -212,7 +212,7 @@ function test8(a: boolean | void) { } else { a; ->a : boolean | void +>a : undefined } } @@ -242,7 +242,7 @@ function test9(a: boolean | number) { } else { a; ->a : number | boolean +>a : undefined } } @@ -259,15 +259,15 @@ function test10(a: boolean | number) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" ->a : number | boolean +>a : undefined >"boolean" : "boolean" a; ->a : boolean +>a : never } else { a; ->a : number +>a : undefined } } else { @@ -292,7 +292,7 @@ function test11(a: boolean | number) { >"boolean" : "boolean" a; ->a : number | boolean +>a : boolean } else { a; @@ -320,7 +320,7 @@ function test12(a: boolean | number) { } else { a; ->a : number | boolean +>a : number } } @@ -350,7 +350,7 @@ function test13(a: boolean | number | void) { } else { a; ->a : number | boolean | void +>a : undefined } } @@ -367,15 +367,15 @@ function test14(a: boolean | number | void) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" ->a : number | boolean | void +>a : undefined >"boolean" : "boolean" a; ->a : boolean +>a : never } else { a; ->a : number | void +>a : undefined } } else { @@ -400,7 +400,7 @@ function test15(a: boolean | number | void) { >"boolean" : "boolean" a; ->a : number | boolean | void +>a : boolean } else { a; @@ -428,7 +428,7 @@ function test16(a: boolean | number | void) { } else { a; ->a : number | boolean | void +>a : number } } diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt index 08706d095b2..8f286e39863 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt @@ -1,12 +1,8 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. - Types of property 'length' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,9): error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. - Types of property 'length' are incompatible. - Type '{}' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,11): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,11): error TS2322: Type '{}' is not assignable to type 'number'. 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[]'. @@ -35,15 +31,13 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy function foo2(x: T, y: U) { return y; } // this is now an error foo2(1, { length: '' }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. -!!! error TS2345: Types of property 'length' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }' foo2(1, { length: {} }); - ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. -!!! error TS2345: Types of property 'length' are incompatible. -!!! error TS2345: Type '{}' is not assignable to type 'number'. + ~~~~~~ +!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }' foo2([], ['']); ~~~~ !!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.types b/tests/baselines/reference/typeParameterExtendingUnion1.types index 85c2096823b..e3eb4c14ca0 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.types +++ b/tests/baselines/reference/typeParameterExtendingUnion1.types @@ -30,9 +30,9 @@ function f(a: T) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : T ->run : () => void +>run : (() => void) | (() => void) run(a); >run(a) : void diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.types b/tests/baselines/reference/typeParameterExtendingUnion2.types index c19076ddd68..074ac3b3fff 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.types +++ b/tests/baselines/reference/typeParameterExtendingUnion2.types @@ -19,9 +19,9 @@ function run(a: Cat | Dog) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : Cat | Dog ->run : () => void +>run : (() => void) | (() => void) } function f(a: T) { @@ -30,9 +30,9 @@ function f(a: T) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : T ->run : () => void +>run : (() => void) | (() => void) run(a); >run(a) : void diff --git a/tests/baselines/reference/typedefTagWrapping.errors.txt b/tests/baselines/reference/typedefTagWrapping.errors.txt new file mode 100644 index 00000000000..f480c1391e8 --- /dev/null +++ b/tests/baselines/reference/typedefTagWrapping.errors.txt @@ -0,0 +1,136 @@ +tests/cases/conformance/jsdoc/mod7.js(5,7): error TS1110: Type expected. +tests/cases/conformance/jsdoc/mod7.js(8,4): error TS1110: Type expected. + + +==== tests/cases/conformance/jsdoc/mod1.js (0 errors) ==== + /** + * @typedef {function(string): boolean} + * Type1 + */ + + /** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ + function callIt(func, arg) { + return func(arg); + } + +==== tests/cases/conformance/jsdoc/mod2.js (0 errors) ==== + /** + * @typedef {{ + * num: number, + * str: string, + * boo: boolean + * }} Type2 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. + * @returns {string|number} The return. + */ + function check(obj) { + return obj.boo ? obj.num : obj.str; + } + +==== tests/cases/conformance/jsdoc/mod3.js (0 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): + * (string|number)} StringOrNumber1 + */ + + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ + function use1(func, bool, str, num) { + return func(bool, str, num) + } + +==== tests/cases/conformance/jsdoc/mod4.js (0 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, + * number): + * (string|number)} StringOrNumber2 + */ + + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ + function use2(func, bool, str, num) { + return func(bool, str, num) + } + +==== tests/cases/conformance/jsdoc/mod5.js (0 errors) ==== + /** + * @typedef {{ + * num: + * number, + * str: + * string, + * boo: + * boolean + * }} Type5 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. + * @returns {string|number} The return. + */ + function check5(obj) { + return obj.boo ? obj.num : obj.str; + } + +==== tests/cases/conformance/jsdoc/mod6.js (0 errors) ==== + /** + * @typedef {{ + * foo: + * *, + * bar: + * * + * }} Type6 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. + * @returns {*} The return. + */ + function check6(obj) { + return obj.foo; + } + + +==== tests/cases/conformance/jsdoc/mod7.js (2 errors) ==== + /** + Multiline type expressions in comments without leading * are not supported. + @typedef {{ + foo: + *, + ~ +!!! error TS1110: Type expected. + bar: + * + }} Type7 + ~ +!!! error TS1110: Type expected. + */ + \ No newline at end of file diff --git a/tests/baselines/reference/typedefTagWrapping.symbols b/tests/baselines/reference/typedefTagWrapping.symbols new file mode 100644 index 00000000000..ea0bb73a849 --- /dev/null +++ b/tests/baselines/reference/typedefTagWrapping.symbols @@ -0,0 +1,185 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** + * @typedef {function(string): boolean} + * Type1 + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { +>callIt : Symbol(callIt, Decl(mod1.js, 0, 0)) +>func : Symbol(func, Decl(mod1.js, 12, 16)) +>arg : Symbol(arg, Decl(mod1.js, 12, 21)) + + return func(arg); +>func : Symbol(func, Decl(mod1.js, 12, 16)) +>arg : Symbol(arg, Decl(mod1.js, 12, 21)) +} + +=== tests/cases/conformance/jsdoc/mod2.js === +/** + * @typedef {{ + * num: number, + * str: string, + * boo: boolean + * }} Type2 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. + * @returns {string|number} The return. + */ +function check(obj) { +>check : Symbol(check, Decl(mod2.js, 0, 0)) +>obj : Symbol(obj, Decl(mod2.js, 13, 15)) + + return obj.boo ? obj.num : obj.str; +>obj.boo : Symbol(boo, Decl(mod2.js, 3, 17)) +>obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>boo : Symbol(boo, Decl(mod2.js, 3, 17)) +>obj.num : Symbol(num, Decl(mod2.js, 1, 14)) +>obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>num : Symbol(num, Decl(mod2.js, 1, 14)) +>obj.str : Symbol(str, Decl(mod2.js, 2, 17)) +>obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>str : Symbol(str, Decl(mod2.js, 2, 17)) +} + +=== tests/cases/conformance/jsdoc/mod3.js === +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): + * (string|number)} StringOrNumber1 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use1(func, bool, str, num) { +>use1 : Symbol(use1, Decl(mod3.js, 0, 0)) +>func : Symbol(func, Decl(mod3.js, 15, 14)) +>bool : Symbol(bool, Decl(mod3.js, 15, 19)) +>str : Symbol(str, Decl(mod3.js, 15, 25)) +>num : Symbol(num, Decl(mod3.js, 15, 30)) + + return func(bool, str, num) +>func : Symbol(func, Decl(mod3.js, 15, 14)) +>bool : Symbol(bool, Decl(mod3.js, 15, 19)) +>str : Symbol(str, Decl(mod3.js, 15, 25)) +>num : Symbol(num, Decl(mod3.js, 15, 30)) +} + +=== tests/cases/conformance/jsdoc/mod4.js === +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, + * number): + * (string|number)} StringOrNumber2 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use2(func, bool, str, num) { +>use2 : Symbol(use2, Decl(mod4.js, 0, 0)) +>func : Symbol(func, Decl(mod4.js, 16, 14)) +>bool : Symbol(bool, Decl(mod4.js, 16, 19)) +>str : Symbol(str, Decl(mod4.js, 16, 25)) +>num : Symbol(num, Decl(mod4.js, 16, 30)) + + return func(bool, str, num) +>func : Symbol(func, Decl(mod4.js, 16, 14)) +>bool : Symbol(bool, Decl(mod4.js, 16, 19)) +>str : Symbol(str, Decl(mod4.js, 16, 25)) +>num : Symbol(num, Decl(mod4.js, 16, 30)) +} + +=== tests/cases/conformance/jsdoc/mod5.js === +/** + * @typedef {{ + * num: + * number, + * str: + * string, + * boo: + * boolean + * }} Type5 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. + * @returns {string|number} The return. + */ +function check5(obj) { +>check5 : Symbol(check5, Decl(mod5.js, 0, 0)) +>obj : Symbol(obj, Decl(mod5.js, 16, 16)) + + return obj.boo ? obj.num : obj.str; +>obj.boo : Symbol(boo, Decl(mod5.js, 5, 12)) +>obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>boo : Symbol(boo, Decl(mod5.js, 5, 12)) +>obj.num : Symbol(num, Decl(mod5.js, 1, 14)) +>obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>num : Symbol(num, Decl(mod5.js, 1, 14)) +>obj.str : Symbol(str, Decl(mod5.js, 3, 12)) +>obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>str : Symbol(str, Decl(mod5.js, 3, 12)) +} + +=== tests/cases/conformance/jsdoc/mod6.js === +/** + * @typedef {{ + * foo: + * *, + * bar: + * * + * }} Type6 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. + * @returns {*} The return. + */ +function check6(obj) { +>check6 : Symbol(check6, Decl(mod6.js, 0, 0)) +>obj : Symbol(obj, Decl(mod6.js, 14, 16)) + + return obj.foo; +>obj.foo : Symbol(foo, Decl(mod6.js, 1, 14)) +>obj : Symbol(obj, Decl(mod6.js, 14, 16)) +>foo : Symbol(foo, Decl(mod6.js, 1, 14)) +} + + +=== tests/cases/conformance/jsdoc/mod7.js === +/** +No type information for this code. Multiline type expressions in comments without leading * are not supported. +No type information for this code. @typedef {{ +No type information for this code. foo: +No type information for this code. *, +No type information for this code. bar: +No type information for this code. * +No type information for this code. }} Type7 +No type information for this code. */ +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typedefTagWrapping.types b/tests/baselines/reference/typedefTagWrapping.types new file mode 100644 index 00000000000..8b49439d7db --- /dev/null +++ b/tests/baselines/reference/typedefTagWrapping.types @@ -0,0 +1,190 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** + * @typedef {function(string): boolean} + * Type1 + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { +>callIt : (func: (arg0: string) => boolean, arg: string) => boolean +>func : (arg0: string) => boolean +>arg : string + + return func(arg); +>func(arg) : boolean +>func : (arg0: string) => boolean +>arg : string +} + +=== tests/cases/conformance/jsdoc/mod2.js === +/** + * @typedef {{ + * num: number, + * str: string, + * boo: boolean + * }} Type2 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. + * @returns {string|number} The return. + */ +function check(obj) { +>check : (obj: { num: number; str: string; boo: boolean; }) => string | number +>obj : { num: number; str: string; boo: boolean; } + + return obj.boo ? obj.num : obj.str; +>obj.boo ? obj.num : obj.str : string | number +>obj.boo : boolean +>obj : { num: number; str: string; boo: boolean; } +>boo : boolean +>obj.num : number +>obj : { num: number; str: string; boo: boolean; } +>num : number +>obj.str : string +>obj : { num: number; str: string; boo: boolean; } +>str : string +} + +=== tests/cases/conformance/jsdoc/mod3.js === +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): + * (string|number)} StringOrNumber1 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use1(func, bool, str, num) { +>use1 : (func: (arg0: boolean, arg1: string, arg2: number) => string | number, bool: boolean, str: string, num: number) => string | number +>func : (arg0: boolean, arg1: string, arg2: number) => string | number +>bool : boolean +>str : string +>num : number + + return func(bool, str, num) +>func(bool, str, num) : string | number +>func : (arg0: boolean, arg1: string, arg2: number) => string | number +>bool : boolean +>str : string +>num : number +} + +=== tests/cases/conformance/jsdoc/mod4.js === +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, + * number): + * (string|number)} StringOrNumber2 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use2(func, bool, str, num) { +>use2 : (func: (arg0: boolean, arg1: string, arg2: number) => string | number, bool: boolean, str: string, num: number) => string | number +>func : (arg0: boolean, arg1: string, arg2: number) => string | number +>bool : boolean +>str : string +>num : number + + return func(bool, str, num) +>func(bool, str, num) : string | number +>func : (arg0: boolean, arg1: string, arg2: number) => string | number +>bool : boolean +>str : string +>num : number +} + +=== tests/cases/conformance/jsdoc/mod5.js === +/** + * @typedef {{ + * num: + * number, + * str: + * string, + * boo: + * boolean + * }} Type5 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. + * @returns {string|number} The return. + */ +function check5(obj) { +>check5 : (obj: { num: number; str: string; boo: boolean; }) => string | number +>obj : { num: number; str: string; boo: boolean; } + + return obj.boo ? obj.num : obj.str; +>obj.boo ? obj.num : obj.str : string | number +>obj.boo : boolean +>obj : { num: number; str: string; boo: boolean; } +>boo : boolean +>obj.num : number +>obj : { num: number; str: string; boo: boolean; } +>num : number +>obj.str : string +>obj : { num: number; str: string; boo: boolean; } +>str : string +} + +=== tests/cases/conformance/jsdoc/mod6.js === +/** + * @typedef {{ + * foo: + * *, + * bar: + * * + * }} Type6 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. + * @returns {*} The return. + */ +function check6(obj) { +>check6 : (obj: { foo: any; bar: any; }) => any +>obj : { foo: any; bar: any; } + + return obj.foo; +>obj.foo : any +>obj : { foo: any; bar: any; } +>foo : any +} + + +=== tests/cases/conformance/jsdoc/mod7.js === +/** +No type information for this code. Multiline type expressions in comments without leading * are not supported. +No type information for this code. @typedef {{ +No type information for this code. foo: +No type information for this code. *, +No type information for this code. bar: +No type information for this code. * +No type information for this code. }} Type7 +No type information for this code. */ +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typeofANonExportedType.types b/tests/baselines/reference/typeofANonExportedType.types index 6a924e6a11d..2d4afac5e69 100644 --- a/tests/baselines/reference/typeofANonExportedType.types +++ b/tests/baselines/reference/typeofANonExportedType.types @@ -101,7 +101,7 @@ enum E { >E : E A ->A : E +>A : E.A } export var r10: typeof E; >r10 : typeof E diff --git a/tests/baselines/reference/typeofAnExportedType.types b/tests/baselines/reference/typeofAnExportedType.types index 21817a0a573..afd2b737c2f 100644 --- a/tests/baselines/reference/typeofAnExportedType.types +++ b/tests/baselines/reference/typeofAnExportedType.types @@ -101,7 +101,7 @@ export enum E { >E : E A ->A : E +>A : E.A } export var r10: typeof E; >r10 : typeof E diff --git a/tests/baselines/reference/undefinedAssignableToEveryType.types b/tests/baselines/reference/undefinedAssignableToEveryType.types index 005f2451f2a..6456ed7c859 100644 --- a/tests/baselines/reference/undefinedAssignableToEveryType.types +++ b/tests/baselines/reference/undefinedAssignableToEveryType.types @@ -17,7 +17,7 @@ var ai: I; enum E { A } >E : E ->A : E +>A : E.A var ae: E; >ae : E diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.types b/tests/baselines/reference/undefinedIsSubtypeOfEverything.types index 31d92c98ccf..90fd5324343 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.types +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.types @@ -143,7 +143,7 @@ class D10 extends Base { enum E { A } >E : E ->A : E +>A : E.A class D11 extends Base { >D11 : D11 diff --git a/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.types b/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.types index 53414d53df2..91298487cdb 100644 --- a/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.types +++ b/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.types @@ -175,7 +175,7 @@ interface I13 { enum E2 { A } >E2 : E2 ->A : E2 +>A : E2.A interface I14 { [x: string]: E2; diff --git a/tests/baselines/reference/unionTypeMembers.types b/tests/baselines/reference/unionTypeMembers.types index 5b19ab5540c..e26d00c45f9 100644 --- a/tests/baselines/reference/unionTypeMembers.types +++ b/tests/baselines/reference/unionTypeMembers.types @@ -95,9 +95,9 @@ str = x.commonMethodType(str); // (a: string) => string so result should be stri >str = x.commonMethodType(str) : string >str : string >x.commonMethodType(str) : string ->x.commonMethodType : (a: string) => string +>x.commonMethodType : ((a: string) => string) | ((a: string) => string) >x : I1 | I2 ->commonMethodType : (a: string) => string +>commonMethodType : ((a: string) => string) | ((a: string) => string) >str : string strOrNum = x.commonPropertyDifferenType; @@ -133,36 +133,36 @@ num = x.commonMethodWithTypeParameter(num); >num = x.commonMethodWithTypeParameter(num) : number >num : number >x.commonMethodWithTypeParameter(num) : number ->x.commonMethodWithTypeParameter : (a: number) => number +>x.commonMethodWithTypeParameter : ((a: number) => number) | ((a: number) => number) >x : I1 | I2 ->commonMethodWithTypeParameter : (a: number) => number +>commonMethodWithTypeParameter : ((a: number) => number) | ((a: number) => number) >num : number num = x.commonMethodWithOwnTypeParameter(num); >num = x.commonMethodWithOwnTypeParameter(num) : number >num : number >x.commonMethodWithOwnTypeParameter(num) : number ->x.commonMethodWithOwnTypeParameter : (a: U) => U +>x.commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >x : I1 | I2 ->commonMethodWithOwnTypeParameter : (a: U) => U +>commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >num : number str = x.commonMethodWithOwnTypeParameter(str); >str = x.commonMethodWithOwnTypeParameter(str) : string >str : string >x.commonMethodWithOwnTypeParameter(str) : string ->x.commonMethodWithOwnTypeParameter : (a: U) => U +>x.commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >x : I1 | I2 ->commonMethodWithOwnTypeParameter : (a: U) => U +>commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >str : string strOrNum = x.commonMethodWithOwnTypeParameter(strOrNum); >strOrNum = x.commonMethodWithOwnTypeParameter(strOrNum) : string | number >strOrNum : string | number >x.commonMethodWithOwnTypeParameter(strOrNum) : string | number ->x.commonMethodWithOwnTypeParameter : (a: U) => U +>x.commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >x : I1 | I2 ->commonMethodWithOwnTypeParameter : (a: U) => U +>commonMethodWithOwnTypeParameter : ((a: U) => U) | ((a: U) => U) >strOrNum : string | number x.propertyOnlyInI1; // error diff --git a/tests/baselines/reference/untypedModuleImport_noImplicitAny_relativePath.errors.txt b/tests/baselines/reference/untypedModuleImport_noImplicitAny_relativePath.errors.txt index 1aeb8489b8d..6047cfa6a69 100644 --- a/tests/baselines/reference/untypedModuleImport_noImplicitAny_relativePath.errors.txt +++ b/tests/baselines/reference/untypedModuleImport_noImplicitAny_relativePath.errors.txt @@ -1,12 +1,10 @@ /a.ts(1,22): error TS7016: Could not find a declaration file for module './node_modules/foo'. '/node_modules/foo/index.js' implicitly has an 'any' type. - Try `npm install @types/foo` if it exists or add a new declaration (.d.ts) file containing `declare module 'foo';` ==== /a.ts (1 errors) ==== import * as foo from "./node_modules/foo"; ~~~~~~~~~~~~~~~~~~~~ !!! error TS7016: Could not find a declaration file for module './node_modules/foo'. '/node_modules/foo/index.js' implicitly has an 'any' type. -!!! error TS7016: Try `npm install @types/foo` if it exists or add a new declaration (.d.ts) file containing `declare module 'foo';` ==== /node_modules/foo/package.json (0 errors) ==== { "name": "foo", "version": "1.2.3" } diff --git a/tests/baselines/reference/untypedModuleImport_noImplicitAny_typesForPackageExist.errors.txt b/tests/baselines/reference/untypedModuleImport_noImplicitAny_typesForPackageExist.errors.txt index db93cf044c8..1881345fc2d 100644 --- a/tests/baselines/reference/untypedModuleImport_noImplicitAny_typesForPackageExist.errors.txt +++ b/tests/baselines/reference/untypedModuleImport_noImplicitAny_typesForPackageExist.errors.txt @@ -1,11 +1,11 @@ /a.ts(2,25): error TS7016: Could not find a declaration file for module 'foo/sub'. '/node_modules/foo/sub.js' implicitly has an 'any' type. If the 'foo' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/foo` /a.ts(3,25): error TS7016: Could not find a declaration file for module 'bar/sub'. '/node_modules/bar/sub.js' implicitly has an 'any' type. - Try `npm install @types/bar` if it exists or add a new declaration (.d.ts) file containing `declare module 'bar';` + Try `npm install @types/bar` if it exists or add a new declaration (.d.ts) file containing `declare module 'bar/sub';` /a.ts(5,30): error TS7016: Could not find a declaration file for module '@scope/foo/sub'. '/node_modules/@scope/foo/sub.js' implicitly has an 'any' type. If the '@scope/foo' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/scope__foo` /a.ts(6,30): error TS7016: Could not find a declaration file for module '@scope/bar/sub'. '/node_modules/@scope/bar/sub.js' implicitly has an 'any' type. - Try `npm install @types/scope__bar` if it exists or add a new declaration (.d.ts) file containing `declare module '@scope/bar';` + Try `npm install @types/scope__bar` if it exists or add a new declaration (.d.ts) file containing `declare module '@scope/bar/sub';` ==== /a.ts (4 errors) ==== @@ -17,7 +17,7 @@ import * as barSub from "bar/sub"; ~~~~~~~~~ !!! error TS7016: Could not find a declaration file for module 'bar/sub'. '/node_modules/bar/sub.js' implicitly has an 'any' type. -!!! error TS7016: Try `npm install @types/bar` if it exists or add a new declaration (.d.ts) file containing `declare module 'bar';` +!!! error TS7016: Try `npm install @types/bar` if it exists or add a new declaration (.d.ts) file containing `declare module 'bar/sub';` import * as scopeFoo from "@scope/foo"; import * as scopeFooSub from "@scope/foo/sub"; ~~~~~~~~~~~~~~~~ @@ -26,7 +26,7 @@ import * as scopeBarSub from "@scope/bar/sub"; ~~~~~~~~~~~~~~~~ !!! error TS7016: Could not find a declaration file for module '@scope/bar/sub'. '/node_modules/@scope/bar/sub.js' implicitly has an 'any' type. -!!! error TS7016: Try `npm install @types/scope__bar` if it exists or add a new declaration (.d.ts) file containing `declare module '@scope/bar';` +!!! error TS7016: Try `npm install @types/scope__bar` if it exists or add a new declaration (.d.ts) file containing `declare module '@scope/bar/sub';` ==== /node_modules/@types/foo/index.d.ts (0 errors) ==== export const foo: number; diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index ecb85253f43..35d6d9ca05b 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -10,19 +10,23 @@ node_modules/bluebird/js/release/async.js(118,21): error TS2300: Duplicate ident node_modules/bluebird/js/release/bluebird.js(5,15): error TS2367: This condition will always return 'false' since the types 'PromiseConstructor' and 'typeof Promise' have no overlap. node_modules/bluebird/js/release/bluebird.js(10,10): error TS2339: Property 'noConflict' does not exist on type 'typeof Promise'. node_modules/bluebird/js/release/catch_filter.js(27,28): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: {}) => string[]) | ((o: any) => string[])' has no compatible call signatures. -node_modules/bluebird/js/release/debuggability.js(18,20): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. -node_modules/bluebird/js/release/debuggability.js(23,19): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. -node_modules/bluebird/js/release/debuggability.js(26,26): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. -node_modules/bluebird/js/release/debuggability.js(29,24): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. -node_modules/bluebird/js/release/debuggability.js(160,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'event' must be of type 'CustomEvent', but here has type 'Event'. -node_modules/bluebird/js/release/debuggability.js(166,26): error TS2339: Property 'detail' does not exist on type 'Event'. -node_modules/bluebird/js/release/debuggability.js(476,19): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/debuggability.js(547,46): error TS2554: Expected 0 arguments, but got 1. -node_modules/bluebird/js/release/debuggability.js(721,5): error TS2721: Cannot invoke an object which is possibly 'null'. -node_modules/bluebird/js/release/debuggability.js(739,30): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. -node_modules/bluebird/js/release/debuggability.js(745,37): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. -node_modules/bluebird/js/release/debuggability.js(784,38): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. -node_modules/bluebird/js/release/debuggability.js(793,25): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(19,20): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. +node_modules/bluebird/js/release/debuggability.js(24,19): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. +node_modules/bluebird/js/release/debuggability.js(27,26): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. +node_modules/bluebird/js/release/debuggability.js(30,24): error TS2367: This condition will always return 'true' since the types 'string | undefined' and 'number' have no overlap. +node_modules/bluebird/js/release/debuggability.js(161,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. +node_modules/bluebird/js/release/debuggability.js(163,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. +node_modules/bluebird/js/release/debuggability.js(168,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'event' must be of type 'CustomEvent', but here has type 'Event'. +node_modules/bluebird/js/release/debuggability.js(174,26): error TS2339: Property 'detail' does not exist on type 'Event'. +node_modules/bluebird/js/release/debuggability.js(175,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. +node_modules/bluebird/js/release/debuggability.js(176,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. +node_modules/bluebird/js/release/debuggability.js(491,19): error TS2350: Only a void function can be called with the 'new' keyword. +node_modules/bluebird/js/release/debuggability.js(562,46): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(736,5): error TS2721: Cannot invoke an object which is possibly 'null'. +node_modules/bluebird/js/release/debuggability.js(754,30): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. +node_modules/bluebird/js/release/debuggability.js(760,37): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. +node_modules/bluebird/js/release/debuggability.js(799,38): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. +node_modules/bluebird/js/release/debuggability.js(808,25): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/errors.js(10,49): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/errors.js(46,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. node_modules/bluebird/js/release/errors.js(92,18): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ (a: T[]): ReadonlyArray; (f: T): T; (o: T): Readonly; } | ((obj: any) => any)' has no compatible call signatures. @@ -82,8 +86,9 @@ node_modules/bluebird/js/release/promise.js(483,18): error TS2339: Property '_ex node_modules/bluebird/js/release/promise.js(489,10): error TS2339: Property '_popContext' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(506,19): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/bluebird/js/release/promise.js(630,14): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(658,14): error TS2339: Property '_ensurePossibleRejectionHandled' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(698,10): error TS2339: Property '_clearCancellationData' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(642,14): error TS2339: Property '_dereferenceTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(659,14): error TS2339: Property '_ensurePossibleRejectionHandled' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(699,10): error TS2339: Property '_clearCancellationData' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise_array.js(71,18): error TS2339: Property '_resolveEmptyArray' does not exist on type 'PromiseArray'. node_modules/bluebird/js/release/promise_array.js(109,30): error TS2554: Expected 0-1 arguments, but got 2. node_modules/bluebird/js/release/promise_array.js(111,30): error TS2554: Expected 0 arguments, but got 1. @@ -156,12 +161,12 @@ node_modules/bluebird/js/release/using.js(78,20): error TS2339: Property 'doDisp node_modules/bluebird/js/release/using.js(97,23): error TS2339: Property 'data' does not exist on type 'FunctionDisposer'. node_modules/bluebird/js/release/using.js(223,15): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/bluebird/js/release/util.js(97,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. -node_modules/bluebird/js/release/util.js(247,28): error TS2554: Expected 0 arguments, but got 2. -node_modules/bluebird/js/release/util.js(275,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. -node_modules/bluebird/js/release/util.js(275,45): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol) => PropertyDescriptor | undefined) | ((o: any, key: any) => { value: any; })' has no compatible call signatures. -node_modules/bluebird/js/release/util.js(363,25): error TS2304: Cannot find name 'chrome'. -node_modules/bluebird/js/release/util.js(363,51): error TS2304: Cannot find name 'chrome'. -node_modules/bluebird/js/release/util.js(364,25): error TS2304: Cannot find name 'chrome'. +node_modules/bluebird/js/release/util.js(251,28): error TS2554: Expected 0 arguments, but got 2. +node_modules/bluebird/js/release/util.js(279,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType) => any) | ((o: any, key: any, desc: any) => any)' has no compatible call signatures. +node_modules/bluebird/js/release/util.js(279,45): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((o: any, p: string | number | symbol) => PropertyDescriptor | undefined) | ((o: any, key: any) => { value: any; })' has no compatible call signatures. +node_modules/bluebird/js/release/util.js(367,25): error TS2304: Cannot find name 'chrome'. +node_modules/bluebird/js/release/util.js(367,51): error TS2304: Cannot find name 'chrome'. +node_modules/bluebird/js/release/util.js(368,25): error TS2304: Cannot find name 'chrome'. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 09fdbcc0b4b..6085bb91b9e 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -554,7 +554,6 @@ node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/cate node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(483,32): error TS2503: Cannot find namespace 'ReportRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(507,24): error TS2339: Property 'open' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(554,8): error TS2339: Property 'CategoryRenderer' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(560,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(566,18): error TS2339: Property 'PerfHintExtendedInfo' does not exist on type 'typeof CategoryRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(43,45): error TS2694: Namespace 'CriticalRequestChainRenderer' has no exported member 'CRCSegment'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(71,15): error TS2304: Cannot find name 'DOM'. @@ -570,12 +569,9 @@ node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc- node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(158,9): error TS2304: Cannot find name 'Util'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(161,9): error TS2304: Cannot find name 'Util'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(184,8): error TS2339: Property 'CriticalRequestChainRenderer' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(188,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(194,30): error TS2339: Property 'CRCDetailsJSON' does not exist on type 'typeof CriticalRequestChainRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(197,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(204,30): error TS2339: Property 'CRCRequest' does not exist on type 'typeof CriticalRequestChainRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(216,42): error TS2694: Namespace 'CriticalRequestChainRenderer' has no exported member 'CRCRequest'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(220,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(228,30): error TS2339: Property 'CRCSegment' does not exist on type 'typeof CriticalRequestChainRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(12,15): error TS2304: Cannot find name 'DOM'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(29,31): error TS2694: Namespace 'DetailsRenderer' has no exported member 'DetailsJSON'. @@ -602,27 +598,19 @@ node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/deta node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(268,18): error TS2304: Cannot find name 'Util'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(285,31): error TS2694: Namespace 'DetailsRenderer' has no exported member 'DetailsJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(298,8): error TS2339: Property 'DetailsRenderer' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(303,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(307,17): error TS2339: Property 'DetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(311,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(316,17): error TS2339: Property 'ListDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(320,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(327,17): error TS2300: Duplicate identifier 'NodeDetailsJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(327,17): error TS2339: Property 'NodeDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(330,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(335,17): error TS2339: Property 'CardsDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(339,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(344,17): error TS2339: Property 'TableHeaderJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(348,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(355,17): error TS2300: Duplicate identifier 'NodeDetailsJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(355,17): error TS2339: Property 'NodeDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(358,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(360,46): error TS2694: Namespace 'DetailsRenderer' has no exported member 'DetailsJSON'. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(361,45): error TS2694: Namespace 'DetailsRenderer' has no exported member 'TableHeaderJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(364,17): error TS2339: Property 'TableDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(367,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(372,17): error TS2339: Property 'ThumbnailDetails' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(375,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(380,17): error TS2339: Property 'LinkDetailsJSON' does not exist on type 'typeof DetailsRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(383,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(388,17): error TS2339: Property 'FilmstripDetails' does not exist on type 'typeof DetailsRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/dom.js(63,67): error TS2339: Property 'querySelector' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/dom.js(76,43): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. @@ -641,13 +629,13 @@ node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/repo node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(119,30): error TS2694: Namespace 'ReportRenderer' has no exported member 'ReportJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(138,30): error TS2694: Namespace 'ReportRenderer' has no exported member 'ReportJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(172,8): error TS2339: Property 'ReportRenderer' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(177,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(193,21): error TS2503: Cannot find namespace 'DetailsRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(197,16): error TS2339: Property 'AuditJSON' does not exist on type 'typeof ReportRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(201,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(206,39): error TS2694: Namespace 'ReportRenderer' has no exported member 'AuditJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(209,16): error TS2339: Property 'CategoryJSON' does not exist on type 'typeof ReportRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(213,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(217,16): error TS2339: Property 'GroupJSON' does not exist on type 'typeof ReportRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(221,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(229,49): error TS2694: Namespace 'ReportRenderer' has no exported member 'CategoryJSON'. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(230,54): error TS2694: Namespace 'ReportRenderer' has no exported member 'GroupJSON'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(237,16): error TS2339: Property 'ReportJSON' does not exist on type 'typeof ReportRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/util.js(124,5): error TS2322: Type '{}' is not assignable to type '{ numPathParts: number; preserveQuery: boolean; preserveHost: boolean; }'. Property 'numPathParts' is missing in type '{}'. @@ -3173,7 +3161,6 @@ node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(85,5): erro node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(91,25): error TS2304: Cannot find name 'FileError'. node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(96,42): error TS2304: Cannot find name 'FileError'. node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(176,25): error TS2304: Cannot find name 'FileError'. -node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(185,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(189,33): error TS2339: Property 'Chunk' does not exist on type 'typeof TempFileBackingStorage'. node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/AutomappingTestRunner.js(48,26): error TS2554: Expected 5 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/AutomappingTestRunner.js(71,80): error TS2345: Argument of type 'Promise' is not assignable to parameter of type '() => Promise'. @@ -3200,7 +3187,11 @@ node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/Persistence Type 'TestMapping' is not assignable to type '{ dispose: () => void; }'. Property '_onBindingAdded' does not exist on type '{ dispose: () => void; }'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(7,51): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. -node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(9,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(9,56): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(10,75): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(11,53): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(12,53): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(12,91): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(22,42): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(47,11): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(47,11): error TS1345: An expression of type 'void' cannot be tested for truthiness @@ -3219,8 +3210,7 @@ node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(14 node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(155,44): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(156,45): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(162,53): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. -node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(169,2): error TS1131: Property or signature expected. -node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(181,28): error TS2339: Property 'DiffState' does not exist on type '(config: any, parserConfig: { diffRows: any[]; baselineLines: string[]; currentLines: string[]; mimeType: string; }) => {}'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(181,28): error TS2339: Property 'DiffState' does not exist on type '(config: any, parserConfig: { diffRows: any[]; baselineLines: string[]; currentLines: string[]; mimeType: string; }) => { startState: () => any; token: (arg0: { backUp: (n: any) => void; column: () => void; current: () => void; ... 10 more ...; sol: () => void; } & StringStream, arg1: any) => string; blankLine: (arg...'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesSidebar.js(30,90): error TS2339: Property 'uiSourceCode' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesSidebar.js(38,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(26,44): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. @@ -3247,7 +3237,6 @@ node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(215,15): node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(216,19): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(239,45): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(270,38): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. -node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(308,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(314,21): error TS2339: Property 'Row' does not exist on type 'typeof ChangesView'. node_modules/chrome-devtools-frontend/front_end/cm/activeline.js(6,17): error TS2307: Cannot find module '../../lib/codemirror'. node_modules/chrome-devtools-frontend/front_end/cm/activeline.js(7,19): error TS2304: Cannot find name 'define'. @@ -3650,7 +3639,6 @@ node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(13,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(20,29): error TS2694: Namespace 'Common.Renderer' has no exported member 'Options'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(27,15): error TS2339: Property 'runtime' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(39,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(40,17): error TS2300: Duplicate identifier 'Options'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(40,17): error TS2339: Property 'Options' does not exist on type '{ (): void; prototype: { render(object: any, options: any): Promise; }; renderPromise(object: any, options?: any): Promise; }'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(63,15): error TS2339: Property 'runtime' does not exist on type 'Window'. @@ -3730,7 +3718,6 @@ node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebar node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(243,61): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(244,63): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(245,57): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(267,52): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(276,72): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/components/DOMPresentationUtils.js(46,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/components/DOMPresentationUtils.js(51,35): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -3808,8 +3795,6 @@ node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(572,16): node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(580,16): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(587,16): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(616,5): error TS2322: Type '({ section: string; title: any; handler: () => void; } | { section: string; title: string; handler: any; })[]' is not assignable to type '{ title: string; handler: () => any; }[]'. -node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(631,2): error TS1131: Property or signature expected. -node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(646,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(666,22): error TS2551: Property 'LinkHandler' does not exist on type 'typeof Linkifier'. Did you mean '_linkHandlers'? node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(668,47): error TS2694: Namespace 'Components.Linkifier' has no exported member 'LinkHandler'. node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(675,1): error TS8022: JSDoc '@extends' is not attached to a class. @@ -4385,7 +4370,6 @@ node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(416 node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(461,42): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(470,51): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(489,49): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(7,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(50,68): error TS2339: Property 'get' does not exist on type 'Multimap'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(115,45): error TS2339: Property 'set' does not exist on type 'Multimap'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(135,32): error TS2694: Namespace 'Coverage' has no exported member 'RawLocation'. @@ -4634,7 +4618,6 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1162,54): node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1170,23): error TS2339: Property 'offsetWidth' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1175,40): error TS2339: Property '__position' does not exist on type 'Element | { __index: number; __position: number; }'. Property '__position' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1200,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1214,19): error TS2339: Property 'ColumnDescriptor' does not exist on type 'typeof DataGrid'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1324,19): error TS2339: Property '_dataGridNode' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1334,14): error TS2551: Property 'dirty' does not exist on type 'DataGridNode'. Did you mean '_dirty'? @@ -5862,8 +5845,6 @@ node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(3 node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(302,71): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(303,9): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(305,44): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(338,5): error TS2322: Type 'ToolbarItem' is not assignable to type '{ item(): any & any; } & { item(): any & any; }'. - Type 'ToolbarItem' is not assignable to type '{ item(): any & any; }'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeToolbar.js(338,5): error TS2322: Type 'ToolbarItem' is not assignable to type '{ item(): any & any; } & { item(): any & any; }'. Type 'ToolbarItem' is not assignable to type '{ item(): any & any; }'. Property 'item' is missing in type 'ToolbarItem'. @@ -5896,6 +5877,8 @@ node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(83,9 node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(84,7): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(84,34): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(84,63): error TS2555: Expected at least 2 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(103,12): error TS2339: Property '_model' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(104,12): error TS2339: Property '_model' does not exist on type 'typeof DeviceModeView'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(105,9): error TS2339: Property 'consume' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(132,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(143,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -5920,8 +5903,18 @@ node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(483, node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeView.js(500,22): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(18,22): error TS2339: Property 'singleton' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(33,24): error TS2694: Namespace 'Protocol' has no exported member 'Page'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(38,30): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(39,26): error TS2339: Property 'setNonEmulatedAvailableSize' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(41,28): error TS2339: Property 'captureFullSizeScreenshot' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(43,28): error TS2339: Property 'captureAreaScreenshot' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(45,28): error TS2339: Property 'captureScreenshot' does not exist on type 'typeof DeviceModeView'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(50,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(53,37): error TS2694: Namespace 'Protocol' has no exported member 'Page'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(63,66): error TS2339: Property 'isShowing' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(70,32): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(71,28): error TS2339: Property 'show' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(73,64): error TS2339: Property 'element' does not exist on type 'typeof DeviceModeView'. +node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(76,30): error TS2339: Property 'detach' does not exist on type 'typeof DeviceModeView'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeWrapper.js(120,45): error TS2694: Namespace 'Protocol' has no exported member 'Page'. node_modules/chrome-devtools-frontend/front_end/emulation/DevicesSettingsTab.js(15,31): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/emulation/DevicesSettingsTab.js(16,46): error TS2555: Expected at least 2 arguments, but got 1. @@ -6194,14 +6187,10 @@ node_modules/chrome-devtools-frontend/front_end/externs.js(79,17): error TS2551: node_modules/chrome-devtools-frontend/front_end/externs.js(82,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(86,17): error TS2339: Property 'rotate' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/externs.js(90,17): error TS2339: Property 'sortNumbers' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/externs.js(92,13): error TS2304: Cannot find name 'S'. node_modules/chrome-devtools-frontend/front_end/externs.js(96,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(100,17): error TS2339: Property 'lowerBound' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/externs.js(102,13): error TS2304: Cannot find name 'S'. node_modules/chrome-devtools-frontend/front_end/externs.js(106,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(110,17): error TS2339: Property 'upperBound' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/externs.js(112,13): error TS2304: Cannot find name 'S'. -node_modules/chrome-devtools-frontend/front_end/externs.js(113,22): error TS2304: Cannot find name 'S'. node_modules/chrome-devtools-frontend/front_end/externs.js(114,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(118,17): error TS2339: Property 'binaryIndexOf' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/externs.js(125,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -6239,7 +6228,8 @@ node_modules/chrome-devtools-frontend/front_end/externs.js(278,13): error TS2355 node_modules/chrome-devtools-frontend/front_end/externs.js(328,175): error TS2694: Namespace 'Adb' has no exported member 'Page'. node_modules/chrome-devtools-frontend/front_end/externs.js(330,88): error TS2694: Namespace 'Adb' has no exported member 'Browser'. node_modules/chrome-devtools-frontend/front_end/externs.js(338,36): error TS2694: Namespace 'Adb' has no exported member 'DevicePortForwardingStatus'. -node_modules/chrome-devtools-frontend/front_end/externs.js(344,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(346,33): error TS2694: Namespace 'Adb' has no exported member 'PortForwardingConfig'. +node_modules/chrome-devtools-frontend/front_end/externs.js(348,35): error TS2694: Namespace 'Adb' has no exported member 'NetworkDiscoveryConfig'. node_modules/chrome-devtools-frontend/front_end/externs.js(366,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(395,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/externs.js(443,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -6289,9 +6279,8 @@ node_modules/chrome-devtools-frontend/front_end/formatter/ScriptFormatter.js(127 node_modules/chrome-devtools-frontend/front_end/formatter/ScriptFormatter.js(134,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/formatter/ScriptFormatter.js(173,45): error TS2694: Namespace 'Formatter.FormatterWorkerPool' has no exported member 'FormatMapping'. node_modules/chrome-devtools-frontend/front_end/formatter/ScriptFormatter.js(215,28): error TS2339: Property 'upperBound' does not exist on type 'number[]'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(14,54): error TS2345: Argument of type '{ ecmaVersion: number; onComment: any[]; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(14,55): error TS2322: Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(14,71): error TS2322: Type 'any[]' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(15,63): error TS2339: Property 'computeLineEndings' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(22,21): error TS2694: Namespace 'Acorn' has no exported member 'TokenOrComment'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/AcornTokenizer.js(33,21): error TS2694: Namespace 'Acorn' has no exported member 'TokenOrComment'. @@ -6319,18 +6308,12 @@ node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(46,69): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(58,26): error TS1110: Type expected. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(96,3): error TS2554: Expected 2-3 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(103,44): error TS2345: Argument of type '{ ecmaVersion: number; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(103,45): error TS2322: Type 'number' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(138,3): error TS2554: Expected 2-3 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(146,35): error TS2345: Argument of type '{ ecmaVersion: number; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(146,36): error TS2322: Type 'number' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(208,5): error TS2554: Expected 2-3 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(223,3): error TS2554: Expected 2-3 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(230,35): error TS2345: Argument of type '{ ranges: false; ecmaVersion: number; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(230,51): error TS2322: Type 'number' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(258,14): error TS2339: Property 'parent' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(258,29): error TS2339: Property 'parent' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(258,72): error TS2339: Property 'parent' does not exist on type 'Node'. @@ -6354,9 +6337,7 @@ node_modules/chrome-devtools-frontend/front_end/formatter_worker/HTMLFormatter.j node_modules/chrome-devtools-frontend/front_end/formatter_worker/HTMLFormatter.js(301,50): error TS2339: Property 'peekLast' does not exist on type 'Element[]'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/HTMLFormatter.js(302,49): error TS2339: Property 'peekLast' does not exist on type 'Element[]'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/HTMLFormatter.js(329,34): error TS2339: Property 'peekLast' does not exist on type 'Element[]'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(54,42): error TS2345: Argument of type '{ ranges: false; ecmaVersion: number; preserveParens: true; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(54,58): error TS2322: Type 'number' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(60,21): error TS2694: Namespace 'Acorn' has no exported member 'TokenOrComment'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(88,15): error TS2339: Property 'parent' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(91,37): error TS2694: Namespace 'Acorn' has no exported member 'TokenOrComment'. @@ -6405,12 +6386,8 @@ node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptForma node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(304,62): error TS2339: Property 'alternate' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(306,23): error TS2339: Property 'consequent' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptFormatter.js(307,18): error TS2339: Property 'consequent' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(14,32): error TS2345: Argument of type '{ ranges: false; ecmaVersion: number; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(16,39): error TS2345: Argument of type '{ ranges: false; ecmaVersion: number; }' is not assignable to parameter of type '{ [x: string]: boolean; }'. - Property 'ecmaVersion' is incompatible with index signature. - Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(14,48): error TS2322: Type 'number' is not assignable to type 'boolean'. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(16,55): error TS2322: Type 'number' is not assignable to type 'boolean'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(19,53): error TS2339: Property 'computeLineEndings' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(22,3): error TS2554: Expected 2-3 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/formatter_worker/JavaScriptOutline.js(34,60): error TS2339: Property 'key' does not exist on type 'Node'. @@ -6518,7 +6495,6 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1083,14): error TS2339: Property 'key' does not exist on type '(arg0: HeapSnapshotNode) => boolean'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1086,14): error TS2339: Property 'key' does not exist on type '(arg0: HeapSnapshotNode) => boolean'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1143,31): error TS2339: Property 'key' does not exist on type '(arg0: HeapSnapshotNode) => boolean'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1195,53): error TS2551: Property 'aggregatesByClassIndex' does not exist on type '{ aggregatesByClassName: { [x: string]: any; }; }'. Did you mean 'aggregatesByClassName'? node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1230,33): error TS2339: Property 'traceNodeId' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1253,14): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1254,23): error TS2339: Property 'id' does not exist on type 'void'. @@ -6526,9 +6502,7 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1345,12): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1355,31): error TS2345: Argument of type 'void' is not assignable to parameter of type 'HeapSnapshotNode'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1369,89): error TS2694: Namespace 'HeapSnapshotWorker.HeapSnapshot' has no exported member 'AggregatedInfo'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1370,4): error TS1131: Property or signature expected. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1424,59): error TS2322: Type '{ aggregatesByClassName: {}; aggregatesByClassIndex: {}; }' is not assignable to type '{ aggregatesByClassName: { [x: string]: any; }; }'. - Object literal may only specify known properties, but 'aggregatesByClassIndex' does not exist in type '{ aggregatesByClassName: { [x: string]: any; }; }'. Did you mean to write 'aggregatesByClassName'? +node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1370,83): error TS2694: Namespace 'HeapSnapshotWorker.HeapSnapshot' has no exported member 'AggregatedInfo'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1428,63): error TS2694: Namespace 'HeapSnapshotWorker.HeapSnapshot' has no exported member 'AggregatedInfo'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1447,12): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1448,29): error TS2339: Property 'classIndex' does not exist on type 'void'. @@ -6573,7 +6547,6 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho Type '(index: number) => HeapSnapshotRetainerEdge' is not assignable to type '(newIndex: number) => { itemIndex(): number; serialize(): any; }'. Type 'HeapSnapshotRetainerEdge' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. Property '_snapshot' does not exist on type '{ itemIndex(): number; serialize(): any; }'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2118,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2126,33): error TS2339: Property 'AggregatedInfo' does not exist on type 'typeof HeapSnapshot'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2205,12): error TS2339: Property 'sort' does not exist on type 'HeapSnapshotItemProvider'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2244,13): error TS2345: Argument of type 'HeapSnapshotEdgeIterator' is not assignable to parameter of type '{ hasNext(): boolean; item(): { itemIndex(): number; serialize(): any; }; next(): void; }'. @@ -6631,7 +6604,6 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker.js(6,8): er node_modules/chrome-devtools-frontend/front_end/help/Help.js(6,19): error TS2694: Namespace 'Help' has no exported member 'ReleaseNote'. node_modules/chrome-devtools-frontend/front_end/help/Help.js(10,22): error TS2694: Namespace 'Help' has no exported member 'ReleaseNote'. node_modules/chrome-devtools-frontend/front_end/help/Help.js(61,74): error TS2694: Namespace 'Help' has no exported member 'ReleaseNoteHighlight'. -node_modules/chrome-devtools-frontend/front_end/help/Help.js(62,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/help/ReleaseNoteText.js(12,25): error TS2694: Namespace 'Help' has no exported member 'ReleaseNote'. node_modules/chrome-devtools-frontend/front_end/help/ReleaseNoteView.js(10,42): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/help/ReleaseNoteView.js(11,30): error TS2555: Expected at least 2 arguments, but got 1. @@ -6920,11 +6892,8 @@ node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(858 node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(861,81): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(928,26): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(932,39): error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'ReadonlyArray<[any, any]>'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray[]): any[][]; (...items: (any[] | ConcatArray)[]): any[][]; }' is not assignable to type '{ (...items: ConcatArray<[any, any]>[]): [any, any][]; (...items: ([any, any] | ConcatArray<[any, any]>)[]): [any, any][]; }'. - Type 'any[][]' is not assignable to type '[any, any][]'. - Type 'any[]' is not assignable to type '[any, any]'. - Property '0' is missing in type 'any[]'. + Type 'any[]' is not assignable to type '[any, any]'. + Property '0' is missing in type 'any[]'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1080,24): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1098,15): error TS2304: Cannot find name 'CSSMatrix'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1143,19): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. @@ -7153,7 +7122,8 @@ node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingMana node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingManager.js(218,82): error TS2339: Property 'selectedIndex' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingManager.js(224,32): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingManager.js(266,15): error TS2339: Property 'singleton' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(14,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(16,35): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'Conditions'. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(17,43): error TS2694: Namespace 'MobileThrottling' has no exported member 'CPUThrottlingRates'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(20,18): error TS2300: Duplicate identifier 'Conditions'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(22,30): error TS2694: Namespace 'MobileThrottling' has no exported member 'Conditions'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(25,16): error TS2555: Expected at least 2 arguments, but got 1. @@ -7165,7 +7135,6 @@ node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPres node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(46,30): error TS2694: Namespace 'MobileThrottling' has no exported member 'Conditions'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(48,10): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(49,16): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(56,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(62,30): error TS2694: Namespace 'MobileThrottling' has no exported member 'PlaceholderConditions'. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(64,10): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(65,16): error TS2555: Expected at least 2 arguments, but got 1. @@ -7452,7 +7421,6 @@ node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(481,66): error TS2694: Namespace 'Network.NetworkLogViewColumns' has no exported member 'Descriptor'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(522,19): error TS2694: Namespace 'UI' has no exported member 'PopoverRequest'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(531,31): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. -node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(601,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(616,31): error TS2300: Duplicate identifier 'Descriptor'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(616,31): error TS2339: Property 'Descriptor' does not exist on type 'typeof NetworkLogViewColumns'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(640,50): error TS2694: Namespace 'Network.NetworkLogViewColumns' has no exported member 'Descriptor'. @@ -8017,9 +7985,8 @@ node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1167,15): node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1169,70): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1273,25): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1286,19): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1387,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1390,34): error TS2694: Namespace 'PerfUI.FlameChart' has no exported member 'GroupStyle'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1393,19): error TS2339: Property 'Group' does not exist on type 'typeof FlameChart'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1397,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1410,19): error TS2339: Property 'GroupStyle' does not exist on type 'typeof FlameChart'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1420,40): error TS2694: Namespace 'PerfUI.FlameChart' has no exported member 'Group'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1438,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -8214,7 +8181,7 @@ node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemMa node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(154,72): error TS2694: Namespace 'Persistence.IsolatedFileSystemManager' has no exported member 'FileSystem'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(171,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(185,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(211,37): error TS2345: Argument of type 'string' is not assignable to parameter of type 'V'. +node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(211,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(222,30): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(284,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(297,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -8321,13 +8288,6 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1164,15): node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1169,24): error TS2304: Cannot find name 'KEY'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1169,30): error TS2304: Cannot find name 'VALUE'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1171,15): error TS2339: Property 'inverse' does not exist on type 'Map'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1191,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1204,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1215,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1223,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1242,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1257,14): error TS2304: Cannot find name 'K'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1264,23): error TS2304: Cannot find name 'K'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1277,14): error TS2339: Property 'pushAll' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1277,40): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1299,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. @@ -8881,11 +8841,8 @@ node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(78,46): node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(79,46): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(80,45): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(84,17): error TS2345: Argument of type '(string | Element)[][]' is not assignable to parameter of type 'ReadonlyArray<[any, any]>'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray<(string | Element)[]>[]): (string | Element)[][]; (...items: ((string | Element)[] | ConcatArray<(string | Element)[]>)[]): (string | Element)[][]; }' is not assignable to type '{ (...items: ConcatArray<[any, any]>[]): [any, any][]; (...items: ([any, any] | ConcatArray<[any, any]>)[]): [any, any][]; }'. - Type '(string | Element)[][]' is not assignable to type '[any, any][]'. - Type '(string | Element)[]' is not assignable to type '[any, any]'. - Property '0' is missing in type '(string | Element)[]'. + Type '(string | Element)[]' is not assignable to type '[any, any]'. + Property '0' is missing in type '(string | Element)[]'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(127,5): error TS2322: Type '(ToolbarButton | ToolbarComboBox)[]' is not assignable to type '({ item(): any & any; } & { item(): any & any; })[]'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(127,5): error TS2322: Type '(ToolbarButton | ToolbarComboBox)[]' is not assignable to type '({ item(): any & any; } & { item(): any & any; })[]'. Type 'ToolbarButton | ToolbarComboBox' is not assignable to type '{ item(): any & any; } & { item(): any & any; }'. @@ -8981,7 +8938,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/TopDownProfileDataGrid. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(168,40): error TS2345: Argument of type 'S' is not assignable to parameter of type 'S'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(170,24): error TS2345: Argument of type 'S' is not assignable to parameter of type 'T'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(194,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(201,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(205,38): error TS2339: Property 'Params' does not exist on type '{ (): void; prototype: { sendMessage(message: string): void; disconnect(): Promise; }; }'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(208,61): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(210,38): error TS2339: Property 'Factory' does not exist on type '{ (): void; prototype: { sendMessage(message: string): void; disconnect(): Promise; }; }'. @@ -9230,7 +9186,7 @@ node_modules/chrome-devtools-frontend/front_end/resources/DatabaseTableView.js(1 node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(41,12): error TS2339: Property 'registerStorageDispatcher' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(43,35): error TS2339: Property 'indexedDBAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(44,33): error TS2339: Property 'storageAgent' does not exist on type 'Target'. -node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(58,4): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(62,24): error TS2694: Namespace 'Protocol' has no exported member 'IndexedDB'. node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(94,37): error TS2694: Namespace 'Protocol' has no exported member 'IndexedDB'. node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(100,25): error TS2694: Namespace 'Protocol' has no exported member 'IndexedDB'. node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(112,24): error TS2694: Namespace 'Protocol' has no exported member 'IndexedDB'. @@ -9637,13 +9593,7 @@ node_modules/chrome-devtools-frontend/front_end/sdk/CookieParser.js(246,25): err node_modules/chrome-devtools-frontend/front_end/sdk/CookieParser.js(250,33): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/sdk/CookieParser.js(325,53): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(11,26): error TS2339: Property 'domdebuggerAgent' does not exist on type 'Target'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(69,50): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(78,50): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(98,50): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(154,59): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(190,60): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(232,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(264,50): error TS2694: Namespace 'SDK.DOMDebuggerModel.DOMBreakpoint' has no exported member 'Type'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(275,24): error TS2694: Namespace 'Protocol' has no exported member 'DOMDebugger'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(387,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(578,9): error TS2555: Expected at least 2 arguments, but got 1. @@ -9822,7 +9772,7 @@ node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(838,24): er node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(839,31): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(899,22): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(908,19): error TS2339: Property 'FunctionDetails' does not exist on type 'typeof DebuggerModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(967,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(967,31): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(971,19): error TS2339: Property 'SetBreakpointResult' does not exist on type 'typeof DebuggerModel'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(987,32): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(991,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. @@ -9922,7 +9872,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(154,5): er Index signature is missing in type '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(166,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(199,20): error TS2339: Property 'Message' does not exist on type 'typeof NetworkManager'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(214,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(220,20): error TS2300: Duplicate identifier 'Conditions'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(220,20): error TS2339: Property 'Conditions' does not exist on type 'typeof NetworkManager'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(222,32): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'Conditions'. @@ -10305,15 +10254,17 @@ node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(449,24): err node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(458,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(484,54): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(485,18): error TS2339: Property 'ExceptionWithTimestamp' does not exist on type 'typeof RuntimeModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(488,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(488,27): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(489,36): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(492,18): error TS2339: Property 'CompileScriptResult' does not exist on type 'typeof RuntimeModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(495,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(503,18): error TS2339: Property 'EvaluationOptions' does not exist on type 'typeof RuntimeModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(506,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(507,36): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(508,25): error TS2694: Namespace 'Protocol' has no exported member 'Error'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(511,18): error TS2339: Property 'EvaluationResult' does not exist on type 'typeof RuntimeModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(514,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(515,25): error TS2694: Namespace 'Protocol' has no exported member 'Error'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(518,18): error TS2339: Property 'QueryObjectResult' does not exist on type 'typeof RuntimeModel'. -node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(522,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(523,30): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(526,30): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(529,18): error TS2339: Property 'ConsoleAPICall' does not exist on type 'typeof RuntimeModel'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(545,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(553,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. @@ -11010,7 +10961,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js( node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(379,13): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(382,13): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(415,52): error TS2694: Namespace 'UI.KeyboardShortcut' has no exported member 'Descriptor'. -node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(429,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(431,36): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(435,30): error TS2300: Duplicate identifier 'Item'. node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(435,30): error TS2339: Property 'Item' does not exist on type 'typeof CallStackSidebarPane'. node_modules/chrome-devtools-frontend/front_end/sources/DebuggerPausedMessage.js(11,33): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. @@ -11725,11 +11676,10 @@ node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(337,33 node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(338,37): error TS2339: Property 'profilerAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(339,36): error TS2339: Property 'runtimeAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(340,35): error TS2339: Property 'targetAgent' does not exist on type 'Target'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(363,62): error TS2339: Property 'result' does not exist on type '{ response: RemoteObject; }'. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(363,62): error TS2339: Property 'result' does not exist on type '{ response: RemoteObject; exceptionDetails: any; }'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(368,34): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(372,42): error TS2339: Property 'result' does not exist on type '{ response: RemoteObject; }'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(372,65): error TS2339: Property 'exceptionDetails' does not exist on type '{ response: RemoteObject; }'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(381,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(372,42): error TS2339: Property 'result' does not exist on type '{ response: RemoteObject; exceptionDetails: any; }'. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(381,35): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(503,30): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(value: [any, any, any, any, any, any, any, any, any, any]) => [any, any, any, any, any, any, any, any, any, any] | PromiseLike<[any, any, any, any, any, any, any, any, any, any]>'. Type 'Function' provides no match for the signature '(value: [any, any, any, any, any, any, any, any, any, any]): [any, any, any, any, any, any, any, any, any, any] | PromiseLike<[any, any, any, any, any, any, any, any, any, any]>'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(641,59): error TS2339: Property 'testRunner' does not exist on type 'Window'. @@ -11811,6 +11761,13 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1261,5): error TS2322: Type 'CodeMirrorPositionHandle' is not assignable to type '{ resolve(): { lineNumber: number; columnNumber: number; }; equal(positionHandle: any): boolean; }'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1261,5): error TS2322: Type 'CodeMirrorPositionHandle' is not assignable to type '{ resolve(): { lineNumber: number; columnNumber: number; }; equal(positionHandle: any): boolean; }'. Property '_codeMirror' does not exist on type '{ resolve(): { lineNumber: number; columnNumber: number; }; equal(positionHandle: any): boolean; }'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1280,21): error TS2339: Property 'autocomplete' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1283,21): error TS2339: Property 'undoLastSelection' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1286,21): error TS2339: Property 'selectNextOccurrence' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1289,21): error TS2339: Property 'moveCamelLeft' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1290,21): error TS2339: Property 'selectCamelLeft' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1293,21): error TS2339: Property 'moveCamelRight' does not exist on type 'typeof commands'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1294,21): error TS2339: Property 'selectCamelRight' does not exist on type 'typeof commands'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1301,31): error TS2339: Property 'listSelections' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1305,38): error TS2339: Property 'findMatchingBracket' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1313,14): error TS2339: Property 'setSelections' does not exist on type 'CodeMirror'. @@ -11843,7 +11800,6 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1637,12): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1637,61): error TS2339: Property 'line' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1637,71): error TS2339: Property 'ch' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1645,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1650,33): error TS2339: Property 'Decoration' does not exist on type 'typeof CodeMirrorTextEditor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1659,29): error TS2694: Namespace 'UI.TextEditor' has no exported member 'Options'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(53,24): error TS2694: Namespace 'CodeMirror' has no exported member 'ChangeObject'. @@ -11985,9 +11941,8 @@ node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(2 node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(295,43): error TS2694: Namespace 'Timeline.PerformanceMonitor' has no exported member 'MetricInfo'. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(320,41): error TS2339: Property 'peekLast' does not exist on type '{ timestamp: number; metrics: Map; }[]'. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(330,24): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(394,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(395,51): error TS2694: Namespace 'Timeline.PerformanceMonitor' has no exported member 'MetricInfo'. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(402,29): error TS2339: Property 'ChartInfo' does not exist on type 'typeof PerformanceMonitor'. -node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(406,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(411,29): error TS2339: Property 'MetricInfo' does not exist on type 'typeof PerformanceMonitor'. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(419,27): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(427,52): error TS2694: Namespace 'Timeline.PerformanceMonitor' has no exported member 'ChartInfo'. @@ -12012,7 +11967,6 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(2 node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(214,58): error TS2694: Namespace 'SDK.TracingManager' has no exported member 'EventPayload'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(233,96): error TS2339: Property 'peekLast' does not exist on type 'Event[]'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(272,1): error TS8022: JSDoc '@extends' is not attached to a class. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(283,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(288,29): error TS2339: Property 'RecordingOptions' does not exist on type 'typeof TimelineController'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineDetailsView.js(29,44): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineDetailsView.js(31,37): error TS2555: Expected at least 2 arguments, but got 1. @@ -12653,7 +12607,6 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2057 node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2059,21): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2078,23): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2078,39): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2146,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2167,15): error TS2339: Property 'colSpan' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2186,10): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2191,5): error TS2322: Type 'string | number' is not assignable to type 'string'. @@ -12893,11 +12846,10 @@ node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(171,22): error TS node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(174,21): error TS2339: Property 'remove' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(179,27): error TS2694: Namespace 'UI.Fragment' has no exported member '_Template'. node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(247,24): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. -node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(272,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(273,33): error TS2694: Namespace 'UI.Fragment' has no exported member '_Bind'. node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(276,13): error TS2551: Property '_Template' does not exist on type 'typeof Fragment'. Did you mean '_template'? -node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(280,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(286,13): error TS2339: Property '_State' does not exist on type 'typeof Fragment'. -node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(290,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(292,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/ui/Fragment.js(307,13): error TS2339: Property '_Bind' does not exist on type 'typeof Fragment'. node_modules/chrome-devtools-frontend/front_end/ui/Geometry.js(210,15): error TS2304: Cannot find name 'CSSMatrix'. node_modules/chrome-devtools-frontend/front_end/ui/Geometry.js(272,13): error TS2304: Cannot find name 'CSSMatrix'. @@ -13341,10 +13293,9 @@ node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(47,15): error T node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(58,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(70,18): error TS2694: Namespace 'UI' has no exported member 'AutocompleteConfig'. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(79,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(91,2): error TS1131: Property or signature expected. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(101,15): error TS2300: Duplicate identifier 'Options'. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(101,15): error TS2339: Property 'Options' does not exist on type '{ (): void; prototype: { widget(): Widget; fullRange(): TextRange; selection(): TextRange; setSelection(selection: TextRange): void; text(textRange?: TextRange): string; setText(text: string): void; ... 5 more ...; tokenAtTextPosition(lineNumber: number, columnNumber: number): { ...; }; }; Events: { ...; }; }'. -node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(105,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(106,119): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(52,74): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(113,39): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(115,24): error TS2339: Property 'style' does not exist on type 'Element'. diff --git a/tests/baselines/reference/user/jimp.log b/tests/baselines/reference/user/jimp.log index 9757da0670e..2a11d85e4c5 100644 --- a/tests/baselines/reference/user/jimp.log +++ b/tests/baselines/reference/user/jimp.log @@ -1,8 +1,8 @@ Exit Code: 1 Standard output: -node_modules/jimp/jimp.d.ts(495,16): error TS7010: 'appendConstructorOption', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/jimp/jimp.d.ts(536,16): error TS7010: 'measureText', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/jimp/jimp.d.ts(537,16): error TS7010: 'measureTextHeight', which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/jimp/jimp.d.ts(487,12): error TS7010: 'appendConstructorOption', which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/jimp/jimp.d.ts(529,12): error TS7010: 'measureText', which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/jimp/jimp.d.ts(530,12): error TS7010: 'measureTextHeight', which lacks return-type annotation, implicitly has an 'any' return type. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index d85a724411a..f2db4a09546 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -343,8 +343,8 @@ node_modules/npm/lib/install/action/refresh-package-json.js(31,43): error TS2339 node_modules/npm/lib/install/action/remove.js(25,37): error TS2339: Property 'prefix' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install/action/remove.js(25,51): error TS2339: Property 'prefix' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install/actions.js(126,24): error TS2339: Property 'limit' does not exist on type 'typeof EventEmitter'. -node_modules/npm/lib/install/actions.js(168,16): error TS2345: Argument of type '"time"' is not assignable to parameter of type '"warning"'. -node_modules/npm/lib/install/actions.js(171,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type '"warning"'. +node_modules/npm/lib/install/actions.js(168,16): error TS2345: Argument of type '"time"' is not assignable to parameter of type 'Signals'. +node_modules/npm/lib/install/actions.js(171,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type 'Signals'. node_modules/npm/lib/install/and-add-parent-to-errors.js(9,10): error TS2339: Property 'parent' does not exist on type 'Error'. node_modules/npm/lib/install/audit.js(32,19): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install/audit.js(89,17): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. @@ -432,8 +432,8 @@ node_modules/npm/lib/install.js(273,7): error TS2532: Object is possibly 'undefi node_modules/npm/lib/install.js(273,7): error TS2684: The 'this' context of type '((err: any, ...args: any[]) => any) | undefined' is not assignable to method's 'this' of type 'Function'. Type 'undefined' is not assignable to type 'Function'. node_modules/npm/lib/install.js(340,25): error TS2339: Property 'failing' does not exist on type 'Installer'. -node_modules/npm/lib/install.js(369,18): error TS2345: Argument of type '"time"' is not assignable to parameter of type '"warning"'. -node_modules/npm/lib/install.js(376,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type '"warning"'. +node_modules/npm/lib/install.js(369,18): error TS2345: Argument of type '"time"' is not assignable to parameter of type 'Signals'. +node_modules/npm/lib/install.js(376,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type 'Signals'. node_modules/npm/lib/install.js(519,40): error TS2339: Property 'globalPrefix' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install.js(597,12): error TS2339: Property 'failing' does not exist on type 'Installer'. node_modules/npm/lib/install.js(614,12): error TS2339: Property 'failing' does not exist on type 'Installer'. @@ -499,6 +499,8 @@ node_modules/npm/lib/ls.js(260,16): error TS2339: Property 'problems' does not e node_modules/npm/lib/ls.js(262,54): error TS2339: Property 'problems' does not exist on type 'string | { name: any; version: any; extraneous: boolean; problems: any; invalid: boolean; from: any; resolved: any; peerInvalid: boolean; dependencies: {}; } | { required: any; missing: boolean; } | { ...; }'. Property 'problems' does not exist on type 'string'. node_modules/npm/lib/ls.js(264,12): error TS2538: Type '{ name: any; version: any; extraneous: boolean; problems: any; invalid: boolean; from: any; resolved: any; peerInvalid: boolean; dependencies: {}; }' cannot be used as an index type. +node_modules/npm/lib/ls.js(264,12): error TS2538: Type '{ required: any; missing: boolean; }' cannot be used as an index type. +node_modules/npm/lib/ls.js(264,12): error TS2538: Type '{ required: any; peerMissing: boolean; }' cannot be used as an index type. node_modules/npm/lib/ls.js(357,40): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/ls.js(362,26): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/ls.js(365,15): error TS2339: Property 'color' does not exist on type 'typeof EventEmitter'. @@ -783,7 +785,7 @@ node_modules/npm/lib/utils/error-handler.js(12,21): error TS2339: Property 'roll node_modules/npm/lib/utils/error-handler.js(23,36): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(29,16): error TS2339: Property 'version' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(33,12): error TS2345: Argument of type '"timing"' is not assignable to parameter of type 'Signals'. -node_modules/npm/lib/utils/error-handler.js(38,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type '"warning"'. +node_modules/npm/lib/utils/error-handler.js(38,16): error TS2345: Argument of type '"timeEnd"' is not assignable to parameter of type 'Signals'. node_modules/npm/lib/utils/error-handler.js(40,11): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(40,32): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(43,39): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. @@ -1485,9 +1487,9 @@ node_modules/npm/test/tap/prepublish-only.js(6,21): error TS2307: Cannot find mo node_modules/npm/test/tap/prepublish.js(3,20): error TS2307: Cannot find module 'tap'. node_modules/npm/test/tap/process-logger.js(2,22): error TS2307: Cannot find module 'tap'. node_modules/npm/test/tap/process-logger.js(7,24): error TS2554: Expected 1-3 arguments, but got 4. -node_modules/npm/test/tap/process-logger.js(8,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type '"warning"'. -node_modules/npm/test/tap/process-logger.js(9,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type '"warning"'. -node_modules/npm/test/tap/process-logger.js(10,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type '"warning"'. +node_modules/npm/test/tap/process-logger.js(8,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. +node_modules/npm/test/tap/process-logger.js(9,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. +node_modules/npm/test/tap/process-logger.js(10,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. node_modules/npm/test/tap/progress-config.js(3,20): error TS2307: Cannot find module 'tap'. node_modules/npm/test/tap/progress-config.js(12,29): error TS2307: Cannot find module 'require-inject'. node_modules/npm/test/tap/progress-config.js(18,9): error TS2339: Property 'stderr' does not exist on type 'typeof process'. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 0bc48d677a2..2ba94206d96 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -16,40 +16,40 @@ node_modules/uglify-js/lib/compress.js(1202,87): error TS2322: Type 'false' is n node_modules/uglify-js/lib/compress.js(1210,29): error TS2322: Type 'false' is not assignable to type 'never'. node_modules/uglify-js/lib/compress.js(1316,38): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(1411,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1507,27): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1539,26): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1963,44): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2149,19): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3205,23): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3218,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3358,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3413,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3430,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3455,62): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3681,23): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3702,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3712,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3871,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => any; add: (key: any, val: any) => any; get: (key: any) => any; del: (key: any) => any; has: (key: any) => boolean; each: (f: any) => void; size: () => any; map: (f: any) => any[]; clone: () => Dictionary & any; toObject: () => any; }', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(3923,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(3979,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4088,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4387,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4471,22): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4821,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4828,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(4832,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(4837,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(5324,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(5759,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. -node_modules/uglify-js/lib/compress.js(5787,32): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5847,24): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5919,24): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5925,26): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6318,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6333,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6336,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(6342,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6370,19): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1519,27): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1551,26): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1975,44): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2161,19): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3214,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3227,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3367,18): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3422,14): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3439,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3464,62): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3690,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3711,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3721,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3880,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => any; add: (key: any, val: any) => any; get: (key: any) => any; del: (key: any) => any; has: (key: any) => boolean; each: (f: any) => void; size: () => any; map: (f: any) => any[]; clone: () => Dictionary & any; toObject: () => any; }', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(3932,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(3988,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4097,18): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4396,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4480,22): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4830,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4837,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(4841,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(4846,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(5333,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(5765,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. +node_modules/uglify-js/lib/compress.js(5792,32): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5855,24): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5927,24): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5933,26): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6337,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6352,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6355,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(6361,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6389,19): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(170,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,18): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/output.js(246,9): error TS2554: Expected 0 arguments, but got 2. diff --git a/tests/baselines/reference/validNullAssignments.types b/tests/baselines/reference/validNullAssignments.types index 98b83a63e1b..5c27f320261 100644 --- a/tests/baselines/reference/validNullAssignments.types +++ b/tests/baselines/reference/validNullAssignments.types @@ -27,7 +27,7 @@ e = null; // ok enum E { A } >E : E ->A : E +>A : E.A E.A = null; // error >E.A = null : null diff --git a/tests/baselines/reference/validNumberAssignments.types b/tests/baselines/reference/validNumberAssignments.types index 5f6304eb1cd..fa9df93717a 100644 --- a/tests/baselines/reference/validNumberAssignments.types +++ b/tests/baselines/reference/validNumberAssignments.types @@ -17,7 +17,7 @@ var c: number = x; enum E { A }; >E : E ->A : E +>A : E.A var d: E = x; >d : E diff --git a/tests/baselines/reference/varBlock.errors.txt b/tests/baselines/reference/varBlock.errors.txt index 6746a760a44..12e3fc6a629 100644 --- a/tests/baselines/reference/varBlock.errors.txt +++ b/tests/baselines/reference/varBlock.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/varBlock.ts(8,16): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(8,18): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(11,22): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/varBlock.ts(11,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/compiler/varBlock.ts(15,15): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(21,16): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(22,20): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(25,19): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(26,24): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(26,33): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(27,27): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(28,33): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(28,43): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(32,11): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(33,16): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(33,25): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(34,19): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(35,25): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(35,35): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(15,17): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(21,18): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(22,22): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(25,21): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(26,26): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(26,35): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(27,29): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(28,35): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(28,45): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(32,13): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(33,18): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(33,26): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(34,21): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(35,27): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(35,37): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(39,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'any', but here has type 'number'. -tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(39,17): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/varBlock.ts (20 errors) ==== @@ -29,7 +29,7 @@ tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allo declare module m3 { var a, b, c; var a1, b1 = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. class C { @@ -42,7 +42,7 @@ tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allo } declare var b = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare var a2, b2, c2; @@ -50,47 +50,47 @@ tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allo declare var da = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare var d3, d4 = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. module m3 { declare var d = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. declare var d2, d3 = 10, d4 = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. export declare var dE = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. export declare var d2E, d3E = 10, d4E = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } declare module m4 { var d = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. var d2, d3 = 10, d4 =10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. export var dE = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. export var d2E, d3E = 10, d4E = 10; - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } @@ -98,5 +98,5 @@ tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allo declare var c = 10; ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'any', but here has type 'number'. - ~ + ~~ !!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 47e8e6ff4f2..65bfc5b20d5 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,25): error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'. + Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -15,5 +16,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var c = new C({ length: 2 }); var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file + ~~~~~~ +!!! error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'. +!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! related TS6500 /.ts/lib.es5.d.ts:332:5: The expected type comes from property 'charAt' which is declared here on type 'string' \ No newline at end of file diff --git a/tests/cases/compiler/abstractPropertyInConstructor.ts b/tests/cases/compiler/abstractPropertyInConstructor.ts index b8386f56e1e..5ea3569e20d 100644 --- a/tests/cases/compiler/abstractPropertyInConstructor.ts +++ b/tests/cases/compiler/abstractPropertyInConstructor.ts @@ -22,6 +22,9 @@ abstract class AbstractClass { abstract method(num: number): void; + other = this.prop; + fn = () => this.prop; + method2() { this.prop = this.prop + "!"; } diff --git a/tests/cases/compiler/ambientConstLiterals.ts b/tests/cases/compiler/ambientConstLiterals.ts index 040b739bf93..d42b8524998 100644 --- a/tests/cases/compiler/ambientConstLiterals.ts +++ b/tests/cases/compiler/ambientConstLiterals.ts @@ -4,7 +4,7 @@ function f(x: T): T { return x; } -enum E { A, B, C } +enum E { A, B, C, "non identifier" } const c1 = "abc"; const c2 = 123; @@ -14,6 +14,7 @@ const c5 = f(123); const c6 = f(-123); const c7 = true; const c8 = E.A; +const c8b = E["non identifier"]; const c9 = { x: "abc" }; const c10 = [123]; const c11 = "abc" + "def"; diff --git a/tests/cases/compiler/arrayFlatMap.ts b/tests/cases/compiler/arrayFlatMap.ts new file mode 100644 index 00000000000..dc67bf02490 --- /dev/null +++ b/tests/cases/compiler/arrayFlatMap.ts @@ -0,0 +1,6 @@ +// @lib: esnext + +const array: number[] = []; +const readonlyArray: ReadonlyArray = []; +array.flatMap((): ReadonlyArray => []); // ok +readonlyArray.flatMap((): ReadonlyArray => []); // ok diff --git a/tests/cases/compiler/arrayIndexWithArrayFails.ts b/tests/cases/compiler/arrayIndexWithArrayFails.ts new file mode 100644 index 00000000000..242e1ff3334 --- /dev/null +++ b/tests/cases/compiler/arrayIndexWithArrayFails.ts @@ -0,0 +1,3 @@ +declare const arr1: (string | string[])[]; +declare const arr2: number[]; +const j = arr2[arr1[0]]; // should error \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts b/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts new file mode 100644 index 00000000000..84eff340164 --- /dev/null +++ b/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef.ts @@ -0,0 +1,10 @@ +// @target: ES5 +function foo1() { + return E.A + enum E { A } +} + +function foo2() { + return E.A + const enum E { A } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts b/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts new file mode 100644 index 00000000000..0d7cb73b3ad --- /dev/null +++ b/tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_preserve.ts @@ -0,0 +1,12 @@ +// @target: ES5 +// @preserveConstEnums: true + +function foo1() { + return E.A + enum E { A } +} + +function foo2() { + return E.A + const enum E { A } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts b/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts index 956705bd7d3..351bdde122e 100644 --- a/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts +++ b/tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts @@ -101,4 +101,4 @@ function foo14() { a: x } let x -} \ No newline at end of file +} diff --git a/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts b/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts index 83b5cbafb6a..2bd0673abd5 100644 --- a/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts +++ b/tests/cases/compiler/contextualSignatureInstatiationContravariance.ts @@ -5,7 +5,7 @@ interface Elephant extends Animal { y2 } var f2: (x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitConstantNoWidening.ts b/tests/cases/compiler/declarationEmitConstantNoWidening.ts new file mode 100644 index 00000000000..6bf6e92c7d4 --- /dev/null +++ b/tests/cases/compiler/declarationEmitConstantNoWidening.ts @@ -0,0 +1,5 @@ +// @declaration: true +export const FOO = 'FOO'; +export class Bar { + readonly type = FOO; // Should be widening literal "FOO" - so either `typeof "FOO"` or = "FOO" +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts b/tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts new file mode 100644 index 00000000000..fc74d6cab4d --- /dev/null +++ b/tests/cases/compiler/declarationEmitEnumReadonlyProperty.ts @@ -0,0 +1,11 @@ +// @declaration: true +enum E { + A = 'a', + B = 'b' +} + +class C { + readonly type = E.A; +} + +let x: E.A = new C().type; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts b/tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts new file mode 100644 index 00000000000..666ea9c2eda --- /dev/null +++ b/tests/cases/compiler/declarationEmitExportAliasVisibiilityMarking.ts @@ -0,0 +1,14 @@ +// @lib: es2015 +// @declaration: true +// @filename: Types.ts +type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; +type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; +export { Suit, Rank }; + +// @filename: Card.ts +import { Suit, Rank } from './Types'; +export default (suit: Suit, rank: Rank) => ({suit, rank}); + +// @filename: index.ts +export let lazyCard = () => import('./Card').then(a => a.default); +export { Suit, Rank } from './Types'; diff --git a/tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts b/tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts new file mode 100644 index 00000000000..3471929a2f7 --- /dev/null +++ b/tests/cases/compiler/declarationEmitPrivateReadonlyLiterals.ts @@ -0,0 +1,8 @@ +// @declaration: true + +class Foo { + private static readonly A = "a"; + private readonly B = "b"; + private static readonly C = 42; + private readonly D = 42; +} diff --git a/tests/cases/compiler/declarationEmitWithComposite.ts b/tests/cases/compiler/declarationEmitWithComposite.ts new file mode 100644 index 00000000000..9d039ce2271 --- /dev/null +++ b/tests/cases/compiler/declarationEmitWithComposite.ts @@ -0,0 +1,13 @@ +// @composite: true +// @fullEmitPaths: true + +// @filename: /foo/tsconfig.json +{ + "compilerOptions": { "composite": true, "outDir": "out" } +} + +// @filename: /foo/test.ts +interface Foo { + x: number; +} +export default Foo; diff --git a/tests/cases/compiler/enumLiteralUnionNotWidened.ts b/tests/cases/compiler/enumLiteralUnionNotWidened.ts new file mode 100644 index 00000000000..407d29b2922 --- /dev/null +++ b/tests/cases/compiler/enumLiteralUnionNotWidened.ts @@ -0,0 +1,20 @@ +// repro from #22093 +enum A { one = "one", two = "two" }; +enum B { foo = "foo", bar = "bar" }; + +type C = A | B.foo; +type D = A | "foo"; + +class List +{ + private readonly items: T[] = []; +} + +function asList(arg: T): List { return new List(); } + +// TypeScript incorrectly infers the return type of "asList(x)" to be "List" +// The correct type is "List" +function fn1(x: C): List { return asList(x); } + +// If we use the literal "foo" instead of B.foo, the correct type is inferred +function fn2(x: D): List { return asList(x); } \ No newline at end of file diff --git a/tests/cases/compiler/errorsWithInvokablesInUnions01.ts b/tests/cases/compiler/errorsWithInvokablesInUnions01.ts new file mode 100644 index 00000000000..56491af71ce --- /dev/null +++ b/tests/cases/compiler/errorsWithInvokablesInUnions01.ts @@ -0,0 +1,18 @@ +interface ConstructableA { + new(): { somePropA: any }; +} + +interface IDirectiveLinkFn { + (scope: TScope): void; +} + +interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { + someUnaccountedProp: any; +} diff --git a/tests/cases/compiler/expandoFunctionContextualTypes.ts b/tests/cases/compiler/expandoFunctionContextualTypes.ts new file mode 100644 index 00000000000..ae624549252 --- /dev/null +++ b/tests/cases/compiler/expandoFunctionContextualTypes.ts @@ -0,0 +1,14 @@ +interface MyComponentProps { + color: "red" | "blue" +} + +interface StatelessComponent

{ + (): any; + defaultProps?: Partial

; +} + +const MyComponent: StatelessComponent = () => null as any; + +MyComponent.defaultProps = { + color: "red" +}; diff --git a/tests/cases/compiler/expandoFunctionContextualTypesJs.ts b/tests/cases/compiler/expandoFunctionContextualTypesJs.ts new file mode 100644 index 00000000000..e69f3dc79c4 --- /dev/null +++ b/tests/cases/compiler/expandoFunctionContextualTypesJs.ts @@ -0,0 +1,57 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @filename: input.js + +/** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + +/** + * @template P + * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ + + /** + * @type {StatelessComponent} + */ +const MyComponent = () => /* @type {any} */(null); + +MyComponent.defaultProps = { + color: "red" +}; + +const MyComponent2 = () => null; + +/** + * @type {MyComponentProps} + */ +MyComponent2.defaultProps = { + color: "red" +} + +/** + * @type {StatelessComponent} + */ +const check = MyComponent2; + +/** + * + * @param {{ props: MyComponentProps }} p + */ +function expectLiteral(p) {} + +function foo() { + /** + * @type {MyComponentProps} + */ + this.props = { color: "red" }; + + expectLiteral(this); +} + +/** + * @type {MyComponentProps} + */ +module.exports = { + color: "red" +} + +expectLiteral({ props: module.exports }); diff --git a/tests/cases/compiler/functionCall18.ts b/tests/cases/compiler/functionCall18.ts new file mode 100644 index 00000000000..848580db729 --- /dev/null +++ b/tests/cases/compiler/functionCall18.ts @@ -0,0 +1,4 @@ +// Repro from #26835 +declare function foo(a: T, b: T); +declare function foo(a: {}); +foo("hello"); diff --git a/tests/cases/compiler/genericRestTypes.ts b/tests/cases/compiler/genericRestTypes.ts index cdfbd54f70d..78eb9b53f70 100644 --- a/tests/cases/compiler/genericRestTypes.ts +++ b/tests/cases/compiler/genericRestTypes.ts @@ -3,7 +3,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; diff --git a/tests/cases/compiler/narrowUnknownByTypeofObject.ts b/tests/cases/compiler/narrowUnknownByTypeofObject.ts new file mode 100644 index 00000000000..36e1c18f4f6 --- /dev/null +++ b/tests/cases/compiler/narrowUnknownByTypeofObject.ts @@ -0,0 +1,6 @@ +// @strictNullChecks: true +function foo(x: unknown) { + if (typeof x === "object") { + x + } +} diff --git a/tests/cases/compiler/narrowingByTypeofInSwitch.ts b/tests/cases/compiler/narrowingByTypeofInSwitch.ts new file mode 100644 index 00000000000..252c1d9445a --- /dev/null +++ b/tests/cases/compiler/narrowingByTypeofInSwitch.ts @@ -0,0 +1,214 @@ +// @strictNullChecks: true +// @strictFunctionTypes: true + +function assertNever(x: never) { + return x; +} + +function assertNumber(x: number) { + return x; +} + +function assertBoolean(x: boolean) { + return x; +} + +function assertString(x: string) { + return x; +} + +function assertSymbol(x: symbol) { + return x; +} + +function assertFunction(x: Function) { + return x; +} + +function assertObject(x: object) { + return x; +} + +function assertUndefined(x: undefined) { + return x; +} + +function assertAll(x: Basic) { + return x; +} + +function assertStringOrNumber(x: string | number) { + return x; +} + +function assertBooleanOrObject(x: boolean | object) { + return x; +} + +type Basic = number | boolean | string | symbol | object | Function | undefined; + +function testUnion(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertObject(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertNever(x); +} + +function testExtendsUnion(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertAll(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertAll(x); +} + +function testAny(x: any) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + case 'object': assertObject(x); return; + case 'string': assertString(x); return; + case 'undefined': assertUndefined(x); return; + } + assertAll(x); // is any +} + +function a1(x: string | object | undefined) { + return x; +} + +function testUnionExplicitDefault(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + default: a1(x); return; + } +} + +function testUnionImplicitDefault(x: Basic) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertFunction(x); return; + case 'symbol': assertSymbol(x); return; + } + return a1(x); +} + +function testExtendsExplicitDefault(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + default: assertAll(x); return; + + } +} + +function testExtendsImplicitDefault(x: T) { + switch (typeof x) { + case 'number': assertNumber(x); return; + case 'boolean': assertBoolean(x); return; + case 'function': assertAll(x); return; + case 'symbol': assertSymbol(x); return; + } + return assertAll(x); +} + +type L = (x: number) => string; +type R = { x: string, y: number } + +function exhaustiveChecks(x: number | string | L | R): string { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return x(42); + case 'object': return x.x; + } +} + +function exhaustiveChecksGenerics(x: T): string { + switch (typeof x) { + case 'number': return x.toString(2); + case 'string': return x; + case 'function': return (x as L)(42); // Can't narrow generic + case 'object': return (x as R).x; // Can't narrow generic + } +} + +function multipleGeneric(xy: X | Y): [X, string] | [Y, number] { + switch (typeof xy) { + case 'function': return [xy, xy(42)]; + case 'object': return [xy, xy.y]; + default: return assertNever(xy); + } +} + +function multipleGenericFuse(xy: X | Y): [X, number] | [Y, string] | [(X | Y)] { + switch (typeof xy) { + case 'function': return [xy, 1]; + case 'object': return [xy, 'two']; + case 'number': return [xy] + } +} + +function multipleGenericExhaustive(xy: X | Y): [X, string] | [Y, number] { + switch (typeof xy) { + case 'object': return [xy, xy.y]; + case 'function': return [xy, xy(42)]; + } +} + +function switchOrdering(x: string | number | boolean) { + switch (typeof x) { + case 'string': return assertString(x); + case 'number': return assertNumber(x); + case 'boolean': return assertBoolean(x); + case 'number': return assertNever(x); + } +} + +function switchOrderingWithDefault(x: string | number | boolean) { + function local(y: string | number | boolean) { + return x; + } + switch (typeof x) { + case 'string': + case 'number': + default: return local(x) + case 'string': return assertNever(x); + case 'number': return assertNever(x); + } +} + +function fallThroughTest(x: string | number | boolean | object) { + switch (typeof x) { + case 'number': + assertNumber(x) + case 'string': + assertStringOrNumber(x) + break; + default: + assertObject(x); + case 'number': + case 'boolean': + assertBooleanOrObject(x); + break; + } +} diff --git a/tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts b/tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts new file mode 100644 index 00000000000..93755f5e5d5 --- /dev/null +++ b/tests/cases/compiler/objectLiteralComputedNameNoDeclarationError.ts @@ -0,0 +1,8 @@ +// @declaration: true +const Foo = { + BANANA: 'banana' as 'banana', +} + +export const Baa = { + [Foo.BANANA]: 1 +}; \ No newline at end of file diff --git a/tests/cases/compiler/parameterListAsTupleType.ts b/tests/cases/compiler/parameterListAsTupleType.ts new file mode 100644 index 00000000000..6bd4579298b --- /dev/null +++ b/tests/cases/compiler/parameterListAsTupleType.ts @@ -0,0 +1,23 @@ +function foo(a: number, b: string) { + return true; +} +type Foops = Parameters; + +const x = (a: number) => 5; +type Xps = Parameters; +const a: Xps = ['should-not-work']; // works, but shouldn't +function t(...args: Xps) {} // should work + +class C { + constructor(a: number, b: string) { + } +} + +type Cps = Parameters; // should not work +type Ccps = ConstructorParameters; // should be [number, string] + +class D { + constructor(a: number, ...rest: string[]) { + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] diff --git a/tests/cases/compiler/requireOfJsonFileInJsFile.ts b/tests/cases/compiler/requireOfJsonFileInJsFile.ts new file mode 100644 index 00000000000..be8a3b00746 --- /dev/null +++ b/tests/cases/compiler/requireOfJsonFileInJsFile.ts @@ -0,0 +1,26 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @strict: true +// @resolveJsonModule: true + +// @Filename: /json.json +{ "a": 0 } + +// @Filename: /js.js +module.exports = { a: 0 }; + +// @Filename: /user.js +const json0 = require("./json.json"); +json0.b; // Error (good) + +/** @type {{ b: number }} */ +const json1 = require("./json.json"); // No error (bad) +json1.b; // No error (OK since that's the type annotation) + +const js0 = require("./js.js"); +json0.b; // Error (good) + +/** @type {{ b: number }} */ +const js1 = require("./js.js"); // Error (good) +js1.b; \ No newline at end of file diff --git a/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.ts b/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.ts new file mode 100644 index 00000000000..6c73015d222 --- /dev/null +++ b/tests/cases/compiler/requireOfJsonFileWithModuleNodeResolutionEmitAmdOutFile.ts @@ -0,0 +1,14 @@ +// @module: amd +// @moduleResolution: node +// @outFile: out/output.js +// @fullEmitPaths: true +// @resolveJsonModule: true + +// @Filename: file1.ts +import * as b from './b.json'; + +// @Filename: b.json +{ + "a": true, + "b": "hello" +} \ No newline at end of file diff --git a/tests/cases/compiler/strictTypeofUnionNarrowing.ts b/tests/cases/compiler/strictTypeofUnionNarrowing.ts new file mode 100644 index 00000000000..f2bddf3f939 --- /dev/null +++ b/tests/cases/compiler/strictTypeofUnionNarrowing.ts @@ -0,0 +1,16 @@ +// @strict: true +function stringify1(anything: { toString(): string } | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify2(anything: {} | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify3(anything: unknown | undefined): string { // should simplify to just `unknown` which should narrow fine + return typeof anything === "string" ? anything.toUpperCase() : ""; +} + +function stringify4(anything: { toString?(): string } | undefined): string { + return typeof anything === "string" ? anything.toUpperCase() : ""; +} diff --git a/tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts b/tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts new file mode 100644 index 00000000000..56c22310433 --- /dev/null +++ b/tests/cases/conformance/controlFlow/definiteAssignmentAssertionsWithObjectShortHand.ts @@ -0,0 +1,9 @@ +// @strict: true +// @declaration: true + +const a: string | undefined = 'ff'; +const foo = { a! } + +const bar = { + a ? () { } +} \ No newline at end of file diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts new file mode 100644 index 00000000000..d4b8ced9b42 --- /dev/null +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList.ts @@ -0,0 +1,48 @@ +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function rest1(a = 1, ...args) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} diff --git a/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts new file mode 100644 index 00000000000..6c9fadd1ac1 --- /dev/null +++ b/tests/cases/conformance/functions/functionWithUseStrictAndSimpleParameterList_es2016.ts @@ -0,0 +1,50 @@ +// @target: es2016 + +function a(a = 10) { + "use strict"; +} + +export var foo = 10; +function b(a = 10) { +} + +function container() { + "use strict"; + function f(a = 10) { + } +} + +function rest(...args: any[]) { + 'use strict'; +} + +function rest1(a = 1, ...args) { + 'use strict'; +} + +function paramDefault(param = 1) { + 'use strict'; +} + +function objectBindingPattern({foo}: any) { + 'use strict'; +} + +function arrayBindingPattern([foo]: any[]) { + 'use strict'; +} + +function manyParameter(a = 10, b = 20) { + "use strict"; +} + +function manyPrologue(a = 10, b = 20) { + "foo"; + "use strict"; +} + +function invalidPrologue(a = 10, b = 20) { + "foo"; + const c = 1; + "use strict"; +} diff --git a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts index cf667840f20..a3b88150f4f 100644 --- a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts +++ b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts @@ -33,3 +33,5 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } diff --git a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts index 5643ea2cc0a..f83eb2dd34e 100644 --- a/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts +++ b/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts @@ -35,3 +35,5 @@ function f7({[foo]: bar}: any[]) { class Foo { constructor(public x = 12, public y = x) {} } + +function f8(foo1: string, bar = foo1) { } diff --git a/tests/cases/conformance/jsdoc/jsdocTemplateTag4.ts b/tests/cases/conformance/jsdoc/jsdocTemplateTag4.ts new file mode 100644 index 00000000000..adbf6bfbaca --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTemplateTag4.ts @@ -0,0 +1,63 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @strict: true +// @Filename: a.js + +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap.prototype.get = function (key) { + return this._map[key + '']; +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Multimap2.prototype.get = function (key) { + return this._map[key + '']; +} + +var Ns = {}; +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +/** + * @param {K} key the key ok + * @returns {V} the value ok + */ +Ns.Multimap3.prototype.get = function (key) { + return this._map[key + '']; +} diff --git a/tests/cases/conformance/jsdoc/jsdocTemplateTag5.ts b/tests/cases/conformance/jsdoc/jsdocTemplateTag5.ts new file mode 100644 index 00000000000..0bfb6b7ca37 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTemplateTag5.ts @@ -0,0 +1,70 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @strict: true +// @Filename: a.js + +/** + * Should work for function declarations + * @constructor + * @template {string} K + * @template V + */ +function Multimap() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +Multimap.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { + return this._map[key + '']; + } +} + +/** + * Should work for initialisers too + * @constructor + * @template {string} K + * @template V + */ +var Multimap2 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +Multimap2.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get: function(key) { + return this._map[key + '']; + } +} + +var Ns = {}; +/** + * Should work for expando-namespaced initialisers too + * @constructor + * @template {string} K + * @template V + */ +Ns.Multimap3 = function() { + /** @type {Object} TODO: Remove the prototype from the fresh object */ + this._map = {}; +}; + +Ns.Multimap3.prototype = { + /** + * @param {K} key the key ok + * @returns {V} the value ok + */ + get(key) { + return this._map[key + '']; + } +} + diff --git a/tests/cases/conformance/jsdoc/typedefTagWrapping.ts b/tests/cases/conformance/jsdoc/typedefTagWrapping.ts new file mode 100644 index 00000000000..19f4f1289a2 --- /dev/null +++ b/tests/cases/conformance/jsdoc/typedefTagWrapping.ts @@ -0,0 +1,138 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true + +// @Filename: mod1.js + +/** + * @typedef {function(string): boolean} + * Type1 + */ + +/** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +function callIt(func, arg) { + return func(arg); +} + +// @Filename: mod2.js + +/** + * @typedef {{ + * num: number, + * str: string, + * boo: boolean + * }} Type2 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. + * @returns {string|number} The return. + */ +function check(obj) { + return obj.boo ? obj.num : obj.str; +} + +// @Filename: mod3.js + +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): + * (string|number)} StringOrNumber1 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use1(func, bool, str, num) { + return func(bool, str, num) +} + +// @Filename: mod4.js + +/** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, + * number): + * (string|number)} StringOrNumber2 + */ + +/** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ +function use2(func, bool, str, num) { + return func(bool, str, num) +} + +// @Filename: mod5.js + +/** + * @typedef {{ + * num: + * number, + * str: + * string, + * boo: + * boolean + * }} Type5 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. + * @returns {string|number} The return. + */ +function check5(obj) { + return obj.boo ? obj.num : obj.str; +} + +// @Filename: mod6.js + +/** + * @typedef {{ + * foo: + * *, + * bar: + * * + * }} Type6 + */ + +/** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. + * @returns {*} The return. + */ +function check6(obj) { + return obj.foo; +} + + +// @Filename: mod7.js + +/** + Multiline type expressions in comments without leading * are not supported. + @typedef {{ + foo: + *, + bar: + * + }} Type7 + */ diff --git a/tests/cases/conformance/salsa/typeFromContextualThisType.ts b/tests/cases/conformance/salsa/typeFromContextualThisType.ts new file mode 100644 index 00000000000..062b238eb8d --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromContextualThisType.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @strict: true +// @Filename: bug25926.js + +/** @type {{ a(): void; b?(n: number): number; }} */ +const o1 = { + a() { + this.b = n => n; + } +}; + +/** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ +const o2 = { + d() { + this.e = this.f = m => this.g || m; + } +}; + diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts new file mode 100644 index 00000000000..7c11a2a64bb --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment31.ts @@ -0,0 +1,26 @@ +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +namespace ExpandoMerge { + export var p2 = 222; +} +ExpandoMerge.p4 = 44444; // ok +ExpandoMerge.p6 = 66666; // ok +ExpandoMerge.p8 = false; // type error +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +ExpandoMerge.p5 = 555555; // ok +ExpandoMerge.p7 = 777777; // ok +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts new file mode 100644 index 00000000000..498aa151e73 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment32.ts @@ -0,0 +1,29 @@ +// @Filename: expando.ts +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + +// @Filename: ns.ts +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts new file mode 100644 index 00000000000..d98f689329d --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment33.ts @@ -0,0 +1,31 @@ +// @Filename: ns.ts +namespace ExpandoMerge { + export var p3 = 333; + export var p4 = 4; + export var p5 = 5; + export let p6 = 6; + export let p7 = 7; + export var p8 = 6; + export let p9 = 7; +} +namespace ExpandoMerge { + export var p2 = 222; +} + + +// @Filename: expando.ts +function ExpandoMerge(n: number) { + return n; +} +ExpandoMerge.p1 = 111 +ExpandoMerge.m = function(n: number) { + return n + 1; +} +ExpandoMerge.p4 = 44444; +ExpandoMerge.p5 = 555555; +ExpandoMerge.p6 = 66666; +ExpandoMerge.p7 = 777777; +ExpandoMerge.p8 = false; // type error +ExpandoMerge.p9 = false; // type error +var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + ExpandoMerge.p5 + ExpandoMerge.p6 + ExpandoMerge.p7 + ExpandoMerge.p8 + ExpandoMerge.p9 + ExpandoMerge.m(12) + ExpandoMerge(1001); + diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment34.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment34.ts new file mode 100644 index 00000000000..1c6be8f0171 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment34.ts @@ -0,0 +1,10 @@ +// @noEmit: true +// @allowjs: true +// @checkjs: true +// @Filename: file1.js +var N = {}; +N.commands = {}; + +// @Filename: file2.js +N.commands.a = 111; +N.commands.b = function () { }; diff --git a/tests/cases/conformance/scanner/ecmascript5/scannerNonAsciiHorizontalWhitespace.ts b/tests/cases/conformance/scanner/ecmascript5/scannerNonAsciiHorizontalWhitespace.ts new file mode 100644 index 00000000000..447cad65684 --- /dev/null +++ b/tests/cases/conformance/scanner/ecmascript5/scannerNonAsciiHorizontalWhitespace.ts @@ -0,0 +1,6 @@ +//// [scannerNonAsciiHorizontalWhitespace.ts] +"  function f() {}" + +//// [scannerNonAsciiHorizontalWhitespace.js] +"  function f() {}" + diff --git a/tests/cases/conformance/types/rest/genericRestParameters1.ts b/tests/cases/conformance/types/rest/genericRestParameters1.ts index ac8434dc5b2..6572512cbfb 100644 --- a/tests/cases/conformance/types/rest/genericRestParameters1.ts +++ b/tests/cases/conformance/types/rest/genericRestParameters1.ts @@ -127,16 +127,14 @@ declare function f30 any)[]>(x: T, ...args: U): U; const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; type T09 = Parameters; type Record1 = { diff --git a/tests/cases/conformance/types/rest/genericRestParameters2.ts b/tests/cases/conformance/types/rest/genericRestParameters2.ts index 1dc0d231dd2..12b9c4f8f1d 100644 --- a/tests/cases/conformance/types/rest/genericRestParameters2.ts +++ b/tests/cases/conformance/types/rest/genericRestParameters2.ts @@ -67,12 +67,10 @@ f20(42, ...t2); f20(42, "hello", ...t3); f20(42, "hello", ...t2, true); -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(x: string, ...args: T) => void>; type T06 = T05<[number, ...boolean[]]>; diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index b6e7c5b88c9..789016762da 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -73,13 +73,3 @@ let overlapConflict: { id:string, a: string } = f({ a: 1 }, { a: 'mismatch' }) let overwriteId: { id: string, a: number, c: number, d: string } = f({ a: 1, id: true }, { c: 1, d: 'no' }) - -// excess property checks -type A = { a: string, b: string }; -type Extra = { a: string, b: string, extra: string }; -const extra1: A = { a: "a", b: "b", extra: "extra" }; -const extra2 = { a: "a", b: "b", extra: "extra" }; -const a1: A = { ...extra1 }; // error spans should be here -const a2: A = { ...extra2 }; // not on the symbol declarations above -const extra3: Extra = { a: "a", b: "b", extra: "extra" }; -const a3: A = { ...extra3 }; // same here diff --git a/tests/cases/conformance/types/spread/spreadExcessProperty.ts b/tests/cases/conformance/types/spread/spreadExcessProperty.ts new file mode 100644 index 00000000000..b5b304e2ff7 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadExcessProperty.ts @@ -0,0 +1,3 @@ +type A = { a: string, b: string }; +const extra1 = { a: "a", b: "b", extra: "extra" }; +const a1: A = { ...extra1 }; // spread should not give excess property errors diff --git a/tests/cases/conformance/types/thisType/inferThisType.ts b/tests/cases/conformance/types/thisType/inferThisType.ts new file mode 100644 index 00000000000..7dc0c1e941a --- /dev/null +++ b/tests/cases/conformance/types/thisType/inferThisType.ts @@ -0,0 +1,10 @@ +declare function f(g: (this: T) => void): T +declare function h(this: number): void; +f(h) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +type r1 = Check<(this: number) => void>; // should be string + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +type r2 = This<(this: number) => void>; // should be number diff --git a/tests/cases/conformance/types/tuple/tupleLengthCheck.ts b/tests/cases/conformance/types/tuple/tupleLengthCheck.ts new file mode 100644 index 00000000000..593c47ee3b2 --- /dev/null +++ b/tests/cases/conformance/types/tuple/tupleLengthCheck.ts @@ -0,0 +1,11 @@ +declare const a: [number, string] +declare const rest: [number, string, ...boolean[]] + +const a1 = a[1] +const a2 = a[2] +const a3 = a[1000] + +const a4 = rest[1] +const a5 = rest[2] +const a6 = rest[3] +const a7 = rest[1000] diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts index c4904413617..e2cc7a69ee5 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts @@ -11,6 +11,6 @@ interface B { var a: A; var b: B; -// Both ok +// Both errors a = b; b = a; diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts index eaabadb7741..9e6cd52ac2b 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts @@ -61,7 +61,7 @@ interface I extends A { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok a15: (x: T) => T[]; // ok a16: (x: T) => number[]; // ok a17: (x: (a: T) => T) => T[]; // ok diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts index b5aa243f6c1..bf60d6518cf 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts index 2a598bb01ed..65e4f4c962e 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts @@ -61,7 +61,7 @@ interface I extends A { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok a15: new (x: T) => T[]; // ok a16: new (x: T) => number[]; // ok a17: new (x: new (a: T) => T) => T[]; // ok diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts index 43813faf8ae..f33820218ea 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts index 43813faf8ae..f33820218ea 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts @@ -44,5 +44,5 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts index 393d0e10d37..30c6579dabb 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts @@ -16,9 +16,9 @@ var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b: number | string; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d: number[] | string[]; diff --git a/tests/cases/fourslash/codeFixUnreachableCode.ts b/tests/cases/fourslash/codeFixUnreachableCode.ts index 9c9eea6dae4..eb5731081e7 100644 --- a/tests/cases/fourslash/codeFixUnreachableCode.ts +++ b/tests/cases/fourslash/codeFixUnreachableCode.ts @@ -3,12 +3,12 @@ ////function f() { //// return f(); //// [|return 1;|] -//// function f() {} +//// function f(a?: EE) { return a; } //// [|return 2;|] //// type T = number; //// interface I {} //// const enum E {} -//// [|enum E {}|] +//// enum EE {} //// namespace N { export type T = number; } //// [|namespace N { export const x: T = 0; }|] //// var x: I; @@ -29,11 +29,23 @@ verify.codeFixAll({ newFileContent: `function f() { return f(); - function f() {} + function f(a?: EE) { return a; } type T = number; interface I {} const enum E {} + enum EE {} namespace N { export type T = number; } var x: I; }`, }); + +function f() { + return f(); + function f(a?: EE) { return a; } + type T = number; + interface I {} + const enum E {} + enum EE {} + namespace N { export type T = number; } + var x: I; +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionsJsxAttribute.ts b/tests/cases/fourslash/completionsJsxAttribute.ts index 75bf20c7488..c4d1513a6ee 100644 --- a/tests/cases/fourslash/completionsJsxAttribute.ts +++ b/tests/cases/fourslash/completionsJsxAttribute.ts @@ -8,15 +8,22 @@ //// interface IntrinsicElements { //// div: { //// /** Doc */ -//// foo: string +//// foo: boolean; +//// bar: string; //// } //// } ////} //// ////

; -goTo.marker(); -verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute", []); +const exact: ReadonlyArray = [ + { name: "foo", kind: "JSX attribute", text: "(JSX attribute) foo: boolean", documentation: "Doc" }, + { name: "bar", kind: "JSX attribute", text: "(JSX attribute) bar: string" }, +]; +verify.completions({ marker: "", exact }); edit.insert("f"); -verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute", []); - +verify.completions({ exact }); +edit.insert("oo "); +verify.completions({ exact: exact[1] }); +edit.insert("b"); +verify.completions({ exact: exact[1] }); diff --git a/tests/cases/fourslash/completionsPaths.ts b/tests/cases/fourslash/completionsPaths.ts index e120b3dcb14..e875e3e2147 100644 --- a/tests/cases/fourslash/completionsPaths.ts +++ b/tests/cases/fourslash/completionsPaths.ts @@ -23,5 +23,7 @@ // @Filename: /src/folder/4.ts ////const foo = require(`x//*4*/`); -verify.completionsAt("1", ["y", "x"], { isNewIdentifierLocation: true }); -verify.completionsAt(["2", "3", "4"], ["bar", "foo"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: "1", exact: ["y", "x"], isNewIdentifierLocation: true }, + { marker: ["2", "3", "4"], exact: ["bar", "foo"], isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionsPaths_importType.ts b/tests/cases/fourslash/completionsPaths_importType.ts new file mode 100644 index 00000000000..4d351f2494e --- /dev/null +++ b/tests/cases/fourslash/completionsPaths_importType.ts @@ -0,0 +1,23 @@ +/// + +// @allowJs: true +// @moduleResolution: node + +// @Filename: /ns.ts +////file content not read + +// @Filename: /node_modules/package/index.ts +////file content not read + +// @Filename: /usage.ts +////type A = typeof import("p/*1*/"); +////type B = import(".//*2*/"); + +// @Filename: /user.js +/////** @type {import("/*3*/")} */ + +verify.completions( + { marker: "1", exact: "package", isNewIdentifierLocation: true }, + { marker: "2", exact: ["lib", "ns", "user", "node_modules"], isNewIdentifierLocation: true }, + { marker: "3", exact: ["package"], isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionsTuple.ts b/tests/cases/fourslash/completionsTuple.ts new file mode 100644 index 00000000000..9ce11b53d99 --- /dev/null +++ b/tests/cases/fourslash/completionsTuple.ts @@ -0,0 +1,18 @@ +/// + +////declare const x: [number, number]; +////x[|./**/|]; + +const replacementSpan = test.ranges()[0]; +verify.completions({ + marker: "", + includes: [ + { name: "0", insertText: '[0]', replacementSpan }, + { name: "1", insertText: '[1]', replacementSpan }, + "length", + ], + excludes: "2", + preferences: { + includeInsertTextCompletions: true, + }, +}); diff --git a/tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts b/tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts index 48befe13442..25059d028ed 100644 --- a/tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts +++ b/tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts @@ -8,7 +8,7 @@ //// * @param {string} o.x - a thing, its ok //// * @param {number} o.y - another thing //// * @param {Object} o.nested - very nested -//// * @param {boolean} o.nested.[|{| "isWriteAccess": true, "isDefinition": true |}great|] - much greatness +//// * @param {boolean} o.nested.[|{| "isDefinition": true |}great|] - much greatness //// * @param {number} o.nested.times - twice? probably!?? //// */ //// function f(o) { return o.nested.[|great|]; } diff --git a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts index f3d4635cebd..3d7a84cb35a 100644 --- a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts +++ b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}x|]: boolean; +//// [|{| "isDefinition": true |}x|]: boolean; ////} ////declare const i: I; ////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } = i; diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts index 7dac0432e94..3c442b8b63a 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -9,7 +9,7 @@ ////} //// ////var x: I = { -//// ["[|{| "isDefinition": true |}prop1|]"]: function () { }, +//// ["[|{| "isWriteAccess": true, "isDefinition": true |}prop1|]"]: function () { }, ////} const ranges = test.ranges(); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts index 81abd714d32..21f9d2c92ba 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -9,7 +9,7 @@ ////} //// ////var x: I = { -//// ["[|{| "isDefinition": true |}42|]"]: function () { } +//// ["[|{| "isWriteAccess": true, "isDefinition": true |}42|]"]: function () { } ////} const ranges = test.ranges(); diff --git a/tests/cases/fourslash/findAllRefsForMappedType.ts b/tests/cases/fourslash/findAllRefsForMappedType.ts index 904dc8c42c7..8965fa046ea 100644 --- a/tests/cases/fourslash/findAllRefsForMappedType.ts +++ b/tests/cases/fourslash/findAllRefsForMappedType.ts @@ -1,6 +1,6 @@ /// -////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number }; +////interface T { [|{| "isDefinition": true |}a|]: number }; ////type U = { [K in keyof T]: string }; ////type V = { [K in keyof U]: boolean }; ////const u: U = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" } diff --git a/tests/cases/fourslash/findAllRefsForObjectSpread.ts b/tests/cases/fourslash/findAllRefsForObjectSpread.ts index c6f111672c8..12c338ca529 100644 --- a/tests/cases/fourslash/findAllRefsForObjectSpread.ts +++ b/tests/cases/fourslash/findAllRefsForObjectSpread.ts @@ -1,7 +1,7 @@ /// -////interface A1 { readonly [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string }; -////interface A2 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]?: number }; +////interface A1 { readonly [|{| "isDefinition": true |}a|]: string }; +////interface A2 { [|{| "isDefinition": true |}a|]?: number }; ////let a1: A1; ////let a2: A2; ////let a12 = { ...a1, ...a2 }; diff --git a/tests/cases/fourslash/findAllRefsForRest.ts b/tests/cases/fourslash/findAllRefsForRest.ts index 026451d68b8..3dac71374f0 100644 --- a/tests/cases/fourslash/findAllRefsForRest.ts +++ b/tests/cases/fourslash/findAllRefsForRest.ts @@ -1,7 +1,7 @@ /// ////interface Gen { //// x: number -//// [|{| "isWriteAccess": true, "isDefinition": true |}parent|]: Gen; +//// [|{| "isDefinition": true |}parent|]: Gen; //// millenial: string; ////} ////let t: Gen; diff --git a/tests/cases/fourslash/findAllRefsInClassExpression.ts b/tests/cases/fourslash/findAllRefsInClassExpression.ts index 19ec2df35d2..8adc64e8e6d 100644 --- a/tests/cases/fourslash/findAllRefsInClassExpression.ts +++ b/tests/cases/fourslash/findAllRefsInClassExpression.ts @@ -1,6 +1,6 @@ /// -////interface I { [|{| "isWriteAccess": true, "isDefinition": true |}boom|](): void; } +////interface I { [|{| "isDefinition": true |}boom|](): void; } ////new class C implements I { //// [|{| "isWriteAccess": true, "isDefinition": true |}boom|](){} ////} diff --git a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts index fdfb00439f6..49dac247294 100644 --- a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts +++ b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts @@ -1,8 +1,8 @@ /// ////interface I { -//// [|{| "isDefinition": true, "isWriteAccess": true |}0|]: number; -//// [|{| "isDefinition": true, "isWriteAccess": true |}s|]: string; +//// [|{| "isDefinition": true |}0|]: number; +//// [|{| "isDefinition": true |}s|]: string; ////} ////interface J { //// a: I[[|0|]], diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts index 3b14e686cc6..9e58a37c589 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts @@ -2,7 +2,7 @@ //// class class1 extends class1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// //// var v: class1; diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts index 23badd64d48..2e776e48acd 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts @@ -1,8 +1,8 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r0 -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1 +//// [|{| "isDefinition": true |}doStuff|](): void; // r0 +//// [|{| "isDefinition": true |}propName|]: string; // r1 //// } //// //// var v: interface1; diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties3.ts b/tests/cases/fourslash/findAllRefsInheritedProperties3.ts index 2c929a559fb..ea5b1ce7bf4 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties3.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties3.ts @@ -2,15 +2,15 @@ //// class class1 extends class1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r0 -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1 +//// [|{| "isDefinition": true |}propName|]: string; // r1 //// } //// interface interface1 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r2 -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r3 +//// [|{| "isDefinition": true |}doStuff|](): void; // r2 +//// [|{| "isDefinition": true |}propName|]: string; // r3 //// } //// class class2 extends class1 implements interface1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r4 -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r5 +//// [|{| "isDefinition": true |}propName|]: string; // r5 //// } //// //// var v: class2; diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts index e2d8887bbe8..2528fef1939 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts @@ -1,12 +1,12 @@ /// //// interface C extends D { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0 -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1 +//// [|{| "isDefinition": true |}prop0|]: string; // r0 +//// [|{| "isDefinition": true |}prop1|]: number; // r1 //// } //// //// interface D extends C { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2 +//// [|{| "isDefinition": true |}prop0|]: string; // r2 //// } //// //// var d: D; diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts index c534a9d6aab..343328405d5 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts @@ -1,12 +1,12 @@ /// //// class C extends D { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0 -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1 +//// [|{| "isDefinition": true |}prop0|]: string; // r0 +//// [|{| "isDefinition": true |}prop1|]: number; // r1 //// } //// //// class D extends C { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2 +//// [|{| "isDefinition": true |}prop0|]: string; // r2 //// } //// //// var d: D; diff --git a/tests/cases/fourslash/findAllRefsMappedType.ts b/tests/cases/fourslash/findAllRefsMappedType.ts index 97658da08c1..8c6c59150af 100644 --- a/tests/cases/fourslash/findAllRefsMappedType.ts +++ b/tests/cases/fourslash/findAllRefsMappedType.ts @@ -1,6 +1,6 @@ /// -////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; } +////interface T { [|{| "isDefinition": true |}a|]: number; } ////type U = { readonly [K in keyof T]?: string }; ////declare const t: T; ////t.[|a|]; diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts index d11bcee506f..5a72ca1c1ec 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; +//// [|{| "isDefinition": true |}property1|]: number; //// property2: string; ////} //// diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts index 6ad98df9cd8..76b6d046b8e 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; +//// [|{| "isDefinition": true |}property1|]: number; //// property2: string; ////} //// diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts index 520dbc8e1e4..f82eca087bb 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; +//// [|{| "isDefinition": true |}property1|]: number; //// property2: string; ////} //// diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts index f25fff9da23..fe0d659f0ec 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; +//// [|{| "isDefinition": true |}property1|]: number; //// property2: string; ////} //// diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts index a8dd5bda227..62d1637f3b3 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -1,7 +1,7 @@ /// ////interface I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; +//// [|{| "isDefinition": true |}property1|]: number; //// property2: string; ////} //// diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts index 69d1f6ac2ff..18fa4e43273 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts @@ -2,6 +2,6 @@ ////let p, b; //// -////p, [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; +////p, [{ [|{| "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; verify.singleReferenceGroup("(property) a: any"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts index 500ca7fe3cf..7d31cfd4345 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts @@ -1,7 +1,7 @@ /// ////interface Recursive { -//// [|{| "isWriteAccess": true, "isDefinition": true |}next|]?: Recursive; +//// [|{| "isDefinition": true |}next|]?: Recursive; //// value: any; ////} //// diff --git a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts index e4e9b830510..d4aefb58ac3 100644 --- a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts +++ b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts @@ -1,7 +1,7 @@ /// ////interface IFoo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; +//// [|{| "isDefinition": true |}a|]: string; ////} ////class C { //// method() { diff --git a/tests/cases/fourslash/findAllRefsReExportLocal.ts b/tests/cases/fourslash/findAllRefsReExportLocal.ts index ed1d0b105b6..603971a2294 100644 --- a/tests/cases/fourslash/findAllRefsReExportLocal.ts +++ b/tests/cases/fourslash/findAllRefsReExportLocal.ts @@ -3,7 +3,7 @@ // @noLib: true // @Filename: /a.ts -////var [|{| "isWriteAccess": true, "isDefinition": true |}x|]; +////var [|{| "isDefinition": true |}x|]; ////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] }; ////export { [|x|] as [|{| "isWriteAccess": true, "isDefinition": true |}y|] }; diff --git a/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts b/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts index 1964ebf2c2c..dff05b219be 100644 --- a/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts +++ b/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts @@ -3,10 +3,10 @@ // @noLib: true ////interface A { -//// readonly [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number | string; +//// readonly [|{| "isDefinition": true |}x|]: number | string; ////} ////interface B extends A { -//// readonly [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; +//// readonly [|{| "isDefinition": true |}x|]: number; ////} ////const a: A = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 }; ////const b: B = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 }; diff --git a/tests/cases/fourslash/findAllRefsRootSymbols.ts b/tests/cases/fourslash/findAllRefsRootSymbols.ts index 77eea3b46b0..0e209765b37 100644 --- a/tests/cases/fourslash/findAllRefsRootSymbols.ts +++ b/tests/cases/fourslash/findAllRefsRootSymbols.ts @@ -1,7 +1,7 @@ /// -////interface I { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: {}; } -////interface J { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: {}; } +////interface I { [|{| "isDefinition": true |}x|]: {}; } +////interface J { [|{| "isDefinition": true |}x|]: {}; } ////declare const o: (I | J) & { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: string }; ////o.[|x|]; diff --git a/tests/cases/fourslash/findAllRefsThisKeyword.ts b/tests/cases/fourslash/findAllRefsThisKeyword.ts index 975b4b37ac2..34995467a27 100644 --- a/tests/cases/fourslash/findAllRefsThisKeyword.ts +++ b/tests/cases/fourslash/findAllRefsThisKeyword.ts @@ -26,10 +26,8 @@ const [global, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); verify.singleReferenceGroup("this", [global]); -verify.referenceGroups(f0, [{ definition: "(parameter) this: any", ranges: [f0, f1] }]); -verify.referenceGroups(f1, [{ definition: "this: any", ranges: [f0, f1] }]); -verify.referenceGroups(g0, [{ definition: "(parameter) this: any", ranges: [g0, g1] }]); -verify.referenceGroups(g1, [{ definition: "this: any", ranges: [g0, g1] }]); +verify.singleReferenceGroup("(parameter) this: any", [f0, f1]); +verify.singleReferenceGroup("(parameter) this: any", [g0, g1]); verify.singleReferenceGroup("this: typeof C", [x, y]); verify.singleReferenceGroup("this: this", [constructor, method]); verify.singleReferenceGroup("(property) this: number", [propDef, propUse]); diff --git a/tests/cases/fourslash/findAllRefsTypedef.ts b/tests/cases/fourslash/findAllRefsTypedef.ts index ecd690c10e5..2e7d8601656 100644 --- a/tests/cases/fourslash/findAllRefsTypedef.ts +++ b/tests/cases/fourslash/findAllRefsTypedef.ts @@ -5,7 +5,7 @@ // @Filename: /a.js /////** //// * @typedef I {Object} -//// * @prop [|{| "isWriteAccess": true, "isDefinition": true |}p|] {number} +//// * @prop [|{| "isDefinition": true |}p|] {number} //// */ //// /////** @type {I} */ diff --git a/tests/cases/fourslash/findAllRefsUnionProperty.ts b/tests/cases/fourslash/findAllRefsUnionProperty.ts index 97b8972c457..3b7813f638b 100644 --- a/tests/cases/fourslash/findAllRefsUnionProperty.ts +++ b/tests/cases/fourslash/findAllRefsUnionProperty.ts @@ -1,8 +1,8 @@ /// ////type T = -//// | { [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "a", [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: number } -//// | { [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "b", [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: string }; +//// | { [|{| "isDefinition": true |}type|]: "a", [|{| "isDefinition": true |}prop|]: number } +//// | { [|{| "isDefinition": true |}type|]: "b", [|{| "isDefinition": true |}prop|]: string }; ////const tt: T = { //// [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "a", //// [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: 0, diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts index d54b48bf662..cf171662596 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts @@ -3,7 +3,7 @@ ////class Foo { //// public _bar; //// public __bar; -//// public [|{| "isWriteAccess": true, "isDefinition": true |}___bar|]; +//// public [|{| "isDefinition": true |}___bar|]; //// public ____bar; ////} //// diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts index 39bc1d73ca3..77197480eb1 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts @@ -2,7 +2,7 @@ ////class Foo { //// public _bar; -//// public [|{| "isWriteAccess": true, "isDefinition": true |}__bar|]; +//// public [|{| "isDefinition": true |}__bar|]; //// public ___bar; //// public ____bar; ////} diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts index 6dbbf9e613b..f19640698cd 100644 --- a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts @@ -2,7 +2,7 @@ //// var [|{| "isWriteAccess": true, "isDefinition": true |}dx|] = "Foo"; //// -//// module M { export var [|{| "isWriteAccess": true, "isDefinition": true |}dx|]; } +//// module M { export var [|{| "isDefinition": true |}dx|]; } //// module M { //// var z = 100; //// export var y = { [|{| "isWriteAccess": true, "isDefinition": true |}dx|], z }; diff --git a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts index f9feb5ddb62..2141399705f 100644 --- a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts +++ b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts @@ -1,7 +1,7 @@ /// //@Filename: a.ts -////var [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; +////var [|{| "isDefinition": true |}x|]: number; //@Filename: b.ts /////// diff --git a/tests/cases/fourslash/findReferencesAfterEdit.ts b/tests/cases/fourslash/findReferencesAfterEdit.ts index 599be2255a3..3787617692a 100644 --- a/tests/cases/fourslash/findReferencesAfterEdit.ts +++ b/tests/cases/fourslash/findReferencesAfterEdit.ts @@ -2,7 +2,7 @@ // @Filename: a.ts ////interface A { -//// [|{| "isWriteAccess": true, "isDefinition": true |}foo|]: string; +//// [|{| "isDefinition": true |}foo|]: string; ////} // @Filename: b.ts diff --git a/tests/cases/fourslash/findReferencesJSXTagName3.ts b/tests/cases/fourslash/findReferencesJSXTagName3.ts index 0d5d74b6e2e..58715ade2fa 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName3.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName3.ts @@ -6,7 +6,7 @@ ////namespace JSX { //// export interface Element { } //// export interface IntrinsicElements { -//// [|{| "isWriteAccess": true, "isDefinition": true |}div|]: any; +//// [|{| "isDefinition": true |}div|]: any; //// } ////} //// diff --git a/tests/cases/fourslash/functionTypes.ts b/tests/cases/fourslash/functionTypes.ts index 6ddba777ae0..5ef931a602d 100644 --- a/tests/cases/fourslash/functionTypes.ts +++ b/tests/cases/fourslash/functionTypes.ts @@ -21,4 +21,10 @@ ////l./*7*/prototype = Object.prototype; verify.noErrors(); -verify.completionsAt(test.markerNames(), ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('1', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('2', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('3', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('4', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('5', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('6', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); +verify.completionsAt('7', ["prototype", "apply", "call", "bind", "toString", "length", "arguments", "caller" ]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts index e4c3c93d0e1..88ab38e5428 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts @@ -1,5 +1,5 @@ /// -////let o = { ["[|{| "isDefinition": true |}foo|]"]: 12 }; +////let o = { ["[|{| "isWriteAccess": true, "isDefinition": true |}foo|]"]: 12 }; ////let y = o.[|foo|]; ////let z = o['[|foo|]']; diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts index fba8875a610..c30bee2b993 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts @@ -15,8 +15,5 @@ verify.importFixAtPosition([ `import { f1 } from "b"; -f1();`, -`import { f1 } from "./a/b"; - f1();`, ]); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts index fa28dea5fe2..285a2e6ff53 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts @@ -14,14 +14,11 @@ ////[|f1/*0*/();|] goTo.file("/a/b/y.ts"); -// Order the local import first because it's simpler. +// Use the local import because it's simpler. verify.importFixAtPosition([ `import { f1 } from "./x"; f1();`, -`import { f1 } from "b/x"; - -f1();` ]); verify.importFixAtPosition([ diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts index 8fc9a97afe3..1923251d10e 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts @@ -19,9 +19,6 @@ verify.importFixAtPosition([ `import { f1 } from "b/x"; f1();`, -`import { f1 } from "../b/x"; - -f1();` ]); verify.importFixAtPosition([ diff --git a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts index 9743d164a9c..f4aa86ca7d7 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts @@ -16,12 +16,9 @@ //// } //// } -// "typeRoots" does not affect module resolution. Importing from "random" would be a compile error. +// "typeRoots" does not affect module resolution, though "baseUrl" does. Importing from "random" would be a compile error. verify.importFixAtPosition([ `import { foo } from "types/random"; foo();`, -`import { foo } from "../types/random"; - -foo();` ]); diff --git a/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts b/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts index dda8b855123..4affd5e33ba 100644 --- a/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts +++ b/tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts @@ -3,7 +3,7 @@ // @Filename: /a.ts ////export const foo = 0; -// @Filename: /b.ts +// @Filename: /x/y.ts ////foo; // @Filename: /tsconfig.json @@ -16,7 +16,7 @@ //// } ////} -goTo.file("/b.ts"); +goTo.file("/x/y.ts"); verify.importFixAtPosition([ `import { foo } from "@root/a"; diff --git a/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts b/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts new file mode 100644 index 00000000000..c2aaef471a4 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFix_preferBaseUrl.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: /tsconfig.json +////{ "compilerOptions": { "baseUrl": "./src" } } + +// @Filename: /src/d0/d1/d2/file.ts +////foo/**/; + +// @Filename: /src/d0/a.ts +////export const foo = 0; + +goTo.file("/src/d0/d1/d2/file.ts"); +verify.importFixAtPosition([ +`import { foo } from "d0/a"; + +foo;` +]); diff --git a/tests/cases/fourslash/importNameCodeFix_rootDirs.ts b/tests/cases/fourslash/importNameCodeFix_rootDirs.ts index d19bb8f4fa5..1367f53b9f3 100644 --- a/tests/cases/fourslash/importNameCodeFix_rootDirs.ts +++ b/tests/cases/fourslash/importNameCodeFix_rootDirs.ts @@ -18,6 +18,6 @@ const nonRelative = 'import { a } from "a";\n\na;'; const relative = nonRelative.replace('"a"', '"./a"'); goTo.file("/b.ts"); -verify.importFixAtPosition([nonRelative, relative]); +verify.importFixAtPosition([nonRelative]); verify.importFixAtPosition([nonRelative], undefined, { importModuleSpecifierPreference: "non-relative" }); verify.importFixAtPosition([relative], undefined, { importModuleSpecifierPreference: "relative" }); diff --git a/tests/cases/fourslash/importTypeModuleCompletions.ts b/tests/cases/fourslash/importTypeModuleCompletions.ts deleted file mode 100644 index 2a2f17818d4..00000000000 --- a/tests/cases/fourslash/importTypeModuleCompletions.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @moduleResolution: node - -// @Filename: /ns.ts -////file content not read -// @Filename: /node_modules/package/index.ts -////file content not read -// @Filename: /usage.ts -////type A = typeof import("p/*1*/"); -////type B = typeof import(".//*2*/"); -verify.completionsAt("1", ["package"], { isNewIdentifierLocation: true }); -verify.completionsAt("2", ["lib", "ns", "node_modules"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures12.ts b/tests/cases/fourslash/jsDocFunctionSignatures12.ts index 29a8ac4caeb..5976d01a3d6 100644 --- a/tests/cases/fourslash/jsDocFunctionSignatures12.ts +++ b/tests/cases/fourslash/jsDocFunctionSignatures12.ts @@ -1,13 +1,32 @@ - /// + // @allowJs: true -// @Filename: Foo.js +// @Filename: jsDocFunctionSignatures.js + /////** -//// * @param {{ stringProp: string, -//// * numProp: number }} o +//// * @param {{ +//// * stringProp: string, +//// * numProp: number, +//// * boolProp: boolean, +//// * anyProp: *, +//// * anotherAnyProp: +//// * *, +//// * functionProp: +//// * function(string, +//// * *): +//// * * +//// * }} o //// */ ////function f1(o) { //// o/**/; ////} + goTo.marker(); -verify.quickInfoIs("(parameter) o: any"); +verify.quickInfoIs(`(parameter) o: { + stringProp: string; + numProp: number; + boolProp: boolean; + anyProp: any; + anotherAnyProp: any; + functionProp: (arg0: string, arg1: any) => any; +}`); diff --git a/tests/cases/fourslash/quickInfoJsdocEnum.ts b/tests/cases/fourslash/quickInfoJsdocEnum.ts new file mode 100644 index 00000000000..de67cacc7d2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsdocEnum.ts @@ -0,0 +1,25 @@ +/// + +// @allowJs: true +// @noLib: true + +// @Filename: /a.js +/////** +//// * Doc +//// * @enum {number} +//// */ +////const E = { +//// A: 0, +////} +//// +/////** @type {/**/E} */ +////const x = E.A; + +verify.noErrors(); + +verify.quickInfoAt("", +`enum E +const E: { + A: number; +}`, +"Doc"); diff --git a/tests/cases/fourslash/referencesForClassMembers.ts b/tests/cases/fourslash/referencesForClassMembers.ts index c2eb8706f59..e60c03524a1 100644 --- a/tests/cases/fourslash/referencesForClassMembers.ts +++ b/tests/cases/fourslash/referencesForClassMembers.ts @@ -1,11 +1,11 @@ /// ////class Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; +//// [|{| "isDefinition": true |}a|]: number; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } ////} ////class MyClass extends Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isDefinition": true |}a|]; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts index 5aaee38d205..12df996629d 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts @@ -1,11 +1,11 @@ /// ////abstract class Base { -//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; -//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; +//// abstract [|{| "isDefinition": true |}a|]: number; +//// abstract [|{| "isDefinition": true |}method|](): void; ////} ////class MyClass extends Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isDefinition": true |}a|]; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts index 6082033b078..103b66ff74b 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts @@ -1,11 +1,11 @@ /// ////class Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: this; +//// [|{| "isDefinition": true |}a|]: this; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|](a?:T, b?:U): this { } ////} ////class MyClass extends Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isDefinition": true |}a|]; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// diff --git a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts index f4e0daaab00..67f09a9dcd1 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts @@ -1,6 +1,6 @@ /// -////interface IFoo { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: number; } +////interface IFoo { [|{| "isDefinition": true |}xy|]: number; } //// ////// Assignment ////var a1: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts index 9ddd31f2fbb..b0bb5d62b4d 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts @@ -2,12 +2,12 @@ ////interface A { //// a: number; -//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: string; +//// [|{| "isDefinition": true |}common|]: string; ////} //// ////interface B { //// b: number; -//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: number; +//// [|{| "isDefinition": true |}common|]: number; ////} //// ////// Assignment diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts index 3ea7cd9b275..a9741d3e39d 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts @@ -6,7 +6,7 @@ ////} //// ////interface B { -//// [|{| "isWriteAccess": true, "isDefinition": true |}b|]: number; +//// [|{| "isDefinition": true |}b|]: number; //// common: number; ////} //// diff --git a/tests/cases/fourslash/referencesForFunctionOverloads.ts b/tests/cases/fourslash/referencesForFunctionOverloads.ts index 7afa5a20133..2a1ea032e20 100644 --- a/tests/cases/fourslash/referencesForFunctionOverloads.ts +++ b/tests/cases/fourslash/referencesForFunctionOverloads.ts @@ -2,7 +2,7 @@ // Function overloads should be highlighted together. -////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string); +////function [|{| "isDefinition": true |}foo|](x: string); ////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string, y: number) { //// [|foo|]('', 43); ////} diff --git a/tests/cases/fourslash/referencesForIndexProperty.ts b/tests/cases/fourslash/referencesForIndexProperty.ts index dba2549e414..4bc0b3620ea 100644 --- a/tests/cases/fourslash/referencesForIndexProperty.ts +++ b/tests/cases/fourslash/referencesForIndexProperty.ts @@ -3,7 +3,7 @@ // References a class property using string index access ////class Foo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property|]: number; +//// [|{| "isDefinition": true |}property|]: number; //// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } ////} //// diff --git a/tests/cases/fourslash/referencesForIndexProperty3.ts b/tests/cases/fourslash/referencesForIndexProperty3.ts index a2e008c937e..69417700ed0 100644 --- a/tests/cases/fourslash/referencesForIndexProperty3.ts +++ b/tests/cases/fourslash/referencesForIndexProperty3.ts @@ -3,7 +3,7 @@ // References to a property of the apparent type using string indexer ////interface Object { -//// [|{| "isWriteAccess": true, "isDefinition": true |}toMyString|](); +//// [|{| "isDefinition": true |}toMyString|](); ////} //// ////var y: Object; diff --git a/tests/cases/fourslash/referencesForInheritedProperties.ts b/tests/cases/fourslash/referencesForInheritedProperties.ts index 808387d18f7..88d7ea7537d 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties.ts @@ -1,11 +1,11 @@ /// ////interface interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 extends interface1{ -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}doStuff|](): void; ////} //// ////class class1 implements interface2 { diff --git a/tests/cases/fourslash/referencesForInheritedProperties2.ts b/tests/cases/fourslash/referencesForInheritedProperties2.ts index f41fbb7f8db..712c7f2ecf2 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties2.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties2.ts @@ -3,11 +3,11 @@ // extends statement in a diffrent declaration ////interface interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 extends interface1 { diff --git a/tests/cases/fourslash/referencesForInheritedProperties3.ts b/tests/cases/fourslash/referencesForInheritedProperties3.ts index c6c870ca350..0eabc6cda9e 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties3.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties3.ts @@ -1,8 +1,8 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// //// var v: interface1; diff --git a/tests/cases/fourslash/referencesForInheritedProperties4.ts b/tests/cases/fourslash/referencesForInheritedProperties4.ts index adf8240ea31..f6a7d48f9d1 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties4.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties4.ts @@ -2,7 +2,7 @@ //// class class1 extends class1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// //// var c: class1; diff --git a/tests/cases/fourslash/referencesForInheritedProperties5.ts b/tests/cases/fourslash/referencesForInheritedProperties5.ts index 12fe3919a1d..232b654c63f 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties5.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties5.ts @@ -1,12 +1,12 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// interface interface2 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// //// var v: interface1; diff --git a/tests/cases/fourslash/referencesForInheritedProperties7.ts b/tests/cases/fourslash/referencesForInheritedProperties7.ts index 44cf510182a..25402d36b6e 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties7.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties7.ts @@ -2,15 +2,15 @@ //// class class1 extends class1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// interface interface1 extends interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// class class2 extends class1 implements interface1 { //// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; +//// [|{| "isDefinition": true |}propName|]: string; //// } //// //// var v: class2; diff --git a/tests/cases/fourslash/referencesForInheritedProperties8.ts b/tests/cases/fourslash/referencesForInheritedProperties8.ts index d0d94b49b57..331a90f9181 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties8.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties8.ts @@ -1,11 +1,11 @@ /// //// interface C extends D { -//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: number; +//// [|{| "isDefinition": true |}propD|]: number; //// } //// interface D extends C { -//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: string; -//// [|{| "isWriteAccess": true, "isDefinition": true |}propC|]: number; +//// [|{| "isDefinition": true |}propD|]: string; +//// [|{| "isDefinition": true |}propC|]: number; //// } //// var d: D; //// d.[|propD|]; diff --git a/tests/cases/fourslash/referencesForInheritedProperties9.ts b/tests/cases/fourslash/referencesForInheritedProperties9.ts index 27bc164a8fc..3648be2f989 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties9.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties9.ts @@ -1,11 +1,11 @@ /// //// class D extends C { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string; +//// [|{| "isDefinition": true |}prop1|]: string; //// } //// //// class C extends D { -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string; +//// [|{| "isDefinition": true |}prop1|]: string; //// } //// //// var c: C; diff --git a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts index 79dc04ecaee..1f28714daa1 100644 --- a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts @@ -1,7 +1,7 @@ /// ////class Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}12|]: any; +//// public [|{| "isDefinition": true |}12|]: any; ////} //// ////var x: Foo; diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index ab3d60f1b86..d5d9ea0a6b6 100644 --- a/tests/cases/fourslash/referencesForOverrides.ts +++ b/tests/cases/fourslash/referencesForOverrides.ts @@ -14,16 +14,16 @@ //// //// module SimpleInterfaceTest { //// export interface IFoo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void; +//// [|{| "isDefinition": true |}ifoo|](): void; //// } //// export interface IBar extends IFoo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void; +//// [|{| "isDefinition": true |}ifoo|](): void; //// } //// } //// //// module SimpleClassInterfaceTest { //// export interface IFoo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void; +//// [|{| "isDefinition": true |}icfoo|](): void; //// } //// export class Bar implements IFoo { //// public [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void { @@ -33,29 +33,29 @@ //// //// module Test { //// export interface IBase { -//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; +//// [|{| "isDefinition": true |}field|]: string; +//// [|{| "isDefinition": true |}method|](): void; //// } //// //// export interface IBlah extends IBase { -//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// [|{| "isDefinition": true |}field|]: string; //// } //// //// export interface IBlah2 extends IBlah { -//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// [|{| "isDefinition": true |}field|]: string; //// } //// //// export interface IDerived extends IBlah2 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; +//// [|{| "isDefinition": true |}method|](): void; //// } //// //// export class Bar implements IDerived { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// public [|{| "isDefinition": true |}field|]: string; //// public [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } //// } //// //// export class BarBlah extends Bar { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// public [|{| "isDefinition": true |}field|]: string; //// } //// } //// diff --git a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts index a84bdc6315a..be00bb7593f 100644 --- a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts +++ b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts @@ -1,7 +1,7 @@ /// ////interface IFoo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doSomething|](v: T): T; +//// [|{| "isDefinition": true |}doSomething|](v: T): T; ////} //// ////var x: IFoo; diff --git a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts index 9e7f30f4c49..816b866421a 100644 --- a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts +++ b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts @@ -3,8 +3,8 @@ ////module FindRef4 { //// module MixedStaticsClassTest { //// export class Foo { -//// [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo; -//// static [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo; +//// [|{| "isDefinition": true |}bar|]: Foo; +//// static [|{| "isDefinition": true |}bar|]: Foo; //// //// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { //// } diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts index 5c98eddadce..88c9a74bc6e 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts @@ -1,7 +1,7 @@ /// ////class Foo { -//// public "[|{| "isWriteAccess": true, "isDefinition": true |}ss|]": any; +//// public "[|{| "isDefinition": true |}ss|]": any; ////} //// ////var x: Foo; diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts index 01e6d424673..98a6dc2ac47 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts @@ -6,7 +6,7 @@ ////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } ////x["[|someProperty|]"] = 3; -////x.[|{| "isWriteAccess": true, "isDefinition": false |}someProperty|] = 5; +////x.[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|] = 5; const ranges = test.ranges(); const [r0, r1, r2] = ranges; diff --git a/tests/cases/fourslash/referencesForUnionProperties.ts b/tests/cases/fourslash/referencesForUnionProperties.ts index b8e24dfae1c..7efff1aabd0 100644 --- a/tests/cases/fourslash/referencesForUnionProperties.ts +++ b/tests/cases/fourslash/referencesForUnionProperties.ts @@ -1,16 +1,16 @@ /// ////interface One { -//// common: { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; }; +//// common: { [|{| "isDefinition": true |}a|]: number; }; ////} //// ////interface Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; +//// [|{| "isDefinition": true |}a|]: string; //// b: string; ////} //// ////interface HasAOrB extends Base { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; +//// [|{| "isDefinition": true |}a|]: string; //// b: string; ////} //// diff --git a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts index a961ebf2411..96d423529c2 100644 --- a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts +++ b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts @@ -1,7 +1,7 @@ /// // @Filename: a.ts -////export var [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +////export var [|{| "isDefinition": true |}a|]; // @Filename: b.ts ////import { [|{| "isWriteAccess": true, "isDefinition": true |}a|] } from './a'; diff --git a/tests/cases/fourslash/signatureHelpInRecursiveType.ts b/tests/cases/fourslash/signatureHelpInRecursiveType.ts new file mode 100644 index 00000000000..ca55be37b55 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpInRecursiveType.ts @@ -0,0 +1,18 @@ +/// + +////type Tail = +//// ((...args: T) => any) extends ((head: any, ...tail: infer R) => any) ? R : never; +//// +////type Reverse = _Reverse; +//// +////type _Reverse = { +//// 1: Result, +//// 0: _Reverse, 0>, +////}[Source extends [] ? 1 : 0]; +//// +////type Foo = Reverse<[0,/**/]>; + +verify.signatureHelp({ + marker: "", + text: "Reverse", +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTypeArguments2.ts b/tests/cases/fourslash/signatureHelpTypeArguments2.ts new file mode 100644 index 00000000000..6d39e6e8870 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTypeArguments2.ts @@ -0,0 +1,37 @@ +/// + +/////** some documentation +//// * @template T some documentation 2 +//// * @template W +//// * @template U,V others +//// * @param a ok +//// * @param b not ok +//// */ +////function f(a: number, b: string, c: boolean): void { } +////f(a: number, b: string, c: boolean): void", + parameterName, + parameterSpan: parameterName, + docComment: "some documentation", + parameterDocComment, + tags: [{ name: "template", text: "T some documentation 2" }, + { name: "template", text: "W" }, + { name: "template", text: "U, V others" }, + { name: "param", text: "a ok" }, + { name: "param", text: "b not ok" }] + } +} + +verify.signatureHelp( + build("f0", "T", "some documentation 2"), + build("f1", "U", "others"), + build("f2", "V", "others"), + build("f3", "W", ""), +); diff --git a/tests/cases/fourslash/tsxFindAllReferences10.ts b/tests/cases/fourslash/tsxFindAllReferences10.ts index 04ac864e4f2..58459c7df1f 100644 --- a/tests/cases/fourslash/tsxFindAllReferences10.ts +++ b/tests/cases/fourslash/tsxFindAllReferences10.ts @@ -15,7 +15,7 @@ //// className?: string; //// } //// interface ButtonProps extends ClickableProps { -//// [|{| "isWriteAccess": true, "isDefinition": true |}onClick|](event?: React.MouseEvent): void; +//// [|{| "isDefinition": true |}onClick|](event?: React.MouseEvent): void; //// } //// interface LinkProps extends ClickableProps { //// goTo: string; diff --git a/tests/cases/fourslash/tsxFindAllReferences3.ts b/tests/cases/fourslash/tsxFindAllReferences3.ts index 2682e01e7d1..e2f9215466a 100644 --- a/tests/cases/fourslash/tsxFindAllReferences3.ts +++ b/tests/cases/fourslash/tsxFindAllReferences3.ts @@ -9,7 +9,7 @@ //// } //// class MyClass { //// props: { -//// [|{| "isWriteAccess": true, "isDefinition": true |}name|]?: string; +//// [|{| "isDefinition": true |}name|]?: string; //// size?: number; //// } //// diff --git a/tests/cases/fourslash/tsxFindAllReferences7.ts b/tests/cases/fourslash/tsxFindAllReferences7.ts index 37ea60c7a38..471cf747258 100644 --- a/tests/cases/fourslash/tsxFindAllReferences7.ts +++ b/tests/cases/fourslash/tsxFindAllReferences7.ts @@ -11,7 +11,7 @@ //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { -//// [|{| "isWriteAccess": true, "isDefinition": true |}propx|]: number +//// [|{| "isDefinition": true |}propx|]: number //// propString: string //// optional?: boolean //// } diff --git a/tests/cases/fourslash/tsxFindAllReferences9.ts b/tests/cases/fourslash/tsxFindAllReferences9.ts index 9fe02500ad9..bb45ce590cf 100644 --- a/tests/cases/fourslash/tsxFindAllReferences9.ts +++ b/tests/cases/fourslash/tsxFindAllReferences9.ts @@ -18,7 +18,7 @@ //// onClick(event?: React.MouseEvent): void; //// } //// interface LinkProps extends ClickableProps { -//// [|{| "isWriteAccess": true, "isDefinition": true |}goTo|]: string; +//// [|{| "isDefinition": true |}goTo|]: string; //// } //// declare function MainButton(buttonProps: ButtonProps): JSX.Element; //// declare function MainButton(linkProps: LinkProps): JSX.Element;