diff --git a/package-lock.json b/package-lock.json index 50123efe16c..292311519f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -288,9 +288,9 @@ } }, "@octokit/core": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.3.1.tgz", - "integrity": "sha512-Dc5NNQOYjgZU5S1goN6A/E500yXOfDUFRGQB8/2Tl16AcfvS3H9PudyOe3ZNE/MaVyHPIfC0htReHMJb1tMrvw==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.4.0.tgz", + "integrity": "sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==", "dev": true, "requires": { "@octokit/auth-token": "^2.4.4", @@ -422,9 +422,9 @@ } }, "@types/chai": { - "version": "4.2.15", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz", - "integrity": "sha512-rYff6FI+ZTKAPkJUoyz7Udq3GaoDZnxYDEvdEdFZASiA7PoErltHezDishqQiSDWrGxvxmplH304jyzQmjp0AQ==", + "version": "4.2.16", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.16.tgz", + "integrity": "sha512-vI5iOAsez9+roLS3M3+Xx7w+WRuDtSmF8bQkrbcIJ2sC1PcDgVoA0WGpa+bIrJ+y8zqY2oi//fUctkxtIcXJCw==", "dev": true }, "@types/convert-source-map": { @@ -1374,9 +1374,9 @@ "dev": true }, "before-after-hook": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.0.tgz", - "integrity": "sha512-jH6rKQIfroBbhEXVmI7XmXe3ix5S/PgJqpzdDPnR8JGLHWNYLsYZ6tK5iWOF/Ra3oqEX0NobXGlzbiylIzVphQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", + "integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==", "dev": true }, "binary-extensions": { @@ -5679,9 +5679,9 @@ } }, "y18n": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", - "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.6.tgz", + "integrity": "sha512-PlVX4Y0lDTN6E2V4ES2tEdyvXkeKzxa8c/vo0pxPr/TqbztddTP0yn7zZylIyiAuxerqj0Q5GhpJ1YJCP8LaZQ==", "dev": true }, "yargs": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9790c3779cf..2e2a5e69d69 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1778,8 +1778,8 @@ namespace ts { /** * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and * the `nameNotFoundMessage` argument is not `undefined`. - * - * ***NOTE**: You should not call this directly. This function is intended to be used only by `resolveName`, + * + * ***NOTE**: You should not call this directly. This function is intended to be used only by `resolveName`, * `resolveEntityName`, and `getSuggestedSymbolForNonexistentSymbol`. * * @param location The location at which to begin name resolution. @@ -2572,6 +2572,7 @@ namespace ts { * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node: Node): boolean { return node.kind === SyntaxKind.ImportEqualsDeclaration @@ -5276,9 +5277,26 @@ namespace ts { return factory.createKeywordTypeNode(SyntaxKind.AnyKeyword); } + function shouldUsePlaceholderForProperty(propertySymbol: Symbol, context: NodeBuilderContext) { + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // Since anonymous types usually come from expressions, this allows us to preserve the output + // for deep mappings which likely come from expressions, while truncating those parts which + // come from mappings over library functions. + return !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped) + && ( + contains(context.reverseMappedStack, propertySymbol as ReverseMappedSymbol) + || ( + context.reverseMappedStack?.[0] + && !(getObjectFlags(last(context.reverseMappedStack).propertyType) & ObjectFlags.Anonymous) + ) + ); + } + function addPropertyToElementList(propertySymbol: Symbol, context: NodeBuilderContext, typeElements: TypeElement[]) { const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped); - const propertyType = propertyIsReverseMapped && context.flags & NodeBuilderFlags.InReverseMappedType ? + const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getTypeOfSymbol(propertySymbol); const saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; @@ -5309,16 +5327,20 @@ namespace ts { } } else { - const savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? NodeBuilderFlags.InReverseMappedType : 0; let propertyTypeNode: TypeNode; - if (propertyIsReverseMapped && !!(savedFlags & NodeBuilderFlags.InReverseMappedType)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { + if (propertyIsReverseMapped) { + context.reverseMappedStack ||= []; + context.reverseMappedStack.push(propertySymbol as ReverseMappedSymbol); + } propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword); + if (propertyIsReverseMapped) { + context.reverseMappedStack!.pop(); + } } - context.flags = savedFlags; const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(SyntaxKind.ReadonlyKeyword)] : undefined; if (modifiers) { @@ -6139,10 +6161,14 @@ namespace ts { function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) { if (type !== errorType && context.enclosingDeclaration) { const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration); - if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation) { + const annotated = getTypeFromTypeNode(annotation); + const thisInstantiated = annotated.flags & TypeFlags.TypeParameter && (annotated as TypeParameter).isThisType ? instantiateType(annotated, signature.mapper) : annotated; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -7846,6 +7872,7 @@ namespace ts { typeParameterNamesByText?: Set; usedSymbolNames?: Set; remappedSymbolNames?: ESMap; + reverseMappedStack?: ReverseMappedSymbol[]; } function isDefaultBindingContext(location: Node) { @@ -11000,6 +11027,14 @@ namespace ts { } } + type ReplaceableIndexedAccessType = IndexedAccessType & { objectType: TypeParameter, indexType: TypeParameter }; + function replaceIndexedAccess(instantiable: Type, type: ReplaceableIndexedAccessType, replacement: Type) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol: Symbol, indexKind: IndexKind) { const declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); if (!declaration) return undefined; @@ -11020,8 +11055,21 @@ namespace ts { inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & TypeFlags.IndexedAccess + && (type.constraintType.type as IndexedAccessType).objectType.flags & TypeFlags.TypeParameter + && (type.constraintType.type as IndexedAccessType).indexType.flags & TypeFlags.TypeParameter) { + // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is + // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of + // type identities produced, we simplify such indexed access occurences + const newTypeParam = (type.constraintType.type as IndexedAccessType).objectType; + const newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type as ReplaceableIndexedAccessType, newTypeParam); + inferredProp.mappedType = newMappedType as MappedType; + inferredProp.constraintType = getIndexType(newTypeParam) as IndexType; + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); @@ -12070,6 +12118,10 @@ namespace ts { return false; } + function isOptionalPropertyDeclaration(node: Declaration) { + return isPropertyDeclaration(node) && node.questionToken; + } + function isOptionalJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag { if (!isJSDocPropertyLikeTag(node)) { return false; @@ -12984,9 +13036,17 @@ namespace ts { function getConditionalFlowTypeOfType(type: Type, node: Node) { let constraints: Type[] | undefined; + let covariant = true; while (node && !isStatement(node) && node.kind !== SyntaxKind.JSDocComment) { const parent = node.parent; - if (parent.kind === SyntaxKind.ConditionalType && node === (parent).trueType) { + // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but + // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax + if (parent.kind === SyntaxKind.Parameter) { + covariant = !covariant; + } + // Always substitute on type parameters, regardless of variance, since even + // in contravarrying positions, they may be reliant on subtuted constraints to be valid + if ((covariant || type.flags & TypeFlags.TypeParameter) && parent.kind === SyntaxKind.ConditionalType && node === (parent).trueType) { const constraint = getImpliedConstraint(type, (parent).checkType, (parent).extendsType); if (constraint) { constraints = append(constraints, constraint); @@ -13898,7 +13958,7 @@ namespace ts { const typeKey = !origin ? getTypeListId(types) : origin.flags & TypeFlags.Union ? `|${getTypeListId((origin).types)}` : origin.flags & TypeFlags.Intersection ? `&${getTypeListId((origin).types)}` : - `#${(origin).type.id}`; + `#${(origin).type.id}|${getTypeListId(types)}`; // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving const id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); let type = unionTypes.get(id); if (!type) { @@ -18409,6 +18469,11 @@ namespace ts { } } else if (target.flags & TypeFlags.TemplateLiteral) { + if (source.flags & TypeFlags.TemplateLiteral) { + // Report unreliable variance for type variables referenced in template literal type placeholders. + // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + } const result = inferTypesFromTemplateLiteralType(source, target as TemplateLiteralType); if (result && every(result, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, (target as TemplateLiteralType).types[i]))) { return Ternary.True; @@ -18453,20 +18518,6 @@ namespace ts { return result; } } - else if (source.flags & TypeFlags.TemplateLiteral) { - if (target.flags & TypeFlags.TemplateLiteral && - (source as TemplateLiteralType).texts.length === (target as TemplateLiteralType).texts.length && - (source as TemplateLiteralType).types.length === (target as TemplateLiteralType).types.length && - every((source as TemplateLiteralType).texts, (t, i) => t === (target as TemplateLiteralType).texts[i]) && - every((instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)) as TemplateLiteralType).types, (t, i) => !!((target as TemplateLiteralType).types[i].flags & (TypeFlags.Any | TypeFlags.String)) || !!isRelatedTo(t, (target as TemplateLiteralType).types[i], /*reportErrors*/ false))) { - return Ternary.True; - } - const constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; - } - } else if (source.flags & TypeFlags.StringMapping) { if (target.flags & TypeFlags.StringMapping && (source).symbol === (target).symbol) { if (result = isRelatedTo((source).type, (target).type, reportErrors)) { @@ -19694,14 +19745,12 @@ namespace ts { function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean { if (depth >= 5) { const identity = getRecursionIdentity(type); - if (identity) { - let count = 0; - for (let i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity) { - count++; - if (count >= 5) { - return true; - } + let count = 0; + for (let i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity) { + count++; + if (count >= 5) { + return true; } } } @@ -19709,15 +19758,20 @@ namespace ts { return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. - function getRecursionIdentity(type: Type): object | undefined { + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // reference the type have a recursion identity that differs from the object identity. + function getRecursionIdentity(type: Type): object { + // Object and array literals are known not to contain recursive references and don't need a recursion identity. if (type.flags & TypeFlags.Object && !isObjectOrArrayLiteralType(type)) { if (getObjectFlags(type) && ObjectFlags.Reference && (type as TypeReference).node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. - return (type as TypeReference).node; + return (type as TypeReference).node!; } if (type.symbol && !(getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol.flags & SymbolFlags.Class)) { // We track all object types that have an associated symbol (representing the origin of the type), but @@ -19729,6 +19783,9 @@ namespace ts { return type.target; } } + if (type.flags & TypeFlags.TypeParameter) { + return type.symbol; + } if (type.flags & TypeFlags.IndexedAccess) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -19740,7 +19797,7 @@ namespace ts { // The root object represents the origin of the conditional type return (type as ConditionalType).root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp: Symbol, targetProp: Symbol): boolean { @@ -20732,7 +20789,11 @@ namespace ts { } function getTypeOfReverseMappedSymbol(symbol: ReverseMappedSymbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + const links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType: Type, target: MappedType, constraint: IndexType): Type { @@ -21157,16 +21218,16 @@ namespace ts { // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. const saveExpandingFlags = expandingFlags; - const sourceIdentity = getRecursionIdentity(source) || source; - const targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source; - if (targetIdentity && contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target; + const sourceIdentity = getRecursionIdentity(source); + const targetIdentity = getRecursionIdentity(target); + if (contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source; + if (contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target; if (expandingFlags !== ExpandingFlags.Both) { - if (sourceIdentity) (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) targetStack.pop(); - if (sourceIdentity) sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = InferencePriority.Circularity; @@ -23807,7 +23868,7 @@ namespace ts { // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === SyntaxKind.Identifier) { + if (location.kind === SyntaxKind.Identifier || location.kind === SyntaxKind.PrivateIdentifier) { if (isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -24071,7 +24132,7 @@ namespace ts { } } else if (isAlias) { - declaration = symbol.declarations?.find(isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -27256,9 +27317,10 @@ namespace ts { let diagnosticMessage; const declarationName = idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration && @@ -35514,8 +35576,8 @@ namespace ts { errorAndMaybeSuggestAwait( condExpr, /*maybeMissingAwait*/ true, - Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, - "true", getTypeNameForErrorDisplay(type), "false"); + Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined, + getTypeNameForErrorDisplay(type)); return; } @@ -35548,7 +35610,7 @@ namespace ts { const isUsed = isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(location, Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead); } } @@ -36832,6 +36894,7 @@ namespace ts { switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -42219,21 +42282,6 @@ namespace ts { } } - function isSomeImportDeclaration(decl: Node): boolean { - switch (decl.kind) { - case SyntaxKind.ImportClause: // For default import - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.NamespaceImport: - case SyntaxKind.ImportSpecifier: // For rename import `x as y` - return true; - case SyntaxKind.Identifier: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === SyntaxKind.ImportSpecifier; - default: - return false; - } - } - namespace JsxNames { export const JSX = "JSX" as __String; export const IntrinsicElements = "IntrinsicElements" as __String; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 298be7bd4e6..cca580d6cde 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -875,6 +875,7 @@ namespace ts { { name: "metadataDecorator", type: "string", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Specify_the_name_of_the_metadata_decorator_function_to_use_when_emitDecoratorMetadata_is_set }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f84a598c2a5..1a1c55a759b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -15,7 +15,7 @@ "category": "Error", "code": 1006 }, - "The parser expected to find a '}' to match the '{' token here.": { + "The parser expected to find a '{1}' to match the '{0}' token here.": { "category": "Error", "code": 1007 }, @@ -3181,7 +3181,7 @@ "category": "Error", "code": 2773 }, - "This condition will always return true since the function is always defined. Did you mean to call it instead?": { + "This condition will always return true since this function appears to always be defined. Did you mean to call it instead?": { "category": "Error", "code": 2774 }, @@ -3289,7 +3289,7 @@ "category": "Error", "code": 2800 }, - "This condition will always return true since the Promise is always truthy.": { + "This condition will always return true since this '{0}' appears to always be defined.": { "category": "Error", "code": 2801 }, @@ -3321,18 +3321,22 @@ "category": "Error", "code": 2808 }, - "Namespace '{0}' from module '{1}' has no exported member '{2}'.": { + "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.": { "category": "Error", "code": 2809 }, - "'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": { + "Namespace '{0}' from module '{1}' has no exported member '{2}'.": { "category": "Error", "code": 2810 }, - "Cannot find namespace '{0}'. Did you mean '{1}?": { + "'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": { "category": "Error", "code": 2811 }, + "Cannot find namespace '{0}'. Did you mean '{1}?": { + "category": "Error", + "code": 2812 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 92d6848d8a9..cdd63c9c947 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -551,6 +551,7 @@ namespace ts { case SyntaxKind.JSDocPrivateTag: case SyntaxKind.JSDocProtectedTag: case SyntaxKind.JSDocReadonlyTag: + case SyntaxKind.JSDocDeprecatedTag: return visitNode(cbNode, (node as JSDocTag).tagName) || (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined)); case SyntaxKind.PartiallyEmittedExpression: @@ -1335,24 +1336,27 @@ namespace ts { return inContext(NodeFlags.AwaitContext); } - function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } - function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): void { + function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { // Don't report another error if it would just be at the same position as the last error. const lastError = lastOrUndefined(parseDiagnostics); + let result: DiagnosticWithDetachedLocation | undefined; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = createDetachedDiagnostic(fileName, start, length, message, arg0); + parseDiagnostics.push(result); } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result; } - function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): void { - parseErrorAtPosition(start, end - start, message, arg0); + function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void { @@ -1542,6 +1546,20 @@ namespace ts { return false; } + function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) { + if (token() === closeKind) { + nextToken(); + return; + } + const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind)); + if (lastError) { + addRelatedInfo( + lastError, + createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind)) + ); + } + } + function parseOptional(t: SyntaxKind): boolean { if (token() === t) { nextToken(); @@ -2092,8 +2110,7 @@ namespace ts { while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - const element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } @@ -5426,10 +5443,11 @@ namespace ts { function parseArrayLiteralExpression(): ArrayLiteralExpression { const pos = getNodePos(); + const openBracketPosition = scanner.getTokenPos(); parseExpected(SyntaxKind.OpenBracketToken); const multiLine = scanner.hasPrecedingLineBreak(); const elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement); - parseExpected(SyntaxKind.CloseBracketToken); + parseExpectedMatchingBrackets(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } @@ -5498,15 +5516,7 @@ namespace ts { parseExpected(SyntaxKind.OpenBraceToken); const multiLine = scanner.hasPrecedingLineBreak(); const properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(SyntaxKind.CloseBraceToken)) { - const lastError = lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === Diagnostics._0_expected.code) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here) - ); - } - } + parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } @@ -5591,16 +5601,14 @@ namespace ts { if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) { const multiLine = scanner.hasPrecedingLineBreak(); const statements = parseList(ParsingContext.BlockStatements, parseStatement); - if (!parseExpected(SyntaxKind.CloseBraceToken)) { - const lastError = lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === Diagnostics._0_expected.code) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here) - ); - } + parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition); + const result = finishNode(factory.createBlock(statements, multiLine), pos); + if (token() === SyntaxKind.EqualsToken) { + parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); } - return finishNode(factory.createBlock(statements, multiLine), pos); + + return result; } else { const statements = createMissingList(); @@ -5647,9 +5655,10 @@ namespace ts { function parseIfStatement(): IfStatement { const pos = getNodePos(); parseExpected(SyntaxKind.IfKeyword); + const openParenPosition = scanner.getTokenPos(); parseExpected(SyntaxKind.OpenParenToken); const expression = allowInAnd(parseExpression); - parseExpected(SyntaxKind.CloseParenToken); + parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition); const thenStatement = parseStatement(); const elseStatement = parseOptional(SyntaxKind.ElseKeyword) ? parseStatement() : undefined; return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); @@ -5660,9 +5669,10 @@ namespace ts { parseExpected(SyntaxKind.DoKeyword); const statement = parseStatement(); parseExpected(SyntaxKind.WhileKeyword); + const openParenPosition = scanner.getTokenPos(); parseExpected(SyntaxKind.OpenParenToken); const expression = allowInAnd(parseExpression); - parseExpected(SyntaxKind.CloseParenToken); + parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in @@ -5675,9 +5685,10 @@ namespace ts { function parseWhileStatement(): WhileStatement { const pos = getNodePos(); parseExpected(SyntaxKind.WhileKeyword); + const openParenPosition = scanner.getTokenPos(); parseExpected(SyntaxKind.OpenParenToken); const expression = allowInAnd(parseExpression); - parseExpected(SyntaxKind.CloseParenToken); + parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition); const statement = parseStatement(); return finishNode(factory.createWhileStatement(expression, statement), pos); } @@ -5749,9 +5760,10 @@ namespace ts { function parseWithStatement(): WithStatement { const pos = getNodePos(); parseExpected(SyntaxKind.WithKeyword); + const openParenPosition = scanner.getTokenPos(); parseExpected(SyntaxKind.OpenParenToken); const expression = allowInAnd(parseExpression); - parseExpected(SyntaxKind.CloseParenToken); + parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition); const statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement); return finishNode(factory.createWithStatement(expression, statement), pos); } @@ -7973,13 +7985,9 @@ namespace ts { hasChildren = true; if (child.kind === SyntaxKind.JSDocTypeTag) { if (childTypeTag) { - parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - const lastError = lastOrUndefined(parseDiagnostics); + const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here) - ); + addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here)); } break; } @@ -8011,7 +8019,7 @@ namespace ts { } const typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment); - return finishNode(typedefTag, start); + return finishNode(typedefTag, start, end); } function parseJSDocTypeNameWithNamespace(nested?: boolean) { diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index ddebecc2e55..d642f79a124 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -1717,7 +1717,11 @@ namespace ts { continue; } const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) continue; + const inputFileNames = new Set(parsed.fileNames.map(f => toPath(state, f))); for (const output of outputs) { + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5270ba0b93a..2f2e6281c81 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4353,7 +4353,6 @@ namespace ts { InObjectTypeLiteral = 1 << 22, InTypeAlias = 1 << 23, // Writing type in type alias declaration InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression - InReverseMappedType = 1 << 25, } // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment diff --git a/src/harness/client.ts b/src/harness/client.ts index f85e0e11131..537ee3f36a0 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -306,7 +306,8 @@ namespace ts.server { fileName: entry.file, textSpan: this.decodeSpan(entry), kind: ScriptElementKind.unknown, - name: "" + name: "", + unverified: entry.unverified, })), textSpan: this.decodeSpan(body.textSpan, request.arguments.file) }; diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 0d24ee4797f..badab5c6cbc 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -135,8 +135,6 @@ namespace compiler { } } } - - this.diagnostics = diagnostics; } public get vfs(): vfs.FileSystem { diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index a39e4525fd6..42917467727 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -685,10 +685,10 @@ namespace FourSlash { } public verifyGoToDefinitionIs(endMarker: ArrayOrSingle) { - this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition()); + this.verifyGoToXWorker(/*startMarker*/ undefined, toArray(endMarker), () => this.getGoToDefinition()); } - public verifyGoToDefinition(arg0: any, endMarkerNames?: ArrayOrSingle | { file: string }) { + public verifyGoToDefinition(arg0: any, endMarkerNames?: ArrayOrSingle | { file: string, unverified?: boolean }) { this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan()); } @@ -705,7 +705,7 @@ namespace FourSlash { this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)); } - private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle | { file: string } | undefined, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { + private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle | { file: string, unverified?: boolean } | undefined, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { if (endMarkerNames) { this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } @@ -725,7 +725,7 @@ namespace FourSlash { } } - private verifyGoToXPlain(startMarkerNames: ArrayOrSingle, endMarkerNames: ArrayOrSingle | { file: string }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { + private verifyGoToXPlain(startMarkerNames: ArrayOrSingle, endMarkerNames: ArrayOrSingle | { file: string, unverified?: boolean }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { for (const start of toArray(startMarkerNames)) { this.verifyGoToXSingle(start, endMarkerNames, getDefs); } @@ -737,12 +737,12 @@ namespace FourSlash { } } - private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle | { file: string }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle | { file: string, unverified?: boolean }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToXWorker(toArray(endMarkerNames), getDefs, startMarkerName); + this.verifyGoToXWorker(startMarkerName, toArray(endMarkerNames), getDefs, startMarkerName); } - private verifyGoToXWorker(endMarkers: readonly (string | { file: string })[], getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) { + private verifyGoToXWorker(startMarker: string | undefined, endMarkers: readonly (string | { marker?: string, file?: string, unverified?: boolean })[], getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) { const defs = getDefs(); let definitions: readonly ts.DefinitionInfo[]; let testName: string; @@ -763,8 +763,11 @@ namespace FourSlash { } ts.zipWith(endMarkers, definitions, (endMarkerOrFileResult, definition, i) => { - const expectedFileName = typeof endMarkerOrFileResult === "string" ? this.getMarkerByName(endMarkerOrFileResult).fileName : endMarkerOrFileResult.file; - const expectedPosition = typeof endMarkerOrFileResult === "string" ? this.getMarkerByName(endMarkerOrFileResult).position : 0; + const markerName = typeof endMarkerOrFileResult === "string" ? endMarkerOrFileResult : endMarkerOrFileResult.marker; + const marker = markerName !== undefined ? this.getMarkerByName(markerName) : undefined; + const expectedFileName = marker?.fileName || typeof endMarkerOrFileResult !== "string" && endMarkerOrFileResult.file; + ts.Debug.assert(typeof expectedFileName === "string"); + const expectedPosition = marker?.position || 0; if (ts.comparePaths(expectedFileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || expectedPosition !== definition.textSpan.start) { const filesToDisplay = ts.deduplicate([expectedFileName, definition.fileName], ts.equateValues); const markers = [{ text: "EXPECTED", fileName: expectedFileName, position: expectedPosition }, { text: "ACTUAL", fileName: definition.fileName, position: definition.textSpan.start }]; @@ -777,7 +780,15 @@ namespace FourSlash { return `// @Filename: ${fileName}\n${fileContent}`; }).join("\n\n"); - this.raiseError(`${testName} failed for definition ${endMarkerOrFileResult} (${i}): expected ${expectedFileName} at ${expectedPosition}, got ${definition.fileName} at ${definition.textSpan.start}\n\n${text}\n`); + this.raiseError(`${testName} failed for definition ${markerName || expectedFileName} (${i}): expected ${expectedFileName} at ${expectedPosition}, got ${definition.fileName} at ${definition.textSpan.start}\n\n${text}\n`); + } + if (definition.unverified && (typeof endMarkerOrFileResult === "string" || !endMarkerOrFileResult.unverified)) { + const isFileResult = typeof endMarkerOrFileResult !== "string" && !!endMarkerOrFileResult.file; + this.raiseError( + `${testName} failed for definition ${markerName || expectedFileName} (${i}): The actual definition was an \`unverified\` result. Use:\n\n` + + ` verify.goToDefinition(${startMarker === undefined ? "startMarker" : `"${startMarker}"`}, { ${isFileResult ? `file: "${expectedFileName}"` : `marker: "${markerName}"`}, unverified: true })\n\n` + + `if this is expected.` + ); } }); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index ffcde781d85..4608601f75a 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1013,7 +1013,7 @@ namespace ts.server.protocol { * Definition response message. Gives text range for definition. */ export interface DefinitionResponse extends Response { - body?: FileSpanWithContext[]; + body?: DefinitionInfo[]; } export interface DefinitionInfoAndBoundSpanResponse extends Response { diff --git a/src/server/session.ts b/src/server/session.ts index e1f92187b3d..c31002b94a6 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1224,6 +1224,7 @@ namespace ts.server { containerName: info.containerName, kind: info.kind, name: info.name, + ...info.unverified && { unverified: info.unverified }, }; }); } @@ -1300,8 +1301,8 @@ namespace ts.server { })); } - private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] { - return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project)); + private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.DefinitionInfo[] { + return definitions.map(def => ({ ...this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project), ...def.unverified && { unverified: def.unverified } })); } /* diff --git a/src/services/codefixes/addMissingAwait.ts b/src/services/codefixes/addMissingAwait.ts index 1b16a33deb3..a31bf50f46e 100644 --- a/src/services/codefixes/addMissingAwait.ts +++ b/src/services/codefixes/addMissingAwait.ts @@ -14,6 +14,7 @@ namespace ts.codefix { Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code, Diagnostics.Type_0_is_not_an_array_type.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 22c1ddc6758..603b64eeb99 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -65,6 +65,10 @@ namespace ts.codefix { const isInJavascript = isInJSFile(functionToConvert); const setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); const functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); + if (!returnsPromise(functionToConvertRenamed, checker)) { + return; + } + const returnStatements = functionToConvertRenamed.body && isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : emptyArray; const transformer: Transformer = { checker, synthNamesMap, setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index 963f8923ee6..e15c507a4ef 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -436,7 +436,9 @@ namespace ts.codefix { /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name: Identifier, moduleSpecifier: StringLiteralLike, checker: TypeChecker, identifiers: Identifiers, quotePreference: QuotePreference): ConvertedImports { const nameSymbol = checker.getSymbolAtLocation(name); @@ -454,15 +456,23 @@ namespace ts.codefix { const { parent } = use; if (isPropertyAccessExpression(parent)) { - const { expression, name: { text: propertyName } } = parent; - Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - let idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); - } + const { name: { text: propertyName } } = parent; + if (propertyName === "default") { + needDefaultImport = true; - (useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(idName)); + const importDefaultName = use.getText(); + (useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(importDefaultName)); + } + else { + Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + let idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + + (useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(idName)); + } } else { needDefaultImport = true; diff --git a/src/services/codefixes/fixMissingCallParentheses.ts b/src/services/codefixes/fixMissingCallParentheses.ts index a144bc40f50..042f7b506c7 100644 --- a/src/services/codefixes/fixMissingCallParentheses.ts +++ b/src/services/codefixes/fixMissingCallParentheses.ts @@ -2,7 +2,7 @@ namespace ts.codefix { const fixId = "fixMissingCallParentheses"; const errorCodes = [ - Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code, ]; registerCodeFix({ diff --git a/src/services/completions.ts b/src/services/completions.ts index 3e5d3a8c2a7..6dd3e51640a 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1659,8 +1659,9 @@ namespace ts.Completions { function isContextTokenValueLocation(contextToken: Node) { return contextToken && - contextToken.kind === SyntaxKind.TypeOfKeyword && - (contextToken.parent.kind === SyntaxKind.TypeQuery || isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === SyntaxKind.TypeOfKeyword && + (contextToken.parent.kind === SyntaxKind.TypeQuery || isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === SyntaxKind.AssertsKeyword && contextToken.parent.kind === SyntaxKind.TypePredicate)); } function isContextTokenTypeLocation(contextToken: Node): boolean { diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 19fd476d87d..77e64bf618b 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -83,12 +83,26 @@ namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; - + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures /*@internal*/ - getLanguageServiceRefCounts(path: Path): [string, number | undefined][]; + getLanguageServiceRefCounts(path: Path, scriptKind: ScriptKind): [string, number | undefined][]; reportStats(): string; } @@ -110,6 +124,11 @@ namespace ts { languageServiceRefCount: number; } + type BucketEntry = DocumentRegistryEntry | ESMap; + function isDocumentRegistryEntry(entry: BucketEntry): entry is DocumentRegistryEntry { + return !!(entry as DocumentRegistryEntry).sourceFile; + } + export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -118,18 +137,24 @@ namespace ts { export function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boolean, currentDirectory = "", externalCache?: ExternalDocumentCache): DocumentRegistry { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. - const buckets = new Map>(); + const buckets = new Map>(); const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function reportStats() { const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => { const entries = buckets.get(name)!; - const sourceFiles: { name: string; refCount: number; }[] = []; + const sourceFiles: { name: string; scriptKind: ScriptKind, refCount: number; }[] = []; entries.forEach((entry, name) => { - sourceFiles.push({ - name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach((value, scriptKind) => sourceFiles.push({ name, scriptKind, refCount: value.languageServiceRefCount })); + } }); sourceFiles.sort((x, y) => y.refCount - x.refCount); return { @@ -160,6 +185,12 @@ namespace ts { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + function getDocumentRegistryEntry(bucketEntry: BucketEntry, scriptKind: ScriptKind | undefined) { + const entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); + Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, `Script kind should match provided ScriptKind:${scriptKind} and sourceFile.scriptKind: ${entry?.sourceFile.scriptKind}, !entry: ${!entry}`); + return entry; + } + function acquireOrUpdateDocument( fileName: string, path: Path, @@ -169,10 +200,11 @@ namespace ts { version: string, acquiring: boolean, scriptKind?: ScriptKind): SourceFile { - - const bucket = getOrUpdate(buckets, key, () => new Map()); - let entry = bucket.get(path); + scriptKind = ensureScriptKind(fileName, scriptKind); const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5; + const bucket = getOrUpdate(buckets, key, () => new Map()); + const bucketEntry = bucket.get(path); + let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { const sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -181,7 +213,7 @@ namespace ts { sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } @@ -195,7 +227,7 @@ namespace ts { sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -221,28 +253,53 @@ namespace ts { Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry!); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + const scriptKindMap = new Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind!, entry!); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind!, entry!); + } + } } - function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void { + function releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void { const path = toPath(fileName, currentDirectory, getCanonicalFileName); const key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void { + function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void { const bucket = Debug.checkDefined(buckets.get(key)); - const entry = bucket.get(path)!; + const bucketEntry = bucket.get(path)!; + const entry = getDocumentRegistryEntry(bucketEntry, scriptKind)!; entry.languageServiceRefCount--; Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind!); + if (bucketEntry.size === 1) { + bucket.set(path, firstDefinedIterator(bucketEntry.values(), identity)!); + } + } } } - function getLanguageServiceRefCounts(path: Path) { + function getLanguageServiceRefCounts(path: Path, scriptKind: ScriptKind) { return arrayFrom(buckets.entries(), ([key, bucket]): [string, number | undefined] => { - const entry = bucket.get(path); + const bucketEntry = bucket.get(path); + const entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 7c0ecda42fb..4f334b1cacd 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1180,7 +1180,9 @@ namespace ts.FindAllReferences { for (const indirectUser of indirectUsers) { for (const node of getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName)) { // Import specifiers should be handled by importSearches - if (isIdentifier(node) && !isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + const symbol = checker.getSymbolAtLocation(node); + const hasExportAssignmentDeclaration = some(symbol?.declarations, d => tryCast(d, isExportAssignment) ? true : false); + if (isIdentifier(node) && !isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index b77b8ed0a4c..76006e0d53f 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -146,7 +146,7 @@ namespace ts.GoToDefinition { end: node.getEnd(), fileName: node.text }, - unverified: !!verifiedFileName, + unverified: !verifiedFileName, }; } } diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 35694333b51..e5eba32d7cd 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -44,6 +44,7 @@ namespace ts.JsDoc { "kind", "lends", "license", + "link", "listens", "member", "memberof", diff --git a/src/services/refactors/convertExport.ts b/src/services/refactors/convertExport.ts index 43096a4d081..799df2f176a 100644 --- a/src/services/refactors/convertExport.ts +++ b/src/services/refactors/convertExport.ts @@ -48,7 +48,7 @@ namespace ts.refactor { }); // If a VariableStatement, will have exactly one VariableDeclaration, with an Identifier for a name. - type ExportToConvert = FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | EnumDeclaration | NamespaceDeclaration | TypeAliasDeclaration | VariableStatement; + type ExportToConvert = FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | EnumDeclaration | NamespaceDeclaration | TypeAliasDeclaration | VariableStatement | ExportAssignment; interface ExportInfo { readonly exportNode: ExportToConvert; readonly exportName: Identifier; // This is exportNode.name except for VariableStatement_s. @@ -67,7 +67,8 @@ namespace ts.refactor { const exportingModuleSymbol = isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - const flags = getSyntacticModifierFlags(exportNode); + const flags = getSyntacticModifierFlags(exportNode) || ((isExportAssignment(exportNode) && !exportNode.isExportEquals) ? ModifierFlags.ExportDefault : ModifierFlags.None); + const wasDefault = !!(flags & ModifierFlags.Default); // If source file already has a default export, don't offer refactor. if (!(flags & ModifierFlags.Export) || !wasDefault && exportingModuleSymbol.exports!.has(InternalSymbolName.Default)) { @@ -95,6 +96,11 @@ namespace ts.refactor { Debug.assert(!wasDefault, "Can't have a default flag here"); return isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault, exportingModuleSymbol } : undefined; } + case SyntaxKind.ExportAssignment: { + const node = exportNode as ExportAssignment; + const exp = node.expression as Identifier; + return node.isExportEquals ? undefined : { exportNode: node, exportName: exp, wasDefault, exportingModuleSymbol }; + } default: return undefined; } @@ -107,7 +113,14 @@ namespace ts.refactor { function changeExport(exportingSourceFile: SourceFile, { wasDefault, exportNode, exportName }: ExportInfo, changes: textChanges.ChangeTracker, checker: TypeChecker): void { if (wasDefault) { - changes.delete(exportingSourceFile, Debug.checkDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword), "Should find a default keyword in modifier list")); + if (isExportAssignment(exportNode) && !exportNode.isExportEquals) { + const exp = exportNode.expression as Identifier; + const spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([spec]))); + } + else { + changes.delete(exportingSourceFile, Debug.checkDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword), "Should find a default keyword in modifier list")); + } } else { const exportKeyword = Debug.checkDefined(findModifier(exportNode, SyntaxKind.ExportKeyword), "Should find an export keyword in modifier list"); @@ -134,7 +147,7 @@ namespace ts.refactor { changes.insertNodeAfter(exportingSourceFile, exportNode, factory.createExportDefault(factory.createIdentifier(exportName.text))); break; default: - Debug.assertNever(exportNode, `Unexpected exportNode kind ${(exportNode as ExportToConvert).kind}`); + Debug.fail(`Unexpected exportNode kind ${(exportNode as ExportToConvert).kind}`); } } } diff --git a/src/services/services.ts b/src/services/services.ts index 5c5ce10cfbb..bd5ba0421c2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1444,7 +1444,7 @@ namespace ts { // not part of the new program. function onReleaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions) { const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined { @@ -1493,9 +1493,13 @@ namespace ts { // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + else { + // Release old source file and fall through to aquire new file with new script kind + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + } } // We didn't already have the file. Fall through and acquire it from the registry. @@ -1531,7 +1535,7 @@ namespace ts { // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host const key = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); forEach(program.getSourceFiles(), f => - documentRegistry.releaseDocumentWithKey(f.resolvedPath, key)); + documentRegistry.releaseDocumentWithKey(f.resolvedPath, key, f.scriptKind)); program = undefined!; // TODO: GH#18217 } host = undefined!; diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index a002f8533e2..e5c439c1740 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -118,10 +118,9 @@ namespace ts { returnsPromise(node, checker); } - function returnsPromise(node: FunctionLikeDeclaration, checker: TypeChecker): boolean { - const functionType = checker.getTypeAtLocation(node); - const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call); - const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + export function returnsPromise(node: FunctionLikeDeclaration, checker: TypeChecker): boolean { + const signature = checker.getSignatureFromDeclaration(node); + const returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index d4662783d87..f398afc46c0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2516,8 +2516,10 @@ namespace ts { } /* @internal */ - export function needsParentheses(expression: Expression) { - return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression); + export function needsParentheses(expression: Expression): boolean { + return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken + || isObjectLiteralExpression(expression) + || isAsExpression(expression) && isObjectLiteralExpression(expression.expression); } export function getContextualTypeFromParent(node: Expression, checker: TypeChecker): Type | undefined { diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 34c55d0d5da..bf372efb81c 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -113,6 +113,7 @@ "unittests/services/textChanges.ts", "unittests/services/transpile.ts", "unittests/tsbuild/amdModulesWithOut.ts", + "unittests/tsbuild/clean.ts", "unittests/tsbuild/configFileErrors.ts", "unittests/tsbuild/configFileExtends.ts", "unittests/tsbuild/containerOnlyReferenced.ts", diff --git a/src/testRunner/unittests/services/convertToAsyncFunction.ts b/src/testRunner/unittests/services/convertToAsyncFunction.ts index 0a36a9ebfcf..b3746687866 100644 --- a/src/testRunner/unittests/services/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/services/convertToAsyncFunction.ts @@ -1680,6 +1680,24 @@ import { fn } from "./module"; function [#|f|]() { return Promise.resolve(0).then(fn); } +`); + + _testConvertToAsyncFunctionFailed("convertToAsyncFunction__NoSuggestionInFunctionsWithNonFixableReturnStatements1", ` +function f(x: number): Promise; +function f(): void; +function [#|f|](x?: number): Promise | void { + if (!x) return; + return fetch('').then(() => {}); +} +`); + + _testConvertToAsyncFunctionFailed("convertToAsyncFunction__NoSuggestionInFunctionsWithNonFixableReturnStatements2", ` +function f(x: number): Promise; +function f(): number; +function [#|f|](x?: number): Promise | number { + if (x) return x; + return fetch('').then(() => {}); +} `); }); diff --git a/src/testRunner/unittests/tsbuild/clean.ts b/src/testRunner/unittests/tsbuild/clean.ts new file mode 100644 index 00000000000..90bb2985290 --- /dev/null +++ b/src/testRunner/unittests/tsbuild/clean.ts @@ -0,0 +1,16 @@ +namespace ts { + describe("unittests:: tsbuild - clean", () => { + verifyTsc({ + scenario: "clean", + subScenario: `file name and output name clashing`, + commandLineArgs: ["--b", "/src/tsconfig.json", "-clean"], + fs: () => loadProjectFromFiles({ + "/src/index.js": "", + "/src/bar.ts": "", + "/src/tsconfig.json": JSON.stringify({ + compilerOptions: { allowJs: true }, + }), + }), + }); + }); +} \ No newline at end of file diff --git a/src/testRunner/unittests/tsserver/documentRegistry.ts b/src/testRunner/unittests/tsserver/documentRegistry.ts index 94098ab1bd9..8c29af51a27 100644 --- a/src/testRunner/unittests/tsserver/documentRegistry.ts +++ b/src/testRunner/unittests/tsserver/documentRegistry.ts @@ -27,7 +27,7 @@ namespace ts.projectSystem { assert.isDefined(moduleInfo); assert.equal(moduleInfo.isOrphan(), moduleIsOrphan); const key = service.documentRegistry.getKeyForCompilationSettings(project.getCompilationSettings()); - assert.deepEqual(service.documentRegistry.getLanguageServiceRefCounts(moduleInfo.path), [[key, moduleIsOrphan ? undefined : 1]]); + assert.deepEqual(service.documentRegistry.getLanguageServiceRefCounts(moduleInfo.path, moduleInfo.scriptKind), [[key, moduleIsOrphan ? undefined : 1]]); } function createServiceAndHost() { diff --git a/src/testRunner/unittests/tsserver/dynamicFiles.ts b/src/testRunner/unittests/tsserver/dynamicFiles.ts index 95976bffa1f..554c4c8c674 100644 --- a/src/testRunner/unittests/tsserver/dynamicFiles.ts +++ b/src/testRunner/unittests/tsserver/dynamicFiles.ts @@ -121,6 +121,28 @@ var x = 10;` service.openClientFile(file.path); checkNumberOfProjects(service, { configuredProjects: 1 }); }); + + it("when changing scriptKind of the untitled files", () => { + const host = createServerHost([libFile], { useCaseSensitiveFileNames: true }); + const service = createProjectService(host, { useInferredProjectPerProjectRoot: true }); + service.openClientFile(untitledFile, "const x = 10;", ScriptKind.TS, tscWatch.projectRoot); + checkNumberOfProjects(service, { inferredProjects: 1 }); + checkProjectActualFiles(service.inferredProjects[0], [untitledFile, libFile.path]); + const program = service.inferredProjects[0].getCurrentProgram()!; + const sourceFile = program.getSourceFile(untitledFile)!; + + // Close untitled file + service.closeClientFile(untitledFile); + + // Open untitled file with different mode + service.openClientFile(untitledFile, "const x = 10;", ScriptKind.TSX, tscWatch.projectRoot); + checkNumberOfProjects(service, { inferredProjects: 1 }); + checkProjectActualFiles(service.inferredProjects[0], [untitledFile, libFile.path]); + const newProgram = service.inferredProjects[0].getCurrentProgram()!; + const newSourceFile = newProgram.getSourceFile(untitledFile)!; + assert.notStrictEqual(newProgram, program); + assert.notStrictEqual(newSourceFile, sourceFile); + }); }); describe("unittests:: tsserver:: dynamicFiles:: ", () => { diff --git a/src/testRunner/unittests/tsserver/partialSemanticServer.ts b/src/testRunner/unittests/tsserver/partialSemanticServer.ts index edede23aee3..755570abc31 100644 --- a/src/testRunner/unittests/tsserver/partialSemanticServer.ts +++ b/src/testRunner/unittests/tsserver/partialSemanticServer.ts @@ -218,7 +218,7 @@ function fooB() { }` assert.deepEqual(response.definitions, [{ file: file2.path, start: { line: 1, offset: 1 }, - end: { line: 1, offset: 1 } + end: { line: 1, offset: 1 }, }]); }); }); diff --git a/src/testRunner/unittests/tsserver/projectReferencesSourcemap.ts b/src/testRunner/unittests/tsserver/projectReferencesSourcemap.ts index 21c72eec41b..d50f879a60d 100644 --- a/src/testRunner/unittests/tsserver/projectReferencesSourcemap.ts +++ b/src/testRunner/unittests/tsserver/projectReferencesSourcemap.ts @@ -4436,4 +4436,4 @@ ${dependencyTs.content}`); }); }); }); -} \ No newline at end of file +} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index dc36f959d75..149a813280d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2299,8 +2299,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -6528,8 +6527,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { @@ -7400,7 +7414,7 @@ declare namespace ts.server.protocol { * Definition response message. Gives text range for definition. */ interface DefinitionResponse extends Response { - body?: FileSpanWithContext[]; + body?: DefinitionInfo[]; } interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c8ff8de3788..315687c6853 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2299,8 +2299,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -6528,8 +6527,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { diff --git a/tests/baselines/reference/assignmentLHSIsValue.errors.txt b/tests/baselines/reference/assignmentLHSIsValue.errors.txt index 1cf07b81622..71809b4605f 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/assignmentLHSIsValue.errors.txt @@ -13,14 +13,15 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected. +tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,19): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,27): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS1128: Declaration or statement expected. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS1005: ';' expected. +tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,13): error TS1005: ';' expected. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,2): error TS2631: Cannot assign to 'M' because it is a namespace. @@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ==== // expected error for all the LHS of assignments var value: any; @@ -105,7 +106,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7 // object literals { a: 0} = value; ~ -!!! error TS1128: Declaration or statement expected. +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. // array literals ['', ''] = value; @@ -132,9 +133,11 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7 // function expression function bar() { } = value; ~ -!!! error TS1128: Declaration or statement expected. +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. () => { } = value; ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + ~~~~~ !!! error TS1005: ';' expected. // function calls diff --git a/tests/baselines/reference/assignmentLHSIsValue.types b/tests/baselines/reference/assignmentLHSIsValue.types index 82dd7f026ad..ad4905acc94 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.types +++ b/tests/baselines/reference/assignmentLHSIsValue.types @@ -146,7 +146,7 @@ function bar() { } = value; >value : any () => { } = value; ->() => { } : () => void +>() => { } = : () => void >value : any // function calls diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index ed28d06d4fa..050600b6b9b 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/bluebirdStaticThis.ts(5,22): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise' but required in type 'Thenable'. -tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. -tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. +tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. ==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== @@ -35,7 +35,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Prom static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ -!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. +!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; static cast(dit: typeof Promise, value: R): Promise; @@ -72,16 +72,16 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Prom static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; ~~~~~~~~~~ -!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; ~~~~~~~~~~ -!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. +!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; static any(dit: typeof Promise, values: Promise.Thenable): Promise; diff --git a/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.js b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.js new file mode 100644 index 00000000000..b3e236ff9cd --- /dev/null +++ b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.js @@ -0,0 +1,53 @@ +//// [callOfConditionalTypeWithConcreteBranches.ts] +type Q = number extends T ? (n: number) => void : never; +function fn(arg: Q) { + // Expected: OK + // Actual: Cannot convert 10 to number & T + arg(10); +} +// Legal invocations are not problematic +fn(m => m.toFixed()); +fn(m => m.toFixed()); + +// Ensure the following real-world example that relies on substitution still works +type ExtractParameters = "parameters" extends keyof T + // The above allows "parameters" to index `T` since all later + // instances are actually implicitly `"parameters" & keyof T` + ? { + [K in keyof T["parameters"]]: T["parameters"][K]; + }[keyof T["parameters"]] + : {}; + +// Original example, but with inverted variance +type Q2 = number extends T ? (cb: (n: number) => void) => void : never; +function fn2(arg: Q2) { + function useT(_arg: T): void {} + // Expected: OK + arg(arg => useT(arg)); +} +// Legal invocations are not problematic +fn2(m => m(42)); +fn2(m => m(42)); + +// webidl-conversions example where substituion must occur, despite contravariance of the position +// due to the invariant usage in `Parameters` + +type X = V extends (...args: any[]) => any ? (...args: Parameters) => void : Function; + +//// [callOfConditionalTypeWithConcreteBranches.js] +function fn(arg) { + // Expected: OK + // Actual: Cannot convert 10 to number & T + arg(10); +} +// Legal invocations are not problematic +fn(function (m) { return m.toFixed(); }); +fn(function (m) { return m.toFixed(); }); +function fn2(arg) { + function useT(_arg) { } + // Expected: OK + arg(function (arg) { return useT(arg); }); +} +// Legal invocations are not problematic +fn2(function (m) { return m(42); }); +fn2(function (m) { return m(42); }); diff --git a/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.symbols b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.symbols new file mode 100644 index 00000000000..dbed1d31aa9 --- /dev/null +++ b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.symbols @@ -0,0 +1,105 @@ +=== tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts === +type Q = number extends T ? (n: number) => void : never; +>Q : Symbol(Q, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 0)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 7)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 7)) +>n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 32)) + +function fn(arg: Q) { +>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 12)) +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 15)) +>Q : Symbol(Q, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 0)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 12)) + + // Expected: OK + // Actual: Cannot convert 10 to number & T + arg(10); +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 15)) +} +// Legal invocations are not problematic +fn(m => m.toFixed()); +>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 7, 20)) +>m.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 7, 20)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +fn(m => m.toFixed()); +>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 11)) +>m.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 11)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) + +// Ensure the following real-world example that relies on substitution still works +type ExtractParameters = "parameters" extends keyof T +>ExtractParameters : Symbol(ExtractParameters, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 29)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23)) + + // The above allows "parameters" to index `T` since all later + // instances are actually implicitly `"parameters" & keyof T` + ? { + [K in keyof T["parameters"]]: T["parameters"][K]; +>K : Symbol(K, Decl(callOfConditionalTypeWithConcreteBranches.ts, 15, 9)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23)) +>K : Symbol(K, Decl(callOfConditionalTypeWithConcreteBranches.ts, 15, 9)) + + }[keyof T["parameters"]] +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23)) + + : {}; + +// Original example, but with inverted variance +type Q2 = number extends T ? (cb: (n: number) => void) => void : never; +>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 8)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 8)) +>cb : Symbol(cb, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 33)) +>n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 38)) + +function fn2(arg: Q2) { +>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13)) +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 16)) +>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13)) + + function useT(_arg: T): void {} +>useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 29)) +>_arg : Symbol(_arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 22, 16)) +>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13)) + + // Expected: OK + arg(arg => useT(arg)); +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 16)) +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24, 6)) +>useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 29)) +>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24, 6)) +} +// Legal invocations are not problematic +fn2(m => m(42)); +>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 21)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 21)) + +fn2(m => m(42)); +>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12)) +>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12)) + +// webidl-conversions example where substituion must occur, despite contravariance of the position +// due to the invariant usage in `Parameters` + +type X = V extends (...args: any[]) => any ? (...args: Parameters) => void : Function; +>X : Symbol(X, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 24)) +>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7)) +>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7)) +>args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 23)) +>args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 49)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.types b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.types new file mode 100644 index 00000000000..2bee57b8fe7 --- /dev/null +++ b/tests/baselines/reference/callOfConditionalTypeWithConcreteBranches.types @@ -0,0 +1,99 @@ +=== tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts === +type Q = number extends T ? (n: number) => void : never; +>Q : Q +>n : number + +function fn(arg: Q) { +>fn : (arg: Q) => void +>arg : Q + + // Expected: OK + // Actual: Cannot convert 10 to number & T + arg(10); +>arg(10) : void +>arg : Q +>10 : 10 +} +// Legal invocations are not problematic +fn(m => m.toFixed()); +>fn(m => m.toFixed()) : void +>fn : (arg: Q) => void +>m => m.toFixed() : (m: number) => string +>m : number +>m.toFixed() : string +>m.toFixed : (fractionDigits?: number) => string +>m : number +>toFixed : (fractionDigits?: number) => string + +fn(m => m.toFixed()); +>fn(m => m.toFixed()) : void +>fn : (arg: Q) => void +>m => m.toFixed() : (m: number) => string +>m : number +>m.toFixed() : string +>m.toFixed : (fractionDigits?: number) => string +>m : number +>toFixed : (fractionDigits?: number) => string + +// Ensure the following real-world example that relies on substitution still works +type ExtractParameters = "parameters" extends keyof T +>ExtractParameters : ExtractParameters + + // The above allows "parameters" to index `T` since all later + // instances are actually implicitly `"parameters" & keyof T` + ? { + [K in keyof T["parameters"]]: T["parameters"][K]; + }[keyof T["parameters"]] + : {}; + +// Original example, but with inverted variance +type Q2 = number extends T ? (cb: (n: number) => void) => void : never; +>Q2 : Q2 +>cb : (n: number) => void +>n : number + +function fn2(arg: Q2) { +>fn2 : (arg: Q2) => void +>arg : Q2 + + function useT(_arg: T): void {} +>useT : (_arg: T) => void +>_arg : T + + // Expected: OK + arg(arg => useT(arg)); +>arg(arg => useT(arg)) : void +>arg : Q2 +>arg => useT(arg) : (arg: T & number) => void +>arg : T & number +>useT(arg) : void +>useT : (_arg: T) => void +>arg : T & number +} +// Legal invocations are not problematic +fn2(m => m(42)); +>fn2(m => m(42)) : void +>fn2 : (arg: Q2) => void +>m => m(42) : (m: (n: number) => void) => void +>m : (n: number) => void +>m(42) : void +>m : (n: number) => void +>42 : 42 + +fn2(m => m(42)); +>fn2(m => m(42)) : void +>fn2 : (arg: Q2) => void +>m => m(42) : (m: (n: number) => void) => void +>m : (n: number) => void +>m(42) : void +>m : (n: number) => void +>42 : 42 + +// webidl-conversions example where substituion must occur, despite contravariance of the position +// due to the invariant usage in `Parameters` + +type X = V extends (...args: any[]) => any ? (...args: Parameters) => void : Function; +>X : X +>args : any[] +>args : Parameters + diff --git a/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.errors.txt b/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.errors.txt deleted file mode 100644 index 087b283af4f..00000000000 --- a/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.errors.txt +++ /dev/null @@ -1,196 +0,0 @@ -tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts(63,84): error TS2344: Type 'GetProps' does not satisfy the constraint 'Shared>'. - Type 'unknown' is not assignable to type 'Shared>'. - Type 'Matching>' is not assignable to type 'Shared>'. - Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - - -==== tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts (1 errors) ==== - declare class Component

{ - constructor(props: Readonly

); - constructor(props: P, context?: any); - readonly props: Readonly

& Readonly<{ children?: {} }>; - } - interface ComponentClass

{ - new (props: P, context?: any): Component

; - propTypes?: WeakValidationMap

; - defaultProps?: Partial

; - displayName?: string; - } - interface FunctionComponent

{ - (props: P & { children?: {} }, context?: any): {} | null; - propTypes?: WeakValidationMap

; - defaultProps?: Partial

; - displayName?: string; - } - - export declare const nominalTypeHack: unique symbol; - export interface Validator { - (props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null; - [nominalTypeHack]?: T; - } - type WeakValidationMap = { - [K in keyof T]?: null extends T[K] - ? Validator - : undefined extends T[K] - ? Validator - : Validator - }; - type ComponentType

= ComponentClass

| FunctionComponent

; - - export type Shared< - InjectedProps, - DecorationTargetProps extends Shared - > = { - [P in Extract]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; - }; - - // Infers prop type from component C - export type GetProps = C extends ComponentType ? P : never; - - export type ConnectedComponentClass< - C extends ComponentType, - P - > = ComponentClass

& { - WrappedComponent: C; - }; - - export type Matching = { - [P in keyof DecorationTargetProps]: P extends keyof InjectedProps - ? InjectedProps[P] extends DecorationTargetProps[P] - ? DecorationTargetProps[P] - : InjectedProps[P] - : DecorationTargetProps[P]; - }; - - export type Omit = Pick>; - - export type InferableComponentEnhancerWithProps = - >>>( - component: C - ) => ConnectedComponentClass, keyof Shared>> & TNeedsProps>; - ~~~~~~~~~~~ -!!! error TS2344: Type 'GetProps' does not satisfy the constraint 'Shared>'. -!!! error TS2344: Type 'unknown' is not assignable to type 'Shared>'. -!!! error TS2344: Type 'Matching>' is not assignable to type 'Shared>'. -!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - \ No newline at end of file diff --git a/tests/baselines/reference/classUsedBeforeInitializedVariables.errors.txt b/tests/baselines/reference/classUsedBeforeInitializedVariables.errors.txt index 685c854039e..3c183ae3c21 100644 --- a/tests/baselines/reference/classUsedBeforeInitializedVariables.errors.txt +++ b/tests/baselines/reference/classUsedBeforeInitializedVariables.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(4,15): error TS2729: Property 'p4' is used before its initialization. -tests/cases/compiler/classUsedBeforeInitializedVariables.ts(7,34): error TS2729: Property 'directlyAssigned' is used before its initialization. -tests/cases/compiler/classUsedBeforeInitializedVariables.ts(16,15): error TS2729: Property 'withinObjectLiteral' is used before its initialization. -tests/cases/compiler/classUsedBeforeInitializedVariables.ts(20,19): error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization. -tests/cases/compiler/classUsedBeforeInitializedVariables.ts(26,19): error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization. -tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization. +tests/cases/compiler/classUsedBeforeInitializedVariables.ts(13,34): error TS2729: Property 'directlyAssigned' is used before its initialization. +tests/cases/compiler/classUsedBeforeInitializedVariables.ts(22,15): error TS2729: Property 'withinObjectLiteral' is used before its initialization. +tests/cases/compiler/classUsedBeforeInitializedVariables.ts(26,19): error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization. +tests/cases/compiler/classUsedBeforeInitializedVariables.ts(32,19): error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization. +tests/cases/compiler/classUsedBeforeInitializedVariables.ts(35,64): error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization. ==== tests/cases/compiler/classUsedBeforeInitializedVariables.ts (6 errors) ==== @@ -15,11 +15,17 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729 !!! error TS2729: Property 'p4' is used before its initialization. !!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:5:5: 'p4' is declared here. p4 = 0; + p5?: number; + + p6?: string; + p7 = { + hello: (this.p6 = "string"), + }; directlyAssigned: any = this.directlyAssigned; ~~~~~~~~~~~~~~~~ !!! error TS2729: Property 'directlyAssigned' is used before its initialization. -!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:7:5: 'directlyAssigned' is declared here. +!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:13:5: 'directlyAssigned' is declared here. withinArrowFunction: any = () => this.withinArrowFunction; @@ -31,14 +37,14 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729 [this.withinObjectLiteral]: true, ~~~~~~~~~~~~~~~~~~~ !!! error TS2729: Property 'withinObjectLiteral' is used before its initialization. -!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:15:5: 'withinObjectLiteral' is declared here. +!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:21:5: 'withinObjectLiteral' is declared here. }; withinObjectLiteralGetterName: any = { get [this.withinObjectLiteralGetterName]() { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization. -!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:19:5: 'withinObjectLiteralGetterName' is declared here. +!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:25:5: 'withinObjectLiteralGetterName' is declared here. return true; } }; @@ -47,13 +53,15 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729 set [this.withinObjectLiteralSetterName](_: any) {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization. -!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:25:5: 'withinObjectLiteralSetterName' is declared here. +!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:31:5: 'withinObjectLiteralSetterName' is declared here. }; withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { }); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization. -!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:29:5: 'withinClassDeclarationExtension' is declared here. +!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:35:5: 'withinClassDeclarationExtension' is declared here. + + fromOptional = this.p5; // These error cases are ignored (not checked by control flow analysis) diff --git a/tests/baselines/reference/classUsedBeforeInitializedVariables.js b/tests/baselines/reference/classUsedBeforeInitializedVariables.js index a1ed369e006..64b09b345af 100644 --- a/tests/baselines/reference/classUsedBeforeInitializedVariables.js +++ b/tests/baselines/reference/classUsedBeforeInitializedVariables.js @@ -4,6 +4,12 @@ class Test { p2 = this.p1; p3 = this.p4; p4 = 0; + p5?: number; + + p6?: string; + p7 = { + hello: (this.p6 = "string"), + }; directlyAssigned: any = this.directlyAssigned; @@ -29,6 +35,8 @@ class Test { withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { }); + fromOptional = this.p5; + // These error cases are ignored (not checked by control flow analysis) assignedByArrowFunction: any = (() => this.assignedByFunction)(); @@ -63,6 +71,9 @@ var Test = /** @class */ (function () { this.p2 = this.p1; this.p3 = this.p4; this.p4 = 0; + this.p7 = { + hello: (this.p6 = "string"), + }; this.directlyAssigned = this.directlyAssigned; this.withinArrowFunction = function () { return _this.withinArrowFunction; }; this.withinFunction = function () { @@ -94,6 +105,7 @@ var Test = /** @class */ (function () { } return class_1; }(this.withinClassDeclarationExtension))); + this.fromOptional = this.p5; // These error cases are ignored (not checked by control flow analysis) this.assignedByArrowFunction = (function () { return _this.assignedByFunction; })(); this.assignedByFunction = (function () { diff --git a/tests/baselines/reference/classUsedBeforeInitializedVariables.symbols b/tests/baselines/reference/classUsedBeforeInitializedVariables.symbols index 4885953ed58..f51022958e6 100644 --- a/tests/baselines/reference/classUsedBeforeInitializedVariables.symbols +++ b/tests/baselines/reference/classUsedBeforeInitializedVariables.symbols @@ -20,76 +20,99 @@ class Test { p4 = 0; >p4 : Symbol(Test.p4, Decl(classUsedBeforeInitializedVariables.ts, 3, 17)) - directlyAssigned: any = this.directlyAssigned; ->directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) ->this.directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) + p5?: number; +>p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) + + p6?: string; +>p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16)) + + p7 = { +>p7 : Symbol(Test.p7, Decl(classUsedBeforeInitializedVariables.ts, 7, 16)) + + hello: (this.p6 = "string"), +>hello : Symbol(hello, Decl(classUsedBeforeInitializedVariables.ts, 8, 10)) +>this.p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) +>p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16)) + + }; + + directlyAssigned: any = this.directlyAssigned; +>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6)) +>this.directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6)) +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) +>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6)) withinArrowFunction: any = () => this.withinArrowFunction; ->withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) ->this.withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) +>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50)) +>this.withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) +>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50)) withinFunction: any = function () { ->withinFunction : Symbol(Test.withinFunction, Decl(classUsedBeforeInitializedVariables.ts, 8, 62)) +>withinFunction : Symbol(Test.withinFunction, Decl(classUsedBeforeInitializedVariables.ts, 14, 62)) return this.withinFunction; }; withinObjectLiteral: any = { ->withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) +>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6)) [this.withinObjectLiteral]: true, ->[this.withinObjectLiteral] : Symbol([this.withinObjectLiteral], Decl(classUsedBeforeInitializedVariables.ts, 14, 32)) ->this.withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) +>[this.withinObjectLiteral] : Symbol([this.withinObjectLiteral], Decl(classUsedBeforeInitializedVariables.ts, 20, 32)) +>this.withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) +>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6)) }; withinObjectLiteralGetterName: any = { ->withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) +>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) get [this.withinObjectLiteralGetterName]() { ->[this.withinObjectLiteralGetterName] : Symbol([this.withinObjectLiteralGetterName], Decl(classUsedBeforeInitializedVariables.ts, 18, 42)) ->this.withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) +>[this.withinObjectLiteralGetterName] : Symbol([this.withinObjectLiteralGetterName], Decl(classUsedBeforeInitializedVariables.ts, 24, 42)) +>this.withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) +>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) return true; } }; withinObjectLiteralSetterName: any = { ->withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) +>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6)) set [this.withinObjectLiteralSetterName](_: any) {} ->[this.withinObjectLiteralSetterName] : Symbol([this.withinObjectLiteralSetterName], Decl(classUsedBeforeInitializedVariables.ts, 24, 42)) ->this.withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) +>[this.withinObjectLiteralSetterName] : Symbol([this.withinObjectLiteralSetterName], Decl(classUsedBeforeInitializedVariables.ts, 30, 42)) +>this.withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) ->_ : Symbol(_, Decl(classUsedBeforeInitializedVariables.ts, 25, 49)) +>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6)) +>_ : Symbol(_, Decl(classUsedBeforeInitializedVariables.ts, 31, 49)) }; withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { }); ->withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) ->this.withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) +>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6)) +>this.withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) +>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6)) + + fromOptional = this.p5; +>fromOptional : Symbol(Test.fromOptional, Decl(classUsedBeforeInitializedVariables.ts, 34, 100)) +>this.p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) +>p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) // These error cases are ignored (not checked by control flow analysis) assignedByArrowFunction: any = (() => this.assignedByFunction)(); ->assignedByArrowFunction : Symbol(Test.assignedByArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 28, 100)) ->this.assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) +>assignedByArrowFunction : Symbol(Test.assignedByArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 36, 27)) +>this.assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69)) >this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) ->assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) +>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69)) assignedByFunction: any = (function () { ->assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) +>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69)) return this.assignedByFunction; })(); diff --git a/tests/baselines/reference/classUsedBeforeInitializedVariables.types b/tests/baselines/reference/classUsedBeforeInitializedVariables.types index f10bf48a8ef..6a10797aa7e 100644 --- a/tests/baselines/reference/classUsedBeforeInitializedVariables.types +++ b/tests/baselines/reference/classUsedBeforeInitializedVariables.types @@ -22,6 +22,27 @@ class Test { >p4 : number >0 : 0 + p5?: number; +>p5 : number + + p6?: string; +>p6 : string + + p7 = { +>p7 : { hello: string; } +>{ hello: (this.p6 = "string"), } : { hello: string; } + + hello: (this.p6 = "string"), +>hello : string +>(this.p6 = "string") : "string" +>this.p6 = "string" : "string" +>this.p6 : string +>this : this +>p6 : string +>"string" : "string" + + }; + directlyAssigned: any = this.directlyAssigned; >directlyAssigned : any >this.directlyAssigned : any @@ -95,6 +116,12 @@ class Test { >this : this >withinClassDeclarationExtension : any + fromOptional = this.p5; +>fromOptional : number +>this.p5 : number +>this : this +>p5 : number + // These error cases are ignored (not checked by control flow analysis) assignedByArrowFunction: any = (() => this.assignedByFunction)(); diff --git a/tests/baselines/reference/commonJsImportBindingElementNarrowType.symbols b/tests/baselines/reference/commonJsImportBindingElementNarrowType.symbols new file mode 100644 index 00000000000..4410ae92d6a --- /dev/null +++ b/tests/baselines/reference/commonJsImportBindingElementNarrowType.symbols @@ -0,0 +1,20 @@ +=== /bar.js === +const { a } = require("./foo"); +>a : Symbol(a, Decl(bar.js, 0, 7)) +>require : Symbol(require) +>"./foo" : Symbol("/foo", Decl(foo.d.ts, 0, 0)) + +if (a) { +>a : Symbol(a, Decl(bar.js, 0, 7)) + + var x = a + 1; +>x : Symbol(x, Decl(bar.js, 2, 5)) +>a : Symbol(a, Decl(bar.js, 0, 7)) +} +=== /foo.d.ts === +// Regresion test for GH#41957 + + +export const a: number | null; +>a : Symbol(a, Decl(foo.d.ts, 3, 12)) + diff --git a/tests/baselines/reference/commonJsImportBindingElementNarrowType.types b/tests/baselines/reference/commonJsImportBindingElementNarrowType.types new file mode 100644 index 00000000000..6eff02b733f --- /dev/null +++ b/tests/baselines/reference/commonJsImportBindingElementNarrowType.types @@ -0,0 +1,24 @@ +=== /bar.js === +const { a } = require("./foo"); +>a : number | null +>require("./foo") : typeof import("/foo") +>require : any +>"./foo" : "./foo" + +if (a) { +>a : number | null + + var x = a + 1; +>x : number +>a + 1 : number +>a : number +>1 : 1 +} +=== /foo.d.ts === +// Regresion test for GH#41957 + + +export const a: number | null; +>a : number | null +>null : null + diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index c8af0683007..4e866e9e9e8 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -121,6 +121,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS if (retValue != 0 ^= { ~~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts:22:20: The parser expected to find a ')' to match the '(' token here. ~ diff --git a/tests/baselines/reference/declarationEmitOverloadedPrivateInference.js b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.js new file mode 100644 index 00000000000..d45313e3a22 --- /dev/null +++ b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.js @@ -0,0 +1,56 @@ +//// [declarationEmitOverloadedPrivateInference.ts] +function noArgs(): string { + return null as any; +} + +function oneArg(input: string): string { + return null as any; +} + +export class Wrapper { + private proxy(fn: (options: T) => U): (options: T) => U; + private proxy(fn: (options?: T) => U, noArgs: true): (options?: T) => U; + + private proxy(fn: (options: T) => U) { + return null as any; + } + + public Proxies = { + Failure: this.proxy(noArgs, true), + Success: this.proxy(oneArg), + }; +} + +//// [declarationEmitOverloadedPrivateInference.js] +"use strict"; +exports.__esModule = true; +exports.Wrapper = void 0; +function noArgs() { + return null; +} +function oneArg(input) { + return null; +} +var Wrapper = /** @class */ (function () { + function Wrapper() { + this.Proxies = { + Failure: this.proxy(noArgs, true), + Success: this.proxy(oneArg) + }; + } + Wrapper.prototype.proxy = function (fn) { + return null; + }; + return Wrapper; +}()); +exports.Wrapper = Wrapper; + + +//// [declarationEmitOverloadedPrivateInference.d.ts] +export declare class Wrapper { + private proxy; + Proxies: { + Failure: (options?: unknown) => string; + Success: (options: string) => string; + }; +} diff --git a/tests/baselines/reference/declarationEmitOverloadedPrivateInference.symbols b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.symbols new file mode 100644 index 00000000000..4b7babe4e92 --- /dev/null +++ b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts === +function noArgs(): string { +>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 0, 0)) + + return null as any; +} + +function oneArg(input: string): string { +>oneArg : Symbol(oneArg, Decl(declarationEmitOverloadedPrivateInference.ts, 2, 1)) +>input : Symbol(input, Decl(declarationEmitOverloadedPrivateInference.ts, 4, 16)) + + return null as any; +} + +export class Wrapper { +>Wrapper : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1)) + + private proxy(fn: (options: T) => U): (options: T) => U; +>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20)) +>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 24)) +>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 29)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20)) +>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 49)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20)) + + private proxy(fn: (options?: T) => U, noArgs: true): (options?: T) => U; +>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20)) +>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 24)) +>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 29)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20)) +>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 47)) +>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 64)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20)) + + private proxy(fn: (options: T) => U) { +>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 20)) +>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 24)) +>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 29)) +>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 18)) +>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 20)) + + return null as any; + } + + public Proxies = { +>Proxies : Symbol(Wrapper.Proxies, Decl(declarationEmitOverloadedPrivateInference.ts, 14, 5)) + + Failure: this.proxy(noArgs, true), +>Failure : Symbol(Failure, Decl(declarationEmitOverloadedPrivateInference.ts, 16, 22)) +>this.proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>this : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1)) +>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 0, 0)) + + Success: this.proxy(oneArg), +>Success : Symbol(Success, Decl(declarationEmitOverloadedPrivateInference.ts, 17, 42)) +>this.proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>this : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1)) +>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82)) +>oneArg : Symbol(oneArg, Decl(declarationEmitOverloadedPrivateInference.ts, 2, 1)) + + }; +} diff --git a/tests/baselines/reference/declarationEmitOverloadedPrivateInference.types b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.types new file mode 100644 index 00000000000..f0e49197d6e --- /dev/null +++ b/tests/baselines/reference/declarationEmitOverloadedPrivateInference.types @@ -0,0 +1,68 @@ +=== tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts === +function noArgs(): string { +>noArgs : () => string + + return null as any; +>null as any : any +>null : null +} + +function oneArg(input: string): string { +>oneArg : (input: string) => string +>input : string + + return null as any; +>null as any : any +>null : null +} + +export class Wrapper { +>Wrapper : Wrapper + + private proxy(fn: (options: T) => U): (options: T) => U; +>proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>fn : (options: T) => U +>options : T +>options : T + + private proxy(fn: (options?: T) => U, noArgs: true): (options?: T) => U; +>proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>fn : (options?: T) => U +>options : T +>noArgs : true +>true : true +>options : T + + private proxy(fn: (options: T) => U) { +>proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>fn : (options: T) => U +>options : T + + return null as any; +>null as any : any +>null : null + } + + public Proxies = { +>Proxies : { Failure: (options?: unknown) => string; Success: (options: string) => string; } +>{ Failure: this.proxy(noArgs, true), Success: this.proxy(oneArg), } : { Failure: (options?: unknown) => string; Success: (options: string) => string; } + + Failure: this.proxy(noArgs, true), +>Failure : (options?: unknown) => string +>this.proxy(noArgs, true) : (options?: unknown) => string +>this.proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>this : this +>proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>noArgs : () => string +>true : true + + Success: this.proxy(oneArg), +>Success : (options: string) => string +>this.proxy(oneArg) : (options: string) => string +>this.proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>this : this +>proxy : { (fn: (options: T) => U): (options: T) => U; (fn: (options?: T) => U, noArgs: true): (options?: T) => U; } +>oneArg : (input: string) => string + + }; +} diff --git a/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types b/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types index 7aff4276be7..b57ceb0b7a4 100644 --- a/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types +++ b/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types @@ -38,13 +38,13 @@ export const updateIfChanged = (t: T) => { >newU : U return Object.assign( ->Object.assign( >(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : ((key: K) => (>(key: K) => (>>(key: K) => (>>>(key: K) => (>>>>(key: K) => (>>>>>(key: K) => (>>>>>>(key: K) => (>>>>>>>(key: K) => (>>>>>>>>(key: K) => (>>>>>>>>>(key: K) => (>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value>>>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>) => U) => T; set: (newU: Value>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>) => U) => T; set: (newU: Value>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>) => U) => T; set: (newU: Value>>>>>) => T; }) & { map: (updater: (u: Value>>>>) => U) => T; set: (newU: Value>>>>) => T; }) & { map: (updater: (u: Value>>>) => U) => T; set: (newU: Value>>>) => T; }) & { map: (updater: (u: Value>>) => U) => T; set: (newU: Value>>) => T; }) & { map: (updater: (u: Value>) => U) => T; set: (newU: Value>) => T; }) & { map: (updater: (u: Value) => U) => T; set: (newU: Value) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; } +>Object.assign( >(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : ((key: K) => (>(key: K) => (>>(key: K) => (>>>(key: K) => (>>>>(key: K) => (>>>>>(key: K) => (>>>>>>(key: K) => (>>>>>>>(key: K) => (>>>>>>>>(key: K) => (>>>>>>>>>(key: K) => (>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value>>>>>>>>>>) => Value>>>>>>>>>>) => T; set: (newU: Value>>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>>) => Value>>>>>>>>>) => T; set: (newU: Value>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>) => Value>>>>>>>>) => T; set: (newU: Value>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>) => Value>>>>>>>) => T; set: (newU: Value>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>) => Value>>>>>>) => T; set: (newU: Value>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>) => Value>>>>>) => T; set: (newU: Value>>>>>) => T; }) & { map: (updater: (u: Value>>>>) => Value>>>>) => T; set: (newU: Value>>>>) => T; }) & { map: (updater: (u: Value>>>) => Value>>>) => T; set: (newU: Value>>>) => T; }) & { map: (updater: (u: Value>>) => Value>>) => T; set: (newU: Value>>) => T; }) & { map: (updater: (u: Value>) => Value>) => T; set: (newU: Value>) => T; }) & { map: (updater: (u: Value) => Value) => T; set: (newU: Value) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >(key: K) => ->>(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : (key: K) => (>(key: K) => (>>(key: K) => (>>>(key: K) => (>>>>(key: K) => (>>>>>(key: K) => (>>>>>>(key: K) => (>>>>>>>(key: K) => (>>>>>>>>(key: K) => (>>>>>>>>>(key: K) => (>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value>>>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>) => U) => T; set: (newU: Value>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>) => U) => T; set: (newU: Value>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>) => U) => T; set: (newU: Value>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>) => U) => T; set: (newU: Value>>>>>) => T; }) & { map: (updater: (u: Value>>>>) => U) => T; set: (newU: Value>>>>) => T; }) & { map: (updater: (u: Value>>>) => U) => T; set: (newU: Value>>>) => T; }) & { map: (updater: (u: Value>>) => U) => T; set: (newU: Value>>) => T; }) & { map: (updater: (u: Value>) => U) => T; set: (newU: Value>) => T; }) & { map: (updater: (u: Value) => U) => T; set: (newU: Value) => T; } +>>(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : (key: K) => (>(key: K) => (>>(key: K) => (>>>(key: K) => (>>>>(key: K) => (>>>>>(key: K) => (>>>>>>(key: K) => (>>>>>>>(key: K) => (>>>>>>>>(key: K) => (>>>>>>>>>(key: K) => (>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value>>>>>>>>>>) => Value>>>>>>>>>>) => T; set: (newU: Value>>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>>) => Value>>>>>>>>>) => T; set: (newU: Value>>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>>) => Value>>>>>>>>) => T; set: (newU: Value>>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>>) => Value>>>>>>>) => T; set: (newU: Value>>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>>) => Value>>>>>>) => T; set: (newU: Value>>>>>>) => T; }) & { map: (updater: (u: Value>>>>>) => Value>>>>>) => T; set: (newU: Value>>>>>) => T; }) & { map: (updater: (u: Value>>>>) => Value>>>>) => T; set: (newU: Value>>>>) => T; }) & { map: (updater: (u: Value>>>) => Value>>>) => T; set: (newU: Value>>>) => T; }) & { map: (updater: (u: Value>>) => Value>>) => T; set: (newU: Value>>) => T; }) & { map: (updater: (u: Value>) => Value>) => T; set: (newU: Value>) => T; }) & { map: (updater: (u: Value) => Value) => T; set: (newU: Value) => T; } >key : K reduce>(u[key as keyof U] as Value, (v: Value) => { diff --git a/tests/baselines/reference/destructionAssignmentError.errors.txt b/tests/baselines/reference/destructionAssignmentError.errors.txt new file mode 100644 index 00000000000..831f9a5fc6c --- /dev/null +++ b/tests/baselines/reference/destructionAssignmentError.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/destructionAssignmentError.ts(6,3): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/destructionAssignmentError.ts(6,10): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/compiler/destructionAssignmentError.ts(11,3): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/destructionAssignmentError.ts(12,1): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + + +==== tests/cases/compiler/destructionAssignmentError.ts (4 errors) ==== + declare function fn(): { a: 1, b: 2 } + let a: number; + let b: number; + + ({ a, b } = fn()); + { a, b } = fn(); + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + + ({ a, b } = + fn()); + + { a, b } + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + = fn(); + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. \ No newline at end of file diff --git a/tests/baselines/reference/destructionAssignmentError.js b/tests/baselines/reference/destructionAssignmentError.js new file mode 100644 index 00000000000..f188ccc1daa --- /dev/null +++ b/tests/baselines/reference/destructionAssignmentError.js @@ -0,0 +1,28 @@ +//// [destructionAssignmentError.ts] +declare function fn(): { a: 1, b: 2 } +let a: number; +let b: number; + +({ a, b } = fn()); +{ a, b } = fn(); + +({ a, b } = +fn()); + +{ a, b } += fn(); + +//// [destructionAssignmentError.js] +var _a, _b; +var a; +var b; +(_a = fn(), a = _a.a, b = _a.b); +{ + a, b; +} +fn(); +(_b = fn(), a = _b.a, b = _b.b); +{ + a, b; +} +fn(); diff --git a/tests/baselines/reference/destructionAssignmentError.symbols b/tests/baselines/reference/destructionAssignmentError.symbols new file mode 100644 index 00000000000..82650703289 --- /dev/null +++ b/tests/baselines/reference/destructionAssignmentError.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/destructionAssignmentError.ts === +declare function fn(): { a: 1, b: 2 } +>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0)) +>a : Symbol(a, Decl(destructionAssignmentError.ts, 0, 24)) +>b : Symbol(b, Decl(destructionAssignmentError.ts, 0, 30)) + +let a: number; +>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3)) + +let b: number; +>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3)) + +({ a, b } = fn()); +>a : Symbol(a, Decl(destructionAssignmentError.ts, 4, 2)) +>b : Symbol(b, Decl(destructionAssignmentError.ts, 4, 5)) +>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0)) + +{ a, b } = fn(); +>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3)) +>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3)) +>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0)) + +({ a, b } = +>a : Symbol(a, Decl(destructionAssignmentError.ts, 7, 2)) +>b : Symbol(b, Decl(destructionAssignmentError.ts, 7, 5)) + +fn()); +>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0)) + +{ a, b } +>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3)) +>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3)) + += fn(); +>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0)) + diff --git a/tests/baselines/reference/destructionAssignmentError.types b/tests/baselines/reference/destructionAssignmentError.types new file mode 100644 index 00000000000..94cbd3f792f --- /dev/null +++ b/tests/baselines/reference/destructionAssignmentError.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/destructionAssignmentError.ts === +declare function fn(): { a: 1, b: 2 } +>fn : () => { a: 1; b: 2;} +>a : 1 +>b : 2 + +let a: number; +>a : number + +let b: number; +>b : number + +({ a, b } = fn()); +>({ a, b } = fn()) : { a: 1; b: 2; } +>{ a, b } = fn() : { a: 1; b: 2; } +>{ a, b } : { a: number; b: number; } +>a : number +>b : number +>fn() : { a: 1; b: 2; } +>fn : () => { a: 1; b: 2; } + +{ a, b } = fn(); +>a, b : number +>a : number +>b : number +>fn() : { a: 1; b: 2; } +>fn : () => { a: 1; b: 2; } + +({ a, b } = +>({ a, b } =fn()) : { a: 1; b: 2; } +>{ a, b } =fn() : { a: 1; b: 2; } +>{ a, b } : { a: number; b: number; } +>a : number +>b : number + +fn()); +>fn() : { a: 1; b: 2; } +>fn : () => { a: 1; b: 2; } + +{ a, b } +>a, b : number +>a : number +>b : number + += fn(); +>fn() : { a: 1; b: 2; } +>fn : () => { a: 1; b: 2; } + diff --git a/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt b/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt index 3a7c89e2f41..6bac6729147 100644 --- a/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt +++ b/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt @@ -16,5 +16,4 @@ tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts(9,2): err } !!! error TS1005: '}' expected. -!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here. -!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:2:20: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.errors.txt b/tests/baselines/reference/excessiveStackDepthFlatArray.errors.txt new file mode 100644 index 00000000000..825a402ca02 --- /dev/null +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/index.tsx(35,13): error TS2322: Type '{ key: string; }' is not assignable to type 'HTMLAttributes'. + Property 'key' does not exist on type 'HTMLAttributes'. + + +==== tests/cases/compiler/index.tsx (1 errors) ==== + interface MiddlewareArray extends Array {} + declare function configureStore(options: { middleware: MiddlewareArray }): void; + + declare const defaultMiddleware: MiddlewareArray; + configureStore({ + middleware: [...defaultMiddleware], // Should not error + }); + + declare namespace React { + type DetailedHTMLProps, T> = E; + interface HTMLAttributes { + children?: ReactNode; + } + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; + type ReactText = string | number; + type ReactChild = ReactText; + type ReactFragment = {} | ReactNodeArray; + interface ReactNodeArray extends Array {} + } + declare namespace JSX { + interface IntrinsicElements { + ul: React.DetailedHTMLProps, HTMLUListElement>; + li: React.DetailedHTMLProps, HTMLLIElement>; + } + } + declare var React: any; + + const Component = () => { + const categories = ['Fruit', 'Vegetables']; + + return ( +

    +
  • All
  • + {categories.map((category) => ( +
  • {category}
  • // Error about 'key' only + ~~~ +!!! error TS2322: Type '{ key: string; }' is not assignable to type 'HTMLAttributes'. +!!! error TS2322: Property 'key' does not exist on type 'HTMLAttributes'. + ))} +
+ ); + }; + \ No newline at end of file diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.js b/tests/baselines/reference/excessiveStackDepthFlatArray.js new file mode 100644 index 00000000000..4578612b4a6 --- /dev/null +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.js @@ -0,0 +1,58 @@ +//// [index.tsx] +interface MiddlewareArray extends Array {} +declare function configureStore(options: { middleware: MiddlewareArray }): void; + +declare const defaultMiddleware: MiddlewareArray; +configureStore({ + middleware: [...defaultMiddleware], // Should not error +}); + +declare namespace React { + type DetailedHTMLProps, T> = E; + interface HTMLAttributes { + children?: ReactNode; + } + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; + type ReactText = string | number; + type ReactChild = ReactText; + type ReactFragment = {} | ReactNodeArray; + interface ReactNodeArray extends Array {} +} +declare namespace JSX { + interface IntrinsicElements { + ul: React.DetailedHTMLProps, HTMLUListElement>; + li: React.DetailedHTMLProps, HTMLLIElement>; + } +} +declare var React: any; + +const Component = () => { + const categories = ['Fruit', 'Vegetables']; + + return ( +
    +
  • All
  • + {categories.map((category) => ( +
  • {category}
  • // Error about 'key' only + ))} +
+ ); +}; + + +//// [index.js] +var __spreadArray = (this && this.__spreadArray) || function (to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) + to[j] = from[i]; + return to; +}; +configureStore({ + middleware: __spreadArray([], defaultMiddleware) +}); +var Component = function () { + var categories = ['Fruit', 'Vegetables']; + return (React.createElement("ul", null, + React.createElement("li", null, "All"), + categories.map(function (category) { return (React.createElement("li", { key: category }, category) // Error about 'key' only + ); }))); +}; diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.symbols b/tests/baselines/reference/excessiveStackDepthFlatArray.symbols new file mode 100644 index 00000000000..08fe546e6da --- /dev/null +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.symbols @@ -0,0 +1,128 @@ +=== tests/cases/compiler/index.tsx === +interface MiddlewareArray extends Array {} +>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0)) +>T : Symbol(T, Decl(index.tsx, 0, 26)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>T : Symbol(T, Decl(index.tsx, 0, 26)) + +declare function configureStore(options: { middleware: MiddlewareArray }): void; +>configureStore : Symbol(configureStore, Decl(index.tsx, 0, 48)) +>options : Symbol(options, Decl(index.tsx, 1, 32)) +>middleware : Symbol(middleware, Decl(index.tsx, 1, 42)) +>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0)) + +declare const defaultMiddleware: MiddlewareArray; +>defaultMiddleware : Symbol(defaultMiddleware, Decl(index.tsx, 3, 13)) +>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0)) + +configureStore({ +>configureStore : Symbol(configureStore, Decl(index.tsx, 0, 48)) + + middleware: [...defaultMiddleware], // Should not error +>middleware : Symbol(middleware, Decl(index.tsx, 4, 16)) +>defaultMiddleware : Symbol(defaultMiddleware, Decl(index.tsx, 3, 13)) + +}); + +declare namespace React { +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) + + type DetailedHTMLProps, T> = E; +>DetailedHTMLProps : Symbol(DetailedHTMLProps, Decl(index.tsx, 8, 25)) +>E : Symbol(E, Decl(index.tsx, 9, 25)) +>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.tsx, 9, 61)) +>T : Symbol(T, Decl(index.tsx, 9, 53)) +>T : Symbol(T, Decl(index.tsx, 9, 53)) +>E : Symbol(E, Decl(index.tsx, 9, 25)) + + interface HTMLAttributes { +>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.tsx, 9, 61)) +>T : Symbol(T, Decl(index.tsx, 10, 27)) + + children?: ReactNode; +>children : Symbol(HTMLAttributes.children, Decl(index.tsx, 10, 31)) +>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3)) + } + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; +>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3)) +>ReactChild : Symbol(ReactChild, Decl(index.tsx, 14, 35)) +>ReactFragment : Symbol(ReactFragment, Decl(index.tsx, 15, 30)) + + type ReactText = string | number; +>ReactText : Symbol(ReactText, Decl(index.tsx, 13, 75)) + + type ReactChild = ReactText; +>ReactChild : Symbol(ReactChild, Decl(index.tsx, 14, 35)) +>ReactText : Symbol(ReactText, Decl(index.tsx, 13, 75)) + + type ReactFragment = {} | ReactNodeArray; +>ReactFragment : Symbol(ReactFragment, Decl(index.tsx, 15, 30)) +>ReactNodeArray : Symbol(ReactNodeArray, Decl(index.tsx, 16, 43)) + + interface ReactNodeArray extends Array {} +>ReactNodeArray : Symbol(ReactNodeArray, Decl(index.tsx, 16, 43)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3)) +} +declare namespace JSX { +>JSX : Symbol(JSX, Decl(index.tsx, 18, 1)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 19, 23)) + + ul: React.DetailedHTMLProps, HTMLUListElement>; +>ul : Symbol(IntrinsicElements.ul, Decl(index.tsx, 20, 31)) +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) +>DetailedHTMLProps : Symbol(React.DetailedHTMLProps, Decl(index.tsx, 8, 25)) +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) +>HTMLAttributes : Symbol(React.HTMLAttributes, Decl(index.tsx, 9, 61)) +>HTMLUListElement : Symbol(HTMLUListElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>HTMLUListElement : Symbol(HTMLUListElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + li: React.DetailedHTMLProps, HTMLLIElement>; +>li : Symbol(IntrinsicElements.li, Decl(index.tsx, 21, 90)) +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) +>DetailedHTMLProps : Symbol(React.DetailedHTMLProps, Decl(index.tsx, 8, 25)) +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) +>HTMLAttributes : Symbol(React.HTMLAttributes, Decl(index.tsx, 9, 61)) +>HTMLLIElement : Symbol(HTMLLIElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>HTMLLIElement : Symbol(HTMLLIElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + } +} +declare var React: any; +>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11)) + +const Component = () => { +>Component : Symbol(Component, Decl(index.tsx, 27, 5)) + + const categories = ['Fruit', 'Vegetables']; +>categories : Symbol(categories, Decl(index.tsx, 28, 7)) + + return ( +
    +>ul : Symbol(JSX.IntrinsicElements.ul, Decl(index.tsx, 20, 31)) + +
  • All
  • +>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90)) +>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90)) + + {categories.map((category) => ( +>categories.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>categories : Symbol(categories, Decl(index.tsx, 28, 7)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>category : Symbol(category, Decl(index.tsx, 33, 23)) + +
  • {category}
  • // Error about 'key' only +>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90)) +>key : Symbol(key, Decl(index.tsx, 34, 11)) +>category : Symbol(category, Decl(index.tsx, 33, 23)) +>category : Symbol(category, Decl(index.tsx, 33, 23)) +>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90)) + + ))} +
+>ul : Symbol(JSX.IntrinsicElements.ul, Decl(index.tsx, 20, 31)) + + ); +}; + diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.types b/tests/baselines/reference/excessiveStackDepthFlatArray.types new file mode 100644 index 00000000000..ae346a034fa --- /dev/null +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.types @@ -0,0 +1,108 @@ +=== tests/cases/compiler/index.tsx === +interface MiddlewareArray extends Array {} +declare function configureStore(options: { middleware: MiddlewareArray }): void; +>configureStore : (options: { middleware: MiddlewareArray;}) => void +>options : { middleware: MiddlewareArray; } +>middleware : MiddlewareArray + +declare const defaultMiddleware: MiddlewareArray; +>defaultMiddleware : MiddlewareArray + +configureStore({ +>configureStore({ middleware: [...defaultMiddleware], // Should not error}) : void +>configureStore : (options: { middleware: MiddlewareArray; }) => void +>{ middleware: [...defaultMiddleware], // Should not error} : { middleware: any[]; } + + middleware: [...defaultMiddleware], // Should not error +>middleware : any[] +>[...defaultMiddleware] : any[] +>...defaultMiddleware : any +>defaultMiddleware : MiddlewareArray + +}); + +declare namespace React { + type DetailedHTMLProps, T> = E; +>DetailedHTMLProps : E + + interface HTMLAttributes { + children?: ReactNode; +>children : ReactNode + } + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; +>ReactNode : ReactNode +>null : null + + type ReactText = string | number; +>ReactText : ReactText + + type ReactChild = ReactText; +>ReactChild : ReactText + + type ReactFragment = {} | ReactNodeArray; +>ReactFragment : ReactFragment + + interface ReactNodeArray extends Array {} +} +declare namespace JSX { + interface IntrinsicElements { + ul: React.DetailedHTMLProps, HTMLUListElement>; +>ul : React.HTMLAttributes +>React : any +>React : any + + li: React.DetailedHTMLProps, HTMLLIElement>; +>li : React.HTMLAttributes +>React : any +>React : any + } +} +declare var React: any; +>React : any + +const Component = () => { +>Component : () => any +>() => { const categories = ['Fruit', 'Vegetables']; return (
  • All
  • {categories.map((category) => (
  • {category}
  • // Error about 'key' only ))}
);} : () => any + + const categories = ['Fruit', 'Vegetables']; +>categories : string[] +>['Fruit', 'Vegetables'] : string[] +>'Fruit' : "Fruit" +>'Vegetables' : "Vegetables" + + return ( +>(
  • All
  • {categories.map((category) => (
  • {category}
  • // Error about 'key' only ))}
) : any + +
    +>
    • All
    • {categories.map((category) => (
    • {category}
    • // Error about 'key' only ))}
    : any +>ul : any + +
  • All
  • +>
  • All
  • : any +>li : any +>li : any + + {categories.map((category) => ( +>categories.map((category) => (
  • {category}
  • // Error about 'key' only )) : any[] +>categories.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>categories : string[] +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>(category) => (
  • {category}
  • // Error about 'key' only ) : (category: string) => any +>category : string +>(
  • {category}
  • // Error about 'key' only ) : any + +
  • {category}
  • // Error about 'key' only +>
  • {category}
  • : any +>li : any +>key : string +>category : string +>category : string +>li : any + + ))} +
+>ul : any + + ); +}; + diff --git a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.errors.txt b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.errors.txt new file mode 100644 index 00000000000..89335637026 --- /dev/null +++ b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.errors.txt @@ -0,0 +1,44 @@ +tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts(20,5): error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'FlatArray'. + Type 'unknown' is not assignable to type 'FlatArray'. + Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. + Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. + Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. + Type 'FlatArray' is not assignable to type 'FlatArray'. + Type 'InnerArr' is not assignable to type 'FlatArray'. + Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr) & InnerArr'. + Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr'. + + +==== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts (1 errors) ==== + // Repro from #43493 + + declare const foo: unknown[]; + const bar = foo.flatMap(bar => bar as Foo); + + interface Foo extends Array {} + + // Repros from comments in #43249 + + const repro_43249 = (value: unknown) => { + if (typeof value !== "string") { + throw new Error("No"); + } + const match = value.match(/anything/) || []; + const [, extracted] = match; + }; + + function f(x: FlatArray, y: FlatArray) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'FlatArray'. +!!! error TS2322: Type 'unknown' is not assignable to type 'FlatArray'. +!!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. +!!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. +!!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. +!!! error TS2322: Type 'FlatArray' is not assignable to type 'FlatArray'. +!!! error TS2322: Type 'InnerArr' is not assignable to type 'FlatArray'. +!!! error TS2322: Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr) & InnerArr'. +!!! error TS2322: Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.js b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.js new file mode 100644 index 00000000000..5fec84b1fc5 --- /dev/null +++ b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.js @@ -0,0 +1,49 @@ +//// [flatArrayNoExcessiveStackDepth.ts] +// Repro from #43493 + +declare const foo: unknown[]; +const bar = foo.flatMap(bar => bar as Foo); + +interface Foo extends Array {} + +// Repros from comments in #43249 + +const repro_43249 = (value: unknown) => { + if (typeof value !== "string") { + throw new Error("No"); + } + const match = value.match(/anything/) || []; + const [, extracted] = match; +}; + +function f(x: FlatArray, y: FlatArray) { + x = y; + y = x; // Error +} + + +//// [flatArrayNoExcessiveStackDepth.js] +"use strict"; +// Repro from #43493 +const bar = foo.flatMap(bar => bar); +// Repros from comments in #43249 +const repro_43249 = (value) => { + if (typeof value !== "string") { + throw new Error("No"); + } + const match = value.match(/anything/) || []; + const [, extracted] = match; +}; +function f(x, y) { + x = y; + y = x; // Error +} + + +//// [flatArrayNoExcessiveStackDepth.d.ts] +declare const foo: unknown[]; +declare const bar: string[]; +interface Foo extends Array { +} +declare const repro_43249: (value: unknown) => void; +declare function f(x: FlatArray, y: FlatArray): void; diff --git a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols new file mode 100644 index 00000000000..4b27f6006cb --- /dev/null +++ b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts === +// Repro from #43493 + +declare const foo: unknown[]; +>foo : Symbol(foo, Decl(flatArrayNoExcessiveStackDepth.ts, 2, 13)) + +const bar = foo.flatMap(bar => bar as Foo); +>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 5)) +>foo.flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --)) +>foo : Symbol(foo, Decl(flatArrayNoExcessiveStackDepth.ts, 2, 13)) +>flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --)) +>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 24)) +>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 24)) +>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43)) + +interface Foo extends Array {} +>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) + +// Repros from comments in #43249 + +const repro_43249 = (value: unknown) => { +>repro_43249 : Symbol(repro_43249, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 5)) +>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21)) + + if (typeof value !== "string") { +>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21)) + + throw new Error("No"); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + const match = value.match(/anything/) || []; +>match : Symbol(match, Decl(flatArrayNoExcessiveStackDepth.ts, 13, 9)) +>value.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21)) +>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + const [, extracted] = match; +>extracted : Symbol(extracted, Decl(flatArrayNoExcessiveStackDepth.ts, 14, 12)) +>match : Symbol(match, Decl(flatArrayNoExcessiveStackDepth.ts, 13, 9)) + +}; + +function f(x: FlatArray, y: FlatArray) { +>f : Symbol(f, Decl(flatArrayNoExcessiveStackDepth.ts, 15, 2)) +>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11)) +>D : Symbol(D, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 15)) +>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34)) +>FlatArray : Symbol(FlatArray, Decl(lib.es2019.array.d.ts, --, --)) +>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11)) +>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57)) +>FlatArray : Symbol(FlatArray, Decl(lib.es2019.array.d.ts, --, --)) +>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11)) +>D : Symbol(D, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 15)) + + x = y; +>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34)) +>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57)) + + y = x; // Error +>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57)) +>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34)) +} + diff --git a/tests/baselines/reference/flatArrayNoExcessiveStackDepth.types b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.types new file mode 100644 index 00000000000..51bde63a33b --- /dev/null +++ b/tests/baselines/reference/flatArrayNoExcessiveStackDepth.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts === +// Repro from #43493 + +declare const foo: unknown[]; +>foo : unknown[] + +const bar = foo.flatMap(bar => bar as Foo); +>bar : string[] +>foo.flatMap(bar => bar as Foo) : string[] +>foo.flatMap : (callback: (this: This, value: unknown, index: number, array: unknown[]) => U | readonly U[], thisArg?: This | undefined) => U[] +>foo : unknown[] +>flatMap : (callback: (this: This, value: unknown, index: number, array: unknown[]) => U | readonly U[], thisArg?: This | undefined) => U[] +>bar => bar as Foo : (this: undefined, bar: unknown) => Foo +>bar : unknown +>bar as Foo : Foo +>bar : unknown + +interface Foo extends Array {} + +// Repros from comments in #43249 + +const repro_43249 = (value: unknown) => { +>repro_43249 : (value: unknown) => void +>(value: unknown) => { if (typeof value !== "string") { throw new Error("No"); } const match = value.match(/anything/) || []; const [, extracted] = match;} : (value: unknown) => void +>value : unknown + + if (typeof value !== "string") { +>typeof value !== "string" : boolean +>typeof value : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>value : unknown +>"string" : "string" + + throw new Error("No"); +>new Error("No") : Error +>Error : ErrorConstructor +>"No" : "No" + } + const match = value.match(/anything/) || []; +>match : RegExpMatchArray +>value.match(/anything/) || [] : RegExpMatchArray +>value.match(/anything/) : RegExpMatchArray | null +>value.match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>value : string +>match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>/anything/ : RegExp +>[] : never[] + + const [, extracted] = match; +> : undefined +>extracted : string +>match : RegExpMatchArray + +}; + +function f(x: FlatArray, y: FlatArray) { +>f : (x: FlatArray, y: FlatArray) => void +>x : FlatArray +>y : FlatArray + + x = y; +>x = y : FlatArray +>x : FlatArray +>y : FlatArray + + y = x; // Error +>y = x : Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr +>y : FlatArray +>x : Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr +} + diff --git a/tests/baselines/reference/genericFunctionInference2.types b/tests/baselines/reference/genericFunctionInference2.types index 75e116d169d..85208d6fee4 100644 --- a/tests/baselines/reference/genericFunctionInference2.types +++ b/tests/baselines/reference/genericFunctionInference2.types @@ -19,7 +19,7 @@ declare const foo: Reducer; const myReducer1: Reducer = combineReducers({ >myReducer1 : Reducer ->combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }> +>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }> >combineReducers : (reducers: { [K in keyof S]: Reducer; }) => Reducer >{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; } @@ -33,8 +33,8 @@ const myReducer1: Reducer = combineReducers({ }); const myReducer2 = combineReducers({ ->myReducer2 : Reducer<{ combined: { foo: any; }; }> ->combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }> +>myReducer2 : Reducer<{ combined: { foo: number; }; }> +>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }> >combineReducers : (reducers: { [K in keyof S]: Reducer; }) => Reducer >{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; } diff --git a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt index 0a864efd0f0..937ad3e8cc6 100644 --- a/tests/baselines/reference/importedModuleAddToGlobal.errors.txt +++ b/tests/baselines/reference/importedModuleAddToGlobal.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2811: Cannot find namespace 'b'. Did you mean 'B? +tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2812: Cannot find namespace 'b'. Did you mean 'B? ==== tests/cases/compiler/importedModuleAddToGlobal.ts (1 errors) ==== @@ -18,6 +18,6 @@ tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2811: Cannot f import a = A; function hello(): b.B { return null; } ~ -!!! error TS2811: Cannot find namespace 'b'. Did you mean 'B? +!!! error TS2812: Cannot find namespace 'b'. Did you mean 'B? !!! related TS2728 tests/cases/compiler/importedModuleAddToGlobal.ts:8:8: 'B' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt index 1925079095a..d6ad166fb0f 100644 --- a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt +++ b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt @@ -4,9 +4,11 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(4,11): error TS2427: Interface name cannot be 'boolean'. tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,1): error TS2304: Cannot find name 'interface'. tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS1005: ';' expected. +tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(6,11): error TS2427: Interface name cannot be 'unknown'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(7,11): error TS2427: Interface name cannot be 'never'. -==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (6 errors) ==== +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (8 errors) ==== interface any { } ~~~ !!! error TS2427: Interface name cannot be 'any'. @@ -23,4 +25,10 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine ~~~~~~~~~ !!! error TS2304: Cannot find name 'interface'. ~~~~ -!!! error TS1005: ';' expected. \ No newline at end of file +!!! error TS1005: ';' expected. + interface unknown {} + ~~~~~~~ +!!! error TS2427: Interface name cannot be 'unknown'. + interface never {} + ~~~~~ +!!! error TS2427: Interface name cannot be 'never'. \ No newline at end of file diff --git a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.js b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.js index ca186b1cef1..2bb4f0be112 100644 --- a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.js +++ b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.js @@ -3,7 +3,9 @@ interface any { } interface number { } interface string { } interface boolean { } -interface void {} +interface void {} +interface unknown {} +interface never {} //// [interfacesWithPredefinedTypesAsNames.js] interface; diff --git a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.symbols b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.symbols index f469eaba590..c79493530ea 100644 --- a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.symbols +++ b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.symbols @@ -12,3 +12,9 @@ interface boolean { } >boolean : Symbol(boolean, Decl(interfacesWithPredefinedTypesAsNames.ts, 2, 20)) interface void {} +interface unknown {} +>unknown : Symbol(unknown, Decl(interfacesWithPredefinedTypesAsNames.ts, 4, 17)) + +interface never {} +>never : Symbol(never, Decl(interfacesWithPredefinedTypesAsNames.ts, 5, 20)) + diff --git a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.types b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.types index 9d6b22cfa48..492facdc845 100644 --- a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.types +++ b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.types @@ -8,3 +8,5 @@ interface void {} >void {} : undefined >{} : {} +interface unknown {} +interface never {} diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt index 08d57bc1721..32f8f4fb5bf 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. +tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. ==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessE var x: c.b; ~ -!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file +!!! error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt index 3ea97375443..cdc0f58fc76 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. +tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. ==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -19,4 +19,4 @@ tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExp export var z: c.b.I; ~ -!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file +!!! error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidInstantiatedModule.errors.txt b/tests/baselines/reference/invalidInstantiatedModule.errors.txt index 518efeba119..33faae21749 100644 --- a/tests/baselines/reference/invalidInstantiatedModule.errors.txt +++ b/tests/baselines/reference/invalidInstantiatedModule.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(2,18): error TS2300: Duplicate identifier 'Point'. tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(3,16): error TS2300: Duplicate identifier 'Point'. -tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M? +tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2812: Cannot find namespace 'm'. Did you mean 'M? ==== tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedMo var m = M2; var p: m.Point; // Error ~ -!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M? +!!! error TS2812: Cannot find namespace 'm'. Did you mean 'M? !!! related TS2728 tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts:1:8: 'M' is declared here. diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.js b/tests/baselines/reference/isomorphicMappedTypeInference.js index aa904e9afa1..778eae45426 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.js +++ b/tests/baselines/reference/isomorphicMappedTypeInference.js @@ -350,12 +350,14 @@ declare function applySpec(obj: Spec): (...args: any[]) => T; declare var g1: (...args: any[]) => { sum: number; nested: { - mul: any; + mul: string; }; }; declare var g2: (...args: any[]) => { foo: { - bar: any; + bar: { + baz: boolean; + }; }; }; declare const foo: (object: T, partial: Partial) => T; diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index 1f1fa0d200a..608c5e79df2 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -434,8 +434,8 @@ declare function applySpec(obj: Spec): (...args: any[]) => T; // Infers g1: (...args: any[]) => { sum: number, nested: { mul: string } } var g1 = applySpec({ ->g1 : (...args: any[]) => { sum: number; nested: { mul: any; }; } ->applySpec({ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }}) : (...args: any[]) => { sum: number; nested: { mul: any; }; } +>g1 : (...args: any[]) => { sum: number; nested: { mul: string; }; } +>applySpec({ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }}) : (...args: any[]) => { sum: number; nested: { mul: string; }; } >applySpec : (obj: Spec) => (...args: any[]) => T >{ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }} : { sum: (a: any) => number; nested: { mul: (b: any) => string; }; } @@ -459,8 +459,8 @@ var g1 = applySpec({ // Infers g2: (...args: any[]) => { foo: { bar: { baz: boolean } } } var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); ->g2 : (...args: any[]) => { foo: { bar: any; }; } ->applySpec({ foo: { bar: { baz: (x: any) => true } } }) : (...args: any[]) => { foo: { bar: any; }; } +>g2 : (...args: any[]) => { foo: { bar: { baz: boolean; }; }; } +>applySpec({ foo: { bar: { baz: (x: any) => true } } }) : (...args: any[]) => { foo: { bar: { baz: boolean; }; }; } >applySpec : (obj: Spec) => (...args: any[]) => T >{ foo: { bar: { baz: (x: any) => true } } } : { foo: { bar: { baz: (x: any) => boolean; }; }; } >foo : { bar: { baz: (x: any) => boolean; }; } diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.js b/tests/baselines/reference/jsDeclarationsInterfaces.js index f7f68846d29..00e78c8286a 100644 --- a/tests/baselines/reference/jsDeclarationsInterfaces.js +++ b/tests/baselines/reference/jsDeclarationsInterfaces.js @@ -135,10 +135,10 @@ export interface B { export interface C { new (): string; new (x: T_1): U_1; - new (x: Q_6): T_1 & Q_6; + new (x: Q_4): T_1 & Q_4; (): number; (x: T_1): U_1; - (x: Q_4): T_1 & Q_4; + (x: Q_3): T_1 & Q_3; field: T_1 & U_1; optionalField?: T_1; readonly readonlyField: T_1 & U_1; diff --git a/tests/baselines/reference/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt b/tests/baselines/reference/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt index 6d2f34fcc58..4a258fc96bd 100644 --- a/tests/baselines/reference/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt +++ b/tests/baselines/reference/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt @@ -18,7 +18,7 @@ tests/cases/conformance/jsdoc/declarations/file.js(6,5): error TS4084: Exported ==== tests/cases/conformance/jsdoc/declarations/file.js (3 errors) ==== /** @typedef {import('./base')} BaseFactory */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS4084: Exported type alias 'BaseFactory' has or is using private name 'Base' from module "tests/cases/conformance/jsdoc/declarations/base". /** * @callback BaseFactoryFactory diff --git a/tests/baselines/reference/jsDocSignature-43394.baseline b/tests/baselines/reference/jsDocSignature-43394.baseline new file mode 100644 index 00000000000..905b7e8bccc --- /dev/null +++ b/tests/baselines/reference/jsDocSignature-43394.baseline @@ -0,0 +1,9 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/jsDocSignature-43394.ts", + "position": 58, + "name": "" + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.js b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.js new file mode 100644 index 00000000000..94e732a4b4d --- /dev/null +++ b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.js @@ -0,0 +1,56 @@ +//// [keyofGenericExtendingClassDoubleLayer.ts] +class Model { + public createdAt: Date; +} + +type ModelAttributes = Omit; + +class AutoModel extends Model> {} + +class PersonModel extends AutoModel { + public age: number; + + toJson() { + let x: keyof this = 'createdAt'; + } +} + + +//// [keyofGenericExtendingClassDoubleLayer.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Model = /** @class */ (function () { + function Model() { + } + return Model; +}()); +var AutoModel = /** @class */ (function (_super) { + __extends(AutoModel, _super); + function AutoModel() { + return _super !== null && _super.apply(this, arguments) || this; + } + return AutoModel; +}(Model)); +var PersonModel = /** @class */ (function (_super) { + __extends(PersonModel, _super); + function PersonModel() { + return _super !== null && _super.apply(this, arguments) || this; + } + PersonModel.prototype.toJson = function () { + var x = 'createdAt'; + }; + return PersonModel; +}(AutoModel)); diff --git a/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.symbols b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.symbols new file mode 100644 index 00000000000..55bb83666e5 --- /dev/null +++ b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts === +class Model { +>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0)) +>Attributes : Symbol(Attributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 12)) + + public createdAt: Date; +>createdAt : Symbol(Model.createdAt, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 31)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) +} + +type ModelAttributes = Omit; +>ModelAttributes : Symbol(ModelAttributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 2, 1)) +>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 21)) +>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 21)) +>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0)) + +class AutoModel extends Model> {} +>AutoModel : Symbol(AutoModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 47)) +>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 16)) +>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0)) +>ModelAttributes : Symbol(ModelAttributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 2, 1)) +>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 16)) + +class PersonModel extends AutoModel { +>PersonModel : Symbol(PersonModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 55)) +>AutoModel : Symbol(AutoModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 47)) +>PersonModel : Symbol(PersonModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 55)) + + public age: number; +>age : Symbol(PersonModel.age, Decl(keyofGenericExtendingClassDoubleLayer.ts, 8, 50)) + + toJson() { +>toJson : Symbol(PersonModel.toJson, Decl(keyofGenericExtendingClassDoubleLayer.ts, 9, 23)) + + let x: keyof this = 'createdAt'; +>x : Symbol(x, Decl(keyofGenericExtendingClassDoubleLayer.ts, 12, 11)) + } +} + diff --git a/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.types b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.types new file mode 100644 index 00000000000..d3108ac94a9 --- /dev/null +++ b/tests/baselines/reference/keyofGenericExtendingClassDoubleLayer.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts === +class Model { +>Model : Model + + public createdAt: Date; +>createdAt : Date +} + +type ModelAttributes = Omit; +>ModelAttributes : ModelAttributes + +class AutoModel extends Model> {} +>AutoModel : AutoModel +>Model : Model> + +class PersonModel extends AutoModel { +>PersonModel : PersonModel +>AutoModel : AutoModel + + public age: number; +>age : number + + toJson() { +>toJson : () => void + + let x: keyof this = 'createdAt'; +>x : keyof this +>'createdAt' : "createdAt" + } +} + diff --git a/tests/baselines/reference/mappedTypeRecursiveInference.errors.txt b/tests/baselines/reference/mappedTypeRecursiveInference.errors.txt deleted file mode 100644 index aff22c7e0b3..00000000000 --- a/tests/baselines/reference/mappedTypeRecursiveInference.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -tests/cases/compiler/mappedTypeRecursiveInference.ts(19,14): error TS2321: Excessive stack depth comparing types 'XMLHttpRequest' and 'Deep<{ onreadystatechange: unknown; readonly readyState: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly response: unknown; readonly responseText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; responseType: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseURL: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseXML: { readonly URL: any; alinkColor: any; readonly all: any; readonly anchors: any; readonly applets: any; bgColor: any; body: any; readonly characterSet: any; readonly charset: any; readonly compatMode: any; readonly contentType: any; cookie: any; readonly currentScript: any; readonly defaultView: any; designMode: any; dir: any; readonly doctype: any; readonly documentElement: any; readonly documentURI: any; domain: any; readonly embeds: any; fgColor: any; readonly forms: any; readonly fullscreen: any; readonly fullscreenEnabled: any; readonly head: any; readonly hidden: any; readonly images: any; readonly implementation: any; readonly inputEncoding: any; readonly lastModified: any; linkColor: any; readonly links: any; location: any; onfullscreenchange: any; onfullscreenerror: any; onpointerlockchange: any; onpointerlockerror: any; onreadystatechange: any; onvisibilitychange: any; readonly ownerDocument: any; readonly plugins: any; readonly readyState: any; readonly referrer: any; readonly scripts: any; readonly scrollingElement: any; readonly timeline: any; title: any; readonly visibilityState: any; vlinkColor: any; adoptNode: any; captureEvents: any; caretPositionFromPoint: any; caretRangeFromPoint: any; clear: any; close: any; createAttribute: any; createAttributeNS: any; createCDATASection: any; createComment: any; createDocumentFragment: any; createElement: any; createElementNS: any; createEvent: any; createNodeIterator: any; createProcessingInstruction: any; createRange: any; createTextNode: any; createTreeWalker: any; elementFromPoint: any; elementsFromPoint: any; execCommand: any; exitFullscreen: any; exitPointerLock: any; getAnimations: any; getElementById: any; getElementsByClassName: any; getElementsByName: any; getElementsByTagName: any; getElementsByTagNameNS: any; getSelection: any; hasFocus: any; importNode: any; open: any; queryCommandEnabled: any; queryCommandIndeterm: any; queryCommandState: any; queryCommandSupported: any; queryCommandValue: any; releaseEvents: any; write: any; writeln: any; addEventListener: any; removeEventListener: any; readonly baseURI: any; readonly childNodes: any; readonly firstChild: any; readonly isConnected: any; readonly lastChild: any; readonly namespaceURI: any; readonly nextSibling: any; readonly nodeName: any; readonly nodeType: any; nodeValue: any; readonly parentElement: any; readonly parentNode: any; readonly previousSibling: any; textContent: any; appendChild: any; cloneNode: any; compareDocumentPosition: any; contains: any; getRootNode: any; hasChildNodes: any; insertBefore: any; isDefaultNamespace: any; isEqualNode: any; isSameNode: any; lookupNamespaceURI: any; lookupPrefix: any; normalize: any; removeChild: any; replaceChild: any; readonly ATTRIBUTE_NODE: any; readonly CDATA_SECTION_NODE: any; readonly COMMENT_NODE: any; readonly DOCUMENT_FRAGMENT_NODE: any; readonly DOCUMENT_NODE: any; readonly DOCUMENT_POSITION_CONTAINED_BY: any; readonly DOCUMENT_POSITION_CONTAINS: any; readonly DOCUMENT_POSITION_DISCONNECTED: any; readonly DOCUMENT_POSITION_FOLLOWING: any; readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any; readonly DOCUMENT_POSITION_PRECEDING: any; readonly DOCUMENT_TYPE_NODE: any; readonly ELEMENT_NODE: any; readonly ENTITY_NODE: any; readonly ENTITY_REFERENCE_NODE: any; readonly NOTATION_NODE: any; readonly PROCESSING_INSTRUCTION_NODE: any; readonly TEXT_NODE: any; dispatchEvent: any; oncopy: any; oncut: any; onpaste: any; readonly activeElement: any; readonly fullscreenElement: any; readonly pointerLockElement: any; readonly styleSheets: any; onabort: any; onanimationcancel: any; onanimationend: any; onanimationiteration: any; onanimationstart: any; onauxclick: any; onblur: any; oncancel: any; oncanplay: any; oncanplaythrough: any; onchange: any; onclick: any; onclose: any; oncontextmenu: any; oncuechange: any; ondblclick: any; ondrag: any; ondragend: any; ondragenter: any; ondragexit: any; ondragleave: any; ondragover: any; ondragstart: any; ondrop: any; ondurationchange: any; onemptied: any; onended: any; onerror: any; onfocus: any; ongotpointercapture: any; oninput: any; oninvalid: any; onkeydown: any; onkeypress: any; onkeyup: any; onload: any; onloadeddata: any; onloadedmetadata: any; onloadstart: any; onlostpointercapture: any; onmousedown: any; onmouseenter: any; onmouseleave: any; onmousemove: any; onmouseout: any; onmouseover: any; onmouseup: any; onpause: any; onplay: any; onplaying: any; onpointercancel: any; onpointerdown: any; onpointerenter: any; onpointerleave: any; onpointermove: any; onpointerout: any; onpointerover: any; onpointerup: any; onprogress: any; onratechange: any; onreset: any; onresize: any; onscroll: any; onsecuritypolicyviolation: any; onseeked: any; onseeking: any; onselect: any; onselectionchange: any; onselectstart: any; onstalled: any; onsubmit: any; onsuspend: any; ontimeupdate: any; ontoggle: any; ontouchcancel?: any; ontouchend?: any; ontouchmove?: any; ontouchstart?: any; ontransitioncancel: any; ontransitionend: any; ontransitionrun: any; ontransitionstart: any; onvolumechange: any; onwaiting: any; onwheel: any; readonly childElementCount: any; readonly children: any; readonly firstElementChild: any; readonly lastElementChild: any; append: any; prepend: any; querySelector: any; querySelectorAll: any; createExpression: any; createNSResolver: any; evaluate: any; }; readonly status: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly statusText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; timeout: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly upload: { addEventListener: any; removeEventListener: any; onabort: any; onerror: any; onload: any; onloadend: any; onloadstart: any; onprogress: any; ontimeout: any; dispatchEvent: any; }; withCredentials: { valueOf: any; }; abort: unknown; getAllResponseHeaders: unknown; getResponseHeader: unknown; open: unknown; overrideMimeType: unknown; send: unknown; setRequestHeader: unknown; readonly DONE: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly HEADERS_RECEIVED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly LOADING: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly OPENED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly UNSENT: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; addEventListener: unknown; removeEventListener: unknown; onabort: unknown; onerror: unknown; onload: unknown; onloadend: unknown; onloadstart: unknown; onprogress: unknown; ontimeout: unknown; dispatchEvent: unknown; }>'. -tests/cases/compiler/mappedTypeRecursiveInference.ts(19,18): error TS2321: Excessive stack depth comparing types 'XMLHttpRequest' and 'Deep<{ onreadystatechange: unknown; readonly readyState: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly response: unknown; readonly responseText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; responseType: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseURL: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseXML: { readonly URL: any; alinkColor: any; readonly all: any; readonly anchors: any; readonly applets: any; bgColor: any; body: any; readonly characterSet: any; readonly charset: any; readonly compatMode: any; readonly contentType: any; cookie: any; readonly currentScript: any; readonly defaultView: any; designMode: any; dir: any; readonly doctype: any; readonly documentElement: any; readonly documentURI: any; domain: any; readonly embeds: any; fgColor: any; readonly forms: any; readonly fullscreen: any; readonly fullscreenEnabled: any; readonly head: any; readonly hidden: any; readonly images: any; readonly implementation: any; readonly inputEncoding: any; readonly lastModified: any; linkColor: any; readonly links: any; location: any; onfullscreenchange: any; onfullscreenerror: any; onpointerlockchange: any; onpointerlockerror: any; onreadystatechange: any; onvisibilitychange: any; readonly ownerDocument: any; readonly plugins: any; readonly readyState: any; readonly referrer: any; readonly scripts: any; readonly scrollingElement: any; readonly timeline: any; title: any; readonly visibilityState: any; vlinkColor: any; adoptNode: any; captureEvents: any; caretPositionFromPoint: any; caretRangeFromPoint: any; clear: any; close: any; createAttribute: any; createAttributeNS: any; createCDATASection: any; createComment: any; createDocumentFragment: any; createElement: any; createElementNS: any; createEvent: any; createNodeIterator: any; createProcessingInstruction: any; createRange: any; createTextNode: any; createTreeWalker: any; elementFromPoint: any; elementsFromPoint: any; execCommand: any; exitFullscreen: any; exitPointerLock: any; getAnimations: any; getElementById: any; getElementsByClassName: any; getElementsByName: any; getElementsByTagName: any; getElementsByTagNameNS: any; getSelection: any; hasFocus: any; importNode: any; open: any; queryCommandEnabled: any; queryCommandIndeterm: any; queryCommandState: any; queryCommandSupported: any; queryCommandValue: any; releaseEvents: any; write: any; writeln: any; addEventListener: any; removeEventListener: any; readonly baseURI: any; readonly childNodes: any; readonly firstChild: any; readonly isConnected: any; readonly lastChild: any; readonly namespaceURI: any; readonly nextSibling: any; readonly nodeName: any; readonly nodeType: any; nodeValue: any; readonly parentElement: any; readonly parentNode: any; readonly previousSibling: any; textContent: any; appendChild: any; cloneNode: any; compareDocumentPosition: any; contains: any; getRootNode: any; hasChildNodes: any; insertBefore: any; isDefaultNamespace: any; isEqualNode: any; isSameNode: any; lookupNamespaceURI: any; lookupPrefix: any; normalize: any; removeChild: any; replaceChild: any; readonly ATTRIBUTE_NODE: any; readonly CDATA_SECTION_NODE: any; readonly COMMENT_NODE: any; readonly DOCUMENT_FRAGMENT_NODE: any; readonly DOCUMENT_NODE: any; readonly DOCUMENT_POSITION_CONTAINED_BY: any; readonly DOCUMENT_POSITION_CONTAINS: any; readonly DOCUMENT_POSITION_DISCONNECTED: any; readonly DOCUMENT_POSITION_FOLLOWING: any; readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any; readonly DOCUMENT_POSITION_PRECEDING: any; readonly DOCUMENT_TYPE_NODE: any; readonly ELEMENT_NODE: any; readonly ENTITY_NODE: any; readonly ENTITY_REFERENCE_NODE: any; readonly NOTATION_NODE: any; readonly PROCESSING_INSTRUCTION_NODE: any; readonly TEXT_NODE: any; dispatchEvent: any; oncopy: any; oncut: any; onpaste: any; readonly activeElement: any; readonly fullscreenElement: any; readonly pointerLockElement: any; readonly styleSheets: any; onabort: any; onanimationcancel: any; onanimationend: any; onanimationiteration: any; onanimationstart: any; onauxclick: any; onblur: any; oncancel: any; oncanplay: any; oncanplaythrough: any; onchange: any; onclick: any; onclose: any; oncontextmenu: any; oncuechange: any; ondblclick: any; ondrag: any; ondragend: any; ondragenter: any; ondragexit: any; ondragleave: any; ondragover: any; ondragstart: any; ondrop: any; ondurationchange: any; onemptied: any; onended: any; onerror: any; onfocus: any; ongotpointercapture: any; oninput: any; oninvalid: any; onkeydown: any; onkeypress: any; onkeyup: any; onload: any; onloadeddata: any; onloadedmetadata: any; onloadstart: any; onlostpointercapture: any; onmousedown: any; onmouseenter: any; onmouseleave: any; onmousemove: any; onmouseout: any; onmouseover: any; onmouseup: any; onpause: any; onplay: any; onplaying: any; onpointercancel: any; onpointerdown: any; onpointerenter: any; onpointerleave: any; onpointermove: any; onpointerout: any; onpointerover: any; onpointerup: any; onprogress: any; onratechange: any; onreset: any; onresize: any; onscroll: any; onsecuritypolicyviolation: any; onseeked: any; onseeking: any; onselect: any; onselectionchange: any; onselectstart: any; onstalled: any; onsubmit: any; onsuspend: any; ontimeupdate: any; ontoggle: any; ontouchcancel?: any; ontouchend?: any; ontouchmove?: any; ontouchstart?: any; ontransitioncancel: any; ontransitionend: any; ontransitionrun: any; ontransitionstart: any; onvolumechange: any; onwaiting: any; onwheel: any; readonly childElementCount: any; readonly children: any; readonly firstElementChild: any; readonly lastElementChild: any; append: any; prepend: any; querySelector: any; querySelectorAll: any; createExpression: any; createNSResolver: any; evaluate: any; }; readonly status: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly statusText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; timeout: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly upload: { addEventListener: any; removeEventListener: any; onabort: any; onerror: any; onload: any; onloadend: any; onloadstart: any; onprogress: any; ontimeout: any; dispatchEvent: any; }; withCredentials: { valueOf: any; }; abort: unknown; getAllResponseHeaders: unknown; getResponseHeader: unknown; open: unknown; overrideMimeType: unknown; send: unknown; setRequestHeader: unknown; readonly DONE: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly HEADERS_RECEIVED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly LOADING: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly OPENED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly UNSENT: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; addEventListener: unknown; removeEventListener: unknown; onabort: unknown; onerror: unknown; onload: unknown; onloadend: unknown; onloadstart: unknown; onprogress: unknown; ontimeout: unknown; dispatchEvent: unknown; }>'. - - -==== tests/cases/compiler/mappedTypeRecursiveInference.ts (2 errors) ==== - interface A { a: A } - declare let a: A; - type Deep = { [K in keyof T]: Deep } - declare function foo(deep: Deep): T; - const out = foo(a); - out.a - out.a.a - out.a.a.a.a.a.a.a - - - interface B { [s: string]: B } - declare let b: B; - const oub = foo(b); - oub.b - oub.b.b - oub.b.a.n.a.n.a - - let xhr: XMLHttpRequest; - const out2 = foo(xhr); - ~~~~~~~~ -!!! error TS2321: Excessive stack depth comparing types 'XMLHttpRequest' and 'Deep<{ onreadystatechange: unknown; readonly readyState: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly response: unknown; readonly responseText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; responseType: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseURL: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseXML: { readonly URL: any; alinkColor: any; readonly all: any; readonly anchors: any; readonly applets: any; bgColor: any; body: any; readonly characterSet: any; readonly charset: any; readonly compatMode: any; readonly contentType: any; cookie: any; readonly currentScript: any; readonly defaultView: any; designMode: any; dir: any; readonly doctype: any; readonly documentElement: any; readonly documentURI: any; domain: any; readonly embeds: any; fgColor: any; readonly forms: any; readonly fullscreen: any; readonly fullscreenEnabled: any; readonly head: any; readonly hidden: any; readonly images: any; readonly implementation: any; readonly inputEncoding: any; readonly lastModified: any; linkColor: any; readonly links: any; location: any; onfullscreenchange: any; onfullscreenerror: any; onpointerlockchange: any; onpointerlockerror: any; onreadystatechange: any; onvisibilitychange: any; readonly ownerDocument: any; readonly plugins: any; readonly readyState: any; readonly referrer: any; readonly scripts: any; readonly scrollingElement: any; readonly timeline: any; title: any; readonly visibilityState: any; vlinkColor: any; adoptNode: any; captureEvents: any; caretPositionFromPoint: any; caretRangeFromPoint: any; clear: any; close: any; createAttribute: any; createAttributeNS: any; createCDATASection: any; createComment: any; createDocumentFragment: any; createElement: any; createElementNS: any; createEvent: any; createNodeIterator: any; createProcessingInstruction: any; createRange: any; createTextNode: any; createTreeWalker: any; elementFromPoint: any; elementsFromPoint: any; execCommand: any; exitFullscreen: any; exitPointerLock: any; getAnimations: any; getElementById: any; getElementsByClassName: any; getElementsByName: any; getElementsByTagName: any; getElementsByTagNameNS: any; getSelection: any; hasFocus: any; importNode: any; open: any; queryCommandEnabled: any; queryCommandIndeterm: any; queryCommandState: any; queryCommandSupported: any; queryCommandValue: any; releaseEvents: any; write: any; writeln: any; addEventListener: any; removeEventListener: any; readonly baseURI: any; readonly childNodes: any; readonly firstChild: any; readonly isConnected: any; readonly lastChild: any; readonly namespaceURI: any; readonly nextSibling: any; readonly nodeName: any; readonly nodeType: any; nodeValue: any; readonly parentElement: any; readonly parentNode: any; readonly previousSibling: any; textContent: any; appendChild: any; cloneNode: any; compareDocumentPosition: any; contains: any; getRootNode: any; hasChildNodes: any; insertBefore: any; isDefaultNamespace: any; isEqualNode: any; isSameNode: any; lookupNamespaceURI: any; lookupPrefix: any; normalize: any; removeChild: any; replaceChild: any; readonly ATTRIBUTE_NODE: any; readonly CDATA_SECTION_NODE: any; readonly COMMENT_NODE: any; readonly DOCUMENT_FRAGMENT_NODE: any; readonly DOCUMENT_NODE: any; readonly DOCUMENT_POSITION_CONTAINED_BY: any; readonly DOCUMENT_POSITION_CONTAINS: any; readonly DOCUMENT_POSITION_DISCONNECTED: any; readonly DOCUMENT_POSITION_FOLLOWING: any; readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any; readonly DOCUMENT_POSITION_PRECEDING: any; readonly DOCUMENT_TYPE_NODE: any; readonly ELEMENT_NODE: any; readonly ENTITY_NODE: any; readonly ENTITY_REFERENCE_NODE: any; readonly NOTATION_NODE: any; readonly PROCESSING_INSTRUCTION_NODE: any; readonly TEXT_NODE: any; dispatchEvent: any; oncopy: any; oncut: any; onpaste: any; readonly activeElement: any; readonly fullscreenElement: any; readonly pointerLockElement: any; readonly styleSheets: any; onabort: any; onanimationcancel: any; onanimationend: any; onanimationiteration: any; onanimationstart: any; onauxclick: any; onblur: any; oncancel: any; oncanplay: any; oncanplaythrough: any; onchange: any; onclick: any; onclose: any; oncontextmenu: any; oncuechange: any; ondblclick: any; ondrag: any; ondragend: any; ondragenter: any; ondragexit: any; ondragleave: any; ondragover: any; ondragstart: any; ondrop: any; ondurationchange: any; onemptied: any; onended: any; onerror: any; onfocus: any; ongotpointercapture: any; oninput: any; oninvalid: any; onkeydown: any; onkeypress: any; onkeyup: any; onload: any; onloadeddata: any; onloadedmetadata: any; onloadstart: any; onlostpointercapture: any; onmousedown: any; onmouseenter: any; onmouseleave: any; onmousemove: any; onmouseout: any; onmouseover: any; onmouseup: any; onpause: any; onplay: any; onplaying: any; onpointercancel: any; onpointerdown: any; onpointerenter: any; onpointerleave: any; onpointermove: any; onpointerout: any; onpointerover: any; onpointerup: any; onprogress: any; onratechange: any; onreset: any; onresize: any; onscroll: any; onsecuritypolicyviolation: any; onseeked: any; onseeking: any; onselect: any; onselectionchange: any; onselectstart: any; onstalled: any; onsubmit: any; onsuspend: any; ontimeupdate: any; ontoggle: any; ontouchcancel?: any; ontouchend?: any; ontouchmove?: any; ontouchstart?: any; ontransitioncancel: any; ontransitionend: any; ontransitionrun: any; ontransitionstart: any; onvolumechange: any; onwaiting: any; onwheel: any; readonly childElementCount: any; readonly children: any; readonly firstElementChild: any; readonly lastElementChild: any; append: any; prepend: any; querySelector: any; querySelectorAll: any; createExpression: any; createNSResolver: any; evaluate: any; }; readonly status: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly statusText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; timeout: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly upload: { addEventListener: any; removeEventListener: any; onabort: any; onerror: any; onload: any; onloadend: any; onloadstart: any; onprogress: any; ontimeout: any; dispatchEvent: any; }; withCredentials: { valueOf: any; }; abort: unknown; getAllResponseHeaders: unknown; getResponseHeader: unknown; open: unknown; overrideMimeType: unknown; send: unknown; setRequestHeader: unknown; readonly DONE: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly HEADERS_RECEIVED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly LOADING: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly OPENED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly UNSENT: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; addEventListener: unknown; removeEventListener: unknown; onabort: unknown; onerror: unknown; onload: unknown; onloadend: unknown; onloadstart: unknown; onprogress: unknown; ontimeout: unknown; dispatchEvent: unknown; }>'. - ~~~ -!!! error TS2321: Excessive stack depth comparing types 'XMLHttpRequest' and 'Deep<{ onreadystatechange: unknown; readonly readyState: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly response: unknown; readonly responseText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; responseType: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseURL: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; readonly responseXML: { readonly URL: any; alinkColor: any; readonly all: any; readonly anchors: any; readonly applets: any; bgColor: any; body: any; readonly characterSet: any; readonly charset: any; readonly compatMode: any; readonly contentType: any; cookie: any; readonly currentScript: any; readonly defaultView: any; designMode: any; dir: any; readonly doctype: any; readonly documentElement: any; readonly documentURI: any; domain: any; readonly embeds: any; fgColor: any; readonly forms: any; readonly fullscreen: any; readonly fullscreenEnabled: any; readonly head: any; readonly hidden: any; readonly images: any; readonly implementation: any; readonly inputEncoding: any; readonly lastModified: any; linkColor: any; readonly links: any; location: any; onfullscreenchange: any; onfullscreenerror: any; onpointerlockchange: any; onpointerlockerror: any; onreadystatechange: any; onvisibilitychange: any; readonly ownerDocument: any; readonly plugins: any; readonly readyState: any; readonly referrer: any; readonly scripts: any; readonly scrollingElement: any; readonly timeline: any; title: any; readonly visibilityState: any; vlinkColor: any; adoptNode: any; captureEvents: any; caretPositionFromPoint: any; caretRangeFromPoint: any; clear: any; close: any; createAttribute: any; createAttributeNS: any; createCDATASection: any; createComment: any; createDocumentFragment: any; createElement: any; createElementNS: any; createEvent: any; createNodeIterator: any; createProcessingInstruction: any; createRange: any; createTextNode: any; createTreeWalker: any; elementFromPoint: any; elementsFromPoint: any; execCommand: any; exitFullscreen: any; exitPointerLock: any; getAnimations: any; getElementById: any; getElementsByClassName: any; getElementsByName: any; getElementsByTagName: any; getElementsByTagNameNS: any; getSelection: any; hasFocus: any; importNode: any; open: any; queryCommandEnabled: any; queryCommandIndeterm: any; queryCommandState: any; queryCommandSupported: any; queryCommandValue: any; releaseEvents: any; write: any; writeln: any; addEventListener: any; removeEventListener: any; readonly baseURI: any; readonly childNodes: any; readonly firstChild: any; readonly isConnected: any; readonly lastChild: any; readonly namespaceURI: any; readonly nextSibling: any; readonly nodeName: any; readonly nodeType: any; nodeValue: any; readonly parentElement: any; readonly parentNode: any; readonly previousSibling: any; textContent: any; appendChild: any; cloneNode: any; compareDocumentPosition: any; contains: any; getRootNode: any; hasChildNodes: any; insertBefore: any; isDefaultNamespace: any; isEqualNode: any; isSameNode: any; lookupNamespaceURI: any; lookupPrefix: any; normalize: any; removeChild: any; replaceChild: any; readonly ATTRIBUTE_NODE: any; readonly CDATA_SECTION_NODE: any; readonly COMMENT_NODE: any; readonly DOCUMENT_FRAGMENT_NODE: any; readonly DOCUMENT_NODE: any; readonly DOCUMENT_POSITION_CONTAINED_BY: any; readonly DOCUMENT_POSITION_CONTAINS: any; readonly DOCUMENT_POSITION_DISCONNECTED: any; readonly DOCUMENT_POSITION_FOLLOWING: any; readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any; readonly DOCUMENT_POSITION_PRECEDING: any; readonly DOCUMENT_TYPE_NODE: any; readonly ELEMENT_NODE: any; readonly ENTITY_NODE: any; readonly ENTITY_REFERENCE_NODE: any; readonly NOTATION_NODE: any; readonly PROCESSING_INSTRUCTION_NODE: any; readonly TEXT_NODE: any; dispatchEvent: any; oncopy: any; oncut: any; onpaste: any; readonly activeElement: any; readonly fullscreenElement: any; readonly pointerLockElement: any; readonly styleSheets: any; onabort: any; onanimationcancel: any; onanimationend: any; onanimationiteration: any; onanimationstart: any; onauxclick: any; onblur: any; oncancel: any; oncanplay: any; oncanplaythrough: any; onchange: any; onclick: any; onclose: any; oncontextmenu: any; oncuechange: any; ondblclick: any; ondrag: any; ondragend: any; ondragenter: any; ondragexit: any; ondragleave: any; ondragover: any; ondragstart: any; ondrop: any; ondurationchange: any; onemptied: any; onended: any; onerror: any; onfocus: any; ongotpointercapture: any; oninput: any; oninvalid: any; onkeydown: any; onkeypress: any; onkeyup: any; onload: any; onloadeddata: any; onloadedmetadata: any; onloadstart: any; onlostpointercapture: any; onmousedown: any; onmouseenter: any; onmouseleave: any; onmousemove: any; onmouseout: any; onmouseover: any; onmouseup: any; onpause: any; onplay: any; onplaying: any; onpointercancel: any; onpointerdown: any; onpointerenter: any; onpointerleave: any; onpointermove: any; onpointerout: any; onpointerover: any; onpointerup: any; onprogress: any; onratechange: any; onreset: any; onresize: any; onscroll: any; onsecuritypolicyviolation: any; onseeked: any; onseeking: any; onselect: any; onselectionchange: any; onselectstart: any; onstalled: any; onsubmit: any; onsuspend: any; ontimeupdate: any; ontoggle: any; ontouchcancel?: any; ontouchend?: any; ontouchmove?: any; ontouchstart?: any; ontransitioncancel: any; ontransitionend: any; ontransitionrun: any; ontransitionstart: any; onvolumechange: any; onwaiting: any; onwheel: any; readonly childElementCount: any; readonly children: any; readonly firstElementChild: any; readonly lastElementChild: any; append: any; prepend: any; querySelector: any; querySelectorAll: any; createExpression: any; createNSResolver: any; evaluate: any; }; readonly status: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly statusText: { toString: any; charAt: any; charCodeAt: any; concat: any; indexOf: any; lastIndexOf: any; localeCompare: any; match: any; replace: any; search: any; slice: any; split: any; substring: any; toLowerCase: any; toLocaleLowerCase: any; toUpperCase: any; toLocaleUpperCase: any; trim: any; readonly length: any; substr: any; valueOf: any; codePointAt: any; includes: any; endsWith: any; normalize: any; repeat: any; startsWith: any; anchor: any; big: any; blink: any; bold: any; fixed: any; fontcolor: any; fontsize: any; italics: any; link: any; small: any; strike: any; sub: any; sup: any; [Symbol.iterator]: any; }; timeout: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly upload: { addEventListener: any; removeEventListener: any; onabort: any; onerror: any; onload: any; onloadend: any; onloadstart: any; onprogress: any; ontimeout: any; dispatchEvent: any; }; withCredentials: { valueOf: any; }; abort: unknown; getAllResponseHeaders: unknown; getResponseHeader: unknown; open: unknown; overrideMimeType: unknown; send: unknown; setRequestHeader: unknown; readonly DONE: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly HEADERS_RECEIVED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly LOADING: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly OPENED: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; readonly UNSENT: { toString: any; toFixed: any; toExponential: any; toPrecision: any; valueOf: any; toLocaleString: any; }; addEventListener: unknown; removeEventListener: unknown; onabort: unknown; onerror: unknown; onload: unknown; onloadend: unknown; onloadstart: unknown; onprogress: unknown; ontimeout: unknown; dispatchEvent: unknown; }>'. - out2.responseXML - out2.responseXML.activeElement.className.length - \ No newline at end of file diff --git a/tests/baselines/reference/missingCloseBracketInArray.errors.txt b/tests/baselines/reference/missingCloseBracketInArray.errors.txt new file mode 100644 index 00000000000..26801c02812 --- /dev/null +++ b/tests/baselines/reference/missingCloseBracketInArray.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/missingCloseBracketInArray.ts(1,48): error TS1005: ']' expected. + + +==== tests/cases/compiler/missingCloseBracketInArray.ts (1 errors) ==== + var alphas:string[] = alphas = ["1","2","3","4" + +!!! error TS1005: ']' expected. +!!! related TS1007 tests/cases/compiler/missingCloseBracketInArray.ts:1:32: The parser expected to find a ']' to match the '[' token here. \ No newline at end of file diff --git a/tests/baselines/reference/missingCloseBracketInArray.js b/tests/baselines/reference/missingCloseBracketInArray.js new file mode 100644 index 00000000000..cb842d1cc74 --- /dev/null +++ b/tests/baselines/reference/missingCloseBracketInArray.js @@ -0,0 +1,5 @@ +//// [missingCloseBracketInArray.ts] +var alphas:string[] = alphas = ["1","2","3","4" + +//// [missingCloseBracketInArray.js] +var alphas = alphas = ["1", "2", "3", "4"]; diff --git a/tests/baselines/reference/missingCloseBracketInArray.symbols b/tests/baselines/reference/missingCloseBracketInArray.symbols new file mode 100644 index 00000000000..4d28f8945fd --- /dev/null +++ b/tests/baselines/reference/missingCloseBracketInArray.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/missingCloseBracketInArray.ts === +var alphas:string[] = alphas = ["1","2","3","4" +>alphas : Symbol(alphas, Decl(missingCloseBracketInArray.ts, 0, 3)) +>alphas : Symbol(alphas, Decl(missingCloseBracketInArray.ts, 0, 3)) + diff --git a/tests/baselines/reference/missingCloseBracketInArray.types b/tests/baselines/reference/missingCloseBracketInArray.types new file mode 100644 index 00000000000..557a865827c --- /dev/null +++ b/tests/baselines/reference/missingCloseBracketInArray.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/missingCloseBracketInArray.ts === +var alphas:string[] = alphas = ["1","2","3","4" +>alphas : string[] +>alphas = ["1","2","3","4" : string[] +>alphas : string[] +>["1","2","3","4" : string[] +>"1" : "1" +>"2" : "2" +>"3" : "3" +>"4" : "4" + diff --git a/tests/baselines/reference/missingCloseParenStatements.errors.txt b/tests/baselines/reference/missingCloseParenStatements.errors.txt new file mode 100644 index 00000000000..3f49d5a0366 --- /dev/null +++ b/tests/baselines/reference/missingCloseParenStatements.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/missingCloseParenStatements.ts(2,26): error TS1005: ')' expected. +tests/cases/compiler/missingCloseParenStatements.ts(4,5): error TS1005: ')' expected. +tests/cases/compiler/missingCloseParenStatements.ts(8,39): error TS1005: ')' expected. +tests/cases/compiler/missingCloseParenStatements.ts(11,35): error TS1005: ')' expected. + + +==== tests/cases/compiler/missingCloseParenStatements.ts (4 errors) ==== + var a1, a2, a3 = 0; + if ( a1 && (a2 + a3 > 0) { + ~ +!!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:2:4: The parser expected to find a ')' to match the '(' token here. + while( (a2 > 0) && a1 + { + ~ +!!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:3:10: The parser expected to find a ')' to match the '(' token here. + do { + var i = i + 1; + a1 = a1 + i; + with ((a2 + a3 > 0) && a1 { + ~ +!!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:8:18: The parser expected to find a ')' to match the '(' token here. + console.log(x); + } + } while (i < 5 && (a1 > 5); + ~ +!!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:11:17: The parser expected to find a ')' to match the '(' token here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/missingCloseParenStatements.js b/tests/baselines/reference/missingCloseParenStatements.js new file mode 100644 index 00000000000..8ba56b6b881 --- /dev/null +++ b/tests/baselines/reference/missingCloseParenStatements.js @@ -0,0 +1,28 @@ +//// [missingCloseParenStatements.ts] +var a1, a2, a3 = 0; +if ( a1 && (a2 + a3 > 0) { + while( (a2 > 0) && a1 + { + do { + var i = i + 1; + a1 = a1 + i; + with ((a2 + a3 > 0) && a1 { + console.log(x); + } + } while (i < 5 && (a1 > 5); + } +} + +//// [missingCloseParenStatements.js] +var a1, a2, a3 = 0; +if (a1 && (a2 + a3 > 0)) { + while ((a2 > 0) && a1) { + do { + var i = i + 1; + a1 = a1 + i; + with ((a2 + a3 > 0) && a1) { + console.log(x); + } + } while (i < 5 && (a1 > 5)); + } +} diff --git a/tests/baselines/reference/missingCloseParenStatements.symbols b/tests/baselines/reference/missingCloseParenStatements.symbols new file mode 100644 index 00000000000..e403570f8e8 --- /dev/null +++ b/tests/baselines/reference/missingCloseParenStatements.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/missingCloseParenStatements.ts === +var a1, a2, a3 = 0; +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) +>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7)) +>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11)) + +if ( a1 && (a2 + a3 > 0) { +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) +>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7)) +>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11)) + + while( (a2 > 0) && a1 +>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7)) +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) + { + do { + var i = i + 1; +>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15)) +>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15)) + + a1 = a1 + i; +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) +>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15)) + + with ((a2 + a3 > 0) && a1 { +>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7)) +>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11)) +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) + + console.log(x); + } + } while (i < 5 && (a1 > 5); +>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15)) +>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3)) + } +} diff --git a/tests/baselines/reference/missingCloseParenStatements.types b/tests/baselines/reference/missingCloseParenStatements.types new file mode 100644 index 00000000000..0d1b7469f60 --- /dev/null +++ b/tests/baselines/reference/missingCloseParenStatements.types @@ -0,0 +1,67 @@ +=== tests/cases/compiler/missingCloseParenStatements.ts === +var a1, a2, a3 = 0; +>a1 : any +>a2 : any +>a3 : number +>0 : 0 + +if ( a1 && (a2 + a3 > 0) { +>a1 && (a2 + a3 > 0) : boolean +>a1 : any +>(a2 + a3 > 0) : boolean +>a2 + a3 > 0 : boolean +>a2 + a3 : any +>a2 : any +>a3 : number +>0 : 0 + + while( (a2 > 0) && a1 +>(a2 > 0) && a1 : any +>(a2 > 0) : boolean +>a2 > 0 : boolean +>a2 : any +>0 : 0 +>a1 : any + { + do { + var i = i + 1; +>i : any +>i + 1 : any +>i : any +>1 : 1 + + a1 = a1 + i; +>a1 = a1 + i : any +>a1 : any +>a1 + i : any +>a1 : any +>i : any + + with ((a2 + a3 > 0) && a1 { +>(a2 + a3 > 0) && a1 : any +>(a2 + a3 > 0) : boolean +>a2 + a3 > 0 : boolean +>a2 + a3 : any +>a2 : any +>a3 : number +>0 : 0 +>a1 : any + + console.log(x); +>console.log(x) : any +>console.log : any +>console : any +>log : any +>x : any + } + } while (i < 5 && (a1 > 5); +>i < 5 && (a1 > 5) : boolean +>i < 5 : boolean +>i : any +>5 : 5 +>(a1 > 5) : boolean +>a1 > 5 : boolean +>a1 : any +>5 : 5 + } +} diff --git a/tests/baselines/reference/nestedClassDeclaration.errors.txt b/tests/baselines/reference/nestedClassDeclaration.errors.txt index 5540ee02437..f897c38d681 100644 --- a/tests/baselines/reference/nestedClassDeclaration.errors.txt +++ b/tests/baselines/reference/nestedClassDeclaration.errors.txt @@ -32,7 +32,6 @@ tests/cases/conformance/classes/nestedClassDeclaration.ts(17,1): error TS1128: D !!! error TS2304: Cannot find name 'C4'. ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/classes/nestedClassDeclaration.ts:14:9: The parser expected to find a '}' to match the '{' token here. } } ~ diff --git a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt index 651c0b66df7..544bddafff2 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt @@ -9,5 +9,4 @@ tests/cases/compiler/objectLiteralWithSemicolons4.ts(3,1): error TS1005: ',' exp !!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ; ~ -!!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/compiler/objectLiteralWithSemicolons4.ts:1:9: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index 692fb7617da..b37200c4f02 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -28,7 +28,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error T !!! error TS2304: Cannot find name 'matchMedia'. ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts:3:10: The parser expected to find a '}' to match the '{' token here. ~ !!! error TS1128: Declaration or statement expected. let o10 = { ...get x() { return 12; }}; diff --git a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt index bc43cd5b776..2cf728848e4 100644 --- a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt +++ b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt @@ -25,7 +25,6 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Decl m(n: number) => string { ~~ !!! error TS1005: '{' expected. -!!! related TS1007 tests/cases/compiler/parseErrorIncorrectReturnToken.ts:8:9: The parser expected to find a '}' to match the '{' token here. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ diff --git a/tests/baselines/reference/parserErrorRecoveryIfStatement2.errors.txt b/tests/baselines/reference/parserErrorRecoveryIfStatement2.errors.txt index 45dd9935a62..b88c48182a2 100644 --- a/tests/baselines/reference/parserErrorRecoveryIfStatement2.errors.txt +++ b/tests/baselines/reference/parserErrorRecoveryIfStatement2.errors.txt @@ -11,6 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErro } ~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement2.ts:3:8: The parser expected to find a ')' to match the '(' token here. f2() { } f3() { diff --git a/tests/baselines/reference/parserErrorRecoveryIfStatement3.errors.txt b/tests/baselines/reference/parserErrorRecoveryIfStatement3.errors.txt index 631cdb08a90..cfd645e5925 100644 --- a/tests/baselines/reference/parserErrorRecoveryIfStatement3.errors.txt +++ b/tests/baselines/reference/parserErrorRecoveryIfStatement3.errors.txt @@ -11,6 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErro } ~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement3.ts:3:8: The parser expected to find a ')' to match the '(' token here. f2() { } f3() { diff --git a/tests/baselines/reference/parserFuzz1.errors.txt b/tests/baselines/reference/parserFuzz1.errors.txt index e11d25c48fa..e90dda55244 100644 --- a/tests/baselines/reference/parserFuzz1.errors.txt +++ b/tests/baselines/reference/parserFuzz1.errors.txt @@ -20,5 +20,4 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): e ~~~~~~ !!! error TS1005: ';' expected. -!!! error TS1005: '{' expected. -!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts:1:9: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! error TS1005: '{' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt index 690604a7b30..15aa8a4bfc1 100644 --- a/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt +++ b/tests/baselines/reference/parserUnfinishedTypeNameBeforeKeyword1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2812: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,20): error TS1003: Identifier expected. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (2 errors) ==== var x: TypeModule1. ~~~~~~~~~~~ -!!! error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? +!!! error TS2812: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2? !!! error TS1003: Identifier expected. module TypeModule2 { diff --git a/tests/baselines/reference/primaryExpressionMods.errors.txt b/tests/baselines/reference/primaryExpressionMods.errors.txt index c947aaf0c6c..1ee38934dea 100644 --- a/tests/baselines/reference/primaryExpressionMods.errors.txt +++ b/tests/baselines/reference/primaryExpressionMods.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/primaryExpressionMods.ts(7,8): error TS2709: Cannot use namespace 'M' as a type. -tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M? +tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2812: Cannot find namespace 'm'. Did you mean 'M? ==== tests/cases/compiler/primaryExpressionMods.ts (2 errors) ==== @@ -17,6 +17,6 @@ tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2811: Cannot find n var x2 = m.a; // Same as M.a var q: m.P; // Error ~ -!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M? +!!! error TS2812: Cannot find namespace 'm'. Did you mean 'M? !!! related TS2728 tests/cases/compiler/primaryExpressionMods.ts:1:8: 'M' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/quickInfoInheritedLinkTag.baseline b/tests/baselines/reference/quickInfoInheritedLinkTag.baseline new file mode 100644 index 00000000000..52047ab8870 --- /dev/null +++ b/tests/baselines/reference/quickInfoInheritedLinkTag.baseline @@ -0,0 +1,111 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoInheritedLinkTag.ts", + "position": 258, + "name": "" + }, + "quickInfo": { + "kind": "method", + "kindModifiers": "deprecated", + "textSpan": { + "start": 257, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "C", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "m", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "Use ", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "PerspectiveCamera#setFocalLength .setFocalLength()", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " and ", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "PerspectiveCamera#filmGauge .filmGauge", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " instead.", + "kind": "text" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.errors.txt b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.errors.txt deleted file mode 100644 index 63e1868ce8f..00000000000 --- a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.errors.txt +++ /dev/null @@ -1,279 +0,0 @@ -tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts(76,50): error TS2344: Type 'GetProps' does not satisfy the constraint 'Shared>'. - Type 'unknown' is not assignable to type 'Shared>'. - Type 'Matching>' is not assignable to type 'Shared>'. - Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. - Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - - -==== tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts (1 errors) ==== - declare class Component

{ - constructor(props: Readonly

); - constructor(props: P, context?: any); - readonly props: Readonly

& Readonly<{ children?: {} }>; - } - interface ComponentClass

{ - new (props: P, context?: any): Component

; - propTypes?: WeakValidationMap

; - defaultProps?: Partial

; - displayName?: string; - } - interface FunctionComponent

{ - (props: P & { children?: {} }, context?: any): {} | null; - propTypes?: WeakValidationMap

; - defaultProps?: Partial

; - displayName?: string; - } - - declare const nominalTypeHack: unique symbol; - interface Validator { - ( - props: object, - propName: string, - componentName: string, - location: string, - propFullName: string - ): Error | null; - [nominalTypeHack]?: T; - } - type WeakValidationMap = { - [K in keyof T]?: null extends T[K] - ? Validator - : undefined extends T[K] - ? Validator - : Validator - }; - type ComponentType

= ComponentClass

| FunctionComponent

; - - type Shared< - InjectedProps, - DecorationTargetProps extends Shared - > = { - [P in Extract< - keyof InjectedProps, - keyof DecorationTargetProps - >]?: InjectedProps[P] extends DecorationTargetProps[P] - ? DecorationTargetProps[P] - : never - }; - - // Infers prop type from component C - type GetProps = C extends ComponentType ? P : never; - - type ConnectedComponentClass, P> = ComponentClass< - P - > & { - WrappedComponent: C; - }; - - type Matching = { - [P in keyof DecorationTargetProps]: P extends keyof InjectedProps - ? InjectedProps[P] extends DecorationTargetProps[P] - ? DecorationTargetProps[P] - : InjectedProps[P] - : DecorationTargetProps[P] - }; - - type Omit = Pick>; - - type InferableComponentEnhancerWithProps = < - C extends ComponentType>> - >( - component: C - ) => ConnectedComponentClass< - C, - Omit, keyof Shared>> & TNeedsProps - ~~~~~~~~~~~ -!!! error TS2344: Type 'GetProps' does not satisfy the constraint 'Shared>'. -!!! error TS2344: Type 'unknown' is not assignable to type 'Shared>'. -!!! error TS2344: Type 'Matching>' is not assignable to type 'Shared>'. -!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]) | (Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>])' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never) | undefined'. -!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps[keyof TInjectedProps & string] ? GetProps[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'keyof GetProps & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string] : GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]) | GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] extends GetProps[keyof TInjectedProps & keyof GetProps & string] ? GetProps[keyof TInjectedProps & keyof GetProps & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string] | GetProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]) | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] extends GetProps[keyof TInjectedProps & Extract>] ? GetProps[keyof TInjectedProps & Extract>] : TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>] | GetProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'Extract> extends keyof TInjectedProps ? TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>] : GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>] | (TInjectedProps[Extract>] extends GetProps[Extract>] ? GetProps[Extract>] : TInjectedProps[Extract>])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P] : GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P] | (TInjectedProps[P] extends GetProps[P] ? GetProps[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[P]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>] | GetProps[Extract>] | GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[Extract>]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[keyof GetProps & string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. -!!! error TS2344: Type 'GetProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps[P] ? GetProps[P] : never'. - >; - - declare const connect: { - ( - mapStateToProps: null | undefined, - mapDispatchToProps: TDispatchProps - ): InferableComponentEnhancerWithProps< - ResolveThunks, - TOwnProps - >; - }; - - type InferThunkActionCreatorType< - TActionCreator extends (...args: any[]) => any - > = TActionCreator extends ( - ...args: infer TParams - ) => (...args: any[]) => infer TReturn - ? (...args: TParams) => TReturn - : TActionCreator; - - type HandleThunkActionCreator = TActionCreator extends ( - ...args: any[] - ) => any - ? InferThunkActionCreatorType - : TActionCreator; - - type ResolveThunks = TDispatchProps extends { - [key: string]: any; - } - ? { [C in keyof TDispatchProps]: HandleThunkActionCreator } - : TDispatchProps; - - interface Dispatch { - (action: T): T; - } - interface Action { - type: T; - } - interface AnyAction extends Action { - [extraProps: string]: any; - } - - const simpleAction = (payload: boolean) => ({ - type: "SIMPLE_ACTION", - payload - }); - const thunkAction = (param1: number, param2: string) => async ( - dispatch: Dispatch, - { foo }: OwnProps - ) => { - return foo; - }; - interface OwnProps { - foo: string; - } - interface TestComponentProps extends OwnProps { - simpleAction: typeof simpleAction; - thunkAction(param1: number, param2: string): Promise; - } - class TestComponent extends Component {} - const mapDispatchToProps = { simpleAction, thunkAction }; - - type Q = HandleThunkActionCreator; - - const Test1 = connect( - null, - mapDispatchToProps - )(TestComponent); - - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/redeclaredProperty.errors.txt b/tests/baselines/reference/redeclaredProperty.errors.txt new file mode 100644 index 00000000000..331e5610f8d --- /dev/null +++ b/tests/baselines/reference/redeclaredProperty.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts(7,12): error TS2729: Property 'b' is used before its initialization. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts (1 errors) ==== + class Base { + b = 1; + } + + class Derived extends Base { + b; + d = this.b; + ~ +!!! error TS2729: Property 'b' is used before its initialization. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts:6:3: 'b' is declared here. + + constructor() { + super(); + this.b = 2; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/redeclaredProperty.js b/tests/baselines/reference/redeclaredProperty.js new file mode 100644 index 00000000000..20af007d62e --- /dev/null +++ b/tests/baselines/reference/redeclaredProperty.js @@ -0,0 +1,28 @@ +//// [redeclaredProperty.ts] +class Base { + b = 1; +} + +class Derived extends Base { + b; + d = this.b; + + constructor() { + super(); + this.b = 2; + } +} + + +//// [redeclaredProperty.js] +class Base { + b = 1; +} +class Derived extends Base { + b; + d = this.b; + constructor() { + super(); + this.b = 2; + } +} diff --git a/tests/baselines/reference/redefinedPararameterProperty.errors.txt b/tests/baselines/reference/redefinedPararameterProperty.errors.txt new file mode 100644 index 00000000000..65763261152 --- /dev/null +++ b/tests/baselines/reference/redefinedPararameterProperty.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts(6,14): error TS2729: Property 'a' is used before its initialization. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts (1 errors) ==== + class Base { + a = 1; + } + + class Derived extends Base { + b = this.a /*undefined*/; + ~ +!!! error TS2729: Property 'a' is used before its initialization. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts:8:17: 'a' is declared here. + + constructor(public a: number) { + super(); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/redefinedPararameterProperty.js b/tests/baselines/reference/redefinedPararameterProperty.js new file mode 100644 index 00000000000..8ad9b5facc0 --- /dev/null +++ b/tests/baselines/reference/redefinedPararameterProperty.js @@ -0,0 +1,26 @@ +//// [redefinedPararameterProperty.ts] +class Base { + a = 1; + } + + class Derived extends Base { + b = this.a /*undefined*/; + + constructor(public a: number) { + super(); + } + } + + +//// [redefinedPararameterProperty.js] +class Base { + a = 1; +} +class Derived extends Base { + a; + b = this.a /*undefined*/; + constructor(a) { + super(); + this.a = a; + } +} diff --git a/tests/baselines/reference/redefinedPararameterProperty.symbols b/tests/baselines/reference/redefinedPararameterProperty.symbols new file mode 100644 index 00000000000..5e05041f539 --- /dev/null +++ b/tests/baselines/reference/redefinedPararameterProperty.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/redefinedPararameterProperty.types b/tests/baselines/reference/redefinedPararameterProperty.types new file mode 100644 index 00000000000..5e05041f539 --- /dev/null +++ b/tests/baselines/reference/redefinedPararameterProperty.types @@ -0,0 +1,3 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 599010b4368..6ecb9471631 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -45,6 +45,7 @@ tests/cases/compiler/reservedWords2.ts(12,17): error TS1138: Parameter declarati !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/reservedWords2.ts:1:14: The parser expected to find a ')' to match the '(' token here. import * as while from "foo" !!! error TS2300: Duplicate identifier '(Missing)'. @@ -58,6 +59,7 @@ tests/cases/compiler/reservedWords2.ts(12,17): error TS1138: Parameter declarati !!! error TS2304: Cannot find name 'from'. ~~~~~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/compiler/reservedWords2.ts:2:20: The parser expected to find a ')' to match the '(' token here. var typeof = 10; ~~~~~~ diff --git a/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.js b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.js new file mode 100644 index 00000000000..aee2773df36 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.js @@ -0,0 +1,82 @@ +//// [reverseMappedTypeDeepDeclarationEmit.ts] +export type Validator = NativeTypeValidator | ObjectValidator + +export type NativeTypeValidator = (n: any) => T | undefined +export type ObjectValidator = { + [K in keyof O]: Validator +} + +//native validators +export declare const SimpleStringValidator: NativeTypeValidator; + +///object validator function +export declare const ObjValidator: (validatorObj: ObjectValidator) => (o: any) => V; + +export const test = { + Test: { + Test1: { + Test2: SimpleStringValidator + }, + } +} + +export const validatorFunc = ObjValidator(test); +export const outputExample = validatorFunc({ + Test: { + Test1: { + Test2: "hi" + }, + } +}); + + +//// [reverseMappedTypeDeepDeclarationEmit.js] +"use strict"; +exports.__esModule = true; +exports.outputExample = exports.validatorFunc = exports.test = void 0; +exports.test = { + Test: { + Test1: { + Test2: exports.SimpleStringValidator + } + } +}; +exports.validatorFunc = (0, exports.ObjValidator)(exports.test); +exports.outputExample = (0, exports.validatorFunc)({ + Test: { + Test1: { + Test2: "hi" + } + } +}); + + +//// [reverseMappedTypeDeepDeclarationEmit.d.ts] +export declare type Validator = NativeTypeValidator | ObjectValidator; +export declare type NativeTypeValidator = (n: any) => T | undefined; +export declare type ObjectValidator = { + [K in keyof O]: Validator; +}; +export declare const SimpleStringValidator: NativeTypeValidator; +export declare const ObjValidator: (validatorObj: ObjectValidator) => (o: any) => V; +export declare const test: { + Test: { + Test1: { + Test2: NativeTypeValidator; + }; + }; +}; +export declare const validatorFunc: (o: any) => { + Test: { + Test1: { + Test2: string; + }; + }; +}; +export declare const outputExample: { + Test: { + Test1: { + Test2: string; + }; + }; +}; diff --git a/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.symbols b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.symbols new file mode 100644 index 00000000000..f7c88c883e6 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.symbols @@ -0,0 +1,81 @@ +=== tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts === +export type Validator = NativeTypeValidator | ObjectValidator +>Validator : Symbol(Validator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 0)) +>T : Symbol(T, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 22)) +>NativeTypeValidator : Symbol(NativeTypeValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 70)) +>T : Symbol(T, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 22)) +>ObjectValidator : Symbol(ObjectValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 62)) +>T : Symbol(T, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 22)) + +export type NativeTypeValidator = (n: any) => T | undefined +>NativeTypeValidator : Symbol(NativeTypeValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 70)) +>T : Symbol(T, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 32)) +>n : Symbol(n, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 38)) +>T : Symbol(T, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 32)) + +export type ObjectValidator = { +>ObjectValidator : Symbol(ObjectValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 62)) +>O : Symbol(O, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 3, 28)) + + [K in keyof O]: Validator +>K : Symbol(K, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 4, 3)) +>O : Symbol(O, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 3, 28)) +>Validator : Symbol(Validator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 0)) +>O : Symbol(O, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 3, 28)) +>K : Symbol(K, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 4, 3)) +} + +//native validators +export declare const SimpleStringValidator: NativeTypeValidator; +>SimpleStringValidator : Symbol(SimpleStringValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 8, 20)) +>NativeTypeValidator : Symbol(NativeTypeValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 0, 70)) + +///object validator function +export declare const ObjValidator: (validatorObj: ObjectValidator) => (o: any) => V; +>ObjValidator : Symbol(ObjValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 20)) +>V : Symbol(V, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 36)) +>validatorObj : Symbol(validatorObj, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 39)) +>ObjectValidator : Symbol(ObjectValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 2, 62)) +>V : Symbol(V, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 36)) +>o : Symbol(o, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 77)) +>V : Symbol(V, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 36)) + +export const test = { +>test : Symbol(test, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 13, 12)) + + Test: { +>Test : Symbol(Test, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 13, 22)) + + Test1: { +>Test1 : Symbol(Test1, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 14, 9)) + + Test2: SimpleStringValidator +>Test2 : Symbol(Test2, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 15, 12)) +>SimpleStringValidator : Symbol(SimpleStringValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 8, 20)) + + }, + } +} + +export const validatorFunc = ObjValidator(test); +>validatorFunc : Symbol(validatorFunc, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 21, 12)) +>ObjValidator : Symbol(ObjValidator, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 11, 20)) +>test : Symbol(test, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 13, 12)) + +export const outputExample = validatorFunc({ +>outputExample : Symbol(outputExample, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 22, 12)) +>validatorFunc : Symbol(validatorFunc, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 21, 12)) + + Test: { +>Test : Symbol(Test, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 22, 44)) + + Test1: { +>Test1 : Symbol(Test1, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 23, 9)) + + Test2: "hi" +>Test2 : Symbol(Test2, Decl(reverseMappedTypeDeepDeclarationEmit.ts, 24, 12)) + + }, + } +}); + diff --git a/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.types b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.types new file mode 100644 index 00000000000..48107f98143 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeDeepDeclarationEmit.types @@ -0,0 +1,72 @@ +=== tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts === +export type Validator = NativeTypeValidator | ObjectValidator +>Validator : Validator + +export type NativeTypeValidator = (n: any) => T | undefined +>NativeTypeValidator : NativeTypeValidator +>n : any + +export type ObjectValidator = { +>ObjectValidator : ObjectValidator + + [K in keyof O]: Validator +} + +//native validators +export declare const SimpleStringValidator: NativeTypeValidator; +>SimpleStringValidator : NativeTypeValidator + +///object validator function +export declare const ObjValidator: (validatorObj: ObjectValidator) => (o: any) => V; +>ObjValidator : (validatorObj: ObjectValidator) => (o: any) => V +>validatorObj : ObjectValidator +>o : any + +export const test = { +>test : { Test: { Test1: { Test2: NativeTypeValidator; }; }; } +>{ Test: { Test1: { Test2: SimpleStringValidator }, }} : { Test: { Test1: { Test2: NativeTypeValidator; }; }; } + + Test: { +>Test : { Test1: { Test2: NativeTypeValidator; }; } +>{ Test1: { Test2: SimpleStringValidator }, } : { Test1: { Test2: NativeTypeValidator; }; } + + Test1: { +>Test1 : { Test2: NativeTypeValidator; } +>{ Test2: SimpleStringValidator } : { Test2: NativeTypeValidator; } + + Test2: SimpleStringValidator +>Test2 : NativeTypeValidator +>SimpleStringValidator : NativeTypeValidator + + }, + } +} + +export const validatorFunc = ObjValidator(test); +>validatorFunc : (o: any) => { Test: { Test1: { Test2: string; }; }; } +>ObjValidator(test) : (o: any) => { Test: { Test1: { Test2: string; }; }; } +>ObjValidator : (validatorObj: ObjectValidator) => (o: any) => V +>test : { Test: { Test1: { Test2: NativeTypeValidator; }; }; } + +export const outputExample = validatorFunc({ +>outputExample : { Test: { Test1: { Test2: string; }; }; } +>validatorFunc({ Test: { Test1: { Test2: "hi" }, }}) : { Test: { Test1: { Test2: string; }; }; } +>validatorFunc : (o: any) => { Test: { Test1: { Test2: string; }; }; } +>{ Test: { Test1: { Test2: "hi" }, }} : { Test: { Test1: { Test2: string; }; }; } + + Test: { +>Test : { Test1: { Test2: string; }; } +>{ Test1: { Test2: "hi" }, } : { Test1: { Test2: string; }; } + + Test1: { +>Test1 : { Test2: string; } +>{ Test2: "hi" } : { Test2: string; } + + Test2: "hi" +>Test2 : string +>"hi" : "hi" + + }, + } +}); + diff --git a/tests/baselines/reference/templateLiteralTypes2.errors.txt b/tests/baselines/reference/templateLiteralTypes2.errors.txt index 662b6704d63..7e9308d47e6 100644 --- a/tests/baselines/reference/templateLiteralTypes2.errors.txt +++ b/tests/baselines/reference/templateLiteralTypes2.errors.txt @@ -1,13 +1,9 @@ tests/cases/conformance/types/literal/templateLiteralTypes2.ts(23,11): error TS2322: Type 'string' is not assignable to type '`abc${string}`'. tests/cases/conformance/types/literal/templateLiteralTypes2.ts(29,11): error TS2322: Type 'string' is not assignable to type '`foo${string}` | `bar${string}`'. tests/cases/conformance/types/literal/templateLiteralTypes2.ts(32,11): error TS2322: Type 'string' is not assignable to type '`foo${string}` | `bar${string}` | `baz${string}`'. -tests/cases/conformance/types/literal/templateLiteralTypes2.ts(67,9): error TS2322: Type '`foo${number}`' is not assignable to type 'String'. -tests/cases/conformance/types/literal/templateLiteralTypes2.ts(68,9): error TS2322: Type '`foo${number}`' is not assignable to type 'Object'. -tests/cases/conformance/types/literal/templateLiteralTypes2.ts(69,9): error TS2322: Type '`foo${number}`' is not assignable to type '{}'. -tests/cases/conformance/types/literal/templateLiteralTypes2.ts(70,9): error TS2322: Type '`foo${number}`' is not assignable to type '{ length: number; }'. -==== tests/cases/conformance/types/literal/templateLiteralTypes2.ts (7 errors) ==== +==== tests/cases/conformance/types/literal/templateLiteralTypes2.ts (3 errors) ==== function ft1(s: string, n: number, u: 'foo' | 'bar' | 'baz', t: T) { const c1 = `abc${s}`; // `abc${string}` const c2 = `abc${n}`; // `abc${number}` @@ -81,17 +77,9 @@ tests/cases/conformance/types/literal/templateLiteralTypes2.ts(70,9): error TS23 function ft14(t: `foo${number}`) { let x1: string = t; let x2: String = t; - ~~ -!!! error TS2322: Type '`foo${number}`' is not assignable to type 'String'. let x3: Object = t; - ~~ -!!! error TS2322: Type '`foo${number}`' is not assignable to type 'Object'. let x4: {} = t; - ~~ -!!! error TS2322: Type '`foo${number}`' is not assignable to type '{}'. let x6: { length: number } = t; - ~~ -!!! error TS2322: Type '`foo${number}`' is not assignable to type '{ length: number; }'. } declare function g1(x: T): T; @@ -134,4 +122,10 @@ tests/cases/conformance/types/literal/templateLiteralTypes2.ts(70,9): error TS23 function getCardTitle(title: string): `test-${string}` { return `test-${title}`; } + + // Repro from #43424 + + const interpolatedStyle = { rotate: 12 }; + function C2(transform: "-moz-initial" | (string & {})) { return 12; } + C2(`rotate(${interpolatedStyle.rotate}dig)`); \ No newline at end of file diff --git a/tests/baselines/reference/templateLiteralTypes2.js b/tests/baselines/reference/templateLiteralTypes2.js index 87be2dbe4fa..37c101be269 100644 --- a/tests/baselines/reference/templateLiteralTypes2.js +++ b/tests/baselines/reference/templateLiteralTypes2.js @@ -111,6 +111,12 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`; function getCardTitle(title: string): `test-${string}` { return `test-${title}`; } + +// Repro from #43424 + +const interpolatedStyle = { rotate: 12 }; +function C2(transform: "-moz-initial" | (string & {})) { return 12; } +C2(`rotate(${interpolatedStyle.rotate}dig)`); //// [templateLiteralTypes2.js] @@ -194,6 +200,10 @@ var pixelStringWithTemplate = pixelValue + "px"; function getCardTitle(title) { return "test-" + title; } +// Repro from #43424 +var interpolatedStyle = { rotate: 12 }; +function C2(transform) { return 12; } +C2("rotate(" + interpolatedStyle.rotate + "dig)"); //// [templateLiteralTypes2.d.ts] @@ -225,3 +235,7 @@ declare type PixelValueType = `${number}px`; declare const pixelString: PixelValueType; declare const pixelStringWithTemplate: PixelValueType; declare function getCardTitle(title: string): `test-${string}`; +declare const interpolatedStyle: { + rotate: number; +}; +declare function C2(transform: "-moz-initial" | (string & {})): number; diff --git a/tests/baselines/reference/templateLiteralTypes2.symbols b/tests/baselines/reference/templateLiteralTypes2.symbols index 6348ebce7f9..4ac9d428a06 100644 --- a/tests/baselines/reference/templateLiteralTypes2.symbols +++ b/tests/baselines/reference/templateLiteralTypes2.symbols @@ -361,3 +361,19 @@ function getCardTitle(title: string): `test-${string}` { >title : Symbol(title, Decl(templateLiteralTypes2.ts, 109, 22)) } +// Repro from #43424 + +const interpolatedStyle = { rotate: 12 }; +>interpolatedStyle : Symbol(interpolatedStyle, Decl(templateLiteralTypes2.ts, 115, 5)) +>rotate : Symbol(rotate, Decl(templateLiteralTypes2.ts, 115, 27)) + +function C2(transform: "-moz-initial" | (string & {})) { return 12; } +>C2 : Symbol(C2, Decl(templateLiteralTypes2.ts, 115, 41)) +>transform : Symbol(transform, Decl(templateLiteralTypes2.ts, 116, 12)) + +C2(`rotate(${interpolatedStyle.rotate}dig)`); +>C2 : Symbol(C2, Decl(templateLiteralTypes2.ts, 115, 41)) +>interpolatedStyle.rotate : Symbol(rotate, Decl(templateLiteralTypes2.ts, 115, 27)) +>interpolatedStyle : Symbol(interpolatedStyle, Decl(templateLiteralTypes2.ts, 115, 5)) +>rotate : Symbol(rotate, Decl(templateLiteralTypes2.ts, 115, 27)) + diff --git a/tests/baselines/reference/templateLiteralTypes2.types b/tests/baselines/reference/templateLiteralTypes2.types index 274e3eb4f0b..24096c9d782 100644 --- a/tests/baselines/reference/templateLiteralTypes2.types +++ b/tests/baselines/reference/templateLiteralTypes2.types @@ -392,3 +392,24 @@ function getCardTitle(title: string): `test-${string}` { >title : string } +// Repro from #43424 + +const interpolatedStyle = { rotate: 12 }; +>interpolatedStyle : { rotate: number; } +>{ rotate: 12 } : { rotate: number; } +>rotate : number +>12 : 12 + +function C2(transform: "-moz-initial" | (string & {})) { return 12; } +>C2 : (transform: "-moz-initial" | (string & {})) => number +>transform : (string & {}) | "-moz-initial" +>12 : 12 + +C2(`rotate(${interpolatedStyle.rotate}dig)`); +>C2(`rotate(${interpolatedStyle.rotate}dig)`) : number +>C2 : (transform: (string & {}) | "-moz-initial") => number +>`rotate(${interpolatedStyle.rotate}dig)` : `rotate(${number}dig)` +>interpolatedStyle.rotate : number +>interpolatedStyle : { rotate: number; } +>rotate : number + diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt b/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt index 0e0b2c98404..132738e4ac1 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt +++ b/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/truthinessCallExpressionCoercion.ts(2,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(18,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(36,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(50,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(66,13): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(76,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(2,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(18,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(36,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(50,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(66,13): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(76,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? ==== tests/cases/compiler/truthinessCallExpressionCoercion.ts (7 errors) ==== function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { if (required) { // error ~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } if (optional) { // ok @@ -29,7 +29,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th if (test) { // error ~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? console.log('test'); } @@ -49,7 +49,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th if (test) { // error ~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? [() => null].forEach(test => { test(); }); @@ -65,7 +65,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th if (x.foo.bar) { // error ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } if (x.foo.bar) { // ok @@ -83,7 +83,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th test() { if (this.isUser) { // error ~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } if (this.maybeIsUser) { // ok @@ -95,7 +95,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th function A(stats: StatsBase) { if (stats.isDirectory) { // err ~~~~~~~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? console.log(`[Directory] ${stats.ctime}`) } } @@ -103,7 +103,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th function B(a: Nested, b: Nested) { if (a.stats.isDirectory) { // err ~~~~~~~~~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? b.stats.isDirectory(); } if (a.stats.isDirectory) { // ok diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt b/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt index ed7ba0a5709..4c041935cde 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt +++ b/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/truthinessCallExpressionCoercion1.ts(3,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion1.ts(19,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion1.ts(33,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion1.ts(46,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion1.ts(3,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion1.ts(19,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion1.ts(33,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion1.ts(46,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? ==== tests/cases/compiler/truthinessCallExpressionCoercion1.ts (5 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T // error required ? console.log('required') : undefined; ~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok optional ? console.log('optional') : undefined; @@ -28,7 +28,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T // error test ? console.log('test') : undefined; ~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok test ? console.log(test) : undefined; @@ -44,7 +44,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T // error test ~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? ? [() => null].forEach(test => { test() }) : undefined; } @@ -59,7 +59,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T // error x.foo.bar ? console.log('x.foo.bar') : undefined; ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok x.foo.bar ? x.foo.bar : undefined; @@ -91,7 +91,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T // error this.isUser ? console.log('this.isUser') : undefined; ~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok this.maybeIsUser ? console.log('this.maybeIsUser') : undefined; diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion2.errors.txt b/tests/baselines/reference/truthinessCallExpressionCoercion2.errors.txt index 6582157de84..d744718a8de 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion2.errors.txt +++ b/tests/baselines/reference/truthinessCallExpressionCoercion2.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(11,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(14,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(41,18): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(44,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(48,11): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(65,46): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(76,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(79,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(99,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(109,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(11,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(14,10): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(41,18): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(44,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(48,11): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(65,46): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(76,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(79,10): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(99,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(109,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? ==== tests/cases/compiler/truthinessCallExpressionCoercion2.ts (11 errors) ==== @@ -24,12 +24,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: // error required1 && console.log('required'); ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // error 1 && required1 && console.log('required'); ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok required1 && required1(); @@ -58,18 +58,18 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: // error required1 && required2 && required1() && console.log('foo'); ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // error if (required1 && b) { ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } // error if (((required1 && b))) { ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } // ok @@ -88,7 +88,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: typeof window !== 'undefined' && window.console && ((window.console as any).firebug || (window.console.exception && window.console.table)); ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } function checksPropertyAccess() { @@ -101,12 +101,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: // error x.foo.bar && console.log('x.foo.bar'); ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // error 1 && x.foo.bar && console.log('x.foo.bar'); ~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok x.foo.bar && x.foo.bar(); @@ -128,7 +128,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: // error x1.a.b.c && x2.a.b.c(); ~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? } class Foo { @@ -140,12 +140,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: // error this.required && console.log('required'); ~~~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // error 1 && this.required && console.log('required'); ~~~~~~~~~~~~~ -!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead? // ok this.required && this.required(); diff --git a/tests/baselines/reference/truthinessPromiseCoercion.errors.txt b/tests/baselines/reference/truthinessPromiseCoercion.errors.txt index a7b7afff1f6..aaba8031475 100644 --- a/tests/baselines/reference/truthinessPromiseCoercion.errors.txt +++ b/tests/baselines/reference/truthinessPromiseCoercion.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/truthinessPromiseCoercion.ts(5,9): error TS2367: This condition will always return 'true' since the types 'Promise' and 'false' have no overlap. -tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2367: This condition will always return 'true' since the types 'Promise' and 'false' have no overlap. +tests/cases/compiler/truthinessPromiseCoercion.ts(5,9): error TS2801: This condition will always return true since this 'Promise' appears to always be defined. +tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2801: This condition will always return true since this 'Promise' appears to always be defined. ==== tests/cases/compiler/truthinessPromiseCoercion.ts (2 errors) ==== @@ -9,14 +9,14 @@ tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2367: This condi async function f() { if (p) {} // err ~ -!!! error TS2367: This condition will always return 'true' since the types 'Promise' and 'false' have no overlap. +!!! error TS2801: This condition will always return true since this 'Promise' appears to always be defined. !!! related TS2773 tests/cases/compiler/truthinessPromiseCoercion.ts:5:9: Did you forget to use 'await'? if (!!p) {} // no err if (p2) {} // no err p ? f.arguments : f.arguments; ~ -!!! error TS2367: This condition will always return 'true' since the types 'Promise' and 'false' have no overlap. +!!! error TS2801: This condition will always return true since this 'Promise' appears to always be defined. !!! related TS2773 tests/cases/compiler/truthinessPromiseCoercion.ts:9:5: Did you forget to use 'await'? !!p ? f.arguments : f.arguments; p2 ? f.arguments : f.arguments; diff --git a/tests/baselines/reference/tsbuild/clean/initial-build/file-name-and-output-name-clashing.js b/tests/baselines/reference/tsbuild/clean/initial-build/file-name-and-output-name-clashing.js new file mode 100644 index 00000000000..e8cecc75d8c --- /dev/null +++ b/tests/baselines/reference/tsbuild/clean/initial-build/file-name-and-output-name-clashing.js @@ -0,0 +1,20 @@ +Input:: +//// [/lib/lib.d.ts] + + +//// [/src/bar.ts] + + +//// [/src/index.js] + + +//// [/src/tsconfig.json] +{"compilerOptions":{"allowJs":true}} + + + +Output:: +/lib/tsc --b /src/tsconfig.json -clean +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js index e6fd723a287..43e04e41056 100644 --- a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js +++ b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -81,11 +76,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js index 4c55b9ce60f..e9ea12ea0d3 100644 --- a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js +++ b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -81,11 +76,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js index a05c649643c..8ad612bca9b 100644 --- a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js +++ b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js @@ -56,11 +56,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:35 AM] Found 1 error. Watching for file changes. @@ -113,11 +108,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:42 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js index 3e563e8f609..6af8477219c 100644 --- a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js +++ b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js @@ -56,11 +56,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:35 AM] Found 1 error. Watching for file changes. @@ -113,11 +108,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:42 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js b/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js index c539e3763b4..61a42c07f86 100644 --- a/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js +++ b/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -166,11 +161,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js index 682a68af31e..97c07812515 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js index 17c877f6ac1..16681988e8f 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js index 0e63864873c..9b41d9d0913 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js index 9c9b6f756c1..bae815eebeb 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js index 46b48bf4ce5..3994e240983 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js index fbb7a7ed574..da78efc9fba 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -110,11 +105,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js index ba168ab833f..95da55bc583 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js index 442f3d18610..3c0a5fcd89b 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js index 13cfbf7708d..eaea5f602e6 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js index 4a82b0f24e5..105964812e7 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js index 101a14226d2..874eff425a3 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js index c90e071624b..bc6607b8d53 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js index 73fb8a3f99e..1f04fa2e666 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js index 928db04fad6..8d6647dbc4d 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js index e2394ec3152..29b3348f4df 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js index accbfbc36e4..0a5da71c0d0 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js index 22e73f151f5..ea636a1de95 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js index 59fc6a820f0..62bccd4b4e1 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js index ea3425d143d..ebda20c91cd 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js index ddff239e3c9..81d203d04cd 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js index daf7e2b9e0f..18759a8a9c6 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js index 4093ad48302..48c8bcb5bd3 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js index b6323d2ed80..27bfca04dbd 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js index 659ad657153..0969d50832b 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/typeAssertions.errors.txt b/tests/baselines/reference/typeAssertions.errors.txt index 9d10ec17fe9..cf132a12d02 100644 --- a/tests/baselines/reference/typeAssertions.errors.txt +++ b/tests/baselines/reference/typeAssertions.errors.txt @@ -93,6 +93,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err !!! error TS2304: Cannot find name 'is'. ~~~~~~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts:44:3: The parser expected to find a ')' to match the '(' token here. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ @@ -108,6 +109,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err !!! error TS2749: 'numOrStr' refers to a value, but is being used as a type here. Did you mean 'typeof numOrStr'? ~~ !!! error TS1005: ')' expected. +!!! related TS1007 tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts:48:3: The parser expected to find a ')' to match the '(' token here. ~~ !!! error TS2304: Cannot find name 'is'. ~~~~~~ diff --git a/tests/baselines/reference/user/grunt.log b/tests/baselines/reference/user/grunt.log new file mode 100644 index 00000000000..88c6738046c --- /dev/null +++ b/tests/baselines/reference/user/grunt.log @@ -0,0 +1,120 @@ +Exit Code: 2 +Standard output: +lib/grunt.js(10,11): error TS2307: Cannot find module 'coffeescript/register' or its corresponding type declarations. +lib/grunt.js(91,13): error TS2551: Property 'task' does not exist on type 'typeof import("/grunt/grunt/lib/grunt.js")'. Did you mean 'tasks'? +lib/grunt.js(96,34): error TS2551: Property 'task' does not exist on type 'typeof import("/grunt/grunt/lib/grunt.js")'. Did you mean 'tasks'? +lib/grunt.js(101,25): error TS2339: Property 'cli' does not exist on type 'typeof import("/grunt/grunt/lib/grunt.js")'. +lib/grunt.js(102,23): error TS2339: Property 'cli' does not exist on type 'typeof import("/grunt/grunt/lib/grunt.js")'. +lib/grunt/config.js(66,18): error TS2339: Property 'template' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/fail.js(22,14): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/fail.js(25,19): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/fail.js(25,65): error TS2339: Property 'underline' does not exist on type '"Used --force, continuing."'. +lib/grunt/fail.js(26,15): error TS2339: Property 'yellow' does not exist on type 'string'. +lib/grunt/fail.js(28,35): error TS2339: Property 'red' does not exist on type 'string'. +lib/grunt/fail.js(35,13): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/fail.js(61,14): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(35,39): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. + Type 'IArguments' is missing the following properties from type 'string[]': pop, push, concat, join, and 26 more. +lib/grunt/file.js(87,33): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[options?: any, patterns?: any, filepaths?: any]'. +lib/grunt/file.js(182,13): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(234,25): error TS2345: Argument of type 'string | Buffer' is not assignable to parameter of type 'string'. + Type 'Buffer' is not assignable to type 'string'. +lib/grunt/file.js(270,23): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(333,7): error TS2367: This condition will always return 'false' since the types 'string | Buffer' and 'boolean' have no overlap. +lib/grunt/file.js(344,23): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(346,29): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(361,13): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(365,13): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/file.js(385,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(391,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(405,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(411,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(417,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(444,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/file.js(454,40): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. +lib/grunt/help.js(58,40): error TS2339: Property 'cli' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/help.js(59,19): error TS2339: Property 'cli' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/help.js(81,9): error TS2551: Property 'task' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. Did you mean 'tasks'? +lib/grunt/help.js(85,21): error TS2551: Property 'task' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. Did you mean 'tasks'? +lib/grunt/help.js(87,22): error TS2551: Property 'task' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. Did you mean 'tasks'? +lib/grunt/task.js(26,23): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +lib/grunt/task.js(39,24): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(44,22): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(50,33): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(55,15): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(65,45): error TS2339: Property 'nameArgs' does not exist on type 'fn'. +lib/grunt/task.js(66,13): error TS2339: Property 'name' does not exist on type 'fn'. +lib/grunt/task.js(66,27): error TS2339: Property 'nameArgs' does not exist on type 'fn'. +lib/grunt/task.js(66,50): error TS2339: Property 'name' does not exist on type 'fn'. +lib/grunt/task.js(95,56): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(104,53): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(110,40): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(115,51): error TS2339: Property 'yellow' does not exist on type '"[no files]"'. +lib/grunt/task.js(136,20): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(142,28): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(143,29): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(168,16): error TS2339: Property 'result' does not exist on type '() => any'. +lib/grunt/task.js(168,31): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(170,21): error TS2339: Property 'result' does not exist on type '() => any'. +lib/grunt/task.js(183,13): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(187,83): error TS2339: Property 'yellow' does not exist on type '"[no src]"'. +lib/grunt/task.js(190,58): error TS2339: Property 'cyan' does not exist on type 'string'. +lib/grunt/task.js(190,77): error TS2339: Property 'yellow' does not exist on type '"[no dest]"'. +lib/grunt/task.js(222,10): error TS2339: Property 'requiresConfig' does not exist on type '(Anonymous function)'. +lib/grunt/task.js(226,29): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(228,15): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(239,39): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +lib/grunt/task.js(241,23): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(248,29): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +lib/grunt/task.js(273,27): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +lib/grunt/task.js(274,25): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +lib/grunt/task.js(285,35): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(348,23): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(361,13): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(377,14): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(390,19): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(390,48): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(398,28): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(413,13): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(436,23): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(437,13): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(443,33): error TS2339: Property 'file' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(447,25): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(453,20): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(456,11): error TS2339: Property 'fatal' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(456,72): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(457,21): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(464,11): error TS2339: Property 'fatal' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(464,52): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(468,10): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/task.js(470,10): error TS2339: Property 'option' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/template.js(15,21): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +lib/grunt/template.js(27,14): error TS2339: Property 'opener' does not exist on type '{}'. +lib/grunt/template.js(28,14): error TS2339: Property 'closer' does not exist on type '{}'. +lib/grunt/template.js(30,22): error TS2339: Property 'opener' does not exist on type '{}'. +lib/grunt/template.js(31,39): error TS2339: Property 'closer' does not exist on type '{}'. +lib/grunt/template.js(33,14): error TS2339: Property 'lodash' does not exist on type '{}'. +lib/grunt/template.js(60,50): error TS2339: Property 'config' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/template.js(86,11): error TS2339: Property 'warn' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/grunt/template.js(86,25): error TS2339: Property 'fail' does not exist on type 'typeof import("/grunt/grunt/lib/grunt")'. +lib/util/task.js(161,36): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[start: number, deleteCount: number, ...items: never[]]'. + Source provides no match for required element at position 0 in target. +lib/util/task.js(211,12): error TS2339: Property '_success' does not exist on type '(Anonymous function)'. +lib/util/task.js(213,28): error TS2339: Property '_options' does not exist on type '(Anonymous function)'. +lib/util/task.js(214,14): error TS2339: Property '_options' does not exist on type '(Anonymous function)'. +lib/util/task.js(267,22): error TS2339: Property '_queue' does not exist on type '(Anonymous function)'. +lib/util/task.js(268,31): error TS2339: Property '_placeholder' does not exist on type '(Anonymous function)'. +lib/util/task.js(268,62): error TS2339: Property '_marker' does not exist on type '(Anonymous function)'. +lib/util/task.js(272,18): error TS2339: Property '_options' does not exist on type '(Anonymous function)'. +lib/util/task.js(273,16): error TS2339: Property '_options' does not exist on type '(Anonymous function)'. +lib/util/task.js(278,12): error TS2339: Property '_queue' does not exist on type '(Anonymous function)'. +lib/util/task.js(278,32): error TS2339: Property '_placeholder' does not exist on type '(Anonymous function)'. +lib/util/task.js(293,12): error TS2339: Property 'runTaskFn' does not exist on type '(Anonymous function)'. +lib/util/task.js(294,36): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +lib/util/task.js(294,42): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +lib/util/task.js(320,21): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +lib/util/task.js(331,7): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + + +Standard error: diff --git a/tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts b/tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts new file mode 100644 index 00000000000..91b236ef61f --- /dev/null +++ b/tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts @@ -0,0 +1,34 @@ +type Q = number extends T ? (n: number) => void : never; +function fn(arg: Q) { + // Expected: OK + // Actual: Cannot convert 10 to number & T + arg(10); +} +// Legal invocations are not problematic +fn(m => m.toFixed()); +fn(m => m.toFixed()); + +// Ensure the following real-world example that relies on substitution still works +type ExtractParameters = "parameters" extends keyof T + // The above allows "parameters" to index `T` since all later + // instances are actually implicitly `"parameters" & keyof T` + ? { + [K in keyof T["parameters"]]: T["parameters"][K]; + }[keyof T["parameters"]] + : {}; + +// Original example, but with inverted variance +type Q2 = number extends T ? (cb: (n: number) => void) => void : never; +function fn2(arg: Q2) { + function useT(_arg: T): void {} + // Expected: OK + arg(arg => useT(arg)); +} +// Legal invocations are not problematic +fn2(m => m(42)); +fn2(m => m(42)); + +// webidl-conversions example where substituion must occur, despite contravariance of the position +// due to the invariant usage in `Parameters` + +type X = V extends (...args: any[]) => any ? (...args: Parameters) => void : Function; \ No newline at end of file diff --git a/tests/cases/compiler/classUsedBeforeInitializedVariables.ts b/tests/cases/compiler/classUsedBeforeInitializedVariables.ts index f10ae4e20a0..74acff583de 100644 --- a/tests/cases/compiler/classUsedBeforeInitializedVariables.ts +++ b/tests/cases/compiler/classUsedBeforeInitializedVariables.ts @@ -5,6 +5,12 @@ class Test { p2 = this.p1; p3 = this.p4; p4 = 0; + p5?: number; + + p6?: string; + p7 = { + hello: (this.p6 = "string"), + }; directlyAssigned: any = this.directlyAssigned; @@ -30,6 +36,8 @@ class Test { withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { }); + fromOptional = this.p5; + // These error cases are ignored (not checked by control flow analysis) assignedByArrowFunction: any = (() => this.assignedByFunction)(); diff --git a/tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts b/tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts new file mode 100644 index 00000000000..ea585eb906e --- /dev/null +++ b/tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts @@ -0,0 +1,22 @@ +// @declaration: true +function noArgs(): string { + return null as any; +} + +function oneArg(input: string): string { + return null as any; +} + +export class Wrapper { + private proxy(fn: (options: T) => U): (options: T) => U; + private proxy(fn: (options?: T) => U, noArgs: true): (options?: T) => U; + + private proxy(fn: (options: T) => U) { + return null as any; + } + + public Proxies = { + Failure: this.proxy(noArgs, true), + Success: this.proxy(oneArg), + }; +} \ No newline at end of file diff --git a/tests/cases/compiler/destructionAssignmentError.ts b/tests/cases/compiler/destructionAssignmentError.ts new file mode 100644 index 00000000000..6845391d659 --- /dev/null +++ b/tests/cases/compiler/destructionAssignmentError.ts @@ -0,0 +1,12 @@ +declare function fn(): { a: 1, b: 2 } +let a: number; +let b: number; + +({ a, b } = fn()); +{ a, b } = fn(); + +({ a, b } = +fn()); + +{ a, b } += fn(); \ No newline at end of file diff --git a/tests/cases/compiler/excessiveStackDepthFlatArray.ts b/tests/cases/compiler/excessiveStackDepthFlatArray.ts new file mode 100644 index 00000000000..b8ad99e287d --- /dev/null +++ b/tests/cases/compiler/excessiveStackDepthFlatArray.ts @@ -0,0 +1,43 @@ +// @lib: es2019,dom +// @jsx: react + +// @Filename: index.tsx +interface MiddlewareArray extends Array {} +declare function configureStore(options: { middleware: MiddlewareArray }): void; + +declare const defaultMiddleware: MiddlewareArray; +configureStore({ + middleware: [...defaultMiddleware], // Should not error +}); + +declare namespace React { + type DetailedHTMLProps, T> = E; + interface HTMLAttributes { + children?: ReactNode; + } + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; + type ReactText = string | number; + type ReactChild = ReactText; + type ReactFragment = {} | ReactNodeArray; + interface ReactNodeArray extends Array {} +} +declare namespace JSX { + interface IntrinsicElements { + ul: React.DetailedHTMLProps, HTMLUListElement>; + li: React.DetailedHTMLProps, HTMLLIElement>; + } +} +declare var React: any; + +const Component = () => { + const categories = ['Fruit', 'Vegetables']; + + return ( +

+ ); +}; diff --git a/tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts b/tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts new file mode 100644 index 00000000000..007adbe342c --- /dev/null +++ b/tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts @@ -0,0 +1,25 @@ +// @strict: true +// @declaration: true +// @target: esnext + +// Repro from #43493 + +declare const foo: unknown[]; +const bar = foo.flatMap(bar => bar as Foo); + +interface Foo extends Array {} + +// Repros from comments in #43249 + +const repro_43249 = (value: unknown) => { + if (typeof value !== "string") { + throw new Error("No"); + } + const match = value.match(/anything/) || []; + const [, extracted] = match; +}; + +function f(x: FlatArray, y: FlatArray) { + x = y; + y = x; // Error +} diff --git a/tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts b/tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts new file mode 100644 index 00000000000..8d3cbff7822 --- /dev/null +++ b/tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts @@ -0,0 +1,15 @@ +class Model { + public createdAt: Date; +} + +type ModelAttributes = Omit; + +class AutoModel extends Model> {} + +class PersonModel extends AutoModel { + public age: number; + + toJson() { + let x: keyof this = 'createdAt'; + } +} diff --git a/tests/cases/compiler/missingCloseBracketInArray.ts b/tests/cases/compiler/missingCloseBracketInArray.ts new file mode 100644 index 00000000000..cb99f0d2277 --- /dev/null +++ b/tests/cases/compiler/missingCloseBracketInArray.ts @@ -0,0 +1 @@ +var alphas:string[] = alphas = ["1","2","3","4" \ No newline at end of file diff --git a/tests/cases/compiler/missingCloseParenStatements.ts b/tests/cases/compiler/missingCloseParenStatements.ts new file mode 100644 index 00000000000..7ff34bdae6a --- /dev/null +++ b/tests/cases/compiler/missingCloseParenStatements.ts @@ -0,0 +1,13 @@ +var a1, a2, a3 = 0; +if ( a1 && (a2 + a3 > 0) { + while( (a2 > 0) && a1 + { + do { + var i = i + 1; + a1 = a1 + i; + with ((a2 + a3 > 0) && a1 { + console.log(x); + } + } while (i < 5 && (a1 > 5); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts b/tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts new file mode 100644 index 00000000000..e6f8c033e77 --- /dev/null +++ b/tests/cases/compiler/reverseMappedTypeDeepDeclarationEmit.ts @@ -0,0 +1,30 @@ +// @declaration: true +export type Validator = NativeTypeValidator | ObjectValidator + +export type NativeTypeValidator = (n: any) => T | undefined +export type ObjectValidator = { + [K in keyof O]: Validator +} + +//native validators +export declare const SimpleStringValidator: NativeTypeValidator; + +///object validator function +export declare const ObjValidator: (validatorObj: ObjectValidator) => (o: any) => V; + +export const test = { + Test: { + Test1: { + Test2: SimpleStringValidator + }, + } +} + +export const validatorFunc = ObjValidator(test); +export const outputExample = validatorFunc({ + Test: { + Test1: { + Test2: "hi" + }, + } +}); diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts new file mode 100644 index 00000000000..4080146e028 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/redeclaredProperty.ts @@ -0,0 +1,17 @@ +// @noTypesAndSymbols: true +// @strictNullChecks: true +// @target: esnext +// @useDefineForClassFields: true +class Base { + b = 1; +} + +class Derived extends Base { + b; + d = this.b; + + constructor() { + super(); + this.b = 2; + } +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts new file mode 100644 index 00000000000..02eabfbfcfa --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/redefinedPararameterProperty.ts @@ -0,0 +1,16 @@ +// @noTypesAndSymbols: true +// @strictNullChecks: true +// @target: esnext +// @useDefineForClassFields: true +class Base { + a = 1; + } + + class Derived extends Base { + b = this.a /*undefined*/; + + constructor(public a: number) { + super(); + } + } + \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/commonJsImportBindingElementNarrowType.ts b/tests/cases/conformance/externalModules/commonJsImportBindingElementNarrowType.ts new file mode 100644 index 00000000000..a98fdc3ef67 --- /dev/null +++ b/tests/cases/conformance/externalModules/commonJsImportBindingElementNarrowType.ts @@ -0,0 +1,15 @@ +// Regresion test for GH#41957 + +// @allowJs: true +// @checkJs: true +// @strictNullChecks: true +// @noEmit: true + +// @Filename: /foo.d.ts +export const a: number | null; + +// @Filename: /bar.js +const { a } = require("./foo"); +if (a) { + var x = a + 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts b/tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts index 56bbaa62e36..edd53d2cdfc 100644 --- a/tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts +++ b/tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts @@ -2,4 +2,6 @@ interface any { } interface number { } interface string { } interface boolean { } -interface void {} \ No newline at end of file +interface void {} +interface unknown {} +interface never {} \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression3.ts b/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression3.ts index 58df0691d8e..18ed3b5ef5a 100644 --- a/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression3.ts +++ b/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression3.ts @@ -1,2 +1 @@ - var texCoords = [2, 2, 0.5000001192092895, 0.8749999 ; 403953552, 0.5000001192092895, 0.8749999403953552]; diff --git a/tests/cases/conformance/types/literal/templateLiteralTypes2.ts b/tests/cases/conformance/types/literal/templateLiteralTypes2.ts index 75ab1485a05..5e51c5b30b2 100644 --- a/tests/cases/conformance/types/literal/templateLiteralTypes2.ts +++ b/tests/cases/conformance/types/literal/templateLiteralTypes2.ts @@ -113,3 +113,9 @@ const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`; function getCardTitle(title: string): `test-${string}` { return `test-${title}`; } + +// Repro from #43424 + +const interpolatedStyle = { rotate: 12 }; +function C2(transform: "-moz-initial" | (string & {})) { return 12; } +C2(`rotate(${interpolatedStyle.rotate}dig)`); diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index d30a92fe114..59daf508ad9 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -53,6 +53,10 @@ //// */ //// //// /** @param /*16*/ */ +//// +//// /** +//// * jsdoc inline tag {@/*17*/} +//// */ verify.completions( { marker: ["1", "2"], includes: ["constructor", "param", "type", "method", "template"] }, @@ -60,4 +64,5 @@ verify.completions( { marker: ["4", "5", "8"], includes: { name: "number", sortText: completion.SortText.GlobalsOrKeywords } }, { marker: ["6", "7", "14"], exact: undefined }, { marker: ["9", "10", "11", "12", "13"], includes: ["@argument", "@returns"] }, + { marker: ["17"], includes: ["link", "tutorial"] }, ); diff --git a/tests/cases/fourslash/completionsAsserts.ts b/tests/cases/fourslash/completionsAsserts.ts new file mode 100644 index 00000000000..cd1d50d953a --- /dev/null +++ b/tests/cases/fourslash/completionsAsserts.ts @@ -0,0 +1,8 @@ +/// + +////declare function assert(argument1: any): asserts a/**/ + +verify.completions({ + marker: "", + includes: { name: "argument1" } +}); diff --git a/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts b/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts index 844c2532775..fb3cdf5bc33 100644 --- a/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts +++ b/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts @@ -5,7 +5,7 @@ // @allowJs: true // @Filename: /a.js -/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] |]*/ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|]|] */ //// /////** //// * @return {[|T|]} diff --git a/tests/cases/fourslash/findAllRefsTypedef_importType.ts b/tests/cases/fourslash/findAllRefsTypedef_importType.ts index f84632d729d..4816406d518 100644 --- a/tests/cases/fourslash/findAllRefsTypedef_importType.ts +++ b/tests/cases/fourslash/findAllRefsTypedef_importType.ts @@ -4,7 +4,7 @@ // @Filename: /a.js ////module.exports = 0; -/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|] |]*/ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|]|] */ ////const dummy = 0; // @Filename: /b.js diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index d1bc7f429c2..295ba1fd142 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -286,8 +286,8 @@ declare namespace FourSlashInterface { * `verify.goToDefinition(["a", "aa"], "b");` verifies that markers "a" and "aa" have the same definition "b". * `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available. */ - goToDefinition(startMarkerNames: ArrayOrSingle, fileResult: { file: string }): void; - goToDefinition(startMarkerNames: ArrayOrSingle, endMarkerNames: ArrayOrSingle): void; + goToDefinition(startMarkerNames: ArrayOrSingle, fileResult: { file: string, unverified?: boolean }): void; + goToDefinition(startMarkerNames: ArrayOrSingle, endMarkerNames: ArrayOrSingle): void; goToDefinition(startMarkerNames: ArrayOrSingle, endMarkerNames: ArrayOrSingle, range: Range): void; /** Performs `goToDefinition` for each pair. */ goToDefinition(startsAndEnds: [ArrayOrSingle, ArrayOrSingle][]): void; diff --git a/tests/cases/fourslash/goToDefinitionCSSPatternAmbientModule.ts b/tests/cases/fourslash/goToDefinitionCSSPatternAmbientModule.ts index 9d595e81eb4..16a53b7501f 100644 --- a/tests/cases/fourslash/goToDefinitionCSSPatternAmbientModule.ts +++ b/tests/cases/fourslash/goToDefinitionCSSPatternAmbientModule.ts @@ -14,4 +14,4 @@ // @Filename: index.ts //// import styles from [|/*1*/"./index.css"|]; -verify.goToDefinition("1", ["2a", "2b"]); +verify.goToDefinition("1", [{ marker: "2a", unverified: true }, "2b"]); diff --git a/tests/cases/fourslash/goToDefinitionScriptImport.ts b/tests/cases/fourslash/goToDefinitionScriptImport.ts index d576f5454ad..5cede98c02a 100644 --- a/tests/cases/fourslash/goToDefinitionScriptImport.ts +++ b/tests/cases/fourslash/goToDefinitionScriptImport.ts @@ -16,5 +16,5 @@ // not JS/TS, but if we can, you should be able to jump to it. //// import [|/*2*/"./stylez.css"|]; -verify.goToDefinition("1", "1d"); -verify.goToDefinition("2", "2d"); +verify.goToDefinition("1", { marker: "1d", unverified: true }); +verify.goToDefinition("2", { marker: "2d", unverified: true }); diff --git a/tests/cases/fourslash/jsDocSignature-43394.ts b/tests/cases/fourslash/jsDocSignature-43394.ts new file mode 100644 index 00000000000..3091c8e5a4b --- /dev/null +++ b/tests/cases/fourslash/jsDocSignature-43394.ts @@ -0,0 +1,9 @@ +/// + +/////** +//// * @typedef {Object} Foo +//// * @property {number} ... +//// * /**/@typedef {number} Bar +//// */ + +verify.baselineSignatureHelp(); diff --git a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts index 4d4bb63058f..44156116d2f 100644 --- a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts +++ b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts @@ -3,7 +3,7 @@ // @allowJs: true // @Filename: a.js -/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] |]*/ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|]|] */ ////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}T|] = 1;|] diff --git a/tests/cases/fourslash/quickInfoInheritedLinkTag.ts b/tests/cases/fourslash/quickInfoInheritedLinkTag.ts new file mode 100644 index 00000000000..f1eb08d1327 --- /dev/null +++ b/tests/cases/fourslash/quickInfoInheritedLinkTag.ts @@ -0,0 +1,15 @@ +/// + +//// export class C { +//// /** +//// * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. +//// */ +//// m() { } +//// } +//// export class D extends C { +//// m() { } // crashes here +//// } +//// new C().m/**/ // and here (with a different thing trying to access undefined) + +verify.noErrors() +verify.baselineQuickInfo(); diff --git a/tests/cases/fourslash/quickInfoOnNarrowedType.ts b/tests/cases/fourslash/quickInfoOnNarrowedType.ts index da9a7ba0c7a..5b0c9a0f14e 100644 --- a/tests/cases/fourslash/quickInfoOnNarrowedType.ts +++ b/tests/cases/fourslash/quickInfoOnNarrowedType.ts @@ -18,6 +18,18 @@ //// /*6*/s; ////} +////class Foo { +//// #privateProperty: string[] | null; +//// constructor() { +//// this.#privateProperty = null; +//// } +//// testMethod() { +//// if (this.#privateProperty === null) +//// return; +//// this./*7*/#privateProperty; +//// } +////} + verify.quickInfos({ 1: "(parameter) strOrNum: string | number", 2: "(parameter) strOrNum: number", @@ -25,6 +37,7 @@ verify.quickInfos({ 4: "let s: string | undefined", 5: "let s: string | undefined", 6: "let s: string", + 7: "(property) Foo.#privateProperty: string[]" }); verify.completions( @@ -33,4 +46,5 @@ verify.completions( { marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } }, { marker: ["4", "5"], includes: { name: "s", text: "let s: string | undefined" } }, { marker: "6", includes: { name: "s", text: "let s: string" } }, + { marker: "7", includes: { name: "#privateProperty", text: "(property) Foo.#privateProperty: string[]" } } ); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction29.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction29.ts new file mode 100644 index 00000000000..b189082832e --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction29.ts @@ -0,0 +1,13 @@ +/// + +////const a = /*a*/()/*b*/ => { +//// return {} as {} +////}; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = () => ({} as {});`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction30.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction30.ts new file mode 100644 index 00000000000..0cef0c3c7fe --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction30.ts @@ -0,0 +1,13 @@ +/// + +////const a = /*a*/()/*b*/ => { +//// return {} as object +////}; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = () => ({} as object);`, +}); diff --git a/tests/cases/fourslash/refactorConvertExport_defaultToNamed2.ts b/tests/cases/fourslash/refactorConvertExport_defaultToNamed2.ts new file mode 100644 index 00000000000..bd18a221837 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertExport_defaultToNamed2.ts @@ -0,0 +1,44 @@ +/// + +// @Filename: /a.ts +////const f = () => {}; +/////*a*/export default f;/*b*/ + +// @Filename: /b.ts +////import f from "./a"; +////import { default as f } from "./a"; +////import { default as g } from "./a"; +////import f, * as a from "./a"; +//// +////export { default } from "./a"; +////export { default as f } from "./a"; +////export { default as i } from "./a"; +//// +////import * as a from "./a"; +////a.default(); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert export", + actionName: "Convert default export to named export", + actionDescription: "Convert default export to named export", + newContent: { + "/a.ts": +`const f = () => {}; +export { f };`, + + "/b.ts": +`import { f } from "./a"; +import { f } from "./a"; +import { f as g } from "./a"; +import * as a from "./a"; +import { f } from "./a"; + +export { f as default } from "./a"; +export { f } from "./a"; +export { f as i } from "./a"; + +import * as a from "./a"; +a.f();`, +}, +}); diff --git a/tests/cases/fourslash/refactorConvertToEs6Module_import_es6DefaultImport.ts b/tests/cases/fourslash/refactorConvertToEs6Module_import_es6DefaultImport.ts new file mode 100644 index 00000000000..9fe26a24010 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToEs6Module_import_es6DefaultImport.ts @@ -0,0 +1,19 @@ +/// + +// @allowJs: true +// @target: esnext + +// @Filename: /a.js +////const x = require('x'); +////x.default(); +////const y = require('y').default; +////y(); + +verify.codeFix({ + description: "Convert to ES6 module", + newFileContent: +`import x from 'x'; +x(); +import y from 'y'; +y();`, +}); diff --git a/tests/cases/fourslash/reverseMappedTypeQuickInfo.ts b/tests/cases/fourslash/reverseMappedTypeQuickInfo.ts index c249db25c69..4f0f454a9fc 100644 --- a/tests/cases/fourslash/reverseMappedTypeQuickInfo.ts +++ b/tests/cases/fourslash/reverseMappedTypeQuickInfo.ts @@ -30,7 +30,7 @@ verify.quickInfoAt("1", `type FinalType = { test: { - test_inner: ...; + test_inner: string; }; }`); verify.quickInfoAt("2", `(property) test_inner: string`); diff --git a/tests/cases/fourslash/server/goToDefinitionScriptImportServer.ts b/tests/cases/fourslash/server/goToDefinitionScriptImportServer.ts index 82e1e6ef5ce..4d781c004d3 100644 --- a/tests/cases/fourslash/server/goToDefinitionScriptImportServer.ts +++ b/tests/cases/fourslash/server/goToDefinitionScriptImportServer.ts @@ -19,6 +19,6 @@ // does not exist, but should return a response to it anyway so an editor can create it. //// import [|/*3*/"./foo.txt"|]; -verify.goToDefinition("1", "1d"); -verify.goToDefinition("2", "2d"); -verify.goToDefinition("3", { file: "/foo.txt" }); +verify.goToDefinition("1", { marker: "1d", unverified: true }); +verify.goToDefinition("2", { marker: "2d", unverified: true }); +verify.goToDefinition("3", { file: "/foo.txt", unverified: true }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts b/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts index 45bfd871aea..30c99deb0a8 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts @@ -3,7 +3,7 @@ // @allowNonTsExtensions: true // @Filename: jsDocTypedef_form2.js //// -//// /** [|@typedef {(string | number)} [|{| "contextRangeIndex": 0 |}NumberLike|] |]*/ +//// /** [|@typedef {(string | number)} [|{| "contextRangeIndex": 0 |}NumberLike|]|] */ //// //// /** @type {[|NumberLike|]} */ //// var numberLike; diff --git a/tests/cases/user/grunt/test.json b/tests/cases/user/grunt/test.json new file mode 100644 index 00000000000..12d374564b2 --- /dev/null +++ b/tests/cases/user/grunt/test.json @@ -0,0 +1,4 @@ +{ + "cloneUrl": "https://github.com/gruntjs/grunt.git", + "types": ["node"] +} diff --git a/tests/cases/user/grunt/tsconfig.json b/tests/cases/user/grunt/tsconfig.json new file mode 100644 index 00000000000..a55e38abd3b --- /dev/null +++ b/tests/cases/user/grunt/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "target": "es2019", + "noImplicitAny": false, + "noImplicitThis": true, + "strict": true, + "maxNodeModuleJsDepth": 0, + "noEmit": true, + "allowJs": true, + "checkJs": true, + "types": ["node"], + "lib": ["esnext"] + }, + "include": ["grunt/lib"] +}