diff --git a/scripts/authors.ts b/scripts/authors.ts index b52898244b6..f92511ed6ef 100644 --- a/scripts/authors.ts +++ b/scripts/authors.ts @@ -15,8 +15,8 @@ type Command = { description?: string; }; -const mailMapPath = path.resolve("../.mailmap"); -const authorsPath = path.resolve("../AUTHORS.md"); +const mailMapPath = path.resolve(__dirname, "../.mailmap"); +const authorsPath = path.resolve(__dirname, "../AUTHORS.md"); function getKnownAuthors(): Author[] { const segmentRegExp = /\s?([^<]+)\s+<([^>]+)>/g; @@ -113,56 +113,54 @@ namespace Commands { const cmd = "git shortlog -se " + specs.join(" "); console.log(cmd); const outputRegExp = /\d+\s+([^<]+)<([^>]+)>/; - const tty = process.platform === 'win32' ? 'CON' : '/dev/tty'; const authors: { name: string, email: string, knownAuthor?: Author }[] = []; - child_process.exec(`${cmd} < ${tty}`, { cwd: path.resolve("../") }, function (error, stdout, stderr) { - if (error) { - console.log(stderr.toString()); - } - else { - const output = stdout.toString(); - const lines = output.split("\n"); - lines.forEach(line => { - if (line) { - let match: RegExpExecArray | null; - if (match = outputRegExp.exec(line)) { - authors.push({ name: match[1], email: match[2] }); - } - else { - throw new Error("Could not parse output: " + line); - } + const {output: [error, stdout, stderr]} = child_process.spawnSync(`git`, ["shortlog", "-se", ...specs], { cwd: path.resolve(__dirname, "../") }); + if (error) { + console.log(stderr.toString()); + } + else { + const output = stdout.toString(); + const lines = output.split("\n"); + lines.forEach(line => { + if (line) { + let match: RegExpExecArray | null; + if (match = outputRegExp.exec(line)) { + authors.push({ name: match[1], email: match[2] }); + } + else { + throw new Error("Could not parse output: " + line); } - }); - - const maps = getKnownAuthorMaps(); - - const lookupAuthor = function ({name, email}: { name: string, email: string }) { - return maps.authorsByEmail[email.toLocaleLowerCase()] || maps.authorsByName[name]; - }; - - const knownAuthors = authors - .map(lookupAuthor) - .filter(a => !!a) - .map(getAuthorName); - const unknownAuthors = authors - .filter(a => !lookupAuthor(a)) - .map(a => `${a.name} <${a.email}>`); - - if (knownAuthors.length) { - console.log("\r\n"); - console.log("Found known authors: "); - console.log("====================="); - deduplicate(knownAuthors).sort(sortAuthors).forEach(log); } + }); - if (unknownAuthors.length) { - console.log("\r\n"); - console.log("Found unknown authors: "); - console.log("====================="); - deduplicate(unknownAuthors).sort(sortAuthors).forEach(log); - } + const maps = getKnownAuthorMaps(); + + const lookupAuthor = function ({name, email}: { name: string, email: string }) { + return maps.authorsByEmail[email.toLocaleLowerCase()] || maps.authorsByName[name]; + }; + + const knownAuthors = authors + .map(lookupAuthor) + .filter(a => !!a) + .map(getAuthorName); + const unknownAuthors = authors + .filter(a => !lookupAuthor(a)) + .map(a => `${a.name} <${a.email}>`); + + if (knownAuthors.length) { + console.log("\r\n"); + console.log("Found known authors: "); + console.log("====================="); + deduplicate(knownAuthors).sort(sortAuthors).forEach(log); } - }); + + if (unknownAuthors.length) { + console.log("\r\n"); + console.log("Found unknown authors: "); + console.log("====================="); + deduplicate(unknownAuthors).sort(sortAuthors).forEach(log); + } + } }; listAuthors.description = "List known and unknown authors for a given spec, e.g. 'node authors.js listAuthors origin/release-2.6..origin/release-2.7'"; } diff --git a/scripts/perf-result-post.js b/scripts/perf-result-post.js new file mode 100644 index 00000000000..5b1c4814a93 --- /dev/null +++ b/scripts/perf-result-post.js @@ -0,0 +1,48 @@ +// @ts-check +/// +// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally +const Octokit = require("@octokit/rest"); +const fs = require("fs"); + +const requester = process.env.requesting_user; +const source = process.env.source_issue; +const postedComment = process.env.status_comment; +console.log(`Loading fragment from ${process.argv[3]}...`); +const outputTableText = fs.readFileSync(process.argv[3], { encoding: "utf8" }); +console.log(`Fragment contents: +${outputTableText}`); + +const gh = new Octokit(); +gh.authenticate({ + type: "token", + token: process.argv[2] +}); +gh.issues.createComment({ + number: +source, + owner: "Microsoft", + repo: "TypeScript", + body: `@${requester} +The results of the perf run you requested are in! Here they are: + +${outputTableText}` +}).then(async data => { + console.log(`Results posted!`); + const newCommentUrl = data.data.html_url; + const comment = await gh.issues.getComment({ + owner: "Microsoft", + repo: "TypeScript", + comment_id: +postedComment + }); + const newBody = `${comment.data.body} + +Update: [The results are in!](${newCommentUrl})`; + return await gh.issues.updateComment({ + owner: "Microsoft", + repo: "TypeScript", + comment_id: +postedComment, + body: newBody + }); +}).catch(e => { + console.error(e); + process.exit(1); +}); diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index ff21d76ad8e..b7f01b838fd 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -230,7 +230,7 @@ namespace ts.BuilderState { // Create the reference map, and set the file infos for (const sourceFile of newProgram.getSourceFiles()) { - const version = sourceFile.version; + const version = Debug.assertDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); const oldInfo = useOldState ? oldState!.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { const newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5142d608515..98a459b6ccd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -232,6 +232,7 @@ namespace ts { getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, agumentCount) => getResolvedSignatureWorker(node, candidatesOutArray, agumentCount, CheckMode.IsForSignatureHelp), getExpandedParameters, + hasEffectiveRestParameter, getConstantValue: nodeIn => { const node = getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; @@ -304,6 +305,8 @@ namespace ts { getNeverType: () => neverType, isSymbolAccessible, getObjectFlags, + isArrayType, + isTupleType, isArrayLikeType, isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes, @@ -388,7 +391,7 @@ namespace ts { const intersectionTypes = createMap(); const literalTypes = createMap(); const indexedAccessTypes = createMap(); - const conditionalTypes = createMap(); + const conditionalTypes = createMap(); const evolvingArrayTypes: EvolvingArrayType[] = []; const undefinedProperties = createMap() as UnderscoreEscapedMap; @@ -1471,7 +1474,14 @@ namespace ts { // @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method. // } // - if (location.parent && isClassElement(location.parent)) { + + // class Decorators are resolved outside of the class to avoid referencing type parameters of that class. + // + // type T = number; + // declare function y(x: T): any; + // @param(1 as T) // <-- T should resolve to the type alias outside of class C + // class C {} + if (location.parent && (isClassElement(location.parent) || location.parent.kind === SyntaxKind.ClassDeclaration)) { location = location.parent; } break; @@ -2342,19 +2352,12 @@ namespace ts { } if (moduleNotFoundError) { - // For relative paths, see if this was possibly a projectReference redirect - if (pathIsRelative(moduleReference)) { - const sourceFile = getSourceFileOfNode(location); - const redirects = sourceFile.redirectedReferences; - if (redirects) { - const normalizedTargetPath = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(sourceFile.fileName)); - for (const ext of [Extension.Ts, Extension.Tsx]) { - const probePath = normalizedTargetPath + ext; - if (redirects.indexOf(probePath) >= 0) { - error(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, moduleReference, probePath); - return undefined; - } - } + // See if this was possibly a projectReference redirect + if (resolvedModule) { + const redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName); + if (redirect) { + error(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName); + return undefined; } } @@ -3489,8 +3492,8 @@ namespace ts { context.inferTypeParameters = (type).root.inferTypeParameters; const extendsTypeNode = typeToTypeNodeHelper((type).extendsType, context); context.inferTypeParameters = saveInferTypeParameters; - const trueTypeNode = typeToTypeNodeHelper(getTrueTypeFromConditionalType(type), context); - const falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); + const trueTypeNode = typeToTypeNodeHelper((type).trueType, context); + const falseTypeNode = typeToTypeNodeHelper((type).falseType, context); context.approximateLength += 15; return createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } @@ -5471,9 +5474,6 @@ namespace ts { } return type; } - if (declaration.kind === SyntaxKind.ExportAssignment) { - return widenTypeForVariableLikeDeclaration(checkExpressionCached((declaration).expression), declaration); - } // Handle variable, parameter or property if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { @@ -5484,7 +5484,10 @@ namespace ts { return reportCircularityError(symbol); } let type: Type | undefined; - if (isInJSFile(declaration) && + if (declaration.kind === SyntaxKind.ExportAssignment) { + type = widenTypeForVariableLikeDeclaration(checkExpressionCached((declaration).expression), declaration); + } + else if (isInJSFile(declaration) && (isCallExpression(declaration) || isBinaryExpression(declaration) || isPropertyAccessExpression(declaration) && isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } @@ -7113,6 +7116,15 @@ namespace ts { let stringIndexInfo: IndexInfo | undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); + if (symbol === globalThisSymbol) { + const varsOnly = createMap() as SymbolTable; + members.forEach(p => { + if (!(p.flags & SymbolFlags.BlockScoped)) { + varsOnly.set(p.escapedName, p); + } + }); + members = varsOnly; + } } setStructuredTypeMembers(type, members, emptyArray, emptyArray, undefined, undefined); if (symbol.flags & SymbolFlags.Class) { @@ -7465,6 +7477,10 @@ namespace ts { } function getConstraintOfIndexedAccess(type: IndexedAccessType) { + return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined; + } + + function getConstraintFromIndexedAccess(type: IndexedAccessType) { const objectType = getConstraintOfType(type.objectType) || type.objectType; if (objectType !== type.objectType) { const constraint = getIndexedAccessType(objectType, type.indexType, /*accessNode*/ undefined, errorType); @@ -7476,24 +7492,14 @@ namespace ts { return baseConstraint && baseConstraint !== type ? baseConstraint : undefined; } - function getDefaultConstraintOfTrueBranchOfConditionalType(root: ConditionalRoot, combinedMapper: TypeMapper | undefined, mapper: TypeMapper | undefined) { - const rootTrueType = root.trueType; - const rootTrueConstraint = !(rootTrueType.flags & TypeFlags.Substitution) - ? rootTrueType - : instantiateType(((rootTrueType).substitute), combinedMapper || mapper).flags & TypeFlags.AnyOrUnknown - ? (rootTrueType).typeVariable - : getIntersectionType([(rootTrueType).substitute, (rootTrueType).typeVariable]); - return instantiateType(rootTrueConstraint, combinedMapper || mapper); - } - function getDefaultConstraintOfConditionalType(type: ConditionalType) { if (!type.resolvedDefaultConstraint) { // An `any` branch of a conditional type would normally be viral - specifically, without special handling here, // a conditional type with a single branch of type `any` would be assignable to anything, since it's constraint would simplify to // just `any`. This result is _usually_ unwanted - so instead here we elide an `any` branch from the constraint type, // in effect treating `any` like `never` rather than `unknown` in this location. - const trueConstraint = getDefaultConstraintOfTrueBranchOfConditionalType(type.root, type.combinedMapper, type.mapper); - const falseConstraint = getFalseTypeFromConditionalType(type); + const trueConstraint = getInferredTrueTypeFromConditionalType(type); + const falseConstraint = type.falseType; type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]); } return type.resolvedDefaultConstraint; @@ -7525,10 +7531,14 @@ namespace ts { return undefined; } - function getConstraintOfConditionalType(type: ConditionalType) { + function getConstraintFromConditionalType(type: ConditionalType) { return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type); } + function getConstraintOfConditionalType(type: ConditionalType) { + return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; + } + function getUnionConstraintOfIntersection(type: IntersectionType, targetIsUnion: boolean) { let constraints: Type[] | undefined; let hasDisjointDomainType = false; @@ -7605,7 +7615,7 @@ namespace ts { if (!pushTypeResolution(t, TypeSystemPropertyName.ImmediateBaseConstraint)) { return circularConstraintType; } - if (constraintDepth === 50) { + if (constraintDepth >= 50) { // We have reached 50 recursive invocations of getImmediateBaseConstraint and there is a // very high likelyhood we're dealing with an infinite generic type that perpetually generates // new type identities as we descend into it. We stop the recursion here and mark this type @@ -7672,8 +7682,11 @@ namespace ts { return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } if (t.flags & TypeFlags.Conditional) { - const constraint = getConstraintOfConditionalType(t); - return constraint && getBaseConstraint(constraint); + const constraint = getConstraintFromConditionalType(t); + constraintDepth++; // Penalize repeating conditional types (this captures the recursion within getConstraintFromConditionalType and carries it forward) + const result = constraint && getBaseConstraint(constraint); + constraintDepth--; + return result; } if (t.flags & TypeFlags.Substitution) { return getBaseConstraint((t).substitute); @@ -7769,7 +7782,7 @@ namespace ts { } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined { - let props: Symbol[] | undefined; + const propSet = createMap(); let indexTypes: Type[] | undefined; const isUnion = containingType.flags & TypeFlags.Union; const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; @@ -7784,7 +7797,10 @@ namespace ts { const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - props = appendIfUnique(props, prop); + const id = "" + getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) | (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) | (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | @@ -7806,9 +7822,10 @@ namespace ts { } } } - if (!props) { + if (!propSet.size) { return undefined; } + const props = arrayFrom(propSet.values()); if (props.length === 1 && !(checkFlags & CheckFlags.Partial) && !indexTypes) { return props[0]; } @@ -8298,7 +8315,7 @@ namespace ts { } } signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? - createTypePredicateFromTypePredicateNode(type, signature.declaration!) : + createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate; } Debug.assert(!!signature.resolvedTypePredicate); @@ -8306,13 +8323,13 @@ namespace ts { return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate; } - function createTypePredicateFromTypePredicateNode(node: TypePredicateNode, func: SignatureDeclaration | JSDocSignature): IdentifierTypePredicate | ThisTypePredicate { + function createTypePredicateFromTypePredicateNode(node: TypePredicateNode, signature: Signature): IdentifierTypePredicate | ThisTypePredicate { const { parameterName } = node; const type = getTypeFromTypeNode(node.type); if (parameterName.kind === SyntaxKind.Identifier) { return createIdentifierTypePredicate( parameterName.escapedText as string, - getTypePredicateParameterIndex(func.parameters, parameterName), + findIndex(signature.parameters, p => p.escapedName === parameterName.escapedText), type); } else { @@ -8320,16 +8337,6 @@ namespace ts { } } - function getTypePredicateParameterIndex(parameterList: ReadonlyArray, parameter: Identifier): number { - for (let i = 0; i < parameterList.length; i++) { - const param = parameterList[i]; - if (param.name.kind === SyntaxKind.Identifier && param.name.escapedText === parameter.escapedText) { - return i; - } - } - return -1; - } - function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) { @@ -8860,6 +8867,9 @@ namespace ts { } function getSubstitutionType(typeVariable: TypeVariable, substitute: Type) { + if (substitute.flags & TypeFlags.AnyOrUnknown) { + return typeVariable; + } const result = createType(TypeFlags.Substitution); result.typeVariable = typeVariable; result.substitute = substitute; @@ -9880,6 +9890,7 @@ namespace ts { getNodeLinks(accessNode!).resolvedSymbol = prop; } } + const propType = getTypeOfSymbol(prop); return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ? getFlowTypeOfReference(accessExpression, propType) : @@ -9923,7 +9934,10 @@ namespace ts { return anyType; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports!.has(propName) && (globalThisSymbol.exports!.get(propName)!.flags & SymbolFlags.BlockScoped)) { + error(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(propName), typeToString(objectType)); + } + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { error(accessExpression, Diagnostics.Property_0_is_a_static_member_of_type_1, propName as string, typeToString(objectType)); } @@ -10138,24 +10152,11 @@ namespace ts { const trueType = instantiateType(root.trueType, mapper); const falseType = instantiateType(root.falseType, mapper); const instantiationId = `${root.isDistributive ? "d" : ""}${getTypeId(checkType)}>${getTypeId(extendsType)}?${getTypeId(trueType)}:${getTypeId(falseType)}`; - if (conditionalTypes.has(instantiationId)) { - const result = conditionalTypes.get(instantiationId); - if (result !== undefined) { - return result; - } - // Somehow the conditional type depends on itself - usually via `infer` types in the `extends` clause - // paired with a (potentially deferred) circularly constrained type. - // The conditional _must_ be deferred. - const deferred = getDeferredConditionalType(root, mapper, /*combinedMapper*/ undefined, checkType, extendsType, trueType, falseType); - conditionalTypes.set(instantiationId, deferred); - return deferred; + const result = conditionalTypes.get(instantiationId); + if (result) { + return result; } - conditionalTypes.set(instantiationId, undefined); const newResult = getConditionalTypeWorker(root, mapper, checkType, extendsType, trueType, falseType); - const cachedRecursiveResult = conditionalTypes.get(instantiationId); - if (cachedRecursiveResult) { - return cachedRecursiveResult; - } conditionalTypes.set(instantiationId, newResult); return newResult; } @@ -10164,7 +10165,7 @@ namespace ts { // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. if (falseType.flags & TypeFlags.Never && isTypeIdenticalTo(getActualTypeVariable(trueType), getActualTypeVariable(checkType))) { if (checkType.flags & TypeFlags.Any || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true - return getDefaultConstraintOfTrueBranchOfConditionalType(root, /*combinedMapper*/ undefined, mapper); + return trueType; } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; @@ -10175,7 +10176,7 @@ namespace ts { return neverType; } else if (checkType.flags & TypeFlags.Any || isIntersectionEmpty(checkType, extendsType)) { // Always false - return falseType; // TODO: Intersect negated `extends` type here + return falseType; } } @@ -10230,21 +10231,15 @@ namespace ts { result.extendsType = extendsType; result.mapper = mapper; result.combinedMapper = combinedMapper; - if (!combinedMapper) { - result.resolvedTrueType = trueType; - result.resolvedFalseType = falseType; - } + result.trueType = trueType; + result.falseType = falseType; result.aliasSymbol = root.aliasSymbol; result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper!); // TODO: GH#18217 return result; } - function getTrueTypeFromConditionalType(type: ConditionalType) { - return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper)); - } - - function getFalseTypeFromConditionalType(type: ConditionalType) { - return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper)); + function getInferredTrueTypeFromConditionalType(type: ConditionalType) { + return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = instantiateType(type.root.trueType, type.combinedMapper || type.mapper)); } function getInferTypeParameters(node: ConditionalTypeNode): TypeParameter[] | undefined { @@ -11185,7 +11180,11 @@ namespace ts { return getSubstitutionType(maybeVariable as TypeVariable, instantiateType((type).substitute, mapper)); } else { - return maybeVariable; + const sub = instantiateType((type).substitute, mapper); + if (sub.flags & TypeFlags.AnyOrUnknown || isTypeSubtypeOf(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + return maybeVariable; + } + return sub; } } return type; @@ -11730,6 +11729,15 @@ namespace ts { type ErrorReporter = (message: DiagnosticMessage, arg0?: string, arg1?: string) => void; + /** + * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` + */ + function isAnySignature(s: Signature) { + return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && + s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + isTypeAny(getReturnTypeOfSignature(s)); + } + /** * See signatureRelatedTo, compareSignaturesIdentical */ @@ -11745,6 +11753,10 @@ namespace ts { return Ternary.True; } + if (isAnySignature(target)) { + return Ternary.True; + } + const targetCount = getParameterCount(target); if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return Ternary.False; @@ -11832,7 +11844,7 @@ namespace ts { if (targetTypePredicate) { const sourceTypePredicate = getTypePredicateOfSignature(source); if (sourceTypePredicate) { - result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration!, target.declaration!, reportErrors, errorReporter, compareTypes); // TODO: GH#18217 + result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes); } else if (isIdentifierTypePredicate(targetTypePredicate)) { if (reportErrors) { @@ -11857,8 +11869,6 @@ namespace ts { function compareTypePredicateRelatedTo( source: TypePredicate, target: TypePredicate, - sourceDeclaration: SignatureDeclaration | JSDocSignature, - targetDeclaration: SignatureDeclaration | JSDocSignature, reportErrors: boolean, errorReporter: ErrorReporter | undefined, compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { @@ -11871,12 +11881,9 @@ namespace ts { } if (source.kind === TypePredicateKind.Identifier) { - const targetPredicate = target as IdentifierTypePredicate; - const sourceIndex = source.parameterIndex - (getThisParameter(sourceDeclaration) ? 1 : 0); - const targetIndex = targetPredicate.parameterIndex - (getThisParameter(targetDeclaration) ? 1 : 0); - if (sourceIndex !== targetIndex) { + if (source.parameterIndex !== (target as IdentifierTypePredicate).parameterIndex) { if (reportErrors) { - errorReporter!(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, targetPredicate.parameterName); + errorReporter!(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, (target as IdentifierTypePredicate).parameterName); errorReporter!(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return Ternary.False; @@ -12714,8 +12721,8 @@ namespace ts { if ((source).root.isDistributive === (target).root.isDistributive) { if (result = isRelatedTo((source).checkType, (target).checkType, /*reportErrors*/ false)) { if (result &= isRelatedTo((source).extendsType, (target).extendsType, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).trueType, (target).trueType, /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).falseType, (target).falseType, /*reportErrors*/ false)) { return result; } } @@ -12836,7 +12843,7 @@ namespace ts { return result; } } - const constraint = getConstraintOfType(source); + const constraint = getConstraintOfType(source); if (!constraint || (source.flags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) { @@ -12868,8 +12875,8 @@ namespace ts { // and Y1 is related to Y2. if (isTypeIdenticalTo((source).extendsType, (target).extendsType) && (isRelatedTo((source).checkType, (target).checkType) || isRelatedTo((target).checkType, (source).checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); + if (result = isRelatedTo((source).trueType, (target).trueType, reportErrors)) { + result &= isRelatedTo((source).falseType, (target).falseType, reportErrors); } if (result) { errorInfo = saveErrorInfo; @@ -14283,7 +14290,7 @@ namespace ts { } } - function forEachMatchingParameterType(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) { + function applyToParameterTypes(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) { const sourceCount = getParameterCount(source); const targetCount = getParameterCount(target); const sourceRestType = getEffectiveRestType(source); @@ -14305,6 +14312,18 @@ namespace ts { } } + function applyToReturnTypes(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) { + const sourceTypePredicate = getTypePredicateOfSignature(source); + const targetTypePredicate = getTypePredicateOfSignature(target); + if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && + (sourceTypePredicate.kind === TypePredicateKind.This || sourceTypePredicate.parameterIndex === (targetTypePredicate).parameterIndex)) { + callback(sourceTypePredicate.type, targetTypePredicate.type); + } + else { + callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + } + function createInferenceContext(typeParameters: ReadonlyArray, signature: Signature | undefined, flags: InferenceFlags, compareTypes?: TypeComparer): InferenceContext { return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable); } @@ -14523,10 +14542,9 @@ namespace ts { emptyObjectType; } - function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { + function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) { let symbolStack: Symbol[]; let visited: Map; - let contravariant = false; let bivariant = false; let propagationType: Type; let allowComplexConstraintInference = true; @@ -14617,9 +14635,11 @@ namespace ts { const candidate = propagationType || source; // We make contravariant inferences only if we are in a pure contravariant position, // i.e. only if we have not descended into a bivariant position. - if (contravariant && !bivariant && !contains(inference.contraCandidates, candidate)) { - inference.contraCandidates = append(inference.contraCandidates, candidate); - inference.inferredType = undefined; + if (contravariant && !bivariant) { + if (!contains(inference.contraCandidates, candidate)) { + inference.contraCandidates = append(inference.contraCandidates, candidate); + inference.inferredType = undefined; + } } else if (!contains(inference.candidates, candidate)) { inference.candidates = append(inference.candidates, candidate); @@ -14691,12 +14711,12 @@ namespace ts { else if (source.flags & TypeFlags.Conditional && target.flags & TypeFlags.Conditional) { inferFromTypes((source).checkType, (target).checkType); inferFromTypes((source).extendsType, (target).extendsType); - inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); - inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); + inferFromTypes((source).trueType, (target).trueType); + inferFromTypes((source).falseType, (target).falseType); } else if (target.flags & TypeFlags.Conditional && !contravariant) { - inferFromTypes(source, getTrueTypeFromConditionalType(target)); - inferFromTypes(source, getFalseTypeFromConditionalType(target)); + inferFromTypes(source, (target).trueType); + inferFromTypes(source, (target).falseType); } else if (target.flags & TypeFlags.UnionOrIntersection) { for (const t of (target).types) { @@ -14924,17 +14944,10 @@ namespace ts { const kind = target.declaration ? target.declaration.kind : SyntaxKind.Unknown; // Once we descend into a bivariant signature we remain bivariant for all nested inferences bivariant = bivariant || kind === SyntaxKind.MethodDeclaration || kind === SyntaxKind.MethodSignature || kind === SyntaxKind.Constructor; - forEachMatchingParameterType(source, target, inferFromContravariantTypes); + applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } - const sourceTypePredicate = getTypePredicateOfSignature(source); - const targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind) { - inferFromTypes(sourceTypePredicate.type, targetTypePredicate.type); - } - else { - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } + applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source: Type, target: Type) { @@ -16600,7 +16613,7 @@ namespace ts { } if (isIdentifierTypePredicate(predicate)) { - const predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; + const predicateArgument = callExpression.arguments[predicate.parameterIndex]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -19530,7 +19543,10 @@ namespace ts { return anyType; } if (leftType.symbol === globalThisSymbol) { - if (noImplicitAny) { + if (globalThisSymbol.exports!.has(right.escapedText) && (globalThisSymbol.exports!.get(right.escapedText)!.flags & SymbolFlags.BlockScoped)) { + error(right, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); + } + else if (noImplicitAny) { error(right, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType)); } return anyType; @@ -20170,18 +20186,14 @@ namespace ts { const restType = getEffectiveRestType(contextualSignature); const mapper = inferenceContext && (restType && restType.flags & TypeFlags.TypeParameter ? inferenceContext.nonFixingMapper : inferenceContext.mapper); const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; - forEachMatchingParameterType(sourceSignature, signature, (source, target) => { + applyToParameterTypes(sourceSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context.inferences, source, target); }); if (!inferenceContext) { - inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), InferencePriority.ReturnType); - const signaturePredicate = getTypePredicateOfSignature(signature); - const contextualPredicate = getTypePredicateOfSignature(sourceSignature); - if (signaturePredicate && contextualPredicate && signaturePredicate.kind === contextualPredicate.kind && - (signaturePredicate.kind === TypePredicateKind.This || signaturePredicate.parameterIndex === (contextualPredicate as IdentifierTypePredicate).parameterIndex)) { - inferTypes(context.inferences, contextualPredicate.type, signaturePredicate.type, InferencePriority.ReturnType); - } + applyToReturnTypes(contextualSignature, signature, (source, target) => { + inferTypes(context.inferences, source, target, InferencePriority.ReturnType); + }); } return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration)); } @@ -23520,23 +23532,30 @@ namespace ts { // potentially add inferred type parameters to the outer function return type. const returnSignature = context.signature && getSingleCallSignature(getReturnTypeOfSignature(context.signature)); if (returnSignature && !returnSignature.typeParameters && !every(context.inferences, hasInferenceCandidates)) { - // Instantiate the expression type with its own type parameters as type arguments. This - // ensures that the type parameters are not erased to type any during type inference such - // that they can be inferred as actual types. + // Instantiate the signature with its own type parameters as type arguments, possibly + // renaming the type parameters to ensure they have unique names. const uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters); - const strippedType = getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters)); - // Infer from the stripped expression type to the contextual type starting with an empty - // set of inference candidates. + const instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters); + // Infer from the parameters of the instantiated signature to the parameters of the + // contextual signature starting with an empty set of inference candidates. const inferences = map(context.inferences, info => createInferenceInfo(info.typeParameter)); - inferTypes(inferences, strippedType, contextualType); - // If we produced some inference candidates and if the type parameters for which we produced - // candidates do not already have existing inferences, we adopt the new inference candidates and - // add the type parameters of the expression type to the set of inferred type parameters for - // the outer function return type. - if (some(inferences, hasInferenceCandidates) && !hasOverlappingInferences(context.inferences, inferences)) { - mergeInferences(context.inferences, inferences); - context.inferredTypeParameters = concatenate(context.inferredTypeParameters, uniqueTypeParameters); - return strippedType; + applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => { + inferTypes(inferences, source, target, /*priority*/ 0, /*contravariant*/ true); + }); + if (some(inferences, hasInferenceCandidates)) { + // We have inference candidates, indicating that one or more type parameters are referenced + // in the parameter types of the contextual signature. Now also infer from the return type. + applyToReturnTypes(instantiatedSignature, contextualSignature, (source, target) => { + inferTypes(inferences, source, target); + }); + // If the type parameters for which we produced candidates do not have any inferences yet, + // we adopt the new inference candidates and add the type parameters of the expression type + // to the set of inferred type parameters for the outer function return type. + if (!hasOverlappingInferences(context.inferences, inferences)) { + mergeInferences(context.inferences, inferences); + context.inferredTypeParameters = concatenate(context.inferredTypeParameters, uniqueTypeParameters); + return getOrCreateTypeFromSignature(instantiatedSignature); + } } } return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context)); @@ -23880,7 +23899,8 @@ namespace ts { return; } - const typePredicate = getTypePredicateOfSignature(getSignatureFromDeclaration(parent)); + const signature = getSignatureFromDeclaration(parent); + const typePredicate = getTypePredicateOfSignature(signature); if (!typePredicate) { return; } @@ -23893,14 +23913,13 @@ namespace ts { } else { if (typePredicate.parameterIndex >= 0) { - if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { - error(parameterName, - Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); + if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + error(parameterName, Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { const leadingError = () => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); checkTypeAssignableTo(typePredicate.type, - getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), + getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, /*headMessage*/ undefined, leadingError); @@ -27985,8 +28004,8 @@ namespace ts { // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & SymbolFlags.ValueModule - && symbol.declarations.length > 1 && !inAmbientContext + && symbol.declarations.length > 1 && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { const firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 979423cdfaa..b188e708a62 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -74,12 +74,7 @@ namespace ts { // TODO(shkamat): update this after reworking ts build API export function createCompilerHostWorker(options: CompilerOptions, setParentNodes?: boolean, system = sys): CompilerHost { const existingDirectories = createMap(); - function getCanonicalFileName(fileName: string): string { - // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. - // otherwise use toLowerCase as a canonical form. - return system.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - + const getCanonicalFileName = createGetCanonicalFileName(system.useCaseSensitiveFileNames); function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined { let text: string | undefined; try { @@ -2268,7 +2263,6 @@ namespace ts { if (refFile) { const redirect = getProjectReferenceRedirect(fileName); if (redirect) { - ((refFile.redirectedReferences || (refFile.redirectedReferences = [])) as string[]).push(fileName); fileName = redirect; // Once we start redirecting to a file, we can potentially come back to it // via a back-reference from another file in the .d.ts folder. If that happens we'll diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 9508613321c..8d20f94afed 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -690,9 +690,15 @@ namespace ts { /* parameters */ [], /* type */ undefined, /* equalsGreaterThanToken */ undefined, - createPropertyAccess( - createSuper(), - name + setEmitFlags( + createPropertyAccess( + setEmitFlags( + createSuper(), + EmitFlags.NoSubstitution + ), + name + ), + EmitFlags.NoSubstitution ) ) )); @@ -717,9 +723,16 @@ namespace ts { /* type */ undefined, /* equalsGreaterThanToken */ undefined, createAssignment( - createPropertyAccess( - createSuper(), - name), + setEmitFlags( + createPropertyAccess( + setEmitFlags( + createSuper(), + EmitFlags.NoSubstitution + ), + name + ), + EmitFlags.NoSubstitution + ), createIdentifier("v") ) ) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 4a127f3236d..63d621c6654 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1338,11 +1338,14 @@ namespace ts { let decorators: (ReadonlyArray | undefined)[] | undefined; if (node) { const parameters = node.parameters; - for (let i = 0; i < parameters.length; i++) { - const parameter = parameters[i]; + const firstParameterIsThis = parameters.length > 0 && parameterIsThisKeyword(parameters[0]); + const firstParameterOffset = firstParameterIsThis ? 1 : 0; + const numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length; + for (let i = 0; i < numParameters; i++) { + const parameter = parameters[i + firstParameterOffset]; if (decorators || parameter.decorators) { if (!decorators) { - decorators = new Array(parameters.length); + decorators = new Array(numParameters); } decorators[i] = parameter.decorators; diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index c649665cf72..cc79c02f1d6 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -792,6 +792,15 @@ namespace ts { newerInputFileName: newestInputFileName }; } + else { + // Check tsconfig time + const configStatus = checkConfigFileUpToDateStatus(project.options.configFilePath!, oldestOutputFileTime, oldestOutputFileName); + if (configStatus) return configStatus; + + // Check extended config time + const extendedConfigStatus = forEach(project.options.configFile!.extendedSourceFiles || emptyArray, configFile => checkConfigFileUpToDateStatus(configFile, oldestOutputFileTime, oldestOutputFileName)); + if (extendedConfigStatus) return extendedConfigStatus; + } if (!buildInfoChecked.hasKey(project.options.configFilePath as ResolvedConfigFileName)) { buildInfoChecked.setValue(project.options.configFilePath as ResolvedConfigFileName, true); @@ -828,6 +837,18 @@ namespace ts { }; } + function checkConfigFileUpToDateStatus(configFile: string, oldestOutputFileTime: Date, oldestOutputFileName: string): Status.OutOfDateWithSelf | undefined { + // Check tsconfig time + const tsconfigTime = host.getModifiedTime(configFile) || missingFileModifiedTime; + if (oldestOutputFileTime < tsconfigTime) { + return { + type: UpToDateStatusType.OutOfDateWithSelf, + outOfDateOutputFileName: oldestOutputFileName, + newerInputFileName: configFile + }; + } + } + function invalidateProject(configFileName: string, reloadLevel?: ConfigFileProgramReloadLevel) { invalidateResolvedProject(resolveProjectName(configFileName), reloadLevel); } @@ -1178,6 +1199,7 @@ namespace ts { } function getOldProgram(proj: ResolvedConfigFileName, parsed: ParsedCommandLine) { + if (options.force) return undefined; const value = builderPrograms.getValue(proj); if (value) return value; return readBuilderProgram(parsed.options, readFileWithCache) as any as T; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fbf83e6a205..bcc3218a017 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2740,12 +2740,6 @@ namespace ts { /* @internal */ resolvedModules?: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; /* @internal */ imports: ReadonlyArray; - /** - * When a file's references are redirected due to project reference directives, - * the original names of the references are stored in this array - */ - /* @internal*/ - redirectedReferences?: ReadonlyArray; // Identifier only if `declare global` /* @internal */ moduleAugmentations: ReadonlyArray; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; @@ -3074,6 +3068,7 @@ namespace ts { getSourceFiles(): ReadonlyArray; getSourceFile(fileName: string): SourceFile | undefined; getResolvedTypeReferenceDirectives(): ReadonlyMap; + getProjectReferenceRedirect(fileName: string): string | undefined; readonly redirectTargetsMap: RedirectTargetsMap; } @@ -3171,6 +3166,7 @@ namespace ts { getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; /* @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; /* @internal */ getExpandedParameters(sig: Signature): ReadonlyArray; + /* @internal */ hasEffectiveRestParameter(sig: Signature): boolean; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; isUndefinedSymbol(symbol: Symbol): boolean; @@ -3251,6 +3247,8 @@ namespace ts { /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ isArrayType(type: Type): boolean; + /* @internal */ isTupleType(type: Type): boolean; /* @internal */ isArrayLikeType(type: Type): boolean; /* @internal */ getObjectFlags(type: Type): ObjectFlags; @@ -4312,8 +4310,10 @@ namespace ts { root: ConditionalRoot; checkType: Type; extendsType: Type; - resolvedTrueType?: Type; - resolvedFalseType?: Type; + trueType: Type; + falseType: Type; + /* @internal */ + resolvedInferredTrueType?: Type; // The `trueType` instantiated with the `combinedMapper`, if present /* @internal */ resolvedDefaultConstraint?: Type; /* @internal */ diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 8a94393e2ce..9b08c54222f 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -275,7 +275,7 @@ namespace ts { } } - export function setGetSourceFileAsHashVersioned(compilerHost: CompilerHost, host: ProgramHost) { + export function setGetSourceFileAsHashVersioned(compilerHost: CompilerHost, host: { createHash?(data: string): string; }) { const originalGetSourceFile = compilerHost.getSourceFile; const computeHash = host.createHash || generateDjb2Hash; compilerHost.getSourceFile = (...args) => { @@ -383,6 +383,56 @@ namespace ts { if (!buildInfo.program) return undefined; return createBuildProgramUsingProgramBuildInfo(buildInfo.program); } + + export function createIncrementalCompilerHost(options: CompilerOptions, system = sys): CompilerHost { + const host = createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); + host.createHash = maybeBind(system, system.createHash); + setGetSourceFileAsHashVersioned(host, system); + changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName)); + return host; + } + + interface IncrementalProgramOptions { + rootNames: ReadonlyArray; + options: CompilerOptions; + configFileParsingDiagnostics?: ReadonlyArray; + projectReferences?: ReadonlyArray; + host?: CompilerHost; + createProgram?: CreateProgram; + } + function createIncrementalProgram({ + rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram + }: IncrementalProgramOptions): T { + host = host || createIncrementalCompilerHost(options); + createProgram = createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram; + const oldProgram = readBuilderProgram(options, path => host!.readFile(path)) as any as T; + return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences); + } + + export interface IncrementalCompilationOptions { + rootNames: ReadonlyArray; + options: CompilerOptions; + configFileParsingDiagnostics?: ReadonlyArray; + projectReferences?: ReadonlyArray; + host?: CompilerHost; + reportDiagnostic?: DiagnosticReporter; + reportErrorSummary?: ReportEmitErrorSummary; + afterProgramEmitAndDiagnostics?(program: EmitAndSemanticDiagnosticsBuilderProgram): void; + system?: System; + } + export function performIncrementalCompilation(input: IncrementalCompilationOptions) { + const system = input.system || sys; + const host = input.host || (input.host = createIncrementalCompilerHost(input.options, system)); + const builderProgram = createIncrementalProgram(input); + const exitStatus = emitFilesAndReportErrors( + builderProgram, + input.reportDiagnostic || createDiagnosticReporter(system), + s => host.trace && host.trace(s), + input.reportErrorSummary || input.options.pretty ? errorCount => system.write(getErrorSummaryText(errorCount, system.newLine)) : undefined + ); + if (input.afterProgramEmitAndDiagnostics) input.afterProgramEmitAndDiagnostics(builderProgram); + return exitStatus; + } } namespace ts { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 16f1a37ae83..089a2630dd8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4425,7 +4425,7 @@ namespace FourSlashInterface { } export namespace Completion { const functionEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "function", kindModifiers: "declare" }); - const constEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "const", kindModifiers: "declare" }); + const varEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "var", kindModifiers: "declare" }); const moduleEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "module", kindModifiers: "declare" }); const keywordEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "keyword" }); const methodEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "method", kindModifiers: "declare" }); @@ -4448,48 +4448,48 @@ namespace FourSlashInterface { typeEntry("PropertyKey"), interfaceEntry("PropertyDescriptor"), interfaceEntry("PropertyDescriptorMap"), - constEntry("Object"), + varEntry("Object"), interfaceEntry("ObjectConstructor"), - constEntry("Function"), + varEntry("Function"), interfaceEntry("FunctionConstructor"), typeEntry("ThisParameterType"), typeEntry("OmitThisParameter"), interfaceEntry("CallableFunction"), interfaceEntry("NewableFunction"), interfaceEntry("IArguments"), - constEntry("String"), + varEntry("String"), interfaceEntry("StringConstructor"), - constEntry("Boolean"), + varEntry("Boolean"), interfaceEntry("BooleanConstructor"), - constEntry("Number"), + varEntry("Number"), interfaceEntry("NumberConstructor"), interfaceEntry("TemplateStringsArray"), interfaceEntry("ImportMeta"), - constEntry("Math"), - constEntry("Date"), + varEntry("Math"), + varEntry("Date"), interfaceEntry("DateConstructor"), interfaceEntry("RegExpMatchArray"), interfaceEntry("RegExpExecArray"), - constEntry("RegExp"), + varEntry("RegExp"), interfaceEntry("RegExpConstructor"), - constEntry("Error"), + varEntry("Error"), interfaceEntry("ErrorConstructor"), - constEntry("EvalError"), + varEntry("EvalError"), interfaceEntry("EvalErrorConstructor"), - constEntry("RangeError"), + varEntry("RangeError"), interfaceEntry("RangeErrorConstructor"), - constEntry("ReferenceError"), + varEntry("ReferenceError"), interfaceEntry("ReferenceErrorConstructor"), - constEntry("SyntaxError"), + varEntry("SyntaxError"), interfaceEntry("SyntaxErrorConstructor"), - constEntry("TypeError"), + varEntry("TypeError"), interfaceEntry("TypeErrorConstructor"), - constEntry("URIError"), + varEntry("URIError"), interfaceEntry("URIErrorConstructor"), - constEntry("JSON"), + varEntry("JSON"), interfaceEntry("ReadonlyArray"), interfaceEntry("ConcatArray"), - constEntry("Array"), + varEntry("Array"), interfaceEntry("ArrayConstructor"), interfaceEntry("TypedPropertyDescriptor"), typeEntry("ClassDecorator"), @@ -4513,30 +4513,30 @@ namespace FourSlashInterface { typeEntry("ReturnType"), typeEntry("InstanceType"), interfaceEntry("ThisType"), - constEntry("ArrayBuffer"), + varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), typeEntry("ArrayBufferLike"), interfaceEntry("ArrayBufferConstructor"), interfaceEntry("ArrayBufferView"), - constEntry("DataView"), + varEntry("DataView"), interfaceEntry("DataViewConstructor"), - constEntry("Int8Array"), + varEntry("Int8Array"), interfaceEntry("Int8ArrayConstructor"), - constEntry("Uint8Array"), + varEntry("Uint8Array"), interfaceEntry("Uint8ArrayConstructor"), - constEntry("Uint8ClampedArray"), + varEntry("Uint8ClampedArray"), interfaceEntry("Uint8ClampedArrayConstructor"), - constEntry("Int16Array"), + varEntry("Int16Array"), interfaceEntry("Int16ArrayConstructor"), - constEntry("Uint16Array"), + varEntry("Uint16Array"), interfaceEntry("Uint16ArrayConstructor"), - constEntry("Int32Array"), + varEntry("Int32Array"), interfaceEntry("Int32ArrayConstructor"), - constEntry("Uint32Array"), + varEntry("Uint32Array"), interfaceEntry("Uint32ArrayConstructor"), - constEntry("Float32Array"), + varEntry("Float32Array"), interfaceEntry("Float32ArrayConstructor"), - constEntry("Float64Array"), + varEntry("Float64Array"), interfaceEntry("Float64ArrayConstructor"), moduleEntry("Intl"), ]; @@ -4552,9 +4552,47 @@ namespace FourSlashInterface { ]; } + function getInJsKeywords(keywords: ReadonlyArray): ReadonlyArray { + return keywords.filter(keyword => { + switch (keyword.name) { + case "enum": + case "interface": + case "implements": + case "private": + case "protected": + case "public": + case "abstract": + case "any": + case "boolean": + case "declare": + case "infer": + case "is": + case "keyof": + case "module": + case "namespace": + case "never": + case "readonly": + case "number": + case "object": + case "string": + case "symbol": + case "type": + case "unique": + case "unknown": + case "global": + case "bigint": + return false; + default: + return true; + } + }); + } + export const classElementKeywords: ReadonlyArray = ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"].map(keywordEntry); + export const classElementInJsKeywords = getInJsKeywords(classElementKeywords); + export const constructorParameterKeywords: ReadonlyArray = ["private", "protected", "public", "readonly"].map((name): ExpectedCompletionEntryObject => ({ name, kind: "keyword" })); @@ -4692,6 +4730,8 @@ namespace FourSlashInterface { } }); + export const statementInJsKeywords = getInJsKeywords(statementKeywords); + export const globalsVars: ReadonlyArray = [ functionEntry("eval"), functionEntry("parseInt"), @@ -4704,36 +4744,36 @@ namespace FourSlashInterface { functionEntry("encodeURIComponent"), functionEntry("escape"), functionEntry("unescape"), - constEntry("NaN"), - constEntry("Infinity"), - constEntry("Object"), - constEntry("Function"), - constEntry("String"), - constEntry("Boolean"), - constEntry("Number"), - constEntry("Math"), - constEntry("Date"), - constEntry("RegExp"), - constEntry("Error"), - constEntry("EvalError"), - constEntry("RangeError"), - constEntry("ReferenceError"), - constEntry("SyntaxError"), - constEntry("TypeError"), - constEntry("URIError"), - constEntry("JSON"), - constEntry("Array"), - constEntry("ArrayBuffer"), - constEntry("DataView"), - constEntry("Int8Array"), - constEntry("Uint8Array"), - constEntry("Uint8ClampedArray"), - constEntry("Int16Array"), - constEntry("Uint16Array"), - constEntry("Int32Array"), - constEntry("Uint32Array"), - constEntry("Float32Array"), - constEntry("Float64Array"), + varEntry("NaN"), + varEntry("Infinity"), + varEntry("Object"), + varEntry("Function"), + varEntry("String"), + varEntry("Boolean"), + varEntry("Number"), + varEntry("Math"), + varEntry("Date"), + varEntry("RegExp"), + varEntry("Error"), + varEntry("EvalError"), + varEntry("RangeError"), + varEntry("ReferenceError"), + varEntry("SyntaxError"), + varEntry("TypeError"), + varEntry("URIError"), + varEntry("JSON"), + varEntry("Array"), + varEntry("ArrayBuffer"), + varEntry("DataView"), + varEntry("Int8Array"), + varEntry("Uint8Array"), + varEntry("Uint8ClampedArray"), + varEntry("Int16Array"), + varEntry("Uint16Array"), + varEntry("Int32Array"), + varEntry("Uint32Array"), + varEntry("Float32Array"), + varEntry("Float64Array"), moduleEntry("Intl"), ]; @@ -4793,6 +4833,18 @@ namespace FourSlashInterface { ...globalKeywordsInsideFunction, ]; + const globalInJsKeywordsInsideFunction = getInJsKeywords(globalKeywordsInsideFunction); + + // TODO: many of these are inappropriate to always provide + export const globalsInJsInsideFunction = (plus: ReadonlyArray): ReadonlyArray => [ + { name: "arguments", kind: "local var" }, + { name: "globalThis", kind: "module" }, + ...globalsVars, + ...plus, + { name: "undefined", kind: "var" }, + ...globalInJsKeywordsInsideFunction, + ]; + // TODO: many of these are inappropriate to always provide export const globalKeywords: ReadonlyArray = [ "break", @@ -4871,6 +4923,8 @@ namespace FourSlashInterface { "of", ].map(keywordEntry); + export const globalInJsKeywords = getInJsKeywords(globalKeywords); + export const insideMethodKeywords: ReadonlyArray = [ "break", "case", @@ -4917,6 +4971,8 @@ namespace FourSlashInterface { "await", ].map(keywordEntry); + export const insideMethodInJsKeywords = getInJsKeywords(insideMethodKeywords); + export const globalKeywordsPlusUndefined: ReadonlyArray = (() => { const i = ts.findIndex(globalKeywords, x => x.name === "unique"); return [...globalKeywords.slice(0, i), keywordEntry("undefined"), ...globalKeywords.slice(i)]; @@ -4929,6 +4985,13 @@ namespace FourSlashInterface { ...globalKeywords ]; + export const globalsInJs: ReadonlyArray = [ + { name: "globalThis", kind: "module" }, + ...globalsVars, + { name: "undefined", kind: "var" }, + ...globalInJsKeywords + ]; + export function globalsPlus(plus: ReadonlyArray): ReadonlyArray { return [ { name: "globalThis", kind: "module" }, @@ -4937,6 +5000,15 @@ namespace FourSlashInterface { { name: "undefined", kind: "var" }, ...globalKeywords]; } + + export function globalsInJsPlus(plus: ReadonlyArray): ReadonlyArray { + return [ + { name: "globalThis", kind: "module" }, + ...globalsVars, + ...plus, + { name: "undefined", kind: "var" }, + ...globalInJsKeywords]; + } } export interface ReferenceGroup { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 4112f5a2ae7..458dc8b9252 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,8 +2,8 @@ /// ECMAScript APIs ///////////////////////////// -declare const NaN: number; -declare const Infinity: number; +declare var NaN: number; +declare var Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -244,7 +244,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare const Object: ObjectConstructor; +declare var Object: ObjectConstructor; /** * Creates a new function. @@ -293,7 +293,7 @@ interface FunctionConstructor { readonly prototype: Function; } -declare const Function: FunctionConstructor; +declare var Function: FunctionConstructor; /** * Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter. @@ -504,7 +504,7 @@ interface StringConstructor { /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare const String: StringConstructor; +declare var String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -517,7 +517,7 @@ interface BooleanConstructor { readonly prototype: Boolean; } -declare const Boolean: BooleanConstructor; +declare var Boolean: BooleanConstructor; interface Number { /** @@ -579,7 +579,7 @@ interface NumberConstructor { } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare const Number: NumberConstructor; +declare var Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { readonly raw: ReadonlyArray; @@ -703,7 +703,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare const Math: Math; +declare var Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -884,7 +884,7 @@ interface DateConstructor { now(): number; } -declare const Date: DateConstructor; +declare var Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -947,7 +947,7 @@ interface RegExpConstructor { lastMatch: string; } -declare const RegExp: RegExpConstructor; +declare var RegExp: RegExpConstructor; interface Error { name: string; @@ -961,7 +961,7 @@ interface ErrorConstructor { readonly prototype: Error; } -declare const Error: ErrorConstructor; +declare var Error: ErrorConstructor; interface EvalError extends Error { } @@ -972,7 +972,7 @@ interface EvalErrorConstructor { readonly prototype: EvalError; } -declare const EvalError: EvalErrorConstructor; +declare var EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -983,7 +983,7 @@ interface RangeErrorConstructor { readonly prototype: RangeError; } -declare const RangeError: RangeErrorConstructor; +declare var RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -994,7 +994,7 @@ interface ReferenceErrorConstructor { readonly prototype: ReferenceError; } -declare const ReferenceError: ReferenceErrorConstructor; +declare var ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -1005,7 +1005,7 @@ interface SyntaxErrorConstructor { readonly prototype: SyntaxError; } -declare const SyntaxError: SyntaxErrorConstructor; +declare var SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -1016,7 +1016,7 @@ interface TypeErrorConstructor { readonly prototype: TypeError; } -declare const TypeError: TypeErrorConstructor; +declare var TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -1027,7 +1027,7 @@ interface URIErrorConstructor { readonly prototype: URIError; } -declare const URIError: URIErrorConstructor; +declare var URIError: URIErrorConstructor; interface JSON { /** @@ -1056,7 +1056,7 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare const JSON: JSON; +declare var JSON: JSON; ///////////////////////////// @@ -1345,7 +1345,7 @@ interface ArrayConstructor { readonly prototype: Array; } -declare const Array: ArrayConstructor; +declare var Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -1504,7 +1504,7 @@ interface ArrayBufferConstructor { new(byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare const ArrayBuffer: ArrayBufferConstructor; +declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -1654,7 +1654,7 @@ interface DataView { interface DataViewConstructor { new(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView; } -declare const DataView: DataViewConstructor; +declare var DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -1929,7 +1929,7 @@ interface Int8ArrayConstructor { } -declare const Int8Array: Int8ArrayConstructor; +declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -2204,7 +2204,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } -declare const Uint8Array: Uint8ArrayConstructor; +declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -2478,7 +2478,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -2753,7 +2753,7 @@ interface Int16ArrayConstructor { } -declare const Int16Array: Int16ArrayConstructor; +declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -3029,7 +3029,7 @@ interface Uint16ArrayConstructor { } -declare const Uint16Array: Uint16ArrayConstructor; +declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -3303,7 +3303,7 @@ interface Int32ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } -declare const Int32Array: Int32ArrayConstructor; +declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -3577,7 +3577,7 @@ interface Uint32ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } -declare const Uint32Array: Uint32ArrayConstructor; +declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -3853,7 +3853,7 @@ interface Float32ArrayConstructor { } -declare const Float32Array: Float32ArrayConstructor; +declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -4128,7 +4128,7 @@ interface Float64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } -declare const Float64Array: Float64ArrayConstructor; +declare var Float64Array: Float64ArrayConstructor; ///////////////////////////// /// ECMAScript Internationalization API diff --git a/src/lib/esnext.bigint.d.ts b/src/lib/esnext.bigint.d.ts index 667422bf890..5718e4a5751 100644 --- a/src/lib/esnext.bigint.d.ts +++ b/src/lib/esnext.bigint.d.ts @@ -34,7 +34,7 @@ interface BigIntConstructor { asUintN(bits: number, int: bigint): bigint; } -declare const BigInt: BigIntConstructor; +declare var BigInt: BigIntConstructor; /** * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the @@ -303,7 +303,7 @@ interface BigInt64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; } -declare const BigInt64Array: BigInt64ArrayConstructor; +declare var BigInt64Array: BigInt64ArrayConstructor; /** * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the @@ -572,7 +572,7 @@ interface BigUint64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; } -declare const BigUint64Array: BigUint64ArrayConstructor; +declare var BigUint64Array: BigUint64ArrayConstructor; interface DataView { /** @@ -606,4 +606,4 @@ interface DataView { * otherwise a little-endian value should be written. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; -} \ No newline at end of file +} diff --git a/src/server/session.ts b/src/server/session.ts index 7cc3f595f82..6cf0619efd1 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -659,16 +659,32 @@ namespace ts.server { } } - if (fileRequest && this.logger.hasLevel(LogLevel.verbose)) { - try { - const { file, project } = this.getFileAndProject(fileRequest); - const scriptInfo = project.getScriptInfoForNormalizedPath(file); - if (scriptInfo) { - const text = getSnapshotText(scriptInfo.getSnapshot()); - msg += `\n\nFile text of ${fileRequest.file}:${indent(text)}\n`; + if (this.logger.hasLevel(LogLevel.verbose)) { + if (fileRequest) { + try { + const { file, project } = this.getFileAndProject(fileRequest); + const scriptInfo = project.getScriptInfoForNormalizedPath(file); + if (scriptInfo) { + const text = getSnapshotText(scriptInfo.getSnapshot()); + msg += `\n\nFile text of ${fileRequest.file}:${indent(text)}\n`; + } } + catch { } // tslint:disable-line no-empty + } + + if (err.message && err.message.indexOf(`Could not find sourceFile:`) !== -1) { + msg += `\n\nProjects::\n`; + let counter = 0; + const addProjectInfo = (project: Project) => { + msg += `\nProject '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter}\n`; + msg += project.filesToString(/*writeProjectFileNames*/ true); + msg += "\n-----------------------------------------------\n"; + counter++; + }; + this.projectService.externalProjects.forEach(addProjectInfo); + this.projectService.configuredProjects.forEach(addProjectInfo); + this.projectService.inferredProjects.forEach(addProjectInfo); } - catch {} // tslint:disable-line no-empty } this.logger.msg(msg, Msg.Err); diff --git a/src/services/completions.ts b/src/services/completions.ts index 5cdaca020cd..01324c9dc84 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -30,6 +30,7 @@ namespace ts.Completions { ConstructorParameterKeywords, // Keywords at constructor parameter FunctionLikeBodyKeywords, // Keywords at function like body TypeKeywords, + Last = TypeKeywords } const enum GlobalsSearch { Continue, Success, Fail } @@ -77,7 +78,7 @@ namespace ts.Completions { } function completionInfoFromData(sourceFile: SourceFile, typeChecker: TypeChecker, compilerOptions: CompilerOptions, log: Log, completionData: CompletionData, preferences: UserPreferences): CompletionInfo | undefined { - const { symbols, completionKind, isInSnippetScope, isNewIdentifierLocation, location, propertyAccessToConvert, keywordFilters, literals, symbolToOriginInfoMap, recommendedCompletion, isJsxInitializer } = completionData; + const { symbols, completionKind, isInSnippetScope, isNewIdentifierLocation, location, propertyAccessToConvert, keywordFilters, literals, symbolToOriginInfoMap, recommendedCompletion, isJsxInitializer, insideJsDocTagTypeExpression } = completionData; if (location && location.parent && isJsxClosingElement(location.parent)) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, @@ -113,7 +114,7 @@ namespace ts.Completions { if (keywordFilters !== KeywordCompletionFilters.None) { const entryNames = arrayToSet(entries, e => e.name); - for (const keywordEntry of getKeywordCompletions(keywordFilters)) { + for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) { if (!entryNames.has(keywordEntry.name)) { entries.push(keywordEntry); } @@ -510,6 +511,7 @@ namespace ts.Completions { readonly recommendedCompletion: Symbol | undefined; readonly previousToken: Node | undefined; readonly isJsxInitializer: IsJsxInitializer; + readonly insideJsDocTagTypeExpression: boolean; } type Request = { readonly kind: CompletionDataKind.JsDocTagName | CompletionDataKind.JsDocTag } | { readonly kind: CompletionDataKind.JsDocParameterName, tag: JSDocParameterTag }; @@ -837,7 +839,22 @@ namespace ts.Completions { const literals = mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), t => t.isLiteral() ? t.value : undefined); const recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); - return { kind: CompletionDataKind.Data, symbols, completionKind, isInSnippetScope, propertyAccessToConvert, isNewIdentifierLocation, location, keywordFilters, literals, symbolToOriginInfoMap, recommendedCompletion, previousToken, isJsxInitializer }; + return { + kind: CompletionDataKind.Data, + symbols, + completionKind, + isInSnippetScope, + propertyAccessToConvert, + isNewIdentifierLocation, + location, + keywordFilters, + literals, + symbolToOriginInfoMap, + recommendedCompletion, + previousToken, + isJsxInitializer, + insideJsDocTagTypeExpression + }; type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag; @@ -890,7 +907,9 @@ namespace ts.Completions { } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) { + if (!isTypeLocation && + symbol.declarations && + symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } @@ -1927,7 +1946,18 @@ namespace ts.Completions { } return res; }); - function getKeywordCompletions(keywordFilter: KeywordCompletionFilters): ReadonlyArray { + + function getKeywordCompletions(keywordFilter: KeywordCompletionFilters, filterOutTsOnlyKeywords: boolean): ReadonlyArray { + if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); + + const index = keywordFilter + KeywordCompletionFilters.Last + 1; + return _keywordCompletions[index] || + (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) + .filter(entry => !isTypeScriptOnlyKeyword(stringToToken(entry.name)!)) + ); + } + + function getTypescriptKeywordCompletions(keywordFilter: KeywordCompletionFilters): ReadonlyArray { return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(entry => { const kind = stringToToken(entry.name)!; switch (keywordFilter) { @@ -1952,6 +1982,40 @@ namespace ts.Completions { })); } + function isTypeScriptOnlyKeyword(kind: SyntaxKind) { + switch (kind) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AnyKeyword: + case SyntaxKind.BigIntKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.EnumKeyword: + case SyntaxKind.GlobalKeyword: + case SyntaxKind.ImplementsKeyword: + case SyntaxKind.InferKeyword: + case SyntaxKind.InterfaceKeyword: + case SyntaxKind.IsKeyword: + case SyntaxKind.KeyOfKeyword: + case SyntaxKind.ModuleKeyword: + case SyntaxKind.NamespaceKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.PublicKeyword: + case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.TypeKeyword: + case SyntaxKind.UniqueKeyword: + case SyntaxKind.UnknownKeyword: + return true; + default: + return false; + } + } + function isInterfaceOrTypeLiteralCompletionKeyword(kind: SyntaxKind): boolean { return kind === SyntaxKind.ReadonlyKeyword; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index ef6a344c992..147fee53393 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -586,25 +586,28 @@ namespace ts.FindAllReferences.Core { } else { const search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.isForRename, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); - - // Try to get the smallest valid scope that we can limit our search to; - // otherwise we'll need to search globally (i.e. include each file). - const scope = getSymbolScope(symbol); - if (scope) { - getReferencesInContainer(scope, scope.getSourceFile(), search, state, /*addReferencesHere*/ !(isSourceFile(scope) && !contains(sourceFiles, scope))); - } - else { - // Global search - for (const sourceFile of state.sourceFiles) { - state.cancellationToken.throwIfCancellationRequested(); - searchForName(sourceFile, search, state); - } - } + getReferencesInContainerOrFiles(symbol, state, search); } return result; } + function getReferencesInContainerOrFiles(symbol: Symbol, state: State, search: Search): void { + // Try to get the smallest valid scope that we can limit our search to; + // otherwise we'll need to search globally (i.e. include each file). + const scope = getSymbolScope(symbol); + if (scope) { + getReferencesInContainer(scope, scope.getSourceFile(), search, state, /*addReferencesHere*/ !(isSourceFile(scope) && !contains(state.sourceFiles, scope))); + } + else { + // Global search + for (const sourceFile of state.sourceFiles) { + state.cancellationToken.throwIfCancellationRequested(); + searchForName(sourceFile, search, state); + } + } + } + function getSpecialSearchKind(node: Node): SpecialSearchKind { switch (node.kind) { case SyntaxKind.ConstructorKeyword: @@ -707,7 +710,6 @@ namespace ts.FindAllReferences.Core { constructor( readonly sourceFiles: ReadonlyArray, readonly sourceFilesSet: ReadonlyMap, - /** True if we're searching for constructor references. */ readonly specialSearchKind: SpecialSearchKind, readonly checker: TypeChecker, readonly cancellationToken: CancellationToken, @@ -1293,6 +1295,7 @@ namespace ts.FindAllReferences.Core { const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); if (classExtending) { findSuperConstructorAccesses(classExtending, pusher()); + findInheritedConstructorReferences(classExtending, state); } } } @@ -1325,35 +1328,44 @@ namespace ts.FindAllReferences.Core { * Reference the constructor and all calls to `new this()`. */ function findOwnConstructorReferences(classSymbol: Symbol, sourceFile: SourceFile, addNode: (node: Node) => void): void { - for (const decl of classSymbol.members!.get(InternalSymbolName.Constructor)!.declarations) { - const ctrKeyword = findChildOfKind(decl, SyntaxKind.ConstructorKeyword, sourceFile)!; - Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); - addNode(ctrKeyword); + const constructorSymbol = getClassConstructorSymbol(classSymbol); + if (constructorSymbol) { + for (const decl of constructorSymbol.declarations) { + const ctrKeyword = findChildOfKind(decl, SyntaxKind.ConstructorKeyword, sourceFile)!; + Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); + addNode(ctrKeyword); + } } - classSymbol.exports!.forEach(member => { - const decl = member.valueDeclaration; - if (decl && decl.kind === SyntaxKind.MethodDeclaration) { - const body = (decl).body; - if (body) { - forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { - if (isNewExpressionTarget(thisKeyword)) { - addNode(thisKeyword); - } - }); + if (classSymbol.exports) { + classSymbol.exports.forEach(member => { + const decl = member.valueDeclaration; + if (decl && decl.kind === SyntaxKind.MethodDeclaration) { + const body = (decl).body; + if (body) { + forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { + if (isNewExpressionTarget(thisKeyword)) { + addNode(thisKeyword); + } + }); + } } - } - }); + }); + } + } + + function getClassConstructorSymbol(classSymbol: Symbol): Symbol | undefined { + return classSymbol.members && classSymbol.members.get(InternalSymbolName.Constructor); } /** Find references to `super` in the constructor of an extending class. */ - function findSuperConstructorAccesses(cls: ClassLikeDeclaration, addNode: (node: Node) => void): void { - const ctr = cls.symbol.members!.get(InternalSymbolName.Constructor); - if (!ctr) { + function findSuperConstructorAccesses(classDeclaration: ClassLikeDeclaration, addNode: (node: Node) => void): void { + const constructor = getClassConstructorSymbol(classDeclaration.symbol); + if (!constructor) { return; } - for (const decl of ctr.declarations) { + for (const decl of constructor.declarations) { Debug.assert(decl.kind === SyntaxKind.Constructor); const body = (decl).body; if (body) { @@ -1366,6 +1378,17 @@ namespace ts.FindAllReferences.Core { } } + function hasOwnConstructor(classDeclaration: ClassLikeDeclaration): boolean { + return !!getClassConstructorSymbol(classDeclaration.symbol); + } + + function findInheritedConstructorReferences(classDeclaration: ClassLikeDeclaration, state: State): void { + if (hasOwnConstructor(classDeclaration)) return; + const classSymbol = classDeclaration.symbol; + const search = state.createSearch(/*location*/ undefined, classSymbol, /*comingFrom*/ undefined); + getReferencesInContainerOrFiles(classSymbol, state, search); + } + function addImplementationReferences(refNode: Node, addReference: (node: Node) => void, state: State): void { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { diff --git a/src/services/refactors/convertParamsToDestructuredObject.ts b/src/services/refactors/convertParamsToDestructuredObject.ts index f813f8ef768..7d2eded741e 100644 --- a/src/services/refactors/convertParamsToDestructuredObject.ts +++ b/src/services/refactors/convertParamsToDestructuredObject.ts @@ -81,7 +81,7 @@ namespace ts.refactor.convertParamsToDestructuredObject { const references = flatMap(names, /*mapfn*/ name => FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken)); const groupedReferences = groupReferences(references); - if (!every(groupedReferences.declarations, decl => contains(names, decl))) { + if (!every(groupedReferences.declarations, /*callback*/ decl => contains(names, decl))) { groupedReferences.valid = false; } @@ -99,7 +99,19 @@ namespace ts.refactor.convertParamsToDestructuredObject { groupedReferences.valid = false; continue; } - if (contains(functionSymbols, checker.getSymbolAtLocation(entry.node), symbolComparer)) { + + /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function. + Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test: + class A { foo(a: number, b: number) { return a + b; } } + class B { foo(c: number, d: number) { return c + d; } } + declare const ab: A | B; + ab.foo(1, 2); + Find all references will return `ab.foo(1, 2)` as a reference to A's `foo` but we could be calling B's `foo`. + When looking for constructor calls, however, the symbol on the constructor call reference is going to be the corresponding class symbol. + So we need to add a special case for this because when calling a constructor of a class through one of its subclasses, + the symbols are going to be different. + */ + if (contains(functionSymbols, checker.getSymbolAtLocation(entry.node), symbolComparer) || isNewExpressionTarget(entry.node)) { const decl = entryToDeclaration(entry); if (decl) { groupedReferences.declarations.push(decl); @@ -233,6 +245,10 @@ namespace ts.refactor.convertParamsToDestructuredObject { function getFunctionDeclarationAtPosition(file: SourceFile, startPosition: number, checker: TypeChecker): ValidFunctionDeclaration | undefined { const node = getTouchingToken(file, startPosition); const functionDeclaration = getContainingFunction(node); + + // don't offer refactor on top-level JSDoc + if (isTopLevelJSDoc(node)) return undefined; + if (functionDeclaration && isValidFunctionDeclaration(functionDeclaration, checker) && rangeContainsRange(functionDeclaration, node) @@ -241,18 +257,35 @@ namespace ts.refactor.convertParamsToDestructuredObject { return undefined; } - function isValidFunctionDeclaration(functionDeclaration: SignatureDeclaration, checker: TypeChecker): functionDeclaration is ValidFunctionDeclaration { - if (!isValidParameterNodeArray(functionDeclaration.parameters)) return false; + function isTopLevelJSDoc(node: Node): boolean { + const containingJSDoc = findAncestor(node, isJSDocNode); + if (containingJSDoc) { + const containingNonJSDoc = findAncestor(containingJSDoc, n => !isJSDocNode(n)); + return !!containingNonJSDoc && isFunctionLikeDeclaration(containingNonJSDoc); + } + return false; + } + + function isValidFunctionDeclaration( + functionDeclaration: SignatureDeclaration, + checker: TypeChecker): functionDeclaration is ValidFunctionDeclaration { + if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { case SyntaxKind.FunctionDeclaration: case SyntaxKind.MethodDeclaration: - return !!functionDeclaration.name && !!functionDeclaration.body && !checker.isImplementationOfOverload(functionDeclaration); + return !!functionDeclaration.name + && !!functionDeclaration.body + && !checker.isImplementationOfOverload(functionDeclaration); case SyntaxKind.Constructor: if (isClassDeclaration(functionDeclaration.parent)) { - return !!functionDeclaration.body && !!functionDeclaration.parent.name && !checker.isImplementationOfOverload(functionDeclaration); + return !!functionDeclaration.body + && !!functionDeclaration.parent.name + && !checker.isImplementationOfOverload(functionDeclaration); } else { - return isValidVariableDeclaration(functionDeclaration.parent.parent) && !!functionDeclaration.body && !checker.isImplementationOfOverload(functionDeclaration); + return isValidVariableDeclaration(functionDeclaration.parent.parent) + && !!functionDeclaration.body + && !checker.isImplementationOfOverload(functionDeclaration); } case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: @@ -261,12 +294,21 @@ namespace ts.refactor.convertParamsToDestructuredObject { return false; } - function isValidParameterNodeArray(parameters: NodeArray): parameters is ValidParameterNodeArray { - return getRefactorableParametersLength(parameters) >= minimumParameterLength && every(parameters, isValidParameterDeclaration); + function isValidParameterNodeArray( + parameters: NodeArray, + checker: TypeChecker): parameters is ValidParameterNodeArray { + return getRefactorableParametersLength(parameters) >= minimumParameterLength + && every(parameters, /*callback*/ paramDecl => isValidParameterDeclaration(paramDecl, checker)); } - function isValidParameterDeclaration(paramDeclaration: ParameterDeclaration): paramDeclaration is ValidParameterDeclaration { - return !paramDeclaration.modifiers && !paramDeclaration.decorators && isIdentifier(paramDeclaration.name); + function isValidParameterDeclaration( + parameterDeclaration: ParameterDeclaration, + checker: TypeChecker): parameterDeclaration is ValidParameterDeclaration { + if (isRestParameter(parameterDeclaration)) { + const type = checker.getTypeAtLocation(parameterDeclaration); + if (!checker.isArrayType(type) && !checker.isTupleType(type)) return false; + } + return !parameterDeclaration.modifiers && !parameterDeclaration.decorators && isIdentifier(parameterDeclaration.name); } function isValidVariableDeclaration(node: Node): node is ValidVariableDeclaration { @@ -291,13 +333,23 @@ namespace ts.refactor.convertParamsToDestructuredObject { return parameters; } + function createPropertyOrShorthandAssignment(name: string, initializer: Expression): PropertyAssignment | ShorthandPropertyAssignment { + if (isIdentifier(initializer) && getTextOfIdentifierOrLiteral(initializer) === name) { + return createShorthandPropertyAssignment(name); + } + return createPropertyAssignment(name, initializer); + } + function createNewArgument(functionDeclaration: ValidFunctionDeclaration, functionArguments: NodeArray): ObjectLiteralExpression { const parameters = getRefactorableParameters(functionDeclaration.parameters); const hasRestParameter = isRestParameter(last(parameters)); const nonRestArguments = hasRestParameter ? functionArguments.slice(0, parameters.length - 1) : functionArguments; const properties = map(nonRestArguments, (arg, i) => { - const property = createPropertyAssignment(getParameterName(parameters[i]), arg); - suppressLeadingAndTrailingTrivia(property.initializer); + const parameterName = getParameterName(parameters[i]); + const property = createPropertyOrShorthandAssignment(parameterName, arg); + + suppressLeadingAndTrailingTrivia(property.name); + if (isPropertyAssignment(property)) suppressLeadingAndTrailingTrivia(property.initializer); copyComments(arg, property); return property; }); @@ -313,15 +365,15 @@ namespace ts.refactor.convertParamsToDestructuredObject { } function createNewParameters(functionDeclaration: ValidFunctionDeclaration, program: Program, host: LanguageServiceHost): NodeArray { + const checker = program.getTypeChecker(); const refactorableParameters = getRefactorableParameters(functionDeclaration.parameters); const bindingElements = map(refactorableParameters, createBindingElementFromParameterDeclaration); const objectParameterName = createObjectBindingPattern(bindingElements); const objectParameterType = createParameterTypeNode(refactorableParameters); - const checker = program.getTypeChecker(); let objectInitializer: Expression | undefined; // If every parameter in the original function was optional, add an empty object initializer to the new object parameter - if (every(refactorableParameters, checker.isOptionalParameter)) { + if (every(refactorableParameters, isOptionalParameter)) { objectInitializer = createObjectLiteral(); } @@ -355,6 +407,20 @@ namespace ts.refactor.convertParamsToDestructuredObject { } return createNodeArray([objectParameter]); + function createBindingElementFromParameterDeclaration(parameterDeclaration: ValidParameterDeclaration): BindingElement { + const element = createBindingElement( + /*dotDotDotToken*/ undefined, + /*propertyName*/ undefined, + getParameterName(parameterDeclaration), + isRestParameter(parameterDeclaration) && isOptionalParameter(parameterDeclaration) ? createArrayLiteral() : parameterDeclaration.initializer); + + suppressLeadingAndTrailingTrivia(element); + if (parameterDeclaration.initializer && element.initializer) { + copyComments(parameterDeclaration.initializer, element.initializer); + } + return element; + } + function createParameterTypeNode(parameters: NodeArray): TypeLiteralNode { const members = map(parameters, createPropertySignatureFromParameterDeclaration); const typeNode = addEmitFlags(createTypeLiteralNode(members), EmitFlags.SingleLine); @@ -370,7 +436,7 @@ namespace ts.refactor.convertParamsToDestructuredObject { const propertySignature = createPropertySignature( /*modifiers*/ undefined, getParameterName(parameterDeclaration), - parameterDeclaration.initializer || isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : parameterDeclaration.questionToken, + isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); @@ -384,24 +450,17 @@ namespace ts.refactor.convertParamsToDestructuredObject { } function getTypeNode(node: Node): TypeNode | undefined { - const checker = program.getTypeChecker(); const type = checker.getTypeAtLocation(node); return getTypeNodeIfAccessible(type, node, program, host); } - } - function createBindingElementFromParameterDeclaration(parameterDeclaration: ValidParameterDeclaration): BindingElement { - const element = createBindingElement( - /*dotDotDotToken*/ undefined, - /*propertyName*/ undefined, - getParameterName(parameterDeclaration), - isRestParameter(parameterDeclaration) ? createArrayLiteral() : parameterDeclaration.initializer); - - suppressLeadingAndTrailingTrivia(element); - if (parameterDeclaration.initializer && element.initializer) { - copyComments(parameterDeclaration.initializer, element.initializer); + function isOptionalParameter(parameterDeclaration: ValidParameterDeclaration): boolean { + if (isRestParameter(parameterDeclaration)) { + const type = checker.getTypeAtLocation(parameterDeclaration); + return !checker.isTupleType(type); + } + return checker.isOptionalParameter(parameterDeclaration); } - return element; } function copyComments(sourceNode: Node, targetNode: Node) { diff --git a/src/services/services.ts b/src/services/services.ts index 7f5772d1489..5f0d3472a3e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1158,7 +1158,7 @@ namespace ts { function getValidSourceFile(fileName: string): SourceFile { const sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find file: '" + fileName + "'."); + throw new Error(`Could not find sourceFile: '${fileName}' in ${program && JSON.stringify(program.getSourceFiles().map(f => f.fileName))}.`); } return sourceFile; } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 70f94e95fc9..0c9f76acacb 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -566,7 +566,7 @@ namespace ts.SignatureHelp { } function itemInfoForParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo { - const isVariadic = candidateSignature.hasRestParameter; + const isVariadic = checker.hasEffectiveRestParameter(candidateSignature); const printer = createPrinter({ removeComments: true }); const typeParameterParts = mapToDisplayParts(writer => { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { diff --git a/src/testRunner/unittests/config/projectReferences.ts b/src/testRunner/unittests/config/projectReferences.ts index 6c8863314fa..3acffd7a8c6 100644 --- a/src/testRunner/unittests/config/projectReferences.ts +++ b/src/testRunner/unittests/config/projectReferences.ts @@ -284,6 +284,28 @@ namespace ts { assertHasError("Issues a useful error", program.getSemanticDiagnostics(), Diagnostics.Output_file_0_has_not_been_built_from_source_file_1); }); }); + + it("issues a nice error when the input file is missing when module reference is not relative", () => { + const spec: TestSpecification = { + "/alpha": { + files: { "/alpha/a.ts": "export const m: number = 3;" }, + references: [] + }, + "/beta": { + files: { "/beta/b.ts": "import { m } from '@alpha/a'" }, + references: ["../alpha"], + options: { + baseUrl: "./", + paths: { + "@alpha/*": ["/alpha/*"] + } + } + } + }; + testProjectReferences(spec, "/beta/tsconfig.json", program => { + assertHasError("Issues a useful error", program.getSemanticDiagnostics(), Diagnostics.Output_file_0_has_not_been_built_from_source_file_1); + }); + }); }); /** diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index c225840a564..6d128b348cc 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -168,14 +168,14 @@ namespace ts { }); describe("can detect when and what to rebuild", () => { - function initializeWithBuild() { + function initializeWithBuild(opts?: BuildOptions) { const fs = projFs.shadow(); const host = new fakes.SolutionBuilderHost(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.buildAllProjects(); host.clearDiagnostics(); tick(); - builder.resetBuildContext(); + builder.resetBuildContext(opts ? { ...opts, verbose: true } : undefined); return { fs, host, builder }; } @@ -254,6 +254,65 @@ namespace ts { [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], ); }); + + it("rebuilds from start if --f is passed", () => { + const { host, builder } = initializeWithBuild({ force: true }); + builder.buildAllProjects(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + [Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/logic/tsconfig.json"], + [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], + [Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/tests/tsconfig.json"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"] + ); + }); + + it("rebuilds when tsconfig changes", () => { + const { fs, host, builder } = initializeWithBuild(); + replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`); + builder.buildAllProjects(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], + [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] + ); + }); + + it("rebuilds when extended config file changes", () => { + const fs = projFs.shadow(); + fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: { target: "es3" } })); + replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`); + const host = new fakes.SolutionBuilderHost(fs); + const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); + builder.buildAllProjects(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"], + [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"] + ); + host.clearDiagnostics(); + tick(); + builder.resetBuildContext(); + fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} })); + builder.buildAllProjects(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.base.json"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], + [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] + ); + }); }); describe("downstream-blocked compilations", () => { diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts index 98a2d4ffa4b..f8647393cb1 100644 --- a/src/testRunner/unittests/tscWatch/helpers.ts +++ b/src/testRunner/unittests/tscWatch/helpers.ts @@ -57,20 +57,23 @@ namespace ts.tscWatch { function checkOutputErrors( host: WatchedSystem, logsBeforeWatchDiagnostic: string[] | undefined, - preErrorsWatchDiagnostic: Diagnostic, + preErrorsWatchDiagnostic: Diagnostic | undefined, logsBeforeErrors: string[] | undefined, errors: ReadonlyArray | ReadonlyArray, disableConsoleClears?: boolean | undefined, - ...postErrorsWatchDiagnostics: Diagnostic[] + ...postErrorsWatchDiagnostics: Diagnostic[] | string[] ) { let screenClears = 0; const outputs = host.getOutput(); - const expectedOutputCount = 1 + errors.length + postErrorsWatchDiagnostics.length + - (logsBeforeWatchDiagnostic ? logsBeforeWatchDiagnostic.length : 0) + (logsBeforeErrors ? logsBeforeErrors.length : 0); + const expectedOutputCount = (preErrorsWatchDiagnostic ? 1 : 0) + + errors.length + + postErrorsWatchDiagnostics.length + + (logsBeforeWatchDiagnostic ? logsBeforeWatchDiagnostic.length : 0) + + (logsBeforeErrors ? logsBeforeErrors.length : 0); assert.equal(outputs.length, expectedOutputCount, JSON.stringify(outputs)); let index = 0; forEach(logsBeforeWatchDiagnostic, log => assertLog("logsBeforeWatchDiagnostic", log)); - assertWatchDiagnostic(preErrorsWatchDiagnostic); + if (preErrorsWatchDiagnostic) assertWatchDiagnostic(preErrorsWatchDiagnostic); forEach(logsBeforeErrors, log => assertLog("logBeforeError", log)); // Verify errors forEach(errors, assertDiagnostic); @@ -98,13 +101,18 @@ namespace ts.tscWatch { index++; } - function assertWatchDiagnostic(diagnostic: Diagnostic) { - const expected = getWatchDiagnosticWithoutDate(diagnostic); - if (!disableConsoleClears && contains(screenStartingMessageCodes, diagnostic.code)) { - assert.equal(host.screenClears[screenClears], index, `Expected screen clear at this diagnostic: ${expected}`); - screenClears++; + function assertWatchDiagnostic(diagnostic: Diagnostic | string) { + if (isString(diagnostic)) { + assert.equal(outputs[index], diagnostic, getOutputAtFailedMessage("Diagnostic", diagnostic)); + } + else { + const expected = getWatchDiagnosticWithoutDate(diagnostic); + if (!disableConsoleClears && contains(screenStartingMessageCodes, diagnostic.code)) { + assert.equal(host.screenClears[screenClears], index, `Expected screen clear at this diagnostic: ${expected}`); + screenClears++; + } + assert.isTrue(endsWith(outputs[index], expected), getOutputAtFailedMessage("Watch diagnostic", expected)); } - assert.isTrue(endsWith(outputs[index], expected), getOutputAtFailedMessage("Watch diagnostic", expected)); index++; } @@ -159,6 +167,18 @@ namespace ts.tscWatch { assert.equal(host.exitCode, expectedExitCode); } + export function checkNormalBuildErrors(host: WatchedSystem, errors: ReadonlyArray | ReadonlyArray, reportErrorSummary?: boolean) { + checkOutputErrors( + host, + /*logsBeforeWatchDiagnostic*/ undefined, + /*preErrorsWatchDiagnostic*/ undefined, + /*logsBeforeErrors*/ undefined, + errors, + /*disableConsoleClears*/ undefined, + ...(reportErrorSummary ? [getErrorSummaryText(errors.length, host.newLine)] : emptyArray) + ); + } + function isDiagnosticMessageChain(message: DiagnosticMessage | DiagnosticMessageChain): message is DiagnosticMessageChain { return !!(message as DiagnosticMessageChain).messageText; } diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts index f21f994914c..35ec5bff555 100644 --- a/src/testRunner/unittests/tscWatch/incremental.ts +++ b/src/testRunner/unittests/tscWatch/incremental.ts @@ -15,9 +15,51 @@ namespace ts.tscWatch { expectedIncrementalEmit?: ReadonlyArray; expectedIncrementalErrors?: ReadonlyArray; } - function verifyIncrementalWatchEmit({ - files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors - }: VerifyIncrementalWatchEmitInput) { + function verifyIncrementalWatchEmit(input: VerifyIncrementalWatchEmitInput) { + it("with tsc --w", () => { + verifyIncrementalWatchEmitWorker({ + input, + emitAndReportErrors: createWatchOfConfigFile, + verifyErrors: checkOutputErrorsInitial + }); + }); + it("with tsc", () => { + verifyIncrementalWatchEmitWorker({ + input, + emitAndReportErrors: incrementalBuild, + verifyErrors: checkNormalBuildErrors + }); + }); + } + + function incrementalBuild(configFile: string, host: WatchedSystem) { + const reportDiagnostic = createDiagnosticReporter(host); + const config = parseConfigFileWithSystem(configFile, {}, host, reportDiagnostic); + if (config) { + performIncrementalCompilation({ + rootNames: config.fileNames, + options: config.options, + projectReferences: config.projectReferences, + configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config), + reportDiagnostic, + system: host + }); + } + return { close: noop }; + } + + interface VerifyIncrementalWatchEmitWorkerInput { + input: VerifyIncrementalWatchEmitInput; + emitAndReportErrors: (configFile: string, host: WatchedSystem) => { close(): void; }; + verifyErrors: (host: WatchedSystem, errors: ReadonlyArray) => void; + } + function verifyIncrementalWatchEmitWorker({ + input: { + files, expectedInitialEmit, expectedInitialErrors, modifyFs, expectedIncrementalEmit, expectedIncrementalErrors + }, + emitAndReportErrors, + verifyErrors + }: VerifyIncrementalWatchEmitWorkerInput) { const host = createWatchedSystem(files, { currentDirectory: project }); const originalWriteFile = host.writeFile; const writtenFiles = createMap(); @@ -26,19 +68,41 @@ namespace ts.tscWatch { writtenFiles.set(path, content); originalWriteFile.call(host, path, content); }; - verifyWatch(host, writtenFiles, expectedInitialEmit, expectedInitialErrors); + verifyBuild({ + host, + writtenFiles, + emitAndReportErrors, + verifyErrors, + expectedEmit: expectedInitialEmit, + expectedErrors: expectedInitialErrors + }); if (modifyFs) { modifyFs(host); - verifyWatch(host, writtenFiles, Debug.assertDefined(expectedIncrementalEmit), Debug.assertDefined(expectedIncrementalErrors)); + verifyBuild({ + host, + writtenFiles, + emitAndReportErrors, + verifyErrors, + expectedEmit: Debug.assertDefined(expectedIncrementalEmit), + expectedErrors: Debug.assertDefined(expectedIncrementalErrors) + }); } } - function verifyWatch(host: WatchedSystem, writtenFiles: Map, expectedEmit: ReadonlyArray, expectedErrors: ReadonlyArray) { + interface VerifyBuildWorker { + host: WatchedSystem; + writtenFiles: Map; + emitAndReportErrors: VerifyIncrementalWatchEmitWorkerInput["emitAndReportErrors"]; + verifyErrors: VerifyIncrementalWatchEmitWorkerInput["verifyErrors"]; + expectedEmit: ReadonlyArray; + expectedErrors: ReadonlyArray; + } + function verifyBuild({ host, writtenFiles, emitAndReportErrors, verifyErrors, expectedEmit, expectedErrors }: VerifyBuildWorker) { writtenFiles.clear(); - const watch = createWatchOfConfigFile("tsconfig.json", host); + const result = emitAndReportErrors("tsconfig.json", host); checkFileEmit(writtenFiles, expectedEmit); - checkOutputErrorsInitial(host, expectedErrors); - watch.close(); + verifyErrors(host, expectedErrors); + result.close(); } function checkFileEmit(actual: Map, expected: ReadonlyArray) { @@ -73,7 +137,7 @@ namespace ts.tscWatch { content: "var y = 20;\n" }; - it("own file emit without errors", () => { + describe("own file emit without errors", () => { const modifiedFile2Content = file2.content.replace("y", "z").replace("20", "10"); verifyIncrementalWatchEmit({ files: [libFile, file1, file2, configFile], @@ -125,7 +189,7 @@ namespace ts.tscWatch { }); }); - it("own file emit with errors", () => { + describe("own file emit with errors", () => { const fileModified: File = { path: file2.path, content: `const y: string = 20;` @@ -208,7 +272,7 @@ namespace ts.tscWatch { }); }); - it("with --out", () => { + describe("with --out", () => { const config: File = { path: configFile.path, content: JSON.stringify({ compilerOptions: { incremental: true, outFile: "out.js" } }) @@ -279,7 +343,7 @@ namespace ts.tscWatch { content: JSON.stringify({ compilerOptions: { incremental: true, module: "amd" } }) }; - it("own file emit without errors", () => { + describe("own file emit without errors", () => { const modifiedFile2Content = file2.content.replace("y", "z").replace("20", "10"); verifyIncrementalWatchEmit({ files: [libFile, file1, file2, config], @@ -330,7 +394,7 @@ namespace ts.tscWatch { }); }); - it("own file emit with errors", () => { + describe("own file emit with errors", () => { const fileModified: File = { path: file2.path, content: `export const y: string = 20;` @@ -412,7 +476,7 @@ namespace ts.tscWatch { }); }); - it("with --out", () => { + describe("with --out", () => { const config: File = { path: configFile.path, content: JSON.stringify({ compilerOptions: { incremental: true, module: "amd", outFile: "out.js" } }) diff --git a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts index 26b7857347a..53a1cb4e421 100644 --- a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts +++ b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts @@ -139,7 +139,7 @@ namespace ts.projectSystem { assert.isTrue(false, `should not find file '${imported.path}'`); } catch (e) { - assert.isTrue(e.message.indexOf(`Could not find file: '${imported.path}'.`) === 0); + assert.isTrue(e.message.indexOf(`Could not find sourceFile: '${imported.path}' in ["${root.path}"].`) === 0, `Actual: ${e.message}`); } const f2Lookups = getLocationsForModuleLookup("f2"); callsTrackingHost.verifyCalledOnEachEntryNTimes(CalledMapsWithSingleArg.fileExists, f2Lookups, 1); diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index b5624b07ec1..ccc04d38088 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -13,7 +13,7 @@ namespace ts { } let reportDiagnostic = createDiagnosticReporter(sys); - function updateReportDiagnostic(options?: CompilerOptions) { + function updateReportDiagnostic(options: CompilerOptions | BuildOptions) { if (shouldBePretty(options)) { reportDiagnostic = createDiagnosticReporter(sys, /*pretty*/ true); } @@ -23,7 +23,7 @@ namespace ts { return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY(); } - function shouldBePretty(options?: CompilerOptions) { + function shouldBePretty(options: CompilerOptions | BuildOptions) { if (!options || typeof options.pretty === "undefined") { return defaultIsPretty(); } @@ -192,7 +192,7 @@ namespace ts { } // Update to pretty if host supports it - updateReportDiagnostic(); + updateReportDiagnostic(buildOptions); if (projects.length === 0) { printVersion(); printHelp(buildOpts, "--build "); @@ -209,8 +209,8 @@ namespace ts { // Use default createProgram const buildHost = buildOptions.watch ? - createSolutionBuilderWithWatchHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : - createSolutionBuilderHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); + createSolutionBuilderWithWatchHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty(buildOptions)), createWatchStatusReporter(buildOptions)) : + createSolutionBuilderHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty(buildOptions)), createReportErrorSummary(buildOptions)); updateCreateProgram(buildHost); buildHost.afterProgramEmitAndDiagnostics = (program: BuilderProgram) => reportStatistics(program.getProgram()); @@ -260,40 +260,16 @@ namespace ts { function performIncrementalCompilation(config: ParsedCommandLine) { const { options, fileNames, projectReferences } = config; - const host = createCompilerHost(options); - const currentDirectory = host.getCurrentDirectory(); - const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames()); - changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, currentDirectory, getCanonicalFileName)); enableStatistics(options); - const oldProgram = readBuilderProgram(options, path => host.readFile(path)); - const configFileParsingDiagnostics = getConfigFileParsingDiagnostics(config); - const programOptions: CreateProgramOptions = { + return sys.exit(ts.performIncrementalCompilation({ rootNames: fileNames, options, - projectReferences, - host, configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config), - }; - const program = createProgram(programOptions); - const builderProgram = createEmitAndSemanticDiagnosticsBuilderProgram( - program, - { - useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, - createHash: maybeBind(sys, sys.createHash), - writeFile: (path, data, writeByteOrderMark) => sys.writeFile(path, data, writeByteOrderMark) - }, - oldProgram, - configFileParsingDiagnostics - ); - - const exitStatus = emitFilesAndReportErrors( - builderProgram, + projectReferences, reportDiagnostic, - s => sys.write(s + sys.newLine), - createReportErrorSummary(options) - ); - reportStatistics(program); - return sys.exit(exitStatus); + reportErrorSummary: createReportErrorSummary(options), + afterProgramEmitAndDiagnostics: builderProgram => reportStatistics(builderProgram.getProgram()) + })); } function updateCreateProgram(host: { createProgram: CreateProgram; }) { @@ -316,7 +292,7 @@ namespace ts { }; } - function createWatchStatusReporter(options?: CompilerOptions) { + function createWatchStatusReporter(options: CompilerOptions | BuildOptions) { return ts.createWatchStatusReporter(sys, shouldBePretty(options)); } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 59ae825a8dc..8208cdba2ab 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2382,8 +2382,8 @@ declare namespace ts { root: ConditionalRoot; checkType: Type; extendsType: Type; - resolvedTrueType?: Type; - resolvedFalseType?: Type; + trueType: Type; + falseType: Type; } interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2b8056735a4..314ccf298cf 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2382,8 +2382,8 @@ declare namespace ts { root: ConditionalRoot; checkType: Type; extendsType: Type; - resolvedTrueType?: Type; - resolvedFalseType?: Type; + trueType: Type; + falseType: Type; } interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.js b/tests/baselines/reference/asyncMethodWithSuper_es6.js index b2a560a432a..a5f216d221a 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.js @@ -124,6 +124,66 @@ class B extends A { // element access (assign) in async arrow (async () => super["x"] = f); } + + async * property_access_only_read_only_in_generator() { + // call with property access + super.x(); + + // property access (read) + const a = super.x; + + // property access in arrow + (() => super.x()); + + // property access in async arrow + (async () => super.x()); + } + + async * property_access_only_write_only_in_generator() { + const f = () => {}; + + // property access (assign) + super.x = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // property access (assign) in arrow + (() => super.x = f); + + // property access (assign) in async arrow + (async () => super.x = f); + } + + async * element_access_only_read_only_in_generator() { + // call with element access + super["x"](); + + // element access (read) + const a = super["x"]; + + // element access in arrow + (() => super["x"]()); + + // element access in async arrow + (async () => super["x"]()); + } + + async * element_access_only_write_only_in_generator() { + const f = () => {}; + + // element access (assign) + super["x"] = f; + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + + // element access (assign) in arrow + (() => super["x"] = f); + + // element access (assign) in async arrow + (async () => super["x"] = f); + } } @@ -253,4 +313,67 @@ class B extends A { (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").value = f; })); }); } + property_access_only_read_only_in_generator() { + const _super = Object.create(null, { + x: { get: () => super.x } + }); + return __asyncGenerator(this, arguments, function* property_access_only_read_only_in_generator_1() { + // call with property access + _super.x.call(this); + // property access (read) + const a = _super.x; + // property access in arrow + (() => _super.x.call(this)); + // property access in async arrow + (() => __awaiter(this, void 0, void 0, function* () { return _super.x.call(this); })); + }); + } + property_access_only_write_only_in_generator() { + const _super = Object.create(null, { + x: { get: () => super.x, set: v => super.x = v } + }); + return __asyncGenerator(this, arguments, function* property_access_only_write_only_in_generator_1() { + const f = () => { }; + // property access (assign) + _super.x = f; + // destructuring assign with property access + ({ f: _super.x } = { f }); + // property access (assign) in arrow + (() => _super.x = f); + // property access (assign) in async arrow + (() => __awaiter(this, void 0, void 0, function* () { return _super.x = f; })); + }); + } + element_access_only_read_only_in_generator() { + const _superIndex = name => super[name]; + const _super = Object.create(null, {}); + return __asyncGenerator(this, arguments, function* element_access_only_read_only_in_generator_1() { + // call with element access + _superIndex("x").call(this); + // element access (read) + const a = _superIndex("x"); + // element access in arrow + (() => _superIndex("x").call(this)); + // element access in async arrow + (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").call(this); })); + }); + } + element_access_only_write_only_in_generator() { + const _superIndex = (function (geti, seti) { + const cache = Object.create(null); + return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } }); + })(name => super[name], (name, value) => super[name] = value); + const _super = Object.create(null, {}); + return __asyncGenerator(this, arguments, function* element_access_only_write_only_in_generator_1() { + const f = () => { }; + // element access (assign) + _superIndex("x").value = f; + // destructuring assign with element access + ({ f: _superIndex("x").value } = { f }); + // element access (assign) in arrow + (() => _superIndex("x").value = f); + // element access (assign) in async arrow + (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").value = f; })); + }); + } } diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.symbols b/tests/baselines/reference/asyncMethodWithSuper_es6.symbols index 842930ce900..59c844fa7de 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.symbols +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.symbols @@ -252,5 +252,127 @@ class B extends A { >"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) >f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 111, 13)) } + + async * property_access_only_read_only_in_generator() { +>property_access_only_read_only_in_generator : Symbol(B.property_access_only_read_only_in_generator, Decl(asyncMethodWithSuper_es6.ts, 124, 5)) + + // call with property access + super.x(); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // property access (read) + const a = super.x; +>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 131, 13)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // property access in arrow + (() => super.x()); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // property access in async arrow + (async () => super.x()); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + } + + async * property_access_only_write_only_in_generator() { +>property_access_only_write_only_in_generator : Symbol(B.property_access_only_write_only_in_generator, Decl(asyncMethodWithSuper_es6.ts, 138, 5)) + + const f = () => {}; +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 141, 13)) + + // property access (assign) + super.x = f; +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 141, 13)) + + // destructuring assign with property access + ({ f: super.x } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 147, 10)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 147, 27)) + + // property access (assign) in arrow + (() => super.x = f); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 141, 13)) + + // property access (assign) in async arrow + (async () => super.x = f); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 141, 13)) + } + + async * element_access_only_read_only_in_generator() { +>element_access_only_read_only_in_generator : Symbol(B.element_access_only_read_only_in_generator, Decl(asyncMethodWithSuper_es6.ts, 154, 5)) + + // call with element access + super["x"](); +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // element access (read) + const a = super["x"]; +>a : Symbol(a, Decl(asyncMethodWithSuper_es6.ts, 161, 13)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // element access in arrow + (() => super["x"]()); +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + + // element access in async arrow + (async () => super["x"]()); +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) + } + + async * element_access_only_write_only_in_generator() { +>element_access_only_write_only_in_generator : Symbol(B.element_access_only_write_only_in_generator, Decl(asyncMethodWithSuper_es6.ts, 168, 5)) + + const f = () => {}; +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 171, 13)) + + // element access (assign) + super["x"] = f; +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 171, 13)) + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 177, 10)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 177, 30)) + + // element access (assign) in arrow + (() => super["x"] = f); +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 171, 13)) + + // element access (assign) in async arrow + (async () => super["x"] = f); +>super : Symbol(A, Decl(asyncMethodWithSuper_es6.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es6.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es6.ts, 171, 13)) + } } diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.types b/tests/baselines/reference/asyncMethodWithSuper_es6.types index 92e132e97b2..ae78d8bc3ad 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.types +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.types @@ -332,6 +332,174 @@ class B extends A { >super["x"] : () => void >super : A >"x" : "x" +>f : () => void + } + + async * property_access_only_read_only_in_generator() { +>property_access_only_read_only_in_generator : () => AsyncIterableIterator + + // call with property access + super.x(); +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // property access (read) + const a = super.x; +>a : () => void +>super.x : () => void +>super : A +>x : () => void + + // property access in arrow + (() => super.x()); +>(() => super.x()) : () => void +>() => super.x() : () => void +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // property access in async arrow + (async () => super.x()); +>(async () => super.x()) : () => Promise +>async () => super.x() : () => Promise +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + } + + async * property_access_only_write_only_in_generator() { +>property_access_only_write_only_in_generator : () => AsyncIterableIterator + + const f = () => {}; +>f : () => void +>() => {} : () => void + + // property access (assign) + super.x = f; +>super.x = f : () => void +>super.x : () => void +>super : A +>x : () => void +>f : () => void + + // destructuring assign with property access + ({ f: super.x } = { f }); +>({ f: super.x } = { f }) : { f: () => void; } +>{ f: super.x } = { f } : { f: () => void; } +>{ f: super.x } : { f: () => void; } +>f : () => void +>super.x : () => void +>super : A +>x : () => void +>{ f } : { f: () => void; } +>f : () => void + + // property access (assign) in arrow + (() => super.x = f); +>(() => super.x = f) : () => () => void +>() => super.x = f : () => () => void +>super.x = f : () => void +>super.x : () => void +>super : A +>x : () => void +>f : () => void + + // property access (assign) in async arrow + (async () => super.x = f); +>(async () => super.x = f) : () => Promise<() => void> +>async () => super.x = f : () => Promise<() => void> +>super.x = f : () => void +>super.x : () => void +>super : A +>x : () => void +>f : () => void + } + + async * element_access_only_read_only_in_generator() { +>element_access_only_read_only_in_generator : () => AsyncIterableIterator + + // call with element access + super["x"](); +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // element access (read) + const a = super["x"]; +>a : () => void +>super["x"] : () => void +>super : A +>"x" : "x" + + // element access in arrow + (() => super["x"]()); +>(() => super["x"]()) : () => void +>() => super["x"]() : () => void +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // element access in async arrow + (async () => super["x"]()); +>(async () => super["x"]()) : () => Promise +>async () => super["x"]() : () => Promise +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + } + + async * element_access_only_write_only_in_generator() { +>element_access_only_write_only_in_generator : () => AsyncIterableIterator + + const f = () => {}; +>f : () => void +>() => {} : () => void + + // element access (assign) + super["x"] = f; +>super["x"] = f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>f : () => void + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>({ f: super["x"] } = { f }) : { f: () => void; } +>{ f: super["x"] } = { f } : { f: () => void; } +>{ f: super["x"] } : { f: () => void; } +>f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>{ f } : { f: () => void; } +>f : () => void + + // element access (assign) in arrow + (() => super["x"] = f); +>(() => super["x"] = f) : () => () => void +>() => super["x"] = f : () => () => void +>super["x"] = f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>f : () => void + + // element access (assign) in async arrow + (async () => super["x"] = f); +>(async () => super["x"] = f) : () => Promise<() => void> +>async () => super["x"] = f : () => Promise<() => void> +>super["x"] = f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" >f : () => void } } diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt index 9adcce6c845..1fb989b75f5 100644 --- a/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt @@ -4,11 +4,13 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarO tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(5,6): error TS2456: Type alias 'typeAlias2' circularly references itself. tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(7,18): error TS2577: Return type annotation circularly references itself. tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(9,6): error TS2456: Type alias 'typeAlias3' circularly references itself. -tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(20,3): error TS2322: Type 'number' is not assignable to type 'ReturnType<(input: Input) => ReturnType>'. -tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(26,20): error TS2322: Type '0' is not assignable to type 'ReturnType<() => ReturnType>'. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(18,6): error TS2456: Type alias 'R' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(19,29): error TS2577: Return type annotation circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(25,6): error TS2456: Type alias 'R2' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(26,15): error TS2577: Return type annotation circularly references itself. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (8 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (10 errors) ==== type typeAlias1 = typeof varOfAliasedType1; ~~~~~~~~~~ !!! error TS2456: Type alias 'typeAlias1' circularly references itself. @@ -39,16 +41,20 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarO } type R = ReturnType; + ~ +!!! error TS2456: Type alias 'R' circularly references itself. function mul(input: Input): R { + ~ +!!! error TS2577: Return type annotation circularly references itself. return input.a * input.b; - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'ReturnType<(input: Input) => ReturnType>'. } // Repro from #26104 type R2 = ReturnType; + ~~ +!!! error TS2456: Type alias 'R2' circularly references itself. function f(): R2 { return 0; } - ~~~~~~~~~ -!!! error TS2322: Type '0' is not assignable to type 'ReturnType<() => ReturnType>'. + ~~ +!!! error TS2577: Return type annotation circularly references itself. \ No newline at end of file diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.types b/tests/baselines/reference/circularTypeofWithVarOrFunc.types index 7f7fe21bba0..c2c8ba7947f 100644 --- a/tests/baselines/reference/circularTypeofWithVarOrFunc.types +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.types @@ -37,11 +37,11 @@ interface Input { } type R = ReturnType; ->R : ReturnType<(input: Input) => ReturnType> ->mul : (input: Input) => ReturnType +>R : any +>mul : (input: Input) => any function mul(input: Input): R { ->mul : (input: Input) => ReturnType +>mul : (input: Input) => any >input : Input return input.a * input.b; @@ -57,10 +57,10 @@ function mul(input: Input): R { // Repro from #26104 type R2 = ReturnType; ->R2 : ReturnType<() => ReturnType> ->f : () => ReturnType +>R2 : any +>f : () => any function f(): R2 { return 0; } ->f : () => ReturnType +>f : () => any >0 : 0 diff --git a/tests/baselines/reference/conditionalTypes1.js b/tests/baselines/reference/conditionalTypes1.js index b592bd33d10..5dc48518384 100644 --- a/tests/baselines/reference/conditionalTypes1.js +++ b/tests/baselines/reference/conditionalTypes1.js @@ -509,8 +509,6 @@ declare function f5(p: K): Extract; declare let x0: { k: "a"; -} & { - k: "a"; a: number; }; declare type OptionsOfKind = Extract void), Function>; // string | numbe >T02 : string | number type T03 = Extract void), Function>; // () => void ->T03 : Function & (() => void) +>T03 : () => void type T04 = NonNullable; // string | number >T04 : string | number @@ -113,7 +113,7 @@ type T10 = Exclude; // { k: "c", c: boolean } >k : "a" | "b" type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } ->T11 : ({ k: "a" | "b"; } & { k: "a"; a: number; }) | ({ k: "a" | "b"; } & { k: "b"; b: string; }) +>T11 : { k: "a"; a: number; } | { k: "b"; b: string; } >k : "a" | "b" type T12 = Exclude; // { k: "c", c: boolean } @@ -122,7 +122,7 @@ type T12 = Exclude; // { k: "c", c: boolean } >k : "b" type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } ->T13 : ({ k: "a"; } & { k: "a"; a: number; }) | ({ k: "b"; } & { k: "a"; a: number; }) | ({ k: "a"; } & { k: "b"; b: string; }) | ({ k: "b"; } & { k: "b"; b: string; }) +>T13 : { k: "a"; a: number; } | { k: "b"; b: string; } >k : "a" >k : "b" @@ -140,8 +140,8 @@ declare function f5(p: K): Extractk : K let x0 = f5("a"); // { k: "a", a: number } ->x0 : { k: "a"; } & { k: "a"; a: number; } ->f5("a") : { k: "a"; } & { k: "a"; a: number; } +>x0 : { k: "a"; a: number; } +>f5("a") : { k: "a"; a: number; } >f5 : (p: K) => Extract >"a" : "a" @@ -150,13 +150,13 @@ type OptionsOfKind = Extract; >k : K type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } ->T16 : ({ k: "a" | "b"; } & { k: "a"; a: number; }) | ({ k: "a" | "b"; } & { k: "b"; b: string; }) +>T16 : { k: "a"; a: number; } | { k: "b"; b: string; } type Select = Extract; >Select : Extract type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } ->T17 : ({ k: "a" | "b"; } & { k: "a"; a: number; }) | ({ k: "a" | "b"; } & { k: "b"; b: string; }) +>T17 : { k: "a"; a: number; } | { k: "b"; b: string; } type TypeName = >TypeName : TypeName diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index 6cf81cf5730..ee7c10ada58 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -21,13 +21,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS23 Type 'A' is not assignable to type 'B'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. - Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. + Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. - Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. + Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. ==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ==== @@ -132,7 +132,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -!!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. +!!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. !!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. !!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. @@ -145,7 +145,8 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 ~ !!! error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. -!!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. +!!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. } // Repros from #22860 diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index 7113ccc2be8..aac6ba47475 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -130,14 +130,14 @@ function f12(x: string | (() => string) | undefined) { >x : string | (() => string) | undefined const f = getFunction(x); // () => string ->f : Function & (() => string) ->getFunction(x) : Function & (() => string) +>f : () => string +>getFunction(x) : () => string >getFunction : (item: T) => Extract >x : string | (() => string) | undefined f(); >f() : string ->f : Function & (() => string) +>f : () => string } type Foo = { foo: string }; diff --git a/tests/baselines/reference/contravariantInferenceAndTypeGuard.js b/tests/baselines/reference/contravariantInferenceAndTypeGuard.js new file mode 100644 index 00000000000..a56fdacf8c9 --- /dev/null +++ b/tests/baselines/reference/contravariantInferenceAndTypeGuard.js @@ -0,0 +1,40 @@ +//// [contravariantInferenceAndTypeGuard.ts] +interface ListItem { + prev: ListItem | null; + next: ListItem | null; + data: TData; +} +type IteratorFn> = (this: TContext, item: TData, node: ListItem, list: List) => TResult; +type FilterFn> = (this: TContext, item: TData, node: ListItem, list: List) => item is TResult; + +declare class List { + filter(fn: FilterFn, context: TContext): List; + filter(fn: FilterFn): List; + filter(fn: IteratorFn, context: TContext): List; + filter(fn: IteratorFn): List; +} +interface Test { + a: string; +} +const list2 = new List(); +const filter1 = list2.filter(function(item, node, list): item is Test { + this.b; // $ExpectType string + item; // $ExpectType Test | null + node; // $ExpectType ListItem + list; // $ExpectType List + return !!item; +}, {b: 'c'}); +const x: List = filter1; // $ExpectType List + + +//// [contravariantInferenceAndTypeGuard.js] +"use strict"; +var list2 = new List(); +var filter1 = list2.filter(function (item, node, list) { + this.b; // $ExpectType string + item; // $ExpectType Test | null + node; // $ExpectType ListItem + list; // $ExpectType List + return !!item; +}, { b: 'c' }); +var x = filter1; // $ExpectType List diff --git a/tests/baselines/reference/contravariantInferenceAndTypeGuard.symbols b/tests/baselines/reference/contravariantInferenceAndTypeGuard.symbols new file mode 100644 index 00000000000..bee31fb1bfc --- /dev/null +++ b/tests/baselines/reference/contravariantInferenceAndTypeGuard.symbols @@ -0,0 +1,157 @@ +=== tests/cases/compiler/contravariantInferenceAndTypeGuard.ts === +interface ListItem { +>ListItem : Symbol(ListItem, Decl(contravariantInferenceAndTypeGuard.ts, 0, 0)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 0, 19)) + + prev: ListItem | null; +>prev : Symbol(ListItem.prev, Decl(contravariantInferenceAndTypeGuard.ts, 0, 27)) +>ListItem : Symbol(ListItem, Decl(contravariantInferenceAndTypeGuard.ts, 0, 0)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 0, 19)) + + next: ListItem | null; +>next : Symbol(ListItem.next, Decl(contravariantInferenceAndTypeGuard.ts, 1, 33)) +>ListItem : Symbol(ListItem, Decl(contravariantInferenceAndTypeGuard.ts, 0, 0)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 0, 19)) + + data: TData; +>data : Symbol(ListItem.data, Decl(contravariantInferenceAndTypeGuard.ts, 2, 33)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 0, 19)) +} +type IteratorFn> = (this: TContext, item: TData, node: ListItem, list: List) => TResult; +>IteratorFn : Symbol(IteratorFn, Decl(contravariantInferenceAndTypeGuard.ts, 4, 1)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 5, 16)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 5, 22)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 5, 31)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 5, 16)) +>this : Symbol(this, Decl(contravariantInferenceAndTypeGuard.ts, 5, 59)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 5, 31)) +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 5, 74)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 5, 16)) +>node : Symbol(node, Decl(contravariantInferenceAndTypeGuard.ts, 5, 87)) +>ListItem : Symbol(ListItem, Decl(contravariantInferenceAndTypeGuard.ts, 0, 0)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 5, 16)) +>list : Symbol(list, Decl(contravariantInferenceAndTypeGuard.ts, 5, 110)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 5, 16)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 5, 22)) + +type FilterFn> = (this: TContext, item: TData, node: ListItem, list: List) => item is TResult; +>FilterFn : Symbol(FilterFn, Decl(contravariantInferenceAndTypeGuard.ts, 5, 141)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 6, 20)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 6, 43)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>this : Symbol(this, Decl(contravariantInferenceAndTypeGuard.ts, 6, 71)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 6, 43)) +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 6, 86)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>node : Symbol(node, Decl(contravariantInferenceAndTypeGuard.ts, 6, 99)) +>ListItem : Symbol(ListItem, Decl(contravariantInferenceAndTypeGuard.ts, 0, 0)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>list : Symbol(list, Decl(contravariantInferenceAndTypeGuard.ts, 6, 122)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 6, 14)) +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 6, 86)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 6, 20)) + +declare class List { +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) + + filter(fn: FilterFn, context: TContext): List; +>filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 9, 11)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 9, 20)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>fn : Symbol(fn, Decl(contravariantInferenceAndTypeGuard.ts, 9, 44)) +>FilterFn : Symbol(FilterFn, Decl(contravariantInferenceAndTypeGuard.ts, 5, 141)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 9, 20)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 9, 11)) +>context : Symbol(context, Decl(contravariantInferenceAndTypeGuard.ts, 9, 83)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 9, 11)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 9, 20)) + + filter(fn: FilterFn): List; +>filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 10, 11)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>fn : Symbol(fn, Decl(contravariantInferenceAndTypeGuard.ts, 10, 34)) +>FilterFn : Symbol(FilterFn, Decl(contravariantInferenceAndTypeGuard.ts, 5, 141)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 10, 11)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TResult : Symbol(TResult, Decl(contravariantInferenceAndTypeGuard.ts, 10, 11)) + + filter(fn: IteratorFn, context: TContext): List; +>filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 11, 11)) +>fn : Symbol(fn, Decl(contravariantInferenceAndTypeGuard.ts, 11, 21)) +>IteratorFn : Symbol(IteratorFn, Decl(contravariantInferenceAndTypeGuard.ts, 4, 1)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 11, 11)) +>context : Symbol(context, Decl(contravariantInferenceAndTypeGuard.ts, 11, 62)) +>TContext : Symbol(TContext, Decl(contravariantInferenceAndTypeGuard.ts, 11, 11)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) + + filter(fn: IteratorFn): List; +>filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>fn : Symbol(fn, Decl(contravariantInferenceAndTypeGuard.ts, 12, 11)) +>IteratorFn : Symbol(IteratorFn, Decl(contravariantInferenceAndTypeGuard.ts, 4, 1)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>TData : Symbol(TData, Decl(contravariantInferenceAndTypeGuard.ts, 8, 19)) +} +interface Test { +>Test : Symbol(Test, Decl(contravariantInferenceAndTypeGuard.ts, 13, 1)) + + a: string; +>a : Symbol(Test.a, Decl(contravariantInferenceAndTypeGuard.ts, 14, 16)) +} +const list2 = new List(); +>list2 : Symbol(list2, Decl(contravariantInferenceAndTypeGuard.ts, 17, 5)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>Test : Symbol(Test, Decl(contravariantInferenceAndTypeGuard.ts, 13, 1)) + +const filter1 = list2.filter(function(item, node, list): item is Test { +>filter1 : Symbol(filter1, Decl(contravariantInferenceAndTypeGuard.ts, 18, 5)) +>list2.filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>list2 : Symbol(list2, Decl(contravariantInferenceAndTypeGuard.ts, 17, 5)) +>filter : Symbol(List.filter, Decl(contravariantInferenceAndTypeGuard.ts, 8, 27), Decl(contravariantInferenceAndTypeGuard.ts, 9, 118), Decl(contravariantInferenceAndTypeGuard.ts, 10, 79), Decl(contravariantInferenceAndTypeGuard.ts, 11, 95)) +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 18, 38)) +>node : Symbol(node, Decl(contravariantInferenceAndTypeGuard.ts, 18, 43)) +>list : Symbol(list, Decl(contravariantInferenceAndTypeGuard.ts, 18, 49)) +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 18, 38)) +>Test : Symbol(Test, Decl(contravariantInferenceAndTypeGuard.ts, 13, 1)) + + this.b; // $ExpectType string +>this.b : Symbol(b, Decl(contravariantInferenceAndTypeGuard.ts, 24, 4)) +>this : Symbol(this, Decl(contravariantInferenceAndTypeGuard.ts, 6, 71)) +>b : Symbol(b, Decl(contravariantInferenceAndTypeGuard.ts, 24, 4)) + + item; // $ExpectType Test | null +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 18, 38)) + + node; // $ExpectType ListItem +>node : Symbol(node, Decl(contravariantInferenceAndTypeGuard.ts, 18, 43)) + + list; // $ExpectType List +>list : Symbol(list, Decl(contravariantInferenceAndTypeGuard.ts, 18, 49)) + + return !!item; +>item : Symbol(item, Decl(contravariantInferenceAndTypeGuard.ts, 18, 38)) + +}, {b: 'c'}); +>b : Symbol(b, Decl(contravariantInferenceAndTypeGuard.ts, 24, 4)) + +const x: List = filter1; // $ExpectType List +>x : Symbol(x, Decl(contravariantInferenceAndTypeGuard.ts, 25, 5)) +>List : Symbol(List, Decl(contravariantInferenceAndTypeGuard.ts, 6, 161)) +>Test : Symbol(Test, Decl(contravariantInferenceAndTypeGuard.ts, 13, 1)) +>filter1 : Symbol(filter1, Decl(contravariantInferenceAndTypeGuard.ts, 18, 5)) + diff --git a/tests/baselines/reference/contravariantInferenceAndTypeGuard.types b/tests/baselines/reference/contravariantInferenceAndTypeGuard.types new file mode 100644 index 00000000000..d0b139a5a7c --- /dev/null +++ b/tests/baselines/reference/contravariantInferenceAndTypeGuard.types @@ -0,0 +1,97 @@ +=== tests/cases/compiler/contravariantInferenceAndTypeGuard.ts === +interface ListItem { + prev: ListItem | null; +>prev : ListItem | null +>null : null + + next: ListItem | null; +>next : ListItem | null +>null : null + + data: TData; +>data : TData +} +type IteratorFn> = (this: TContext, item: TData, node: ListItem, list: List) => TResult; +>IteratorFn : IteratorFn +>this : TContext +>item : TData +>node : ListItem +>list : List + +type FilterFn> = (this: TContext, item: TData, node: ListItem, list: List) => item is TResult; +>FilterFn : FilterFn +>this : TContext +>item : TData +>node : ListItem +>list : List + +declare class List { +>List : List + + filter(fn: FilterFn, context: TContext): List; +>filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>fn : FilterFn +>context : TContext + + filter(fn: FilterFn): List; +>filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>fn : FilterFn> + + filter(fn: IteratorFn, context: TContext): List; +>filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>fn : IteratorFn +>context : TContext + + filter(fn: IteratorFn): List; +>filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>fn : IteratorFn> +} +interface Test { + a: string; +>a : string +} +const list2 = new List(); +>list2 : List +>new List() : List +>List : typeof List +>null : null + +const filter1 = list2.filter(function(item, node, list): item is Test { +>filter1 : List +>list2.filter(function(item, node, list): item is Test { this.b; // $ExpectType string item; // $ExpectType Test | null node; // $ExpectType ListItem list; // $ExpectType List return !!item;}, {b: 'c'}) : List +>list2.filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>list2 : List +>filter : { (fn: FilterFn, context: TContext): List; (fn: FilterFn>): List; (fn: IteratorFn, context: TContext): List; (fn: IteratorFn>): List; } +>function(item, node, list): item is Test { this.b; // $ExpectType string item; // $ExpectType Test | null node; // $ExpectType ListItem list; // $ExpectType List return !!item;} : (this: { b: string; }, item: Test | null, node: ListItem, list: List) => item is Test +>item : Test | null +>node : ListItem +>list : List + + this.b; // $ExpectType string +>this.b : string +>this : { b: string; } +>b : string + + item; // $ExpectType Test | null +>item : Test | null + + node; // $ExpectType ListItem +>node : ListItem + + list; // $ExpectType List +>list : List + + return !!item; +>!!item : boolean +>!item : boolean +>item : Test | null + +}, {b: 'c'}); +>{b: 'c'} : { b: string; } +>b : string +>'c' : "c" + +const x: List = filter1; // $ExpectType List +>x : List +>filter1 : List + diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter2.js b/tests/baselines/reference/decoratorOnClassMethodParameter2.js new file mode 100644 index 00000000000..1b52268117b --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodParameter2.js @@ -0,0 +1,26 @@ +//// [decoratorOnClassMethodParameter2.ts] +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + method(this: C, @dec p: number) {} +} + +//// [decoratorOnClassMethodParameter2.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +var C = /** @class */ (function () { + function C() { + } + C.prototype.method = function (p) { }; + __decorate([ + __param(0, dec) + ], C.prototype, "method", null); + return C; +}()); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter2.symbols b/tests/baselines/reference/decoratorOnClassMethodParameter2.symbols new file mode 100644 index 00000000000..efb8abc1433 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodParameter2.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter2.ts === +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; +>dec : Symbol(dec, Decl(decoratorOnClassMethodParameter2.ts, 0, 0)) +>target : Symbol(target, Decl(decoratorOnClassMethodParameter2.ts, 0, 21)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodParameter2.ts, 0, 36)) +>parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodParameter2.ts, 0, 66)) + +class C { +>C : Symbol(C, Decl(decoratorOnClassMethodParameter2.ts, 0, 97)) + + method(this: C, @dec p: number) {} +>method : Symbol(C.method, Decl(decoratorOnClassMethodParameter2.ts, 2, 9)) +>this : Symbol(this, Decl(decoratorOnClassMethodParameter2.ts, 3, 11)) +>C : Symbol(C, Decl(decoratorOnClassMethodParameter2.ts, 0, 97)) +>dec : Symbol(dec, Decl(decoratorOnClassMethodParameter2.ts, 0, 0)) +>p : Symbol(p, Decl(decoratorOnClassMethodParameter2.ts, 3, 19)) +} diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter2.types b/tests/baselines/reference/decoratorOnClassMethodParameter2.types new file mode 100644 index 00000000000..12d9e2a022c --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodParameter2.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter2.ts === +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>target : Object +>propertyKey : string | symbol +>parameterIndex : number + +class C { +>C : C + + method(this: C, @dec p: number) {} +>method : (this: C, p: number) => void +>this : C +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>p : number +} diff --git a/tests/baselines/reference/decoratorOnClassMethodThisParameter.errors.txt b/tests/baselines/reference/decoratorOnClassMethodThisParameter.errors.txt new file mode 100644 index 00000000000..f87a3fa7f39 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodThisParameter.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts(4,17): error TS1003: Identifier expected. +tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts(4,17): error TS2680: A 'this' parameter must be the first parameter. + + +==== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts (2 errors) ==== + declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; + + class C { + method(@dec this: C) {} + ~~~~ +!!! error TS1003: Identifier expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. + } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethodThisParameter.js b/tests/baselines/reference/decoratorOnClassMethodThisParameter.js new file mode 100644 index 00000000000..74b835c1383 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodThisParameter.js @@ -0,0 +1,26 @@ +//// [decoratorOnClassMethodThisParameter.ts] +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + method(@dec this: C) {} +} + +//// [decoratorOnClassMethodThisParameter.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +var C = /** @class */ (function () { + function C() { + } + C.prototype.method = function () { }; + __decorate([ + __param(0, dec) + ], C.prototype, "method", null); + return C; +}()); diff --git a/tests/baselines/reference/decoratorOnClassMethodThisParameter.symbols b/tests/baselines/reference/decoratorOnClassMethodThisParameter.symbols new file mode 100644 index 00000000000..13d6bb152ee --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodThisParameter.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts === +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; +>dec : Symbol(dec, Decl(decoratorOnClassMethodThisParameter.ts, 0, 0)) +>target : Symbol(target, Decl(decoratorOnClassMethodThisParameter.ts, 0, 21)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodThisParameter.ts, 0, 36)) +>parameterIndex : Symbol(parameterIndex, Decl(decoratorOnClassMethodThisParameter.ts, 0, 66)) + +class C { +>C : Symbol(C, Decl(decoratorOnClassMethodThisParameter.ts, 0, 97)) + + method(@dec this: C) {} +>method : Symbol(C.method, Decl(decoratorOnClassMethodThisParameter.ts, 2, 9)) +>dec : Symbol(dec, Decl(decoratorOnClassMethodThisParameter.ts, 0, 0)) +> : Symbol((Missing), Decl(decoratorOnClassMethodThisParameter.ts, 3, 11)) +>this : Symbol(this, Decl(decoratorOnClassMethodThisParameter.ts, 3, 15)) +>C : Symbol(C, Decl(decoratorOnClassMethodThisParameter.ts, 0, 97)) +} diff --git a/tests/baselines/reference/decoratorOnClassMethodThisParameter.types b/tests/baselines/reference/decoratorOnClassMethodThisParameter.types new file mode 100644 index 00000000000..8b58cb7b493 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassMethodThisParameter.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts === +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>target : Object +>propertyKey : string | symbol +>parameterIndex : number + +class C { +>C : C + + method(@dec this: C) {} +>method : (: any, this: C) => void +>dec : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +> : any +>this : C +} diff --git a/tests/baselines/reference/decoratorReferences.js b/tests/baselines/reference/decoratorReferences.js new file mode 100644 index 00000000000..6189cfc52c9 --- /dev/null +++ b/tests/baselines/reference/decoratorReferences.js @@ -0,0 +1,35 @@ +//// [decoratorReferences.ts] +declare function y(...args: any[]): any; +type T = number; +@y(1 as T, C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +class C { + @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class + method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. +} + +//// [decoratorReferences.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +var C = /** @class */ (function () { + function C() { + } + C_1 = C; + C.prototype.method = function (x, y) { }; // <-- decorator y should be resolved at the class declaration, not the parameter. + var C_1; + __decorate([ + y(null) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class + , + __param(0, y) + ], C.prototype, "method"); + C = C_1 = __decorate([ + y(1, C_1) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class + ], C); + return C; +}()); diff --git a/tests/baselines/reference/decoratorReferences.symbols b/tests/baselines/reference/decoratorReferences.symbols new file mode 100644 index 00000000000..d018367e07d --- /dev/null +++ b/tests/baselines/reference/decoratorReferences.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/decoratorReferences.ts === +declare function y(...args: any[]): any; +>y : Symbol(y, Decl(decoratorReferences.ts, 0, 0)) +>args : Symbol(args, Decl(decoratorReferences.ts, 0, 19)) + +type T = number; +>T : Symbol(T, Decl(decoratorReferences.ts, 0, 40)) + +@y(1 as T, C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +>y : Symbol(y, Decl(decoratorReferences.ts, 0, 0)) +>T : Symbol(T, Decl(decoratorReferences.ts, 0, 40)) +>C : Symbol(C, Decl(decoratorReferences.ts, 1, 16)) + +class C { +>C : Symbol(C, Decl(decoratorReferences.ts, 1, 16)) +>T : Symbol(T, Decl(decoratorReferences.ts, 3, 8)) + + @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class +>y : Symbol(y, Decl(decoratorReferences.ts, 0, 0)) +>T : Symbol(T, Decl(decoratorReferences.ts, 3, 8)) + + method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. +>method : Symbol(C.method, Decl(decoratorReferences.ts, 3, 12)) +>y : Symbol(y, Decl(decoratorReferences.ts, 0, 0)) +>x : Symbol(x, Decl(decoratorReferences.ts, 5, 11)) +>y : Symbol(y, Decl(decoratorReferences.ts, 5, 16)) +} diff --git a/tests/baselines/reference/decoratorReferences.types b/tests/baselines/reference/decoratorReferences.types new file mode 100644 index 00000000000..14a9f9e667b --- /dev/null +++ b/tests/baselines/reference/decoratorReferences.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/decoratorReferences.ts === +declare function y(...args: any[]): any; +>y : (...args: any[]) => any +>args : any[] + +type T = number; +>T : number + +@y(1 as T, C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +>y(1 as T, C) : any +>y : (...args: any[]) => any +>1 as T : number +>1 : 1 +>C : typeof C + +class C { +>C : C + + @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class +>y(null as T) : any +>y : (...args: any[]) => any +>null as T : T +>null : null + + method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. +>method : (x: any, y: any) => void +>y : (...args: any[]) => any +>x : any +>y : any +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 035d912b638..7cd59c5a93a 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -!!! related TS2728 /.ts/lib.es5.d.ts:1368:15: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1368:13: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '[[any]]'. diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt index 2030b47b3ec..59cc07d6751 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10): error TS2339: Property 'name' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10 var f2 = (x: string) => { this.name = x ~~~~ -!!! error TS2540: Cannot assign to 'name' because it is a read-only property. +!!! error TS2339: Property 'name' does not exist on type 'typeof globalThis'. } function foo(func: () => boolean) { } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols index e130eafd770..e201b4c1eaf 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols @@ -12,9 +12,7 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) this.name = x ->this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >this : Symbol(globalThis) ->name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt index fb644a4127e..1914093efb3 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6,10): error TS2339: Property 'name' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6 var f2 = (x: string) => { this.name = x ~~~~ -!!! error TS2540: Cannot assign to 'name' because it is a read-only property. +!!! error TS2339: Property 'name' does not exist on type 'typeof globalThis'. } function foo(func: () => boolean){ } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols index d370a207de6..dbddfc5a161 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols @@ -12,9 +12,7 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) this.name = x ->this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >this : Symbol(globalThis) ->name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) } diff --git a/tests/baselines/reference/extendGlobalThis.js b/tests/baselines/reference/extendGlobalThis.js new file mode 100644 index 00000000000..c8b73a0c39f --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/extendGlobalThis.ts] //// + +//// [extension.d.ts] +declare global { + namespace globalThis { + var test: string; + } +} + +export {} + +//// [index.ts] +import "./extention"; + +globalThis.tests = "a-b"; +console.log(globalThis.test.split("-")); + + +//// [index.js] +"use strict"; +exports.__esModule = true; +require("./extention"); +globalThis.tests = "a-b"; +console.log(globalThis.test.split("-")); diff --git a/tests/baselines/reference/extendGlobalThis.symbols b/tests/baselines/reference/extendGlobalThis.symbols new file mode 100644 index 00000000000..944d7b23715 --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/extension.d.ts === +declare global { +>global : Symbol(global, Decl(extension.d.ts, 0, 0)) + + namespace globalThis { +>globalThis : Symbol(globalThis) + + var test: string; +>test : Symbol(test, Decl(extension.d.ts, 2, 11)) + } +} + +export {} + +=== tests/cases/compiler/index.ts === +import "./extention"; + +globalThis.tests = "a-b"; +>globalThis : Symbol(globalThis) + +console.log(globalThis.test.split("-")); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>globalThis.test.split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) +>globalThis.test : Symbol(test, Decl(extension.d.ts, 2, 11)) +>globalThis : Symbol(globalThis) +>test : Symbol(test, Decl(extension.d.ts, 2, 11)) +>split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/extendGlobalThis.types b/tests/baselines/reference/extendGlobalThis.types new file mode 100644 index 00000000000..88fe0462d65 --- /dev/null +++ b/tests/baselines/reference/extendGlobalThis.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/extension.d.ts === +declare global { +>global : typeof global + + namespace globalThis { +>globalThis : typeof globalThis + + var test: string; +>test : string + } +} + +export {} + +=== tests/cases/compiler/index.ts === +import "./extention"; + +globalThis.tests = "a-b"; +>globalThis.tests = "a-b" : "a-b" +>globalThis.tests : any +>globalThis : typeof globalThis +>tests : any +>"a-b" : "a-b" + +console.log(globalThis.test.split("-")); +>console.log(globalThis.test.split("-")) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>globalThis.test.split("-") : string[] +>globalThis.test.split : (separator: string | RegExp, limit?: number) => string[] +>globalThis.test : string +>globalThis : typeof globalThis +>test : string +>split : (separator: string | RegExp, limit?: number) => string[] +>"-" : "-" + diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index d30cd737ab1..ff4531e5a0f 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -69,20 +69,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat var d=new XDate(); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. d.getDay(); d=new XDate(1978,2); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. d.getXDate(); var n=XDate.parse("3/2/2004"); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. n=XDate.UTC(1964,2,1); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/genericFunctionInference1.errors.txt b/tests/baselines/reference/genericFunctionInference1.errors.txt index fd423a4ea5a..7fcbc93ea0d 100644 --- a/tests/baselines/reference/genericFunctionInference1.errors.txt +++ b/tests/baselines/reference/genericFunctionInference1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunctionInference1.ts(83,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. +tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument of type '(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'. Type 'number' is not assignable to type 'string'. @@ -62,6 +62,11 @@ tests/cases/compiler/genericFunctionInference1.ts(83,14): error TS2345: Argument const f50 = pipe5(list); // No higher order inference + declare function wrap3(f: (a: A, b1: B, b2: B) => C): (a: A, b1: B, b2: B) => C; + declare function baz(t1: T, t2: T, u: U): [T, U]; + + let f60 = wrap3(baz); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -198,4 +203,9 @@ tests/cases/compiler/genericFunctionInference1.ts(83,14): error TS2345: Argument foo2(() => {}); foo2(identity); foo2(identity, 1); + + // Repro from #30324 + + declare function times(fn: (i: number) => T): (n: number) => T[]; + const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] \ No newline at end of file diff --git a/tests/baselines/reference/genericFunctionInference1.js b/tests/baselines/reference/genericFunctionInference1.js index bfca871a6c9..7180fca9033 100644 --- a/tests/baselines/reference/genericFunctionInference1.js +++ b/tests/baselines/reference/genericFunctionInference1.js @@ -58,6 +58,11 @@ declare function pipe5(f: (a: A) => B): { f: (a: A) => B }; const f50 = pipe5(list); // No higher order inference +declare function wrap3(f: (a: A, b1: B, b2: B) => C): (a: A, b1: B, b2: B) => C; +declare function baz(t1: T, t2: T, u: U): [T, U]; + +let f60 = wrap3(baz); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -191,6 +196,11 @@ declare function foo2(fn: T, a?: U, b?: U): [T, U]; foo2(() => {}); foo2(identity); foo2(identity, 1); + +// Repro from #30324 + +declare function times(fn: (i: number) => T): (n: number) => T[]; +const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] //// [genericFunctionInference1.js] @@ -231,6 +241,7 @@ const f32 = pipe3(list, list); const f40 = pipe4([list, box]); const f41 = pipe4([box, list]); const f50 = pipe5(list); // No higher order inference +let f60 = wrap3(baz); // #417 function mirror(f) { return f; } var identityM = mirror(identity); @@ -276,3 +287,4 @@ const fn62 = pipe(getArray, x => x, x => first(x)); foo2(() => { }); foo2(identity); foo2(identity, 1); +const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] diff --git a/tests/baselines/reference/genericFunctionInference1.symbols b/tests/baselines/reference/genericFunctionInference1.symbols index cad4d862d9c..9d6005de9cf 100644 --- a/tests/baselines/reference/genericFunctionInference1.symbols +++ b/tests/baselines/reference/genericFunctionInference1.symbols @@ -457,299 +457,339 @@ const f50 = pipe5(list); // No higher order inference >pipe5 : Symbol(pipe5, Decl(genericFunctionInference1.ts, 53, 31)) >list : Symbol(list, Decl(genericFunctionInference1.ts, 2, 124)) +declare function wrap3(f: (a: A, b1: B, b2: B) => C): (a: A, b1: B, b2: B) => C; +>wrap3 : Symbol(wrap3, Decl(genericFunctionInference1.ts, 57, 24)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 59, 23)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 59, 25)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 59, 28)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 59, 32)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 59, 36)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 59, 23)) +>b1 : Symbol(b1, Decl(genericFunctionInference1.ts, 59, 41)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 59, 25)) +>b2 : Symbol(b2, Decl(genericFunctionInference1.ts, 59, 48)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 59, 25)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 59, 28)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 59, 64)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 59, 23)) +>b1 : Symbol(b1, Decl(genericFunctionInference1.ts, 59, 69)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 59, 25)) +>b2 : Symbol(b2, Decl(genericFunctionInference1.ts, 59, 76)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 59, 25)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 59, 28)) + +declare function baz(t1: T, t2: T, u: U): [T, U]; +>baz : Symbol(baz, Decl(genericFunctionInference1.ts, 59, 89)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 60, 21)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 60, 23)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 60, 21)) +>t1 : Symbol(t1, Decl(genericFunctionInference1.ts, 60, 37)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 60, 21)) +>t2 : Symbol(t2, Decl(genericFunctionInference1.ts, 60, 43)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 60, 21)) +>u : Symbol(u, Decl(genericFunctionInference1.ts, 60, 50)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 60, 23)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 60, 21)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 60, 23)) + +let f60 = wrap3(baz); +>f60 : Symbol(f60, Decl(genericFunctionInference1.ts, 62, 3)) +>wrap3 : Symbol(wrap3, Decl(genericFunctionInference1.ts, 57, 24)) +>baz : Symbol(baz, Decl(genericFunctionInference1.ts, 59, 89)) + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } ->mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 57, 24)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 61, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 61, 18)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 61, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 61, 26)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 61, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 61, 18)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 61, 40)) ->A : Symbol(A, Decl(genericFunctionInference1.ts, 61, 16)) ->B : Symbol(B, Decl(genericFunctionInference1.ts, 61, 18)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 61, 22)) +>mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 62, 21)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 66, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 66, 26)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 66, 40)) +>A : Symbol(A, Decl(genericFunctionInference1.ts, 66, 16)) +>B : Symbol(B, Decl(genericFunctionInference1.ts, 66, 18)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 66, 22)) var identityM = mirror(identity); ->identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 62, 3)) ->mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 57, 24)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 67, 3)) +>mirror : Symbol(mirror, Decl(genericFunctionInference1.ts, 62, 21)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) var x = 1; ->x : Symbol(x, Decl(genericFunctionInference1.ts, 64, 3)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) var y = identity(x); ->y : Symbol(y, Decl(genericFunctionInference1.ts, 65, 3)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 64, 3)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 70, 3)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) var z = identityM(x); ->z : Symbol(z, Decl(genericFunctionInference1.ts, 66, 3)) ->identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 62, 3)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 64, 3)) +>z : Symbol(z, Decl(genericFunctionInference1.ts, 71, 3)) +>identityM : Symbol(identityM, Decl(genericFunctionInference1.ts, 67, 3)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 69, 3)) // #3038 export function keyOf(value: { key: a; }): a { ->keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 66, 21)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 70, 22)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 70, 25)) ->key : Symbol(key, Decl(genericFunctionInference1.ts, 70, 33)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 70, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 70, 22)) +>keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 71, 21)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 75, 25)) +>key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 75, 22)) return value.key; ->value.key : Symbol(key, Decl(genericFunctionInference1.ts, 70, 33)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 70, 25)) ->key : Symbol(key, Decl(genericFunctionInference1.ts, 70, 33)) +>value.key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 75, 25)) +>key : Symbol(key, Decl(genericFunctionInference1.ts, 75, 33)) } export interface Data { ->Data : Symbol(Data, Decl(genericFunctionInference1.ts, 72, 1)) +>Data : Symbol(Data, Decl(genericFunctionInference1.ts, 77, 1)) key: number; ->key : Symbol(Data.key, Decl(genericFunctionInference1.ts, 73, 23)) +>key : Symbol(Data.key, Decl(genericFunctionInference1.ts, 78, 23)) value: Date; ->value : Symbol(Data.value, Decl(genericFunctionInference1.ts, 74, 16)) +>value : Symbol(Data.value, Decl(genericFunctionInference1.ts, 79, 16)) >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } var data: Data[] = []; ->data : Symbol(data, Decl(genericFunctionInference1.ts, 78, 3)) ->Data : Symbol(Data, Decl(genericFunctionInference1.ts, 72, 1)) +>data : Symbol(data, Decl(genericFunctionInference1.ts, 83, 3)) +>Data : Symbol(Data, Decl(genericFunctionInference1.ts, 77, 1)) declare function toKeys(values: a[], toKey: (value: a) => string): string[]; ->toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 78, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 80, 24)) ->values : Symbol(values, Decl(genericFunctionInference1.ts, 80, 27)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 80, 24)) ->toKey : Symbol(toKey, Decl(genericFunctionInference1.ts, 80, 39)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 80, 48)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 80, 24)) +>toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 83, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) +>values : Symbol(values, Decl(genericFunctionInference1.ts, 85, 27)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) +>toKey : Symbol(toKey, Decl(genericFunctionInference1.ts, 85, 39)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 85, 48)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 85, 24)) toKeys(data, keyOf); // Error ->toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 78, 22)) ->data : Symbol(data, Decl(genericFunctionInference1.ts, 78, 3)) ->keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 66, 21)) +>toKeys : Symbol(toKeys, Decl(genericFunctionInference1.ts, 83, 22)) +>data : Symbol(data, Decl(genericFunctionInference1.ts, 83, 3)) +>keyOf : Symbol(keyOf, Decl(genericFunctionInference1.ts, 71, 21)) // #9366 function flip(f: (a: a, b: b) => c): (b: b, a: a) => c { ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 82, 20)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 14)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 16)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 86, 19)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 86, 23)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 27)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 14)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 32)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 16)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 86, 19)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 47)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 16)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 52)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 14)) ->c : Symbol(c, Decl(genericFunctionInference1.ts, 86, 19)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 91, 23)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 27)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 32)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 47)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 52)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) +>c : Symbol(c, Decl(genericFunctionInference1.ts, 91, 19)) return (b: b, a: a) => f(a, b); ->b : Symbol(b, Decl(genericFunctionInference1.ts, 87, 10)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 86, 16)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 87, 15)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 86, 14)) ->f : Symbol(f, Decl(genericFunctionInference1.ts, 86, 23)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 87, 15)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 87, 10)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 92, 10)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 91, 16)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 92, 15)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 91, 14)) +>f : Symbol(f, Decl(genericFunctionInference1.ts, 91, 23)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 92, 15)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 92, 10)) } function zip(x: T, y: U): [T, U] { ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 88, 1)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 89, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 89, 15)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 89, 19)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 89, 13)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 89, 24)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 89, 15)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 89, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 89, 15)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 94, 19)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 94, 24)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 94, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 94, 15)) return [x, y]; ->x : Symbol(x, Decl(genericFunctionInference1.ts, 89, 19)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 89, 24)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 94, 19)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 94, 24)) } var expected: (y: U, x: T) => [T, U] = flip(zip); ->expected : Symbol(expected, Decl(genericFunctionInference1.ts, 93, 3)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 93, 15)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 93, 17)) ->y : Symbol(y, Decl(genericFunctionInference1.ts, 93, 21)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 93, 17)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 93, 26)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 93, 15)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 93, 15)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 93, 17)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 82, 20)) ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 88, 1)) +>expected : Symbol(expected, Decl(genericFunctionInference1.ts, 98, 3)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) +>y : Symbol(y, Decl(genericFunctionInference1.ts, 98, 21)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 98, 26)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 15)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 17)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) var actual = flip(zip); ->actual : Symbol(actual, Decl(genericFunctionInference1.ts, 94, 3)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 82, 20)) ->zip : Symbol(zip, Decl(genericFunctionInference1.ts, 88, 1)) +>actual : Symbol(actual, Decl(genericFunctionInference1.ts, 99, 3)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) +>zip : Symbol(zip, Decl(genericFunctionInference1.ts, 93, 1)) // #9366 const map = (transform: (t: T) => U) => ->map : Symbol(map, Decl(genericFunctionInference1.ts, 98, 5)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 15)) ->transform : Symbol(transform, Decl(genericFunctionInference1.ts, 98, 19)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 98, 31)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 13)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 98, 15)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 103, 15)) +>transform : Symbol(transform, Decl(genericFunctionInference1.ts, 103, 19)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 103, 31)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 103, 15)) (arr: T[]) => arr.map(transform) ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 99, 5)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 98, 13)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 104, 5)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 103, 13)) >arr.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 99, 5)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 104, 5)) >map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) ->transform : Symbol(transform, Decl(genericFunctionInference1.ts, 98, 19)) +>transform : Symbol(transform, Decl(genericFunctionInference1.ts, 103, 19)) const identityStr = (t: string) => t; ->identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 101, 5)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 101, 21)) ->t : Symbol(t, Decl(genericFunctionInference1.ts, 101, 21)) +>identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 106, 5)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 106, 21)) +>t : Symbol(t, Decl(genericFunctionInference1.ts, 106, 21)) const arr: string[] = map(identityStr)(['a']); ->arr : Symbol(arr, Decl(genericFunctionInference1.ts, 103, 5)) ->map : Symbol(map, Decl(genericFunctionInference1.ts, 98, 5)) ->identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 101, 5)) +>arr : Symbol(arr, Decl(genericFunctionInference1.ts, 108, 5)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) +>identityStr : Symbol(identityStr, Decl(genericFunctionInference1.ts, 106, 5)) const arr1: string[] = map(identity)(['a']); ->arr1 : Symbol(arr1, Decl(genericFunctionInference1.ts, 104, 5)) ->map : Symbol(map, Decl(genericFunctionInference1.ts, 98, 5)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>arr1 : Symbol(arr1, Decl(genericFunctionInference1.ts, 109, 5)) +>map : Symbol(map, Decl(genericFunctionInference1.ts, 103, 5)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) // #9949 function of2(one: a, two: b): [a, b] { ->of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 104, 44)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 108, 13)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 108, 15)) ->one : Symbol(one, Decl(genericFunctionInference1.ts, 108, 19)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 108, 13)) ->two : Symbol(two, Decl(genericFunctionInference1.ts, 108, 26)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 108, 15)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 108, 13)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 108, 15)) +>of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 109, 44)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) +>one : Symbol(one, Decl(genericFunctionInference1.ts, 113, 19)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) +>two : Symbol(two, Decl(genericFunctionInference1.ts, 113, 26)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 113, 13)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 113, 15)) return [one, two]; ->one : Symbol(one, Decl(genericFunctionInference1.ts, 108, 19)) ->two : Symbol(two, Decl(genericFunctionInference1.ts, 108, 26)) +>one : Symbol(one, Decl(genericFunctionInference1.ts, 113, 19)) +>two : Symbol(two, Decl(genericFunctionInference1.ts, 113, 26)) } const flipped = flip(of2); ->flipped : Symbol(flipped, Decl(genericFunctionInference1.ts, 112, 5)) ->flip : Symbol(flip, Decl(genericFunctionInference1.ts, 82, 20)) ->of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 104, 44)) +>flipped : Symbol(flipped, Decl(genericFunctionInference1.ts, 117, 5)) +>flip : Symbol(flip, Decl(genericFunctionInference1.ts, 87, 20)) +>of2 : Symbol(of2, Decl(genericFunctionInference1.ts, 109, 44)) // #29904.1 type Component

= (props: P) => {}; ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 116, 15)) ->props : Symbol(props, Decl(genericFunctionInference1.ts, 116, 21)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 116, 15)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 121, 15)) +>props : Symbol(props, Decl(genericFunctionInference1.ts, 121, 21)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 121, 15)) declare const myHoc1:

(C: Component

) => Component

; ->myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 118, 13)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 118, 23)) ->C : Symbol(C, Decl(genericFunctionInference1.ts, 118, 26)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 118, 23)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 118, 23)) +>myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 123, 13)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 123, 26)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 123, 23)) declare const myHoc2:

(C: Component

) => Component

; ->myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 119, 13)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 119, 23)) ->C : Symbol(C, Decl(genericFunctionInference1.ts, 119, 26)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 119, 23)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->P : Symbol(P, Decl(genericFunctionInference1.ts, 119, 23)) +>myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 124, 13)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) +>C : Symbol(C, Decl(genericFunctionInference1.ts, 124, 26)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>P : Symbol(P, Decl(genericFunctionInference1.ts, 124, 23)) declare const MyComponent1: Component<{ foo: 1 }>; ->MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 121, 13)) ->Component : Symbol(Component, Decl(genericFunctionInference1.ts, 112, 26)) ->foo : Symbol(foo, Decl(genericFunctionInference1.ts, 121, 39)) +>MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 126, 13)) +>Component : Symbol(Component, Decl(genericFunctionInference1.ts, 117, 26)) +>foo : Symbol(foo, Decl(genericFunctionInference1.ts, 126, 39)) const enhance = pipe( ->enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 123, 5)) +>enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 128, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) myHoc1, ->myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 118, 13)) +>myHoc1 : Symbol(myHoc1, Decl(genericFunctionInference1.ts, 123, 13)) myHoc2, ->myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 119, 13)) +>myHoc2 : Symbol(myHoc2, Decl(genericFunctionInference1.ts, 124, 13)) ); const MyComponent2 = enhance(MyComponent1); ->MyComponent2 : Symbol(MyComponent2, Decl(genericFunctionInference1.ts, 128, 5)) ->enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 123, 5)) ->MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 121, 13)) +>MyComponent2 : Symbol(MyComponent2, Decl(genericFunctionInference1.ts, 133, 5)) +>enhance : Symbol(enhance, Decl(genericFunctionInference1.ts, 128, 5)) +>MyComponent1 : Symbol(MyComponent1, Decl(genericFunctionInference1.ts, 126, 13)) // #29904.2 const fn20 = pipe((_a?: {}) => 1); ->fn20 : Symbol(fn20, Decl(genericFunctionInference1.ts, 132, 5)) +>fn20 : Symbol(fn20, Decl(genericFunctionInference1.ts, 137, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) ->_a : Symbol(_a, Decl(genericFunctionInference1.ts, 132, 19)) +>_a : Symbol(_a, Decl(genericFunctionInference1.ts, 137, 19)) // #29904.3 type Fn = (n: number) => number; ->Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 132, 34)) ->n : Symbol(n, Decl(genericFunctionInference1.ts, 136, 11)) +>Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 137, 34)) +>n : Symbol(n, Decl(genericFunctionInference1.ts, 141, 11)) const fn30: Fn = pipe( ->fn30 : Symbol(fn30, Decl(genericFunctionInference1.ts, 137, 5)) ->Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 132, 34)) +>fn30 : Symbol(fn30, Decl(genericFunctionInference1.ts, 142, 5)) +>Fn : Symbol(Fn, Decl(genericFunctionInference1.ts, 137, 34)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) x => x + 1, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 137, 22)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 137, 22)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 142, 22)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 142, 22)) x => x * 2, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 138, 15)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 138, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 143, 15)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 143, 15)) ); const promise = Promise.resolve(1); ->promise : Symbol(promise, Decl(genericFunctionInference1.ts, 142, 5)) +>promise : Symbol(promise, Decl(genericFunctionInference1.ts, 147, 5)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) promise.then( >promise.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->promise : Symbol(promise, Decl(genericFunctionInference1.ts, 142, 5)) +>promise : Symbol(promise, Decl(genericFunctionInference1.ts, 147, 5)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) pipe( >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) x => x + 1, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 144, 9)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 144, 9)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 149, 9)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 149, 9)) x => x * 2, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 145, 19)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 145, 19)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 150, 19)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 150, 19)) ), ); @@ -757,121 +797,137 @@ promise.then( // #29904.4 declare const getString: () => string; ->getString : Symbol(getString, Decl(genericFunctionInference1.ts, 152, 13)) +>getString : Symbol(getString, Decl(genericFunctionInference1.ts, 157, 13)) declare const orUndefined: (name: string) => string | undefined; ->orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 153, 13)) ->name : Symbol(name, Decl(genericFunctionInference1.ts, 153, 28)) +>orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 158, 13)) +>name : Symbol(name, Decl(genericFunctionInference1.ts, 158, 28)) declare const identity: (value: T) => T; ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 154, 25)) ->value : Symbol(value, Decl(genericFunctionInference1.ts, 154, 28)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 154, 25)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 154, 25)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) +>value : Symbol(value, Decl(genericFunctionInference1.ts, 159, 28)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 159, 25)) const fn40 = pipe( ->fn40 : Symbol(fn40, Decl(genericFunctionInference1.ts, 156, 5)) +>fn40 : Symbol(fn40, Decl(genericFunctionInference1.ts, 161, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getString, ->getString : Symbol(getString, Decl(genericFunctionInference1.ts, 152, 13)) +>getString : Symbol(getString, Decl(genericFunctionInference1.ts, 157, 13)) string => orUndefined(string), ->string : Symbol(string, Decl(genericFunctionInference1.ts, 157, 14)) ->orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 153, 13)) ->string : Symbol(string, Decl(genericFunctionInference1.ts, 157, 14)) +>string : Symbol(string, Decl(genericFunctionInference1.ts, 162, 14)) +>orUndefined : Symbol(orUndefined, Decl(genericFunctionInference1.ts, 158, 13)) +>string : Symbol(string, Decl(genericFunctionInference1.ts, 162, 14)) identity, ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) ); // #29904.6 declare const getArray: () => string[]; ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 164, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) declare const first: (ts: T[]) => T; ->first : Symbol(first, Decl(genericFunctionInference1.ts, 165, 13)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 165, 22)) ->ts : Symbol(ts, Decl(genericFunctionInference1.ts, 165, 25)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 165, 22)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 165, 22)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) +>ts : Symbol(ts, Decl(genericFunctionInference1.ts, 170, 25)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 170, 22)) const fn60 = pipe( ->fn60 : Symbol(fn60, Decl(genericFunctionInference1.ts, 167, 5)) +>fn60 : Symbol(fn60, Decl(genericFunctionInference1.ts, 172, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 164, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) x => x, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 168, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 168, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 173, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 173, 13)) first, ->first : Symbol(first, Decl(genericFunctionInference1.ts, 165, 13)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) ); const fn61 = pipe( ->fn61 : Symbol(fn61, Decl(genericFunctionInference1.ts, 173, 5)) +>fn61 : Symbol(fn61, Decl(genericFunctionInference1.ts, 178, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 164, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) identity, ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) first, ->first : Symbol(first, Decl(genericFunctionInference1.ts, 165, 13)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) ); const fn62 = pipe( ->fn62 : Symbol(fn62, Decl(genericFunctionInference1.ts, 179, 5)) +>fn62 : Symbol(fn62, Decl(genericFunctionInference1.ts, 184, 5)) >pipe : Symbol(pipe, Decl(genericFunctionInference1.ts, 0, 0), Decl(genericFunctionInference1.ts, 0, 84), Decl(genericFunctionInference1.ts, 1, 104)) getArray, ->getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 164, 13)) +>getArray : Symbol(getArray, Decl(genericFunctionInference1.ts, 169, 13)) x => x, ->x : Symbol(x, Decl(genericFunctionInference1.ts, 180, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 180, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 185, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 185, 13)) x => first(x), ->x : Symbol(x, Decl(genericFunctionInference1.ts, 181, 11)) ->first : Symbol(first, Decl(genericFunctionInference1.ts, 165, 13)) ->x : Symbol(x, Decl(genericFunctionInference1.ts, 181, 11)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 186, 11)) +>first : Symbol(first, Decl(genericFunctionInference1.ts, 170, 13)) +>x : Symbol(x, Decl(genericFunctionInference1.ts, 186, 11)) ); // Repro from #30297 declare function foo2(fn: T, a?: U, b?: U): [T, U]; ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 183, 2)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 187, 22)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 187, 24)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 187, 22)) ->fn : Symbol(fn, Decl(genericFunctionInference1.ts, 187, 32)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 187, 22)) ->a : Symbol(a, Decl(genericFunctionInference1.ts, 187, 38)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 187, 24)) ->b : Symbol(b, Decl(genericFunctionInference1.ts, 187, 45)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 187, 24)) ->T : Symbol(T, Decl(genericFunctionInference1.ts, 187, 22)) ->U : Symbol(U, Decl(genericFunctionInference1.ts, 187, 24)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) +>fn : Symbol(fn, Decl(genericFunctionInference1.ts, 192, 32)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) +>a : Symbol(a, Decl(genericFunctionInference1.ts, 192, 38)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) +>b : Symbol(b, Decl(genericFunctionInference1.ts, 192, 45)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 192, 22)) +>U : Symbol(U, Decl(genericFunctionInference1.ts, 192, 24)) foo2(() => {}); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 183, 2)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) foo2(identity); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 183, 2)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) foo2(identity, 1); ->foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 183, 2)) ->identity : Symbol(identity, Decl(genericFunctionInference1.ts, 154, 13)) +>foo2 : Symbol(foo2, Decl(genericFunctionInference1.ts, 188, 2)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) + +// Repro from #30324 + +declare function times(fn: (i: number) => T): (n: number) => T[]; +>times : Symbol(times, Decl(genericFunctionInference1.ts, 196, 18)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) +>fn : Symbol(fn, Decl(genericFunctionInference1.ts, 200, 26)) +>i : Symbol(i, Decl(genericFunctionInference1.ts, 200, 31)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) +>n : Symbol(n, Decl(genericFunctionInference1.ts, 200, 50)) +>T : Symbol(T, Decl(genericFunctionInference1.ts, 200, 23)) + +const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] +>a2 : Symbol(a2, Decl(genericFunctionInference1.ts, 201, 5)) +>times : Symbol(times, Decl(genericFunctionInference1.ts, 196, 18)) +>identity : Symbol(identity, Decl(genericFunctionInference1.ts, 159, 13)) diff --git a/tests/baselines/reference/genericFunctionInference1.types b/tests/baselines/reference/genericFunctionInference1.types index a06ad6cffc5..7b0cb2a0e36 100644 --- a/tests/baselines/reference/genericFunctionInference1.types +++ b/tests/baselines/reference/genericFunctionInference1.types @@ -421,6 +421,28 @@ const f50 = pipe5(list); // No higher order inference >pipe5 : (f: (a: A) => B) => { f: (a: A) => B; } >list : (a: T) => T[] +declare function wrap3(f: (a: A, b1: B, b2: B) => C): (a: A, b1: B, b2: B) => C; +>wrap3 : (f: (a: A, b1: B, b2: B) => C) => (a: A, b1: B, b2: B) => C +>f : (a: A, b1: B, b2: B) => C +>a : A +>b1 : B +>b2 : B +>a : A +>b1 : B +>b2 : B + +declare function baz(t1: T, t2: T, u: U): [T, U]; +>baz : (t1: T, t2: T, u: U) => [T, U] +>t1 : T +>t2 : T +>u : U + +let f60 = wrap3(baz); +>f60 : (a: T, b1: U, b2: U) => [T, U] +>wrap3(baz) : (a: T, b1: U, b2: U) => [T, U] +>wrap3 : (f: (a: A, b1: B, b2: B) => C) => (a: A, b1: B, b2: B) => C +>baz : (t1: T, t2: T, u: U) => [T, U] + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -823,3 +845,19 @@ foo2(identity, 1); >identity : (value: T) => T >1 : 1 +// Repro from #30324 + +declare function times(fn: (i: number) => T): (n: number) => T[]; +>times : (fn: (i: number) => T) => (n: number) => T[] +>fn : (i: number) => T +>i : number +>n : number + +const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] +>a2 : number[] +>times(identity)(5) : number[] +>times(identity) : (n: number) => number[] +>times : (fn: (i: number) => T) => (n: number) => T[] +>identity : (value: T) => T +>5 : 5 + diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt b/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt new file mode 100644 index 00000000000..725e5a1643c --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(5,12): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(6,12): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(8,1): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(9,1): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(14,40): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(15,40): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + + +==== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts (6 errors) ==== + var x = 1 + const y = 2 + let z = 3 + globalThis.x // ok + globalThis.y // should error, no property 'y' + ~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + globalThis.z // should error, no property 'z' + ~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + globalThis['x'] // ok + globalThis['y'] // should error, no property 'y' + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + globalThis['z'] // should error, no property 'z' + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + globalThis.Float64Array // ok + globalThis.Infinity // ok + + declare let test1: (typeof globalThis)['x'] // ok + declare let test2: (typeof globalThis)['y'] // error + ~~~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + declare let test3: (typeof globalThis)['z'] // error + ~~~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + declare let themAll: keyof typeof globalThis + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.js b/tests/baselines/reference/globalThisBlockscopedProperties.js new file mode 100644 index 00000000000..0683ea4dff0 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.js @@ -0,0 +1,31 @@ +//// [globalThisBlockscopedProperties.ts] +var x = 1 +const y = 2 +let z = 3 +globalThis.x // ok +globalThis.y // should error, no property 'y' +globalThis.z // should error, no property 'z' +globalThis['x'] // ok +globalThis['y'] // should error, no property 'y' +globalThis['z'] // should error, no property 'z' +globalThis.Float64Array // ok +globalThis.Infinity // ok + +declare let test1: (typeof globalThis)['x'] // ok +declare let test2: (typeof globalThis)['y'] // error +declare let test3: (typeof globalThis)['z'] // error +declare let themAll: keyof typeof globalThis + + +//// [globalThisBlockscopedProperties.js] +var x = 1; +var y = 2; +var z = 3; +globalThis.x; // ok +globalThis.y; // should error, no property 'y' +globalThis.z; // should error, no property 'z' +globalThis['x']; // ok +globalThis['y']; // should error, no property 'y' +globalThis['z']; // should error, no property 'z' +globalThis.Float64Array; // ok +globalThis.Infinity; // ok diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.symbols b/tests/baselines/reference/globalThisBlockscopedProperties.symbols new file mode 100644 index 00000000000..54256c11861 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.symbols @@ -0,0 +1,57 @@ +=== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts === +var x = 1 +>x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +const y = 2 +>y : Symbol(y, Decl(globalThisBlockscopedProperties.ts, 1, 5)) + +let z = 3 +>z : Symbol(z, Decl(globalThisBlockscopedProperties.ts, 2, 3)) + +globalThis.x // ok +>globalThis.x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) +>globalThis : Symbol(globalThis) +>x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +globalThis.y // should error, no property 'y' +>globalThis : Symbol(globalThis) + +globalThis.z // should error, no property 'z' +>globalThis : Symbol(globalThis) + +globalThis['x'] // ok +>globalThis : Symbol(globalThis) +>'x' : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +globalThis['y'] // should error, no property 'y' +>globalThis : Symbol(globalThis) + +globalThis['z'] // should error, no property 'z' +>globalThis : Symbol(globalThis) + +globalThis.Float64Array // ok +>globalThis.Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>globalThis : Symbol(globalThis) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +globalThis.Infinity // ok +>globalThis.Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) +>globalThis : Symbol(globalThis) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +declare let test1: (typeof globalThis)['x'] // ok +>test1 : Symbol(test1, Decl(globalThisBlockscopedProperties.ts, 12, 11)) +>globalThis : Symbol(globalThis) + +declare let test2: (typeof globalThis)['y'] // error +>test2 : Symbol(test2, Decl(globalThisBlockscopedProperties.ts, 13, 11)) +>globalThis : Symbol(globalThis) + +declare let test3: (typeof globalThis)['z'] // error +>test3 : Symbol(test3, Decl(globalThisBlockscopedProperties.ts, 14, 11)) +>globalThis : Symbol(globalThis) + +declare let themAll: keyof typeof globalThis +>themAll : Symbol(themAll, Decl(globalThisBlockscopedProperties.ts, 15, 11)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.types b/tests/baselines/reference/globalThisBlockscopedProperties.types new file mode 100644 index 00000000000..564fa3f00d3 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.types @@ -0,0 +1,69 @@ +=== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts === +var x = 1 +>x : number +>1 : 1 + +const y = 2 +>y : 2 +>2 : 2 + +let z = 3 +>z : number +>3 : 3 + +globalThis.x // ok +>globalThis.x : number +>globalThis : typeof globalThis +>x : number + +globalThis.y // should error, no property 'y' +>globalThis.y : any +>globalThis : typeof globalThis +>y : any + +globalThis.z // should error, no property 'z' +>globalThis.z : any +>globalThis : typeof globalThis +>z : any + +globalThis['x'] // ok +>globalThis['x'] : number +>globalThis : typeof globalThis +>'x' : "x" + +globalThis['y'] // should error, no property 'y' +>globalThis['y'] : any +>globalThis : typeof globalThis +>'y' : "y" + +globalThis['z'] // should error, no property 'z' +>globalThis['z'] : any +>globalThis : typeof globalThis +>'z' : "z" + +globalThis.Float64Array // ok +>globalThis.Float64Array : Float64ArrayConstructor +>globalThis : typeof globalThis +>Float64Array : Float64ArrayConstructor + +globalThis.Infinity // ok +>globalThis.Infinity : number +>globalThis : typeof globalThis +>Infinity : number + +declare let test1: (typeof globalThis)['x'] // ok +>test1 : number +>globalThis : typeof globalThis + +declare let test2: (typeof globalThis)['y'] // error +>test2 : any +>globalThis : typeof globalThis + +declare let test3: (typeof globalThis)['z'] // error +>test3 : any +>globalThis : typeof globalThis + +declare let themAll: keyof typeof globalThis +>themAll : "undefined" | "x" | "globalThis" | "eval" | "parseInt" | "parseFloat" | "isNaN" | "isFinite" | "decodeURI" | "decodeURIComponent" | "encodeURI" | "encodeURIComponent" | "escape" | "unescape" | "NaN" | "Infinity" | "Object" | "Function" | "String" | "Boolean" | "Number" | "Math" | "Date" | "RegExp" | "Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError" | "JSON" | "Array" | "ArrayBuffer" | "DataView" | "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "Intl" | "alert" | "blur" | "cancelAnimationFrame" | "captureEvents" | "close" | "confirm" | "departFocus" | "focus" | "getComputedStyle" | "getMatchedCSSRules" | "getSelection" | "matchMedia" | "moveBy" | "moveTo" | "msWriteProfilerMark" | "open" | "postMessage" | "print" | "prompt" | "releaseEvents" | "requestAnimationFrame" | "resizeBy" | "resizeTo" | "scroll" | "scrollBy" | "scrollTo" | "stop" | "webkitCancelAnimationFrame" | "webkitConvertPointFromNodeToPage" | "webkitConvertPointFromPageToNode" | "webkitRequestAnimationFrame" | "toString" | "dispatchEvent" | "atob" | "btoa" | "fetch" | "clearInterval" | "clearTimeout" | "createImageBitmap" | "queueMicrotask" | "setInterval" | "setTimeout" | "addEventListener" | "removeEventListener" | "RTCStatsReport" | "AbortController" | "AbortSignal" | "AbstractRange" | "AnalyserNode" | "Animation" | "AnimationEffect" | "AnimationEvent" | "AnimationPlaybackEvent" | "AnimationTimeline" | "ApplicationCache" | "Attr" | "AudioBuffer" | "AudioBufferSourceNode" | "AudioContext" | "AudioDestinationNode" | "AudioListener" | "AudioNode" | "AudioParam" | "AudioParamMap" | "AudioProcessingEvent" | "AudioScheduledSourceNode" | "AudioTrack" | "AudioTrackList" | "AudioWorklet" | "AudioWorkletNode" | "BarProp" | "BaseAudioContext" | "BeforeUnloadEvent" | "BhxBrowser" | "BiquadFilterNode" | "Blob" | "BroadcastChannel" | "ByteLengthQueuingStrategy" | "CDATASection" | "CSS" | "CSSConditionRule" | "CSSFontFaceRule" | "CSSGroupingRule" | "CSSImportRule" | "CSSKeyframeRule" | "CSSKeyframesRule" | "CSSMediaRule" | "CSSNamespaceRule" | "CSSPageRule" | "CSSRule" | "CSSRuleList" | "CSSStyleDeclaration" | "CSSStyleRule" | "CSSStyleSheet" | "CSSSupportsRule" | "Cache" | "CacheStorage" | "CanvasGradient" | "CanvasPattern" | "CanvasRenderingContext2D" | "CaretPosition" | "ChannelMergerNode" | "ChannelSplitterNode" | "CharacterData" | "ClientRect" | "ClientRectList" | "Clipboard" | "ClipboardEvent" | "CloseEvent" | "Comment" | "CompositionEvent" | "Console" | "ConstantSourceNode" | "ConvolverNode" | "CountQueuingStrategy" | "Crypto" | "CryptoKey" | "CryptoKeyPair" | "CustomElementRegistry" | "CustomEvent" | "DOMError" | "DOMException" | "DOMImplementation" | "DOMMatrix" | "SVGMatrix" | "WebKitCSSMatrix" | "DOMMatrixReadOnly" | "DOMParser" | "DOMPoint" | "SVGPoint" | "DOMPointReadOnly" | "DOMQuad" | "DOMRect" | "SVGRect" | "DOMRectList" | "DOMRectReadOnly" | "DOMSettableTokenList" | "DOMStringList" | "DOMStringMap" | "DOMTokenList" | "DataCue" | "DataTransfer" | "DataTransferItem" | "DataTransferItemList" | "DeferredPermissionRequest" | "DelayNode" | "DeviceAcceleration" | "DeviceLightEvent" | "DeviceMotionEvent" | "DeviceOrientationEvent" | "DeviceRotationRate" | "Document" | "DocumentFragment" | "DocumentTimeline" | "DocumentType" | "DragEvent" | "DynamicsCompressorNode" | "Element" | "ErrorEvent" | "Event" | "EventSource" | "EventTarget" | "ExtensionScriptApis" | "File" | "FileList" | "FileReader" | "FocusEvent" | "FocusNavigationEvent" | "FormData" | "GainNode" | "Gamepad" | "GamepadButton" | "GamepadEvent" | "GamepadHapticActuator" | "GamepadPose" | "HTMLAllCollection" | "HTMLAnchorElement" | "HTMLAppletElement" | "HTMLAreaElement" | "HTMLAudioElement" | "HTMLBRElement" | "HTMLBaseElement" | "HTMLBaseFontElement" | "HTMLBodyElement" | "HTMLButtonElement" | "HTMLCanvasElement" | "HTMLCollection" | "HTMLDListElement" | "HTMLDataElement" | "HTMLDataListElement" | "HTMLDetailsElement" | "HTMLDialogElement" | "HTMLDirectoryElement" | "HTMLDivElement" | "HTMLDocument" | "HTMLElement" | "HTMLEmbedElement" | "HTMLFieldSetElement" | "HTMLFontElement" | "HTMLFormControlsCollection" | "HTMLFormElement" | "HTMLFrameElement" | "HTMLFrameSetElement" | "HTMLHRElement" | "HTMLHeadElement" | "HTMLHeadingElement" | "HTMLHtmlElement" | "HTMLIFrameElement" | "HTMLImageElement" | "HTMLInputElement" | "HTMLLIElement" | "HTMLLabelElement" | "HTMLLegendElement" | "HTMLLinkElement" | "HTMLMainElement" | "HTMLMapElement" | "HTMLMarqueeElement" | "HTMLMediaElement" | "HTMLMenuElement" | "HTMLMetaElement" | "HTMLMeterElement" | "HTMLModElement" | "HTMLOListElement" | "HTMLObjectElement" | "HTMLOptGroupElement" | "HTMLOptionElement" | "HTMLOptionsCollection" | "HTMLOutputElement" | "HTMLParagraphElement" | "HTMLParamElement" | "HTMLPictureElement" | "HTMLPreElement" | "HTMLProgressElement" | "HTMLQuoteElement" | "HTMLScriptElement" | "HTMLSelectElement" | "HTMLSlotElement" | "HTMLSourceElement" | "HTMLSpanElement" | "HTMLStyleElement" | "HTMLTableCaptionElement" | "HTMLTableCellElement" | "HTMLTableColElement" | "HTMLTableDataCellElement" | "HTMLTableElement" | "HTMLTableHeaderCellElement" | "HTMLTableRowElement" | "HTMLTableSectionElement" | "HTMLTemplateElement" | "HTMLTextAreaElement" | "HTMLTimeElement" | "HTMLTitleElement" | "HTMLTrackElement" | "HTMLUListElement" | "HTMLUnknownElement" | "HTMLVideoElement" | "HashChangeEvent" | "Headers" | "History" | "IDBCursor" | "IDBCursorWithValue" | "IDBDatabase" | "IDBFactory" | "IDBIndex" | "IDBKeyRange" | "IDBObjectStore" | "IDBOpenDBRequest" | "IDBRequest" | "IDBTransaction" | "IDBVersionChangeEvent" | "IIRFilterNode" | "ImageBitmap" | "ImageBitmapRenderingContext" | "ImageData" | "IntersectionObserver" | "IntersectionObserverEntry" | "KeyboardEvent" | "KeyframeEffect" | "ListeningStateChangedEvent" | "Location" | "MSAssertion" | "MSBlobBuilder" | "MSFIDOCredentialAssertion" | "MSFIDOSignature" | "MSFIDOSignatureAssertion" | "MSGesture" | "MSGestureEvent" | "MSGraphicsTrust" | "MSInputMethodContext" | "MSMediaKeyError" | "MSMediaKeyMessageEvent" | "MSMediaKeyNeededEvent" | "MSMediaKeySession" | "MSMediaKeys" | "MSPointerEvent" | "MSStream" | "MediaDeviceInfo" | "MediaDevices" | "MediaElementAudioSourceNode" | "MediaEncryptedEvent" | "MediaError" | "MediaKeyMessageEvent" | "MediaKeySession" | "MediaKeyStatusMap" | "MediaKeySystemAccess" | "MediaKeys" | "MediaList" | "MediaQueryList" | "MediaQueryListEvent" | "MediaSource" | "MediaStream" | "MediaStreamAudioDestinationNode" | "MediaStreamAudioSourceNode" | "MediaStreamError" | "MediaStreamErrorEvent" | "MediaStreamEvent" | "MediaStreamTrack" | "MediaStreamTrackAudioSourceNode" | "MediaStreamTrackEvent" | "MessageChannel" | "MessageEvent" | "MessagePort" | "MimeType" | "MimeTypeArray" | "MouseEvent" | "MutationEvent" | "MutationObserver" | "MutationRecord" | "NamedNodeMap" | "NavigationPreloadManager" | "Navigator" | "Node" | "NodeFilter" | "NodeIterator" | "NodeList" | "Notification" | "OfflineAudioCompletionEvent" | "OfflineAudioContext" | "OscillatorNode" | "OverflowEvent" | "PageTransitionEvent" | "PannerNode" | "Path2D" | "PaymentAddress" | "PaymentRequest" | "PaymentRequestUpdateEvent" | "PaymentResponse" | "PerfWidgetExternal" | "Performance" | "PerformanceEntry" | "PerformanceMark" | "PerformanceMeasure" | "PerformanceNavigation" | "PerformanceNavigationTiming" | "PerformanceObserver" | "PerformanceObserverEntryList" | "PerformanceResourceTiming" | "PerformanceTiming" | "PeriodicWave" | "PermissionRequest" | "PermissionRequestedEvent" | "Plugin" | "PluginArray" | "PointerEvent" | "PopStateEvent" | "ProcessingInstruction" | "ProgressEvent" | "PromiseRejectionEvent" | "PushManager" | "PushSubscription" | "PushSubscriptionOptions" | "RTCCertificate" | "RTCDTMFSender" | "RTCDTMFToneChangeEvent" | "RTCDataChannel" | "RTCDataChannelEvent" | "RTCDtlsTransport" | "RTCDtlsTransportStateChangedEvent" | "RTCDtmfSender" | "RTCError" | "RTCErrorEvent" | "RTCIceCandidate" | "RTCIceCandidatePairChangedEvent" | "RTCIceGatherer" | "RTCIceGathererEvent" | "RTCIceTransport" | "RTCIceTransportStateChangedEvent" | "RTCIdentityAssertion" | "RTCPeerConnection" | "RTCPeerConnectionIceErrorEvent" | "RTCPeerConnectionIceEvent" | "RTCRtpReceiver" | "RTCRtpSender" | "RTCRtpTransceiver" | "RTCSctpTransport" | "RTCSessionDescription" | "RTCSrtpSdesTransport" | "RTCSsrcConflictEvent" | "RTCStatsEvent" | "RTCStatsProvider" | "RTCTrackEvent" | "RadioNodeList" | "RandomSource" | "Range" | "ReadableStream" | "ReadableStreamBYOBReader" | "ReadableStreamReader" | "Request" | "Response" | "SVGAElement" | "SVGAngle" | "SVGAnimateElement" | "SVGAnimateMotionElement" | "SVGAnimateTransformElement" | "SVGAnimatedAngle" | "SVGAnimatedBoolean" | "SVGAnimatedEnumeration" | "SVGAnimatedInteger" | "SVGAnimatedLength" | "SVGAnimatedLengthList" | "SVGAnimatedNumber" | "SVGAnimatedNumberList" | "SVGAnimatedPreserveAspectRatio" | "SVGAnimatedRect" | "SVGAnimatedString" | "SVGAnimatedTransformList" | "SVGAnimationElement" | "SVGCircleElement" | "SVGClipPathElement" | "SVGComponentTransferFunctionElement" | "SVGCursorElement" | "SVGDefsElement" | "SVGDescElement" | "SVGElement" | "SVGElementInstance" | "SVGElementInstanceList" | "SVGEllipseElement" | "SVGFEBlendElement" | "SVGFEColorMatrixElement" | "SVGFEComponentTransferElement" | "SVGFECompositeElement" | "SVGFEConvolveMatrixElement" | "SVGFEDiffuseLightingElement" | "SVGFEDisplacementMapElement" | "SVGFEDistantLightElement" | "SVGFEFloodElement" | "SVGFEFuncAElement" | "SVGFEFuncBElement" | "SVGFEFuncGElement" | "SVGFEFuncRElement" | "SVGFEGaussianBlurElement" | "SVGFEImageElement" | "SVGFEMergeElement" | "SVGFEMergeNodeElement" | "SVGFEMorphologyElement" | "SVGFEOffsetElement" | "SVGFEPointLightElement" | "SVGFESpecularLightingElement" | "SVGFESpotLightElement" | "SVGFETileElement" | "SVGFETurbulenceElement" | "SVGFilterElement" | "SVGForeignObjectElement" | "SVGGElement" | "SVGGeometryElement" | "SVGGradientElement" | "SVGGraphicsElement" | "SVGImageElement" | "SVGLength" | "SVGLengthList" | "SVGLineElement" | "SVGLinearGradientElement" | "SVGMarkerElement" | "SVGMaskElement" | "SVGMetadataElement" | "SVGNumber" | "SVGNumberList" | "SVGPathElement" | "SVGPathSeg" | "SVGPathSegArcAbs" | "SVGPathSegArcRel" | "SVGPathSegClosePath" | "SVGPathSegCurvetoCubicAbs" | "SVGPathSegCurvetoCubicRel" | "SVGPathSegCurvetoCubicSmoothAbs" | "SVGPathSegCurvetoCubicSmoothRel" | "SVGPathSegCurvetoQuadraticAbs" | "SVGPathSegCurvetoQuadraticRel" | "SVGPathSegCurvetoQuadraticSmoothAbs" | "SVGPathSegCurvetoQuadraticSmoothRel" | "SVGPathSegLinetoAbs" | "SVGPathSegLinetoHorizontalAbs" | "SVGPathSegLinetoHorizontalRel" | "SVGPathSegLinetoRel" | "SVGPathSegLinetoVerticalAbs" | "SVGPathSegLinetoVerticalRel" | "SVGPathSegList" | "SVGPathSegMovetoAbs" | "SVGPathSegMovetoRel" | "SVGPatternElement" | "SVGPointList" | "SVGPolygonElement" | "SVGPolylineElement" | "SVGPreserveAspectRatio" | "SVGRadialGradientElement" | "SVGRectElement" | "SVGSVGElement" | "SVGScriptElement" | "SVGStopElement" | "SVGStringList" | "SVGStyleElement" | "SVGSwitchElement" | "SVGSymbolElement" | "SVGTSpanElement" | "SVGTextContentElement" | "SVGTextElement" | "SVGTextPathElement" | "SVGTextPositioningElement" | "SVGTitleElement" | "SVGTransform" | "SVGTransformList" | "SVGUnitTypes" | "SVGUseElement" | "SVGViewElement" | "SVGZoomAndPan" | "SVGZoomEvent" | "ScopedCredential" | "ScopedCredentialInfo" | "Screen" | "ScreenOrientation" | "ScriptProcessorNode" | "SecurityPolicyViolationEvent" | "Selection" | "ServiceUIFrameContext" | "ServiceWorker" | "ServiceWorkerContainer" | "ServiceWorkerMessageEvent" | "ServiceWorkerRegistration" | "ShadowRoot" | "SourceBuffer" | "SourceBufferList" | "SpeechGrammar" | "SpeechGrammarList" | "SpeechRecognition" | "SpeechRecognitionAlternative" | "SpeechRecognitionError" | "SpeechRecognitionEvent" | "SpeechRecognitionResult" | "SpeechRecognitionResultList" | "SpeechSynthesis" | "SpeechSynthesisErrorEvent" | "SpeechSynthesisEvent" | "SpeechSynthesisUtterance" | "SpeechSynthesisVoice" | "StaticRange" | "StereoPannerNode" | "Storage" | "StorageEvent" | "StorageManager" | "StyleMedia" | "StyleSheet" | "StyleSheetList" | "SubtleCrypto" | "SyncManager" | "Text" | "TextDecoder" | "TextEncoder" | "TextEvent" | "TextMetrics" | "TextTrack" | "TextTrackCue" | "TextTrackCueList" | "TextTrackList" | "TimeRanges" | "Touch" | "TouchEvent" | "TouchList" | "TrackEvent" | "TransformStream" | "TransitionEvent" | "TreeWalker" | "UIEvent" | "URL" | "webkitURL" | "URLSearchParams" | "VRDisplay" | "VRDisplayCapabilities" | "VRDisplayEvent" | "VREyeParameters" | "VRFieldOfView" | "VRFrameData" | "VRPose" | "VTTCue" | "VTTRegion" | "ValidityState" | "VideoPlaybackQuality" | "VideoTrack" | "VideoTrackList" | "WaveShaperNode" | "WebAuthentication" | "WebAuthnAssertion" | "WebGLActiveInfo" | "WebGLBuffer" | "WebGLContextEvent" | "WebGLFramebuffer" | "WebGLObject" | "WebGLProgram" | "WebGLRenderbuffer" | "WebGLRenderingContext" | "WebGLShader" | "WebGLShaderPrecisionFormat" | "WebGLTexture" | "WebGLUniformLocation" | "WebKitPoint" | "WebSocket" | "WheelEvent" | "Window" | "Worker" | "Worklet" | "WritableStream" | "XMLDocument" | "XMLHttpRequest" | "XMLHttpRequestEventTarget" | "XMLHttpRequestUpload" | "XMLSerializer" | "XPathEvaluator" | "XPathExpression" | "XPathNSResolver" | "XPathResult" | "XSLTProcessor" | "webkitRTCPeerConnection" | "Audio" | "Image" | "Option" | "applicationCache" | "caches" | "clientInformation" | "closed" | "crypto" | "customElements" | "defaultStatus" | "devicePixelRatio" | "doNotTrack" | "document" | "event" | "external" | "frameElement" | "frames" | "history" | "innerHeight" | "innerWidth" | "isSecureContext" | "length" | "location" | "locationbar" | "menubar" | "msContentScript" | "navigator" | "offscreenBuffering" | "oncompassneedscalibration" | "ondevicelight" | "ondevicemotion" | "ondeviceorientation" | "onmousewheel" | "onmsgesturechange" | "onmsgesturedoubletap" | "onmsgestureend" | "onmsgesturehold" | "onmsgesturestart" | "onmsgesturetap" | "onmsinertiastart" | "onmspointercancel" | "onmspointerdown" | "onmspointerenter" | "onmspointerleave" | "onmspointermove" | "onmspointerout" | "onmspointerover" | "onmspointerup" | "onorientationchange" | "onreadystatechange" | "onvrdisplayactivate" | "onvrdisplayblur" | "onvrdisplayconnect" | "onvrdisplaydeactivate" | "onvrdisplaydisconnect" | "onvrdisplayfocus" | "onvrdisplaypointerrestricted" | "onvrdisplaypointerunrestricted" | "onvrdisplaypresentchange" | "opener" | "orientation" | "outerHeight" | "outerWidth" | "pageXOffset" | "pageYOffset" | "parent" | "performance" | "personalbar" | "screen" | "screenLeft" | "screenTop" | "screenX" | "screenY" | "scrollX" | "scrollY" | "scrollbars" | "self" | "speechSynthesis" | "status" | "statusbar" | "styleMedia" | "toolbar" | "top" | "window" | "sessionStorage" | "localStorage" | "console" | "onabort" | "onanimationcancel" | "onanimationend" | "onanimationiteration" | "onanimationstart" | "onauxclick" | "onblur" | "oncancel" | "oncanplay" | "oncanplaythrough" | "onchange" | "onclick" | "onclose" | "oncontextmenu" | "oncuechange" | "ondblclick" | "ondrag" | "ondragend" | "ondragenter" | "ondragexit" | "ondragleave" | "ondragover" | "ondragstart" | "ondrop" | "ondurationchange" | "onemptied" | "onended" | "onerror" | "onfocus" | "ongotpointercapture" | "oninput" | "oninvalid" | "onkeydown" | "onkeypress" | "onkeyup" | "onload" | "onloadeddata" | "onloadedmetadata" | "onloadend" | "onloadstart" | "onlostpointercapture" | "onmousedown" | "onmouseenter" | "onmouseleave" | "onmousemove" | "onmouseout" | "onmouseover" | "onmouseup" | "onpause" | "onplay" | "onplaying" | "onpointercancel" | "onpointerdown" | "onpointerenter" | "onpointerleave" | "onpointermove" | "onpointerout" | "onpointerover" | "onpointerup" | "onprogress" | "onratechange" | "onreset" | "onresize" | "onscroll" | "onsecuritypolicyviolation" | "onseeked" | "onseeking" | "onselect" | "onselectionchange" | "onselectstart" | "onstalled" | "onsubmit" | "onsuspend" | "ontimeupdate" | "ontoggle" | "ontouchcancel" | "ontouchend" | "ontouchmove" | "ontouchstart" | "ontransitioncancel" | "ontransitionend" | "ontransitionrun" | "ontransitionstart" | "onvolumechange" | "onwaiting" | "onwheel" | "indexedDB" | "origin" | "onafterprint" | "onbeforeprint" | "onbeforeunload" | "onhashchange" | "onlanguagechange" | "onmessage" | "onmessageerror" | "onoffline" | "ononline" | "onpagehide" | "onpageshow" | "onpopstate" | "onrejectionhandled" | "onstorage" | "onunhandledrejection" | "onunload" | "importScripts" | "ActiveXObject" | "WScript" | "WSH" | "Enumerator" | "VBArray" +>globalThis : typeof globalThis + diff --git a/tests/baselines/reference/globalThisReadonlyProperties.errors.txt b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt index 925cf90a10c..a4b7876c485 100644 --- a/tests/baselines/reference/globalThisReadonlyProperties.errors.txt +++ b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(1,12): error TS2540: Cannot assign to 'globalThis' because it is a read-only property. -tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS2540: Cannot assign to 'y' because it is a read-only property. +tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es2019/globalThisReadonlyProperties.ts (2 errors) ==== @@ -11,5 +11,5 @@ tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS25 globalThis.x = 3 globalThis.y = 4 // should error ~ -!!! error TS2540: Cannot assign to 'y' because it is a read-only property. +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. \ No newline at end of file diff --git a/tests/baselines/reference/globalThisReadonlyProperties.symbols b/tests/baselines/reference/globalThisReadonlyProperties.symbols index df59ee45ca3..b597a27584f 100644 --- a/tests/baselines/reference/globalThisReadonlyProperties.symbols +++ b/tests/baselines/reference/globalThisReadonlyProperties.symbols @@ -16,7 +16,5 @@ globalThis.x = 3 >x : Symbol(x, Decl(globalThisReadonlyProperties.ts, 1, 3)) globalThis.y = 4 // should error ->globalThis.y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) >globalThis : Symbol(globalThis) ->y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) diff --git a/tests/baselines/reference/infiniteConstraints.errors.txt b/tests/baselines/reference/infiniteConstraints.errors.txt index a31bf10adb1..414fa8f9213 100644 --- a/tests/baselines/reference/infiniteConstraints.errors.txt +++ b/tests/baselines/reference/infiniteConstraints.errors.txt @@ -1,12 +1,13 @@ tests/cases/compiler/infiniteConstraints.ts(3,37): error TS2589: Type instantiation is excessively deep and possibly infinite. tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude]'. +tests/cases/compiler/infiniteConstraints.ts(21,21): error TS2536: Type '"val"' cannot be used to index type 'Extract>'. +tests/cases/compiler/infiniteConstraints.ts(21,57): error TS2536: Type '"val"' cannot be used to index type 'Extract], Record<"val", string>>'. tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'. tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'. -tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2589: Type instantiation is excessively deep and possibly infinite. -==== tests/cases/compiler/infiniteConstraints.ts (6 errors) ==== +==== tests/cases/compiler/infiniteConstraints.ts (7 errors) ==== // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint type T1], { val: string }>["val"] }> = B; @@ -32,6 +33,10 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2589: Type instantia declare function ensureNoDuplicates< T extends { [K in keyof T]: Extract["val"] extends Extract], Value>["val"] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type '"val"' cannot be used to index type 'Extract>'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type '"val"' cannot be used to index type 'Extract], Record<"val", string>>'. ? never : any } @@ -55,6 +60,4 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2589: Type instantia declare function function1}>(): T[keyof T]["foo"]; ~~~~~~~~~~~~~~~~~ !!! error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'. - ~~~~~~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. \ No newline at end of file diff --git a/tests/baselines/reference/invalidTypeOfTarget.errors.txt b/tests/baselines/reference/invalidTypeOfTarget.errors.txt index b6da9a1eb77..c57838334f9 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.errors.txt +++ b/tests/baselines/reference/invalidTypeOfTarget.errors.txt @@ -36,7 +36,7 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts var x7: typeof function f() { }; ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? -!!! related TS2728 /.ts/lib.es5.d.ts:316:15: 'Function' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:316:13: 'Function' is declared here. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt index ab9d0a34a55..2d5b8277e98 100644 --- a/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt @@ -11,4 +11,4 @@ tests/cases/conformance/parser/ecmascript5/Expressions/parserMemberAccessAfterPo !!! error TS1005: ';' expected. ~~~~~~~~ !!! error TS2552: Cannot find name 'toString'. Did you mean 'String'? -!!! related TS2728 /.ts/lib.es5.d.ts:527:15: 'String' is declared here. \ No newline at end of file +!!! related TS2728 /.ts/lib.es5.d.ts:527:13: 'String' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt index 5d1059f6eff..e6996491818 100644 --- a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt index 1f8845e808a..72a6b13b608 100644 --- a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt index 4242d1faeca..38fb5e321d2 100644 --- a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts(142,3): error T $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/parserUnicode1.errors.txt b/tests/baselines/reference/parserUnicode1.errors.txt index aa9cf504714..4bcc26a6434 100644 --- a/tests/baselines/reference/parserUnicode1.errors.txt +++ b/tests/baselines/reference/parserUnicode1.errors.txt @@ -11,13 +11,13 @@ tests/cases/conformance/parser/ecmascript5/parserUnicode1.ts(10,5): error TS2552 $ERROR('#6.1: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } } catch (e) { $ERROR('#6.2: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.js b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.js new file mode 100644 index 00000000000..2eeda64fc98 --- /dev/null +++ b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.js @@ -0,0 +1,219 @@ +//// [reactReduxLikeDeferredInferenceAllowsAssignment.ts] +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 +>; + +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); + + +//// [reactReduxLikeDeferredInferenceAllowsAssignment.js] +"use strict"; +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 (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var _this = this; +var simpleAction = function (payload) { return ({ + type: "SIMPLE_ACTION", + payload: payload +}); }; +var thunkAction = function (param1, param2) { return function (dispatch, _a) { + var foo = _a.foo; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + return [2 /*return*/, foo]; + }); + }); +}; }; +var TestComponent = /** @class */ (function (_super) { + __extends(TestComponent, _super); + function TestComponent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TestComponent; +}(Component)); +var mapDispatchToProps = { simpleAction: simpleAction, thunkAction: thunkAction }; +var Test1 = connect(null, mapDispatchToProps)(TestComponent); diff --git a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.symbols b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.symbols new file mode 100644 index 00000000000..ec954dfde79 --- /dev/null +++ b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.symbols @@ -0,0 +1,471 @@ +=== tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts === +declare class Component

{ +>Component : Symbol(Component, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 0)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 24)) + + constructor(props: Readonly

); +>props : Symbol(props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 1, 14)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 24)) + + constructor(props: P, context?: any); +>props : Symbol(props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 2, 14)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 24)) +>context : Symbol(context, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 2, 23)) + + readonly props: Readonly

& Readonly<{ children?: {} }>; +>props : Symbol(Component.props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 2, 39)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 24)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +>children : Symbol(children, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 3, 42)) +} +interface ComponentClass

{ +>ComponentClass : Symbol(ComponentClass, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 4, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 5, 25)) + + new (props: P, context?: any): Component

; +>props : Symbol(props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 6, 7)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 5, 25)) +>context : Symbol(context, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 6, 16)) +>Component : Symbol(Component, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 0)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 5, 25)) + + propTypes?: WeakValidationMap

; +>propTypes : Symbol(ComponentClass.propTypes, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 6, 46)) +>WeakValidationMap : Symbol(WeakValidationMap, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 28, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 5, 25)) + + defaultProps?: Partial

; +>defaultProps : Symbol(ComponentClass.defaultProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 7, 35)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 5, 25)) + + displayName?: string; +>displayName : Symbol(ComponentClass.displayName, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 8, 28)) +} +interface FunctionComponent

{ +>FunctionComponent : Symbol(FunctionComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 10, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 11, 28)) + + (props: P & { children?: {} }, context?: any): {} | null; +>props : Symbol(props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 12, 3)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 11, 28)) +>children : Symbol(children, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 12, 15)) +>context : Symbol(context, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 12, 32)) + + propTypes?: WeakValidationMap

; +>propTypes : Symbol(FunctionComponent.propTypes, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 12, 59)) +>WeakValidationMap : Symbol(WeakValidationMap, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 28, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 11, 28)) + + defaultProps?: Partial

; +>defaultProps : Symbol(FunctionComponent.defaultProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 13, 35)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 11, 28)) + + displayName?: string; +>displayName : Symbol(FunctionComponent.displayName, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 14, 28)) +} + +declare const nominalTypeHack: unique symbol; +>nominalTypeHack : Symbol(nominalTypeHack, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 13)) + +interface Validator { +>Validator : Symbol(Validator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 45)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 19, 20)) + + ( + props: object, +>props : Symbol(props, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 20, 3)) + + propName: string, +>propName : Symbol(propName, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 21, 18)) + + componentName: string, +>componentName : Symbol(componentName, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 22, 21)) + + location: string, +>location : Symbol(location, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 23, 26)) + + propFullName: string +>propFullName : Symbol(propFullName, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 24, 21)) + + ): Error | null; +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + [nominalTypeHack]?: T; +>[nominalTypeHack] : Symbol(Validator[nominalTypeHack], Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 26, 18)) +>nominalTypeHack : Symbol(nominalTypeHack, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 13)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 19, 20)) +} +type WeakValidationMap = { +>WeakValidationMap : Symbol(WeakValidationMap, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 28, 1)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) + + [K in keyof T]?: null extends T[K] +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) + + ? Validator +>Validator : Symbol(Validator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 45)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) + + : undefined extends T[K] +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) + + ? Validator +>Validator : Symbol(Validator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 45)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) + + : Validator +>Validator : Symbol(Validator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 18, 45)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 29, 23)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 30, 3)) + +}; +type ComponentType

= ComponentClass

| FunctionComponent

; +>ComponentType : Symbol(ComponentType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 35, 2)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 19)) +>ComponentClass : Symbol(ComponentClass, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 4, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 19)) +>FunctionComponent : Symbol(FunctionComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 10, 1)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 19)) + +type Shared< +>Shared : Symbol(Shared, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 70)) + + InjectedProps, +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 38, 12)) + + DecorationTargetProps extends Shared +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 39, 16)) +>Shared : Symbol(Shared, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 70)) +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 38, 12)) +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 39, 16)) + +> = { + [P in Extract< +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 42, 3)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) + + keyof InjectedProps, +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 38, 12)) + + keyof DecorationTargetProps +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 39, 16)) + + >]?: InjectedProps[P] extends DecorationTargetProps[P] +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 38, 12)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 42, 3)) +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 39, 16)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 42, 3)) + + ? DecorationTargetProps[P] +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 39, 16)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 42, 3)) + + : never +}; + +// Infers prop type from component C +type GetProps = C extends ComponentType ? P : never; +>GetProps : Symbol(GetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 48, 2)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 14)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 14)) +>ComponentType : Symbol(ComponentType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 35, 2)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 48)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 48)) + +type ConnectedComponentClass, P> = ComponentClass< +>ConnectedComponentClass : Symbol(ConnectedComponentClass, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 64)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 53, 29)) +>ComponentType : Symbol(ComponentType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 35, 2)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 53, 58)) +>ComponentClass : Symbol(ComponentClass, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 4, 1)) + + P +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 53, 58)) + +> & { + WrappedComponent: C; +>WrappedComponent : Symbol(WrappedComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 55, 5)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 53, 29)) + +}; + +type Matching = { +>Matching : Symbol(Matching, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 57, 2)) +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 14)) +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 28)) + + [P in keyof DecorationTargetProps]: P extends keyof InjectedProps +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 28)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 14)) + + ? InjectedProps[P] extends DecorationTargetProps[P] +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 14)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 28)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) + + ? DecorationTargetProps[P] +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 28)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) + + : InjectedProps[P] +>InjectedProps : Symbol(InjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 14)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) + + : DecorationTargetProps[P] +>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 59, 28)) +>P : Symbol(P, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 60, 3)) + +}; + +type Omit = Pick>; +>Omit : Symbol(Omit, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 65, 2)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 10)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 12)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 10)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 10)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 10)) +>K : Symbol(K, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 12)) + +type InferableComponentEnhancerWithProps = < +>InferableComponentEnhancerWithProps : Symbol(InferableComponentEnhancerWithProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 63)) +>TInjectedProps : Symbol(TInjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 41)) +>TNeedsProps : Symbol(TNeedsProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 56)) + + C extends ComponentType>> +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) +>ComponentType : Symbol(ComponentType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 35, 2)) +>Matching : Symbol(Matching, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 57, 2)) +>TInjectedProps : Symbol(TInjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 41)) +>GetProps : Symbol(GetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 48, 2)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) + +>( + component: C +>component : Symbol(component, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 71, 2)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) + +) => ConnectedComponentClass< +>ConnectedComponentClass : Symbol(ConnectedComponentClass, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 51, 64)) + + C, +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) + + Omit, keyof Shared>> & TNeedsProps +>Omit : Symbol(Omit, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 65, 2)) +>GetProps : Symbol(GetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 48, 2)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) +>Shared : Symbol(Shared, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 36, 70)) +>TInjectedProps : Symbol(TInjectedProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 41)) +>GetProps : Symbol(GetProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 48, 2)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 73)) +>TNeedsProps : Symbol(TNeedsProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 69, 56)) + +>; + +declare const connect: { +>connect : Symbol(connect, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 78, 13)) + + ( +>no_state : Symbol(no_state, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 3)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 17)) +>TOwnProps : Symbol(TOwnProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 38)) + + mapStateToProps: null | undefined, +>mapStateToProps : Symbol(mapStateToProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 55)) + + mapDispatchToProps: TDispatchProps +>mapDispatchToProps : Symbol(mapDispatchToProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 80, 38)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 17)) + + ): InferableComponentEnhancerWithProps< +>InferableComponentEnhancerWithProps : Symbol(InferableComponentEnhancerWithProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 67, 63)) + + ResolveThunks, +>ResolveThunks : Symbol(ResolveThunks, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 100, 19)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 17)) + + TOwnProps +>TOwnProps : Symbol(TOwnProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 79, 38)) + + >; +}; + +type InferThunkActionCreatorType< +>InferThunkActionCreatorType : Symbol(InferThunkActionCreatorType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 86, 2)) + + TActionCreator extends (...args: any[]) => any +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 88, 33)) +>args : Symbol(args, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 89, 26)) + +> = TActionCreator extends ( +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 88, 33)) + + ...args: infer TParams +>args : Symbol(args, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 90, 28)) +>TParams : Symbol(TParams, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 91, 16)) + +) => (...args: any[]) => infer TReturn +>args : Symbol(args, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 92, 6)) +>TReturn : Symbol(TReturn, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 92, 30)) + + ? (...args: TParams) => TReturn +>args : Symbol(args, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 93, 5)) +>TParams : Symbol(TParams, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 91, 16)) +>TReturn : Symbol(TReturn, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 92, 30)) + + : TActionCreator; +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 88, 33)) + +type HandleThunkActionCreator = TActionCreator extends ( +>HandleThunkActionCreator : Symbol(HandleThunkActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 94, 19)) +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 96, 30)) +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 96, 30)) + + ...args: any[] +>args : Symbol(args, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 96, 72)) + +) => any + ? InferThunkActionCreatorType +>InferThunkActionCreatorType : Symbol(InferThunkActionCreatorType, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 86, 2)) +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 96, 30)) + + : TActionCreator; +>TActionCreator : Symbol(TActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 96, 30)) + +type ResolveThunks = TDispatchProps extends { +>ResolveThunks : Symbol(ResolveThunks, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 100, 19)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 102, 19)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 102, 19)) + + [key: string]: any; +>key : Symbol(key, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 103, 3)) +} + ? { [C in keyof TDispatchProps]: HandleThunkActionCreator } +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 105, 7)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 102, 19)) +>HandleThunkActionCreator : Symbol(HandleThunkActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 94, 19)) +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 102, 19)) +>C : Symbol(C, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 105, 7)) + + : TDispatchProps; +>TDispatchProps : Symbol(TDispatchProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 102, 19)) + +interface Dispatch { +>Dispatch : Symbol(Dispatch, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 106, 19)) +>A : Symbol(A, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 108, 19)) +>Action : Symbol(Action, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 110, 1)) +>AnyAction : Symbol(AnyAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 113, 1)) + + (action: T): T; +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 109, 3)) +>A : Symbol(A, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 108, 19)) +>action : Symbol(action, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 109, 16)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 109, 3)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 109, 3)) +} +interface Action { +>Action : Symbol(Action, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 110, 1)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 111, 17)) + + type: T; +>type : Symbol(Action.type, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 111, 27)) +>T : Symbol(T, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 111, 17)) +} +interface AnyAction extends Action { +>AnyAction : Symbol(AnyAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 113, 1)) +>Action : Symbol(Action, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 110, 1)) + + [extraProps: string]: any; +>extraProps : Symbol(extraProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 115, 3)) +} + +const simpleAction = (payload: boolean) => ({ +>simpleAction : Symbol(simpleAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 118, 5)) +>payload : Symbol(payload, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 118, 22)) + + type: "SIMPLE_ACTION", +>type : Symbol(type, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 118, 45)) + + payload +>payload : Symbol(payload, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 119, 24)) + +}); +const thunkAction = (param1: number, param2: string) => async ( +>thunkAction : Symbol(thunkAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 122, 5)) +>param1 : Symbol(param1, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 122, 21)) +>param2 : Symbol(param2, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 122, 36)) + + dispatch: Dispatch, +>dispatch : Symbol(dispatch, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 122, 63)) +>Dispatch : Symbol(Dispatch, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 106, 19)) + + { foo }: OwnProps +>foo : Symbol(foo, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 124, 3)) +>OwnProps : Symbol(OwnProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 127, 2)) + +) => { + return foo; +>foo : Symbol(foo, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 124, 3)) + +}; +interface OwnProps { +>OwnProps : Symbol(OwnProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 127, 2)) + + foo: string; +>foo : Symbol(OwnProps.foo, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 128, 20)) +} +interface TestComponentProps extends OwnProps { +>TestComponentProps : Symbol(TestComponentProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 130, 1)) +>OwnProps : Symbol(OwnProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 127, 2)) + + simpleAction: typeof simpleAction; +>simpleAction : Symbol(TestComponentProps.simpleAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 131, 47)) +>simpleAction : Symbol(simpleAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 118, 5)) + + thunkAction(param1: number, param2: string): Promise; +>thunkAction : Symbol(TestComponentProps.thunkAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 132, 36)) +>param1 : Symbol(param1, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 133, 14)) +>param2 : Symbol(param2, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 133, 29)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) +} +class TestComponent extends Component {} +>TestComponent : Symbol(TestComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 134, 1)) +>Component : Symbol(Component, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 0, 0)) +>TestComponentProps : Symbol(TestComponentProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 130, 1)) + +const mapDispatchToProps = { simpleAction, thunkAction }; +>mapDispatchToProps : Symbol(mapDispatchToProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 136, 5)) +>simpleAction : Symbol(simpleAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 136, 28)) +>thunkAction : Symbol(thunkAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 136, 42)) + +type Q = HandleThunkActionCreator; +>Q : Symbol(Q, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 136, 57)) +>HandleThunkActionCreator : Symbol(HandleThunkActionCreator, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 94, 19)) +>simpleAction : Symbol(simpleAction, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 118, 5)) + +const Test1 = connect( +>Test1 : Symbol(Test1, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 140, 5)) +>connect : Symbol(connect, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 78, 13)) + + null, + mapDispatchToProps +>mapDispatchToProps : Symbol(mapDispatchToProps, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 136, 5)) + +)(TestComponent); +>TestComponent : Symbol(TestComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 134, 1)) + diff --git a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types new file mode 100644 index 00000000000..767d94535cb --- /dev/null +++ b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types @@ -0,0 +1,288 @@ +=== tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts === +declare class Component

{ +>Component : Component

+ + constructor(props: Readonly

); +>props : Readonly

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

& Readonly<{ children?: {} }>; +>props : Readonly

& Readonly<{ children?: {} | undefined; }> +>children : {} | undefined +} +interface ComponentClass

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

; +>props : P +>context : any + + propTypes?: WeakValidationMap

; +>propTypes : WeakValidationMap

| undefined + + defaultProps?: Partial

; +>defaultProps : Partial

| undefined + + displayName?: string; +>displayName : string | undefined +} +interface FunctionComponent

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

; +>propTypes : WeakValidationMap

| undefined + + defaultProps?: Partial

; +>defaultProps : Partial

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

= ComponentClass

| FunctionComponent

; +>ComponentType : ComponentType

+ +type Shared< +>Shared : 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; +>GetProps : GetProps + +type ConnectedComponentClass, P> = ComponentClass< +>ConnectedComponentClass : ConnectedComponentClass + + P +> & { + WrappedComponent: C; +>WrappedComponent : C + +}; + +type Matching = { +>Matching : Matching + + [P in keyof DecorationTargetProps]: P extends keyof InjectedProps + ? InjectedProps[P] extends DecorationTargetProps[P] + ? DecorationTargetProps[P] + : InjectedProps[P] + : DecorationTargetProps[P] +}; + +type Omit = Pick>; +>Omit : Pick> + +type InferableComponentEnhancerWithProps = < +>InferableComponentEnhancerWithProps : InferableComponentEnhancerWithProps + + C extends ComponentType>> +>( + component: C +>component : C + +) => ConnectedComponentClass< + C, + Omit, keyof Shared>> & TNeedsProps +>; + +declare const connect: { +>connect : (mapStateToProps: null | undefined, mapDispatchToProps: TDispatchProps) => InferableComponentEnhancerWithProps, TOwnProps> + + ( + mapStateToProps: null | undefined, +>mapStateToProps : null | undefined +>null : null + + mapDispatchToProps: TDispatchProps +>mapDispatchToProps : TDispatchProps + + ): InferableComponentEnhancerWithProps< + ResolveThunks, + TOwnProps + >; +}; + +type InferThunkActionCreatorType< +>InferThunkActionCreatorType : InferThunkActionCreatorType + + TActionCreator extends (...args: any[]) => any +>args : any[] + +> = TActionCreator extends ( + ...args: infer TParams +>args : TParams + +) => (...args: any[]) => infer TReturn +>args : any[] + + ? (...args: TParams) => TReturn +>args : TParams + + : TActionCreator; + +type HandleThunkActionCreator = TActionCreator extends ( +>HandleThunkActionCreator : HandleThunkActionCreator + + ...args: any[] +>args : any[] + +) => any + ? InferThunkActionCreatorType + : TActionCreator; + +type ResolveThunks = TDispatchProps extends { +>ResolveThunks : ResolveThunks + + [key: string]: any; +>key : string +} + ? { [C in keyof TDispatchProps]: HandleThunkActionCreator } + : TDispatchProps; + +interface Dispatch { + (action: T): T; +>action : T +} +interface Action { + type: T; +>type : T +} +interface AnyAction extends Action { + [extraProps: string]: any; +>extraProps : string +} + +const simpleAction = (payload: boolean) => ({ +>simpleAction : (payload: boolean) => { type: string; payload: boolean; } +>(payload: boolean) => ({ type: "SIMPLE_ACTION", payload}) : (payload: boolean) => { type: string; payload: boolean; } +>payload : boolean +>({ type: "SIMPLE_ACTION", payload}) : { type: string; payload: boolean; } +>{ type: "SIMPLE_ACTION", payload} : { type: string; payload: boolean; } + + type: "SIMPLE_ACTION", +>type : string +>"SIMPLE_ACTION" : "SIMPLE_ACTION" + + payload +>payload : boolean + +}); +const thunkAction = (param1: number, param2: string) => async ( +>thunkAction : (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise +>(param1: number, param2: string) => async ( dispatch: Dispatch, { foo }: OwnProps) => { return foo;} : (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise +>param1 : number +>param2 : string +>async ( dispatch: Dispatch, { foo }: OwnProps) => { return foo;} : (dispatch: Dispatch, { foo }: OwnProps) => Promise + + dispatch: Dispatch, +>dispatch : Dispatch + + { foo }: OwnProps +>foo : string + +) => { + return foo; +>foo : string + +}; +interface OwnProps { + foo: string; +>foo : string +} +interface TestComponentProps extends OwnProps { + simpleAction: typeof simpleAction; +>simpleAction : (payload: boolean) => { type: string; payload: boolean; } +>simpleAction : (payload: boolean) => { type: string; payload: boolean; } + + thunkAction(param1: number, param2: string): Promise; +>thunkAction : (param1: number, param2: string) => Promise +>param1 : number +>param2 : string +} +class TestComponent extends Component {} +>TestComponent : TestComponent +>Component : Component + +const mapDispatchToProps = { simpleAction, thunkAction }; +>mapDispatchToProps : { simpleAction: (payload: boolean) => { type: string; payload: boolean; }; thunkAction: (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise; } +>{ simpleAction, thunkAction } : { simpleAction: (payload: boolean) => { type: string; payload: boolean; }; thunkAction: (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise; } +>simpleAction : (payload: boolean) => { type: string; payload: boolean; } +>thunkAction : (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise + +type Q = HandleThunkActionCreator; +>Q : (payload: boolean) => { type: string; payload: boolean; } +>simpleAction : (payload: boolean) => { type: string; payload: boolean; } + +const Test1 = connect( +>Test1 : ConnectedComponentClass> +>connect( null, mapDispatchToProps)(TestComponent) : ConnectedComponentClass> +>connect( null, mapDispatchToProps) : InferableComponentEnhancerWithProps<{ simpleAction: (payload: boolean) => { type: string; payload: boolean; }; thunkAction: (param1: number, param2: string) => Promise; }, {}> +>connect : (mapStateToProps: null | undefined, mapDispatchToProps: TDispatchProps) => InferableComponentEnhancerWithProps, TOwnProps> + + null, +>null : null + + mapDispatchToProps +>mapDispatchToProps : { simpleAction: (payload: boolean) => { type: string; payload: boolean; }; thunkAction: (param1: number, param2: string) => (dispatch: Dispatch, { foo }: OwnProps) => Promise; } + +)(TestComponent); +>TestComponent : typeof TestComponent + diff --git a/tests/baselines/reference/recursiveResolveTypeMembers.errors.txt b/tests/baselines/reference/recursiveResolveTypeMembers.errors.txt index 2a6bab18cba..ad5fe6dc1ae 100644 --- a/tests/baselines/reference/recursiveResolveTypeMembers.errors.txt +++ b/tests/baselines/reference/recursiveResolveTypeMembers.errors.txt @@ -1,13 +1,16 @@ +tests/cases/compiler/recursiveResolveTypeMembers.ts(4,49): error TS2577: Return type annotation circularly references itself. tests/cases/compiler/recursiveResolveTypeMembers.ts(4,58): error TS2304: Cannot find name 'H'. tests/cases/compiler/recursiveResolveTypeMembers.ts(4,62): error TS2574: A rest element type must be an array type. tests/cases/compiler/recursiveResolveTypeMembers.ts(4,79): error TS2304: Cannot find name 'R'. -==== tests/cases/compiler/recursiveResolveTypeMembers.ts (3 errors) ==== +==== tests/cases/compiler/recursiveResolveTypeMembers.ts (4 errors) ==== // Repro from #25291 type PromisedTuple void> = U extends (h: infer H, ...args: infer R) => [Promise, ...PromisedTuple] ? [] : [] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2577: Return type annotation circularly references itself. ~ !!! error TS2304: Cannot find name 'H'. ~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index dd3727b0216..c632915e72f 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -1,7 +1,8 @@ -tests/cases/compiler/redefineArray.ts(1,1): error TS2588: Cannot assign to 'Array' because it is a constant. +tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. ==== tests/cases/compiler/redefineArray.ts (1 errors) ==== Array = function (n:number, s:string) {return n;}; ~~~~~ -!!! error TS2588: Cannot assign to 'Array' because it is a constant. \ No newline at end of file +!!! error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. +!!! related TS2728 /.ts/lib.es5.d.ts:1364:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.types b/tests/baselines/reference/redefineArray.types index 03d36c1007c..51b1e67846b 100644 --- a/tests/baselines/reference/redefineArray.types +++ b/tests/baselines/reference/redefineArray.types @@ -1,7 +1,7 @@ === tests/cases/compiler/redefineArray.ts === Array = function (n:number, s:string) {return n;}; >Array = function (n:number, s:string) {return n;} : (n: number, s: string) => number ->Array : any +>Array : ArrayConstructor >function (n:number, s:string) {return n;} : (n: number, s: string) => number >n : number >s : string diff --git a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt index 473590f63e5..575b38c4832 100644 --- a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt index fa25b5cc170..63c080074f0 100644 --- a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.3_A1.1_T2.ts(17,3): error $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt index 6dc7a99446b..382c345b12c 100644 --- a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts(142,3): error $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.errors.txt b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.errors.txt new file mode 100644 index 00000000000..9cea32dfa59 --- /dev/null +++ b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/QSpinner.js(3,1): error TS7022: 'default' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== tests/cases/compiler/QSpinner.js (1 errors) ==== + import DefaultSpinner from './QSpinner' + + export default { + ~~~~~~~~~~~~~~~~ + mixins: [DefaultSpinner], + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + name: 'QSpinner' + ~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS7022: 'default' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + \ No newline at end of file diff --git a/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.js b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.js new file mode 100644 index 00000000000..ae736acdb2f --- /dev/null +++ b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.js @@ -0,0 +1,17 @@ +//// [QSpinner.js] +import DefaultSpinner from './QSpinner' + +export default { + mixins: [DefaultSpinner], + name: 'QSpinner' +} + + +//// [QSpinner.js] +"use strict"; +exports.__esModule = true; +var QSpinner_1 = require("./QSpinner"); +exports["default"] = { + mixins: [QSpinner_1["default"]], + name: 'QSpinner' +}; diff --git a/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.symbols b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.symbols new file mode 100644 index 00000000000..b7ead9cab77 --- /dev/null +++ b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/QSpinner.js === +import DefaultSpinner from './QSpinner' +>DefaultSpinner : Symbol(DefaultSpinner, Decl(QSpinner.js, 0, 6)) + +export default { + mixins: [DefaultSpinner], +>mixins : Symbol(mixins, Decl(QSpinner.js, 2, 16)) +>DefaultSpinner : Symbol(DefaultSpinner, Decl(QSpinner.js, 0, 6)) + + name: 'QSpinner' +>name : Symbol(name, Decl(QSpinner.js, 3, 27)) +} + diff --git a/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.types b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.types new file mode 100644 index 00000000000..b4d1545186f --- /dev/null +++ b/tests/baselines/reference/selfReferentialDefaultNoStackOverflow.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/QSpinner.js === +import DefaultSpinner from './QSpinner' +>DefaultSpinner : any + +export default { +>{ mixins: [DefaultSpinner], name: 'QSpinner'} : { mixins: any[]; name: string; } + + mixins: [DefaultSpinner], +>mixins : any[] +>[DefaultSpinner] : any[] +>DefaultSpinner : any + + name: 'QSpinner' +>name : string +>'QSpinner' : "QSpinner" +} + diff --git a/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.js b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.js new file mode 100644 index 00000000000..c4bb71f2818 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.js @@ -0,0 +1,10 @@ +//// [substitutionTypesCompareCorrectlyInRestrictiveInstances.ts] +type UnionKeys = T extends any ? keyof T : never; +type BugHelper = T extends any ? Exclude, keyof T> : never +type Bug = BugHelper +type Q = UnionKeys<{ a : any } | { b: any }> // should be "a" | "b" +type R = Bug<{ a : any } | { b: any }> // should be "a" | "b" + + +//// [substitutionTypesCompareCorrectlyInRestrictiveInstances.js] +"use strict"; diff --git a/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.symbols b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.symbols new file mode 100644 index 00000000000..31f23823705 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/substitutionTypesCompareCorrectlyInRestrictiveInstances.ts === +type UnionKeys = T extends any ? keyof T : never; +>UnionKeys : Symbol(UnionKeys, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 0)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 15)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 15)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 15)) + +type BugHelper = T extends any ? Exclude, keyof T> : never +>BugHelper : Symbol(BugHelper, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 52)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 15)) +>TAll : Symbol(TAll, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 17)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 15)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>UnionKeys : Symbol(UnionKeys, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 0)) +>TAll : Symbol(TAll, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 17)) +>T : Symbol(T, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 15)) + +type Bug = BugHelper +>Bug : Symbol(Bug, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 83)) +>TAll : Symbol(TAll, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 2, 9)) +>BugHelper : Symbol(BugHelper, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 52)) +>TAll : Symbol(TAll, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 2, 9)) +>TAll : Symbol(TAll, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 2, 9)) + +type Q = UnionKeys<{ a : any } | { b: any }> // should be "a" | "b" +>Q : Symbol(Q, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 2, 39)) +>UnionKeys : Symbol(UnionKeys, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 0, 0)) +>a : Symbol(a, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 3, 20)) +>b : Symbol(b, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 3, 34)) + +type R = Bug<{ a : any } | { b: any }> // should be "a" | "b" +>R : Symbol(R, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 3, 44)) +>Bug : Symbol(Bug, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 1, 83)) +>a : Symbol(a, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 4, 14)) +>b : Symbol(b, Decl(substitutionTypesCompareCorrectlyInRestrictiveInstances.ts, 4, 28)) + diff --git a/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.types b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.types new file mode 100644 index 00000000000..f6c8eb08cd9 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesCompareCorrectlyInRestrictiveInstances.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/substitutionTypesCompareCorrectlyInRestrictiveInstances.ts === +type UnionKeys = T extends any ? keyof T : never; +>UnionKeys : UnionKeys + +type BugHelper = T extends any ? Exclude, keyof T> : never +>BugHelper : BugHelper + +type Bug = BugHelper +>Bug : BugHelper + +type Q = UnionKeys<{ a : any } | { b: any }> // should be "a" | "b" +>Q : "a" | "b" +>a : any +>b : any + +type R = Bug<{ a : any } | { b: any }> // should be "a" | "b" +>R : "a" | "b" +>a : any +>b : any + diff --git a/tests/baselines/reference/thisTypeInFunctions.errors.txt b/tests/baselines/reference/thisTypeInFunctions.errors.txt new file mode 100644 index 00000000000..114a5b1335d --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions.errors.txt @@ -0,0 +1,206 @@ +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(118,29): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(119,32): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(120,36): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + + +==== tests/cases/conformance/types/thisType/thisTypeInFunctions.ts (3 errors) ==== + // body checking + class B { + n: number; + } + class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } + } + class D extends C { } + interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; + } + function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; + } + function justThis(this: { y: number }): number { + return this.y; + } + function implicitThis(n: number): number { + return this.m + n + 12; + } + let impl: I = { + a: 12, + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) + explicitVoid1() { return 12; }, + explicitStructural() { + return this.a; + }, + explicitInterface() { + return this.a; + }, + explicitThis() { + return this.a; + }, + } + impl.explicitVoid1 = function () { return 12; }; + impl.explicitVoid2 = () => 12; + impl.explicitStructural = function() { return this.a; }; + impl.explicitInterface = function() { return this.a; }; + impl.explicitStructural = () => 12; + impl.explicitInterface = () => 12; + impl.explicitThis = function () { return this.a; }; + // parameter checking + let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; + let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; + ok.f(13); + implicitThis(12); + implicitAnyOk.f(12); + + let c = new C(); + let d = new D(); + let ripped = c.explicitC; + c.explicitC(12); + c.explicitProperty(12); + c.explicitThis(12); + d.explicitC(12); + d.explicitProperty(12); + d.explicitThis(12); + let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, + } = { + n: 12, + explicitThis: c.explicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid + }; + reconstructed.explicitThis(10); + reconstructed.explicitProperty(11); + let explicitVoid = reconstructed.explicitVoid; + explicitVoid(12); + // assignment checking + let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any + let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; + let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; + + let unspecifiedLambda: (x: number) => number = x => x + 12; + let specifiedLambda: (this: void, x: number) => number = x => x + 12; + let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; + let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; + + + let explicitCFunction: (this: C, m: number) => number; + let explicitPropertyFunction: (this: {n: number}, m: number) => number; + c.explicitC = explicitCFunction; + c.explicitC = function(this: C, m: number) { return this.n + m }; + c.explicitProperty = explicitPropertyFunction; + c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; + c.explicitProperty = reconstructed.explicitProperty; + + // lambdas are assignable to anything + c.explicitC = m => m; + c.explicitThis = m => m; + c.explicitProperty = m => m; + + // this inside lambdas refer to outer scope + // the outer-scoped lambda at top-level is still just `any` + c.explicitC = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + c.explicitThis = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + c.explicitProperty = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + + //NOTE: this=C here, I guess? + c.explicitThis = explicitCFunction; + c.explicitThis = function(this: C, m: number) { return this.n + m }; + + // this:any compatibility + c.explicitC = function(m) { return this.n + m }; + c.explicitProperty = function(m) { return this.n + m }; + c.explicitThis = function(m) { return this.n + m }; + + // this: contextual typing + c.explicitThis = function(this, m) { return this.n + m }; + + // this: superclass compatibility + c.explicitC = function(this: B, m: number) { return this.n + m }; + + // this:void compatibility + c.explicitVoid = n => n; + + // class-based assignability + class Base1 { + x: number; + public polymorphic(this: this): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static explicitStatic(this: typeof Base1): number { return this.y; } + static y: number; + } + class Derived1 extends Base1 { + y: number + } + class Base2 { + y: number + polymorphic(this: this): number { return this.y; } + explicit(this: Base1): number { return this.x; } + } + class Derived2 extends Base2 { + x: number + } + let b1 = new Base1(); + let b2 = new Base2(); + let d1 = new Derived1(); + let d2 = new Derived2(); + d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } + d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } + + // bivariance-allowed cases + d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } + d2.polymorphic = d1.explicit // ok, 'y' in { x, y } + b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } + b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } + + ////// use this-type for construction with new //// + function InterfaceThis(this: I) { + this.a = 12; + } + function LiteralTypeThis(this: {x: string}) { + this.x = "ok"; + } + function AnyThis(this: any) { + this.x = "ok"; + } + let interfaceThis = new InterfaceThis(); + let literalTypeThis = new LiteralTypeThis(); + let anyThis = new AnyThis(); + + //// type parameter inference //// + declare var f: { + (this: void, x: number): number, + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; + }; + let n: number = f.call(12); + + function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index c1dcdb9829d..38c34bcb7a2 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -497,9 +497,7 @@ c.explicitC = m => m + this.n; >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitThis = m => m + this.n; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) @@ -507,9 +505,7 @@ c.explicitThis = m => m + this.n; >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitProperty = m => m + this.n; >c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) @@ -517,9 +513,7 @@ c.explicitProperty = m => m + this.n; >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 7408a764f1a..7082cad3941 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -580,43 +580,43 @@ c.explicitProperty = m => m; // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC = m => m + this.n : (this: C, m: number) => number +>c.explicitC = m => m + this.n : (this: C, m: number) => any >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => number +>m => m + this.n : (this: C, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any c.explicitThis = m => m + this.n; ->c.explicitThis = m => m + this.n : (this: C, m: number) => number +>c.explicitThis = m => m + this.n : (this: C, m: number) => any >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => number +>m => m + this.n : (this: C, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any c.explicitProperty = m => m + this.n; ->c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => number +>c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => any >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m + this.n : (this: { n: number; }, m: number) => number +>m => m + this.n : (this: { n: number; }, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/baselines/reference/user/TypeScript-Node-Starter.log b/tests/baselines/reference/user/TypeScript-Node-Starter.log index 9a0b3b00726..8d05a006048 100644 --- a/tests/baselines/reference/user/TypeScript-Node-Starter.log +++ b/tests/baselines/reference/user/TypeScript-Node-Starter.log @@ -1,6 +1,9 @@ Exit Code: 1 Standard output: node_modules/@types/passport-facebook/index.d.ts(50,31): error TS2689: Cannot extend an interface 'passport.Strategy'. Did you mean 'implements'? +src/controllers/user.ts(95,5): error TS2345: Argument of type '{ email: any; password: any; }' is not assignable to parameter of type 'Partial'. + Object literal may only specify known properties, and 'email' does not exist in type 'Partial'. +src/controllers/user.ts(105,16): error TS7006: Parameter 'err' implicitly has an 'any' type. diff --git a/tests/baselines/reference/user/adonis-framework.log b/tests/baselines/reference/user/adonis-framework.log index ca5bc8a93ad..6e8082d87e4 100644 --- a/tests/baselines/reference/user/adonis-framework.log +++ b/tests/baselines/reference/user/adonis-framework.log @@ -19,6 +19,7 @@ node_modules/adonis-framework/src/Config/index.js(37,15): error TS2304: Cannot f node_modules/adonis-framework/src/Config/index.js(39,15): error TS2304: Cannot find name 'Mixed'. node_modules/adonis-framework/src/Config/index.js(58,15): error TS2304: Cannot find name 'Mixed'. node_modules/adonis-framework/src/Encryption/index.js(53,15): error TS2304: Cannot find name 'Mixed'. +node_modules/adonis-framework/src/Encryption/index.js(71,34): error TS2345: Argument of type 'string' is not assignable to parameter of type '"utf8" | "ascii" | "binary" | undefined'. node_modules/adonis-framework/src/Encryption/index.js(77,50): error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string'. node_modules/adonis-framework/src/Encryption/index.js(85,23): error TS8024: JSDoc '@param' tag has name 'value', but there is no parameter with that name. node_modules/adonis-framework/src/Encryption/index.js(87,15): error TS2304: Cannot find name 'Mixed'. @@ -49,21 +50,21 @@ node_modules/adonis-framework/src/Event/index.js(271,25): error TS2345: Argument node_modules/adonis-framework/src/Event/index.js(278,25): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[string, any, TimerHandler]'. node_modules/adonis-framework/src/Event/index.js(294,30): error TS2345: Argument of type 'Function' is not assignable to parameter of type 'Listener'. node_modules/adonis-framework/src/Exceptions/index.js(13,14): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -node_modules/adonis-framework/src/Exceptions/index.js(27,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(40,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(52,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(63,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(75,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(87,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(99,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(112,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(125,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(138,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(151,12): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(27,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(40,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(52,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(63,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(75,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(87,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(99,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(112,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(125,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(138,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(151,21): error TS2554: Expected 0 arguments, but got 3. node_modules/adonis-framework/src/Exceptions/index.js(164,14): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -node_modules/adonis-framework/src/Exceptions/index.js(178,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(191,12): error TS2554: Expected 0 arguments, but got 3. -node_modules/adonis-framework/src/Exceptions/index.js(205,12): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(178,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(191,21): error TS2554: Expected 0 arguments, but got 3. +node_modules/adonis-framework/src/Exceptions/index.js(205,21): error TS2554: Expected 0 arguments, but got 3. node_modules/adonis-framework/src/File/index.js(175,5): error TS2322: Type 'Promise' is not assignable to type 'boolean'. node_modules/adonis-framework/src/File/index.js(273,5): error TS2322: Type 'boolean | ""' is not assignable to type 'boolean'. Type '""' is not assignable to type 'boolean'. @@ -135,7 +136,7 @@ node_modules/adonis-framework/src/Route/index.js(333,29): error TS2345: Argument node_modules/adonis-framework/src/Route/index.js(343,33): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'any[]'. node_modules/adonis-framework/src/Route/index.js(354,20): error TS2694: Namespace 'Route' has no exported member 'Group'. node_modules/adonis-framework/src/Route/index.js(368,3): error TS2322: Type 'null' is not assignable to type 'string'. -node_modules/adonis-framework/src/Route/index.js(396,10): error TS2554: Expected 2 arguments, but got 3. +node_modules/adonis-framework/src/Route/index.js(396,63): error TS2554: Expected 2 arguments, but got 3. node_modules/adonis-framework/src/Route/index.js(407,20): error TS2694: Namespace 'Route' has no exported member 'resources'. node_modules/adonis-framework/src/Route/index.js(501,42): error TS2345: Argument of type 'boolean | undefined' is not assignable to parameter of type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/user/async.log b/tests/baselines/reference/user/async.log index 1bc91ed6ca4..844979b145b 100644 --- a/tests/baselines/reference/user/async.log +++ b/tests/baselines/reference/user/async.log @@ -123,7 +123,7 @@ node_modules/async/dist/async.js(1951,10): error TS8024: JSDoc '@param' tag has node_modules/async/dist/async.js(1990,16): error TS2554: Expected 3 arguments, but got 1. node_modules/async/dist/async.js(2116,20): error TS2345: Argument of type 'Function | undefined' is not assignable to parameter of type 'number | undefined'. Type 'Function' is not assignable to type 'number'. -node_modules/async/dist/async.js(2274,21): error TS2554: Expected 0 arguments, but got 2. +node_modules/async/dist/async.js(2274,29): error TS2554: Expected 0 arguments, but got 2. node_modules/async/dist/async.js(2425,20): error TS1005: '}' expected. node_modules/async/dist/async.js(2450,5): error TS2740: Type '{ _tasks: DLL; concurrency: any; payload: any; saturated: () => void; unsaturated: () => void; buffer: number; empty: () => void; drain: () => void; error: () => void; started: boolean; paused: boolean; push: (data: any, callback: any) => void; ... 9 more ...; resume: () => void; }' is missing the following properties from type 'NodeModule': exports, require, id, filename, and 4 more. node_modules/async/dist/async.js(2521,9): error TS2722: Cannot invoke an object which is possibly 'undefined'. diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index 08b954bc9c5..a315b232a4a 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -14,7 +14,7 @@ node_modules/bluebird/js/release/bluebird.js(10,10): error TS2339: Property 'noC node_modules/bluebird/js/release/call_get.js(11,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/call_get.js(12,25): error TS2339: Property 'isIdentifier' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/call_get.js(73,40): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/call_get.js(74,13): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/call_get.js(74,27): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/cancel.js(4,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/cancel.js(5,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/cancel.js(93,14): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. @@ -50,14 +50,14 @@ node_modules/bluebird/js/release/debuggability.js(211,31): error TS2339: Propert node_modules/bluebird/js/release/debuggability.js(242,56): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'any[]'. Type 'IArguments' is missing the following properties from type 'any[]': pop, push, concat, join, and 26 more. node_modules/bluebird/js/release/debuggability.js(274,18): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(338,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(338,51): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/debuggability.js(352,18): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(424,18): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(426,18): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(491,19): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/debuggability.js(562,46): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(562,59): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/debuggability.js(601,18): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(648,32): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(648,46): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/debuggability.js(736,5): error TS2721: Cannot invoke an object which is possibly 'null'. node_modules/bluebird/js/release/debuggability.js(739,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(754,30): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. @@ -65,7 +65,7 @@ node_modules/bluebird/js/release/debuggability.js(760,37): error TS2339: Propert node_modules/bluebird/js/release/debuggability.js(799,38): error TS2339: Property 'stack' does not exist on type 'CapturedTrace'. node_modules/bluebird/js/release/debuggability.js(804,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(805,10): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/debuggability.js(808,25): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/debuggability.js(879,4): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/debuggability.js(885,14): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/debuggability.js(890,22): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/errors.js(5,21): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. @@ -81,7 +81,7 @@ node_modules/bluebird/js/release/generators.js(159,21): error TS2350: Only a voi node_modules/bluebird/js/release/generators.js(190,15): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/generators.js(208,15): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/generators.js(208,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/generators.js(220,5): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/generators.js(220,16): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/join.js(6,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/join.js(7,21): error TS2339: Property 'tryCatch' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/join.js(8,21): error TS2339: Property 'errorObj' does not exist on type 'typeof ret'. @@ -191,8 +191,8 @@ node_modules/bluebird/js/release/promise_array.js(26,6): error TS2339: Property node_modules/bluebird/js/release/promise_array.js(61,19): error TS2339: Property 'asArray' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(64,72): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(71,18): error TS2339: Property '_resolveEmptyArray' does not exist on type 'PromiseArray'. -node_modules/bluebird/js/release/promise_array.js(109,30): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/bluebird/js/release/promise_array.js(111,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/promise_array.js(109,76): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/bluebird/js/release/promise_array.js(111,53): error TS2554: Expected 0 arguments, but got 1. node_modules/bluebird/js/release/promisify.js(6,25): error TS2339: Property 'withAppended' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(7,29): error TS2339: Property 'maybeWrapAsError' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(8,24): error TS2339: Property 'canEvaluate' does not exist on type 'typeof ret'. @@ -200,7 +200,7 @@ node_modules/bluebird/js/release/promisify.js(24,17): error TS2339: Property 'is node_modules/bluebird/js/release/promisify.js(43,20): error TS2339: Property 'getDataPropertyOrDefault' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(54,27): error TS2350: Only a void function can be called with the 'new' keyword. node_modules/bluebird/js/release/promisify.js(63,21): error TS2339: Property 'inheritedDataKeys' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promisify.js(69,22): error TS2554: Expected 0-1 arguments, but got 3. +node_modules/bluebird/js/release/promisify.js(69,41): error TS2554: Expected 0-1 arguments, but got 3. node_modules/bluebird/js/release/promisify.js(93,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'number', but here has type 'any'. node_modules/bluebird/js/release/promisify.js(100,17): error TS2339: Property 'filledRange' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promisify.js(104,17): error TS2339: Property 'filledRange' does not exist on type 'typeof ret'. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index d8ba01ed72f..3aa179962f9 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -47,7 +47,7 @@ node_modules/chrome-devtools-frontend/front_end/Tests.js(416,5): error TS2554: E node_modules/chrome-devtools-frontend/front_end/Tests.js(440,5): error TS2554: Expected 4 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/Tests.js(475,5): error TS2554: Expected 4 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/Tests.js(571,33): error TS2339: Property 'deprecatedRunAfterPendingDispatches' does not exist on type 'typeof InspectorBackend'. -node_modules/chrome-devtools-frontend/front_end/Tests.js(590,27): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/Tests.js(590,57): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/Tests.js(619,44): error TS2339: Property 'emulationAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/Tests.js(666,38): error TS2339: Property 'inputAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/Tests.js(668,38): error TS2339: Property 'inputAgent' does not exist on type 'Target'. @@ -452,7 +452,7 @@ node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheSto node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(135,10): error TS2554: Expected 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/application_test_runner/IndexedDBTestRunner.js(12,40): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/IndexedDBTestRunner.js(47,42): error TS2339: Property 'resources' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/application_test_runner/IndexedDBTestRunner.js(140,24): error TS2554: Expected 1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/application_test_runner/IndexedDBTestRunner.js(140,85): error TS2554: Expected 1 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/application_test_runner/ResourceTreeTestRunner.js(69,18): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/ResourcesTestRunner.js(76,15): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/ResourcesTestRunner.js(77,33): error TS2339: Property 'resources' does not exist on type 'any[]'. @@ -533,7 +533,7 @@ node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(944,23): node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(950,47): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(952,19): error TS2304: Cannot find name 'DOM'. node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(954,32): error TS2304: Cannot find name 'CategoryRenderer'. -node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(955,20): error TS2554: Expected 0 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(955,60): error TS2554: Expected 0 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(967,41): error TS2304: Cannot find name 'DetailsRenderer'. node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(969,15): error TS2304: Cannot find name 'DOM'. node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(978,15): error TS2503: Cannot find namespace 'DetailsRenderer'. @@ -682,22 +682,22 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/Audits2Service.js node_modules/chrome-devtools-frontend/front_end/audits2_worker/Audits2Service.js(131,8): error TS2339: Property 'document' does not exist on type 'Global'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/Audits2Service.js(132,8): error TS2339: Property 'document' does not exist on type 'Global'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,1): error TS2739: Type '(o: any, u: any) => any' is missing the following properties from type 'NodeRequire': resolve, cache, extensions, main -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,121): error TS2554: Expected 1 arguments, but got 2. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,141): error TS2554: Expected 1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,125): error TS2554: Expected 1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,145): error TS2554: Expected 1 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(2,203): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(5494,9): error TS2339: Property 'stableSort' does not exist on type '{ category: any; group: any; duration: any; }[]'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(5878,16): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(5879,17): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(5878,60): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(5879,62): error TS2554: Expected 0-1 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(6400,21): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(8112,74): error TS2339: Property 'name' does not exist on type 'ComputedArtifact'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9093,1): error TS2554: Expected 0-2 arguments, but got 3. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9117,1): error TS2554: Expected 0-2 arguments, but got 3. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9093,57): error TS2554: Expected 0-2 arguments, but got 3. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9117,73): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9467,15): error TS2339: Property 'axe' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10092,16): error TS2304: Cannot find name 'd41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10513,19): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10811,19): error TS2304: Cannot find name 'getElementsInDocument'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12197,22): error TS2554: Expected 0 arguments, but got 2. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12327,24): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12197,34): error TS2554: Expected 0 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12327,36): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(13607,7): error TS2339: Property 'protocolMethod' does not exist on type 'Error'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(13608,7): error TS2339: Property 'protocolError' does not exist on type 'Error'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(14352,1): error TS2722: Cannot invoke an object which is possibly 'undefined'. @@ -731,13 +731,13 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15882,16): error TS2339: Property '_logs' does not exist on type 'typeof ConsoleQuieter'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15891,16): error TS2339: Property '_logs' does not exist on type 'typeof ConsoleQuieter'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15894,16): error TS2339: Property '_logs' does not exist on type 'typeof ConsoleQuieter'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(16213,5): error TS2554: Expected 0 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(16219,5): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(16213,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(16219,23): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(16733,11): error TS2339: Property 'NodeTimingData' does not exist on type 'typeof Simulator'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(17089,26): error TS2339: Property '__proto__' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(17089,45): error TS2339: Property '__proto__' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(17501,1): error TS2322: Type 'any[]' is not assignable to type 'string'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(18010,1): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(18010,29): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19499,6): error TS2339: Property 'Util' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19585,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. Type 'void | { artifacts: any; auditResults: any[]; }' is not assignable to type 'void'. @@ -886,7 +886,7 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28589,5): error TS2339: Property 'removeListener' does not exist on type 'Readable'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28590,5): error TS2339: Property 'removeListener' does not exist on type 'Readable'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28591,5): error TS2339: Property 'removeListener' does not exist on type 'Readable'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28746,1): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28746,19): error TS2554: Expected 0-1 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28797,6): error TS2339: Property 'emit' does not exist on type 'Readable'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(28855,19): error TS2339: Property 'emit' does not exist on type 'Readable'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(29117,47): error TS2300: Duplicate identifier '_transform'. @@ -2823,7 +2823,7 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60141,1): error TS2304: Cannot find name 'WebInspector'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60144,1): error TS2304: Cannot find name 'WebInspector'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60162,11): error TS2304: Cannot find name 'WebInspector'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60222,1): error TS2554: Expected 0-2 arguments, but got 3. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60222,51): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60267,11): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60267,32): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(60268,1): error TS2304: Cannot find name 'define'. @@ -3517,8 +3517,8 @@ node_modules/chrome-devtools-frontend/front_end/cm_modes/coffeescript.js(11,43): node_modules/chrome-devtools-frontend/front_end/cm_modes/coffeescript.js(12,5): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_modes/coffeescript.js(41,3): error TS2740: Type 'RegExp' is missing the following properties from type 'string[]': length, pop, push, concat, and 28 more. node_modules/chrome-devtools-frontend/front_end/cm_modes/coffeescript.js(282,24): error TS2339: Property 'exec' does not exist on type 'string[]'. -node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(6,5): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(6,17): error TS2307: Cannot find module '../../lib/codemirror'. +node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(6,42): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(6,50): error TS2307: Cannot find module '../xml/xml'. node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(6,73): error TS2307: Cannot find module '../javascript/javascript'. node_modules/chrome-devtools-frontend/front_end/cm_modes/jsx.js(7,19): error TS2304: Cannot find name 'define'. @@ -3528,8 +3528,8 @@ node_modules/chrome-devtools-frontend/front_end/cm_modes/livescript.js(11,17): e node_modules/chrome-devtools-frontend/front_end/cm_modes/livescript.js(12,19): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_modes/livescript.js(12,43): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_modes/livescript.js(13,5): error TS2304: Cannot find name 'define'. -node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(6,5): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(6,17): error TS2307: Cannot find module '../../lib/codemirror'. +node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(6,42): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(6,50): error TS2307: Cannot find module '../htmlmixed/htmlmixed'. node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(6,85): error TS2307: Cannot find module '../clike/clike'. node_modules/chrome-devtools-frontend/front_end/cm_modes/php.js(7,19): error TS2304: Cannot find name 'define'. @@ -3553,15 +3553,15 @@ node_modules/chrome-devtools-frontend/front_end/cm_web_modes/css.js(6,17): error node_modules/chrome-devtools-frontend/front_end/cm_web_modes/css.js(7,19): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/css.js(7,43): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/css.js(8,5): error TS2304: Cannot find name 'define'. -node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(6,5): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(6,17): error TS2307: Cannot find module '../../lib/codemirror'. +node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(6,42): error TS2554: Expected 0-1 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(6,50): error TS2307: Cannot find module '../htmlmixed/htmlmixed'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(7,17): error TS2307: Cannot find module '../../addon/mode/multiplex'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(8,19): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(8,43): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlembedded.js(9,5): error TS2304: Cannot find name 'define'. -node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,5): error TS2554: Expected 0-1 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,17): error TS2307: Cannot find module '../../lib/codemirror'. +node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,42): error TS2554: Expected 0-1 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,50): error TS2307: Cannot find module '../xml/xml'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,73): error TS2307: Cannot find module '../javascript/javascript'. node_modules/chrome-devtools-frontend/front_end/cm_web_modes/htmlmixed.js(6,110): error TS2307: Cannot find module '../css/css'. @@ -3748,7 +3748,7 @@ node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(152,25): err node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(161,25): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(211,34): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(215,29): error TS2339: Property 'asParsedURL' does not exist on type 'string'. -node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(318,32): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(318,49): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(375,18): error TS2339: Property 'asParsedURL' does not exist on type 'String'. node_modules/chrome-devtools-frontend/front_end/common/SegmentedRange.js(48,37): error TS2339: Property 'lowerBound' does not exist on type 'Segment[]'. node_modules/chrome-devtools-frontend/front_end/common/Settings.js(49,10): error TS2339: Property 'runtime' does not exist on type 'Window'. @@ -3900,7 +3900,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.j node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(192,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(200,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(255,28): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. -node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(256,27): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(256,55): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(257,31): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(264,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(279,14): error TS2555: Expected at least 2 arguments, but got 1. @@ -4179,7 +4179,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(70 node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(733,19): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(735,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(736,31): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(750,27): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(750,54): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(803,34): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(804,31): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(806,43): error TS2339: Property 'style' does not exist on type 'Element'. @@ -4517,7 +4517,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(98,48): er node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(109,26): error TS2352: Conversion of type 'DataGridNode' to type 'NODE_TYPE' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(121,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(123,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(134,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(134,45): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(135,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(139,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(159,33): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. @@ -6341,11 +6341,11 @@ node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(274,3): error TS2554: Expected 2-3 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(287,26): error TS2339: Property 'computeLineEndings' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(295,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'formatter' must be of type 'HTMLFormatter', but here has type 'CSSFormatter'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(296,9): error TS2554: Expected 2 arguments, but got 4. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(296,45): error TS2554: Expected 2 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(299,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'formatter' must be of type 'HTMLFormatter', but here has type 'JavaScriptFormatter'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(300,9): error TS2554: Expected 2 arguments, but got 4. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(300,45): error TS2554: Expected 2 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(303,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'formatter' must be of type 'HTMLFormatter', but here has type 'IdentityFormatter'. -node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(304,9): error TS2554: Expected 2 arguments, but got 4. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(304,45): error TS2554: Expected 2 arguments, but got 4. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(313,3): error TS2554: Expected 2-3 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(334,24): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/HTMLFormatter.js(98,21): error TS2339: Property 'isWhitespace' does not exist on type 'string'. @@ -7755,7 +7755,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete.js(471,33): error TS2339: Property 'CompletionGroup' does not exist on type 'typeof JavaScriptAutocomplete'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(82,35): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(91,29): error TS2339: Property 'createChild' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(108,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(108,50): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(114,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(129,7): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(145,50): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -7768,7 +7768,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSectio node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(181,18): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(207,22): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,58): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(211,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(263,20): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(268,22): error TS2339: Property 'setTextContentTruncatedIfNeeded' does not exist on type 'Element'. @@ -8079,12 +8079,12 @@ node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineOverviewPane.js( node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineOverviewPane.js(490,39): error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'boolean'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineOverviewPane.js(495,14): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineOverviewPane.js(508,61): error TS2339: Property 'boxInWindow' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(74,36): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(74,72): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(81,20): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(91,33): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(98,5): error TS2554: Expected 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(108,20): error TS2339: Property 'timeline' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(120,43): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(120,79): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(130,13): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(131,97): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(135,35): error TS2339: Property 'timeline' does not exist on type 'any[]'. @@ -8093,7 +8093,7 @@ node_modules/chrome-devtools-frontend/front_end/performance_test_runner/Timeline node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(159,9): error TS2554: Expected 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(189,60): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(220,44): error TS2339: Property 'peekLast' does not exist on type 'any[]'. -node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(254,19): error TS2554: Expected 2 arguments, but got 3. +node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(255,46): error TS2554: Expected 2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(321,53): error TS2345: Argument of type 'number' is not assignable to parameter of type 'V'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(347,30): error TS2339: Property 'timeline' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/performance_test_runner/TimelineTestRunner.js(355,13): error TS2339: Property 'timeline' does not exist on type 'any[]'. @@ -8309,7 +8309,7 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1277,40): node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1299,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1321,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1324,6): error TS2339: Property 'setImmediate' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1326,32): error TS2556: Expected 0 arguments, but got 1 or more. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1326,41): error TS2556: Expected 0 arguments, but got 1 or more. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1331,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1335,19): error TS2339: Property 'spread' does not exist on type 'Promise'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1348,19): error TS2339: Property 'catchException' does not exist on type 'Promise'. @@ -10421,7 +10421,7 @@ node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(134,32): err node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(139,30): error TS2345: Argument of type 'TemplateStringsArray' is not assignable to parameter of type 'string | string[]'. Type 'TemplateStringsArray' is not assignable to type 'string[]'. node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(149,24): error TS2554: Expected 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(165,32): error TS2554: Expected 2 arguments, but got 3. +node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(165,78): error TS2554: Expected 2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/sdk/ServerTiming.js(186,25): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sdk/ServiceWorkerCacheModel.js(15,12): error TS2339: Property 'registerStorageDispatcher' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/ServiceWorkerCacheModel.js(20,31): error TS2339: Property 'cacheStorageAgent' does not exist on type 'Target'. @@ -11055,7 +11055,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(80,71): error TS2339: Property 'uiLocation' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(131,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(131,55): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(159,11): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -11544,8 +11544,8 @@ node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,107): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,128): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,140): error TS2304: Cannot find name 'define'. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,482): error TS2554: Expected 1 arguments, but got 2. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,502): error TS2554: Expected 1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,486): error TS2554: Expected 1 arguments, but got 2. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,506): error TS2554: Expected 1 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(1,564): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3,1): error TS2323: Cannot redeclare exported variable '__esModule'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(166,1): error TS2323: Cannot redeclare exported variable '__esModule'. @@ -11617,12 +11617,12 @@ node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3498,10): error TS2339: Property 'emit' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3515,14): error TS2339: Property 'emit' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3528,20): error TS2300: Duplicate identifier 'write'. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3569,5): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3569,16): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3623,21): error TS2339: Property 'cancel' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3629,14): error TS2339: Property 'cancel' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3634,10): error TS2339: Property 'emit' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3635,10): error TS2339: Property 'emit' does not exist on type 'Terminal'. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3637,5): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3637,18): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3638,17): error TS2339: Property 'cancel' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3675,40): error TS2339: Property 'browser' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3689,40): error TS2339: Property 'browser' does not exist on type 'Terminal'. @@ -11630,8 +11630,8 @@ node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3919,10): error TS2339: Property 'cancel' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3936,10): error TS2339: Property 'emit' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3937,10): error TS2339: Property 'emit' does not exist on type 'Terminal'. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3939,5): error TS2554: Expected 0 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3946,13): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3939,18): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3946,26): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3953,15): error TS2339: Property 'visualBell' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3960,14): error TS2339: Property 'popOnBell' does not exist on type 'Terminal'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/build/xterm.js(3964,15): error TS2339: Property 'debug' does not exist on type 'Terminal'. @@ -13401,7 +13401,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1561,11): error TS node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1562,17): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1570,25): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1574,11): error TS2339: Property 'value' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1633,64): error TS2554: Expected 0 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1633,77): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1646,40): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1649,25): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1715,20): error TS2339: Property 'type' does not exist on type 'Element'. diff --git a/tests/baselines/reference/user/debug.log b/tests/baselines/reference/user/debug.log index 4879bb3f8b3..6047cfab7a9 100644 --- a/tests/baselines/reference/user/debug.log +++ b/tests/baselines/reference/user/debug.log @@ -5,8 +5,8 @@ node_modules/debug/dist/debug.js(3,165): error TS2539: Cannot assign to '_typeof node_modules/debug/dist/debug.js(8,21): error TS2304: Cannot find name 'define'. node_modules/debug/dist/debug.js(8,46): error TS2304: Cannot find name 'define'. node_modules/debug/dist/debug.js(9,5): error TS2304: Cannot find name 'define'. -node_modules/debug/dist/debug.js(33,33): error TS2554: Expected 1 arguments, but got 2. -node_modules/debug/dist/debug.js(34,27): error TS2554: Expected 1 arguments, but got 2. +node_modules/debug/dist/debug.js(33,38): error TS2554: Expected 1 arguments, but got 2. +node_modules/debug/dist/debug.js(34,32): error TS2554: Expected 1 arguments, but got 2. node_modules/debug/dist/debug.js(36,21): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/debug/dist/debug.js(89,38): error TS2339: Property 'length' does not exist on type 'string | number'. Property 'length' does not exist on type 'number'. diff --git a/tests/baselines/reference/user/graceful-fs.log b/tests/baselines/reference/user/graceful-fs.log index b11ec8af215..826f2e5f5bc 100644 --- a/tests/baselines/reference/user/graceful-fs.log +++ b/tests/baselines/reference/user/graceful-fs.log @@ -7,7 +7,7 @@ node_modules/graceful-fs/clone.js(15,38): error TS2345: Argument of type 'Proper node_modules/graceful-fs/graceful-fs.js(14,3): error TS2322: Type '(msg: string, ...param: any[]) => void' is not assignable to type '() => void'. node_modules/graceful-fs/graceful-fs.js(17,37): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any, ...any[]]'. Type 'IArguments' is missing the following properties from type '[any, ...any[]]': 0, pop, push, concat, and 27 more. -node_modules/graceful-fs/graceful-fs.js(24,5): error TS2554: Expected 0 arguments, but got 1. +node_modules/graceful-fs/graceful-fs.js(24,11): error TS2554: Expected 0 arguments, but got 1. node_modules/graceful-fs/graceful-fs.js(30,54): error TS2339: Property '__patched' does not exist on type 'typeof import("fs")'. node_modules/graceful-fs/graceful-fs.js(32,8): error TS2339: Property '__patched' does not exist on type 'typeof import("fs")'. node_modules/graceful-fs/graceful-fs.js(52,37): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[number]'. @@ -17,8 +17,8 @@ node_modules/graceful-fs/graceful-fs.js(175,5): error TS2539: Cannot assign to ' node_modules/graceful-fs/graceful-fs.js(197,68): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. Type 'IArguments' is missing the following properties from type '[any?, any?, ...any[]]': pop, push, concat, join, and 26 more. node_modules/graceful-fs/graceful-fs.js(220,70): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, any?, ...any[]]'. -node_modules/graceful-fs/graceful-fs.js(269,3): error TS2554: Expected 0 arguments, but got 3. -node_modules/graceful-fs/graceful-fs.js(276,5): error TS2554: Expected 0 arguments, but got 3. +node_modules/graceful-fs/graceful-fs.js(269,9): error TS2554: Expected 0 arguments, but got 3. +node_modules/graceful-fs/graceful-fs.js(276,11): error TS2554: Expected 0 arguments, but got 3. diff --git a/tests/baselines/reference/user/lodash.log b/tests/baselines/reference/user/lodash.log index 79200e0d87b..18428758c6f 100644 --- a/tests/baselines/reference/user/lodash.log +++ b/tests/baselines/reference/user/lodash.log @@ -34,7 +34,7 @@ node_modules/lodash/_baseClone.js(128,43): error TS2345: Argument of type 'numbe node_modules/lodash/_baseClone.js(157,17): error TS2552: Cannot find name 'keysIn'. Did you mean 'keys'? node_modules/lodash/_baseDifference.js(37,5): error TS2322: Type '(array?: any[] | undefined, value: any, comparator: Function) => boolean' is not assignable to type '(array?: any[] | undefined, value: any) => boolean'. node_modules/lodash/_baseDifference.js(43,5): error TS2740: Type 'SetCache' is missing the following properties from type 'any[]': length, pop, concat, join, and 27 more. -node_modules/lodash/_baseDifference.js(60,15): error TS2554: Expected 2 arguments, but got 3. +node_modules/lodash/_baseDifference.js(60,42): error TS2554: Expected 2 arguments, but got 3. node_modules/lodash/_baseFlatten.js(19,29): error TS2322: Type '(value: any) => boolean' is not assignable to type 'boolean | undefined'. Type '(value: any) => boolean' is not assignable to type 'true'. node_modules/lodash/_baseFlatten.js(24,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Boolean' has no compatible call signatures. @@ -72,18 +72,18 @@ node_modules/lodash/_baseSlice.js(26,35): error TS2532: Object is possibly 'unde node_modules/lodash/_baseSortBy.js(14,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(a: any, b: any) => number'. Type 'Function' provides no match for the signature '(a: any, b: any): number'. node_modules/lodash/_baseUniq.js(30,5): error TS2322: Type '(array?: any[] | undefined, value: any, comparator: Function) => boolean' is not assignable to type '(array?: any[] | undefined, value: any) => boolean'. -node_modules/lodash/_baseUniq.js(33,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_baseUniq.js(33,43): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/_baseUniq.js(39,5): error TS2322: Type 'SetCache' is not assignable to type 'any[]'. -node_modules/lodash/_baseUniq.js(62,15): error TS2554: Expected 2 arguments, but got 3. +node_modules/lodash/_baseUniq.js(62,40): error TS2554: Expected 2 arguments, but got 3. node_modules/lodash/_baseWrapperValue.js(18,21): error TS2339: Property 'value' does not exist on type 'LazyWrapper'. node_modules/lodash/_cloneArrayBuffer.js(11,16): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/lodash/_cloneBuffer.js(4,69): error TS2339: Property 'nodeType' does not exist on type '(buffer: any, isDeep?: boolean | undefined) => any'. node_modules/lodash/_cloneBuffer.js(7,80): error TS2339: Property 'nodeType' does not exist on type '{ "../../../tests/cases/user/lodash/node_modules/lodash/_cloneBuffer": (buffer: any, isDeep?: boolean | undefined) => any; }'. node_modules/lodash/_cloneBuffer.js(22,14): error TS2577: Return type annotation circularly references itself. node_modules/lodash/_cloneBuffer.js(24,22): error TS2502: 'buffer' is referenced directly or indirectly in its own type annotation. -node_modules/lodash/_copySymbols.js(13,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/lodash/_copySymbolsIn.js(13,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/lodash/_createAggregator.js(19,37): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/_copySymbols.js(13,40): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_copySymbolsIn.js(13,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_createAggregator.js(19,60): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/_createCompounder.js(20,24): error TS2554: Expected 3 arguments, but got 1. node_modules/lodash/_createCtor.js(19,22): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/lodash/_createCtor.js(20,22): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -94,11 +94,11 @@ node_modules/lodash/_createCtor.js(24,22): error TS2351: Cannot use 'new' with a node_modules/lodash/_createCtor.js(25,22): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/lodash/_createCtor.js(26,22): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/lodash/_createCurry.js(37,46): error TS2339: Property 'placeholder' does not exist on type '(...args: any[]) => any'. -node_modules/lodash/_createFind.js(16,22): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/_createFind.js(16,46): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/_createFind.js(21,34): error TS2454: Variable 'iteratee' is used before being assigned. node_modules/lodash/_createFlow.js(38,22): error TS2454: Variable 'wrapper' is used before being assigned. node_modules/lodash/_createFlow.js(42,13): error TS2454: Variable 'wrapper' is used before being assigned. -node_modules/lodash/_createFlow.js(47,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_createFlow.js(47,50): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/_createFlow.js(53,19): error TS2454: Variable 'wrapper' is used before being assigned. node_modules/lodash/_createFlow.js(53,55): error TS2454: Variable 'wrapper' is used before being assigned. node_modules/lodash/_createFlow.js(56,13): error TS2454: Variable 'wrapper' is used before being assigned. @@ -121,7 +121,7 @@ node_modules/lodash/_createHybrid.js(73,38): error TS2538: Type 'Function' canno node_modules/lodash/_createHybrid.js(81,18): error TS2532: Object is possibly 'undefined'. node_modules/lodash/_createHybrid.js(82,7): error TS2322: Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -node_modules/lodash/_createWrap.js(71,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_createWrap.js(71,46): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/_createWrap.js(94,29): error TS2345: Argument of type 'TimerHandler' is not assignable to parameter of type 'Function'. Type 'string' is not assignable to type 'Function'. node_modules/lodash/_createWrap.js(96,26): error TS2345: Argument of type 'TimerHandler' is not assignable to parameter of type 'Function'. @@ -140,7 +140,7 @@ node_modules/lodash/_equalByTag.js(86,7): error TS2454: Variable 'convert' is us node_modules/lodash/_equalObjects.js(70,18): error TS2322: Type 'boolean' is not assignable to type 'number'. node_modules/lodash/_getHolder.js(10,17): error TS2339: Property 'placeholder' does not exist on type 'Function'. node_modules/lodash/_getRawTag.js(36,7): error TS2454: Variable 'unmasked' is used before being assigned. -node_modules/lodash/_getSymbolsIn.js(19,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_getSymbolsIn.js(19,34): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/_hasPath.js(35,50): error TS2454: Variable 'key' is used before being assigned. node_modules/lodash/_hashDelete.js(7,20): error TS8024: JSDoc '@param' tag has name 'hash', but there is no parameter with that name. node_modules/lodash/_initCloneArray.js(16,16): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -149,7 +149,7 @@ node_modules/lodash/_initCloneArray.js(21,26): error TS2339: Property 'input' do node_modules/lodash/_insertWrapDetails.js(10,5): error TS1223: 'returns' tag already specified. node_modules/lodash/_insertWrapDetails.js(15,5): error TS2322: Type 'string' is not assignable to type 'any[]'. node_modules/lodash/_insertWrapDetails.js(20,3): error TS2322: Type 'string' is not assignable to type 'any[]'. -node_modules/lodash/_isLaziable.js(24,14): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/_isLaziable.js(24,22): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/_isLaziable.js(25,12): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/lodash/_memoizeCapped.js(22,22): error TS2339: Property 'cache' does not exist on type 'Function'. node_modules/lodash/_mergeData.js(60,26): error TS2554: Expected 4 arguments, but got 3. @@ -198,7 +198,7 @@ node_modules/lodash/core.js(721,13): error TS2403: Subsequent variable declarati node_modules/lodash/core.js(749,18): error TS8024: JSDoc '@param' tag has name 'value', but there is no parameter with that name. node_modules/lodash/core.js(811,53): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. node_modules/lodash/core.js(826,24): error TS8024: JSDoc '@param' tag has name 'paths', but there is no parameter with that name. -node_modules/lodash/core.js(848,12): error TS2554: Expected 1 arguments, but got 2. +node_modules/lodash/core.js(848,57): error TS2554: Expected 1 arguments, but got 2. node_modules/lodash/core.js(864,9): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(865,16): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(865,47): error TS2532: Object is possibly 'undefined'. @@ -212,11 +212,11 @@ node_modules/lodash/core.js(871,40): error TS2532: Object is possibly 'undefined node_modules/lodash/core.js(872,5): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(876,37): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(886,22): error TS8024: JSDoc '@param' tag has name 'array', but there is no parameter with that name. -node_modules/lodash/core.js(1118,24): error TS2554: Expected 1 arguments, but got 2. +node_modules/lodash/core.js(1118,48): error TS2554: Expected 1 arguments, but got 2. node_modules/lodash/core.js(1123,36): error TS2454: Variable 'iteratee' is used before being assigned. node_modules/lodash/core.js(1313,20): error TS2322: Type 'boolean' is not assignable to type 'number'. -node_modules/lodash/core.js(1338,12): error TS2554: Expected 1 arguments, but got 2. -node_modules/lodash/core.js(1349,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/core.js(1338,60): error TS2554: Expected 1 arguments, but got 2. +node_modules/lodash/core.js(1349,42): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/core.js(1434,23): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. node_modules/lodash/core.js(1438,44): error TS2532: Object is possibly 'undefined'. @@ -224,7 +224,7 @@ node_modules/lodash/core.js(1442,29): error TS2532: Object is possibly 'undefine node_modules/lodash/core.js(1445,29): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(1446,24): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(1449,17): error TS2538: Type 'undefined' cannot be used as an index type. -node_modules/lodash/core.js(1566,33): error TS2554: Expected 1 arguments, but got 2. +node_modules/lodash/core.js(1566,57): error TS2554: Expected 1 arguments, but got 2. node_modules/lodash/core.js(1709,41): error TS2532: Object is possibly 'undefined'. node_modules/lodash/core.js(1745,18): error TS2348: Value of type 'typeof lodash' is not callable. Did you mean to include 'new'? node_modules/lodash/core.js(1872,12): error TS1003: Identifier expected. @@ -232,8 +232,8 @@ node_modules/lodash/core.js(1872,12): error TS8024: JSDoc '@param' tag has name node_modules/lodash/core.js(2142,12): error TS1003: Identifier expected. node_modules/lodash/core.js(2142,12): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/core.js(2183,41): error TS8024: JSDoc '@param' tag has name 'iteratees', but there is no parameter with that name. -node_modules/lodash/core.js(2473,21): error TS2554: Expected 0 arguments, but got 1. -node_modules/lodash/core.js(2609,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/core.js(2473,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/lodash/core.js(2609,51): error TS2554: Expected 0 arguments, but got 1. node_modules/lodash/core.js(2644,12): error TS2554: Expected 3-5 arguments, but got 2. node_modules/lodash/core.js(3245,58): error TS2345: Argument of type 'string | any[]' is not assignable to parameter of type 'string | number | symbol'. Type 'any[]' is not assignable to type 'string | number | symbol'. @@ -266,24 +266,24 @@ node_modules/lodash/difference.js(29,52): error TS2345: Argument of type '(value Type '(value: any) => boolean' is not assignable to type 'true'. node_modules/lodash/differenceBy.js(40,52): error TS2345: Argument of type '(value: any) => boolean' is not assignable to parameter of type 'boolean | undefined'. Type '(value: any) => boolean' is not assignable to type 'true'. -node_modules/lodash/differenceBy.js(40,78): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/differenceBy.js(40,101): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/differenceWith.js(36,52): error TS2345: Argument of type '(value: any) => boolean' is not assignable to parameter of type 'boolean | undefined'. Type '(value: any) => boolean' is not assignable to type 'true'. node_modules/lodash/drop.js(13,10): error TS1003: Identifier expected. node_modules/lodash/drop.js(13,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/dropRight.js(13,10): error TS1003: Identifier expected. node_modules/lodash/dropRight.js(13,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/dropRightWhile.js(41,24): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/dropWhile.js(41,24): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/dropRightWhile.js(41,48): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/dropWhile.js(41,48): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/escape.js(39,39): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(substring: string, ...args: any[]) => string'. node_modules/lodash/every.js(23,10): error TS1003: Identifier expected. node_modules/lodash/every.js(23,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/every.js(53,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/filter.js(45,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/findIndex.js(52,31): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/findKey.js(41,30): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/findLastIndex.js(56,31): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/findLastKey.js(41,30): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/every.js(53,51): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/filter.js(45,51): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/findIndex.js(52,55): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/findKey.js(41,54): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/findLastIndex.js(56,55): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/findLastKey.js(41,54): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/fp.js(2,18): error TS2554: Expected 3-4 arguments, but got 2. node_modules/lodash/fp/_baseConvert.js(143,5): error TS2559: Type 'Function' has no properties in common with type '{ cap?: boolean; curry?: boolean; fixed?: boolean; immutable?: boolean; rearg?: boolean; }'. node_modules/lodash/fp/_baseConvert.js(144,5): error TS2322: Type 'string' is not assignable to type 'Function'. @@ -341,24 +341,24 @@ node_modules/lodash/fp/string.js(2,26): error TS2345: Argument of type '{ 'camel node_modules/lodash/fp/util.js(2,26): error TS2345: Argument of type '{ 'attempt': Function; 'bindAll': Function; 'cond': (pairs: any[]) => Function; 'conforms': (source: any) => Function; 'constant': (value: any) => Function; 'defaultTo': (value: any, defaultValue: any) => any; ... 25 more ...; 'uniqueId': (prefix?: string | undefined) => string; }' is not assignable to parameter of type 'string'. node_modules/lodash/includes.js(24,10): error TS1003: Identifier expected. node_modules/lodash/includes.js(24,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/intersectionBy.js(41,32): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/intersectionBy.js(41,55): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/isBuffer.js(8,80): error TS2339: Property 'nodeType' does not exist on type '{ "../../../tests/cases/user/lodash/node_modules/lodash/isBuffer": any; }'. node_modules/lodash/isEqual.js(32,10): error TS2554: Expected 3-5 arguments, but got 2. node_modules/lodash/isEqualWith.js(38,59): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'boolean'. node_modules/lodash/iteratee.js(50,74): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. node_modules/lodash/keys.js(34,32): error TS2554: Expected 2 arguments, but got 1. -node_modules/lodash/map.js(50,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/mapKeys.js(28,14): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/map.js(50,50): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/mapKeys.js(28,37): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/mapKeys.js(31,29): error TS2722: Cannot invoke an object which is possibly 'undefined'. -node_modules/lodash/mapValues.js(35,14): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/mapValues.js(35,37): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/mapValues.js(38,34): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/lodash/matches.js(36,40): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. node_modules/lodash/matchesProperty.js(34,30): error TS2345: Argument of type 'string | any[]' is not assignable to parameter of type 'string'. Type 'any[]' is not assignable to type 'string'. node_modules/lodash/matchesProperty.js(34,56): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -node_modules/lodash/maxBy.js(30,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/meanBy.js(28,26): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/minBy.js(30,27): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/maxBy.js(30,50): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/meanBy.js(28,49): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/minBy.js(30,50): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/mixin.js(49,49): error TS2532: Object is possibly 'undefined'. node_modules/lodash/mixin.js(66,61): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'any[]'. node_modules/lodash/nthArg.js(28,26): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. @@ -374,11 +374,11 @@ node_modules/lodash/pickBy.js(33,12): error TS2722: Cannot invoke an object whic node_modules/lodash/plant.js(42,21): error TS2339: Property '__wrapped__' does not exist on type '{}'. node_modules/lodash/property.js(29,37): error TS2345: Argument of type 'string | symbol' is not assignable to parameter of type 'string'. Type 'symbol' is not assignable to type 'string'. -node_modules/lodash/pullAllBy.js(29,34): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/reduce.js(48,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/reduceRight.js(33,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/reject.js(43,34): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/remove.js(41,15): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/pullAllBy.js(29,57): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/reduce.js(48,50): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/reduceRight.js(33,50): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/reject.js(43,58): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/remove.js(41,39): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/repeat.js(15,10): error TS1003: Identifier expected. node_modules/lodash/repeat.js(15,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/replace.js(15,29): error TS8029: JSDoc '@param' tag has name 'replacement', but there is no parameter with that name. It would match 'arguments' if it had an array type. @@ -386,19 +386,19 @@ node_modules/lodash/sampleSize.js(17,10): error TS1003: Identifier expected. node_modules/lodash/sampleSize.js(17,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/some.js(18,10): error TS1003: Identifier expected. node_modules/lodash/some.js(18,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/some.js(48,27): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/sortedIndexBy.js(30,42): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/sortedLastIndexBy.js(30,42): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/sortedUniqBy.js(22,29): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/some.js(48,51): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/sortedIndexBy.js(30,65): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/sortedLastIndexBy.js(30,65): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/sortedUniqBy.js(22,52): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/split.js(33,5): error TS2322: Type 'undefined' is not assignable to type 'string | RegExp'. node_modules/lodash/spread.js(53,22): error TS2538: Type 'undefined' cannot be used as an index type. -node_modules/lodash/sumBy.js(29,22): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/sumBy.js(29,45): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/take.js(13,10): error TS1003: Identifier expected. node_modules/lodash/take.js(13,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/takeRight.js(13,10): error TS1003: Identifier expected. node_modules/lodash/takeRight.js(13,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/takeRightWhile.js(41,24): error TS2554: Expected 0-1 arguments, but got 2. -node_modules/lodash/takeWhile.js(41,24): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/takeRightWhile.js(41,48): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/takeWhile.js(41,48): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/template.js(65,10): error TS1003: Identifier expected. node_modules/lodash/template.js(65,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/template.js(146,34): error TS2532: Object is possibly 'undefined'. @@ -419,7 +419,7 @@ node_modules/lodash/throttle.js(62,31): error TS2345: Argument of type '{ 'leadi Type 'undefined' is not assignable to type 'number'. node_modules/lodash/toLower.js(11,21): error TS8024: JSDoc '@param' tag has name 'string', but there is no parameter with that name. node_modules/lodash/toUpper.js(11,21): error TS8024: JSDoc '@param' tag has name 'string', but there is no parameter with that name. -node_modules/lodash/transform.js(46,14): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/transform.js(46,37): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/transform.js(60,12): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/lodash/trim.js(20,10): error TS1003: Identifier expected. node_modules/lodash/trim.js(20,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. @@ -438,16 +438,16 @@ node_modules/lodash/union.js(23,42): error TS2345: Argument of type '(value: any Type '(value: any) => boolean' is not assignable to type 'true'. node_modules/lodash/unionBy.js(36,42): error TS2345: Argument of type '(value: any) => boolean' is not assignable to parameter of type 'boolean | undefined'. Type '(value: any) => boolean' is not assignable to type 'true'. -node_modules/lodash/unionBy.js(36,68): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/unionBy.js(36,91): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/unionWith.js(31,42): error TS2345: Argument of type '(value: any) => boolean' is not assignable to parameter of type 'boolean | undefined'. Type '(value: any) => boolean' is not assignable to type 'true'. -node_modules/lodash/uniqBy.js(28,52): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/uniqBy.js(28,75): error TS2554: Expected 0-1 arguments, but got 2. node_modules/lodash/words.js(15,10): error TS1003: Identifier expected. node_modules/lodash/words.js(15,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/wrapperAt.js(34,17): error TS2339: Property 'slice' does not exist on type 'LazyWrapper'. node_modules/lodash/wrapperAt.js(40,51): error TS2339: Property 'thru' does not exist on type 'LodashWrapper'. node_modules/lodash/wrapperReverse.js(33,23): error TS2339: Property 'reverse' does not exist on type 'LazyWrapper'. -node_modules/lodash/xorBy.js(36,58): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/lodash/xorBy.js(36,81): error TS2554: Expected 0-1 arguments, but got 2. diff --git a/tests/baselines/reference/user/minimatch.log b/tests/baselines/reference/user/minimatch.log index 46070e413e3..fcddf77d650 100644 --- a/tests/baselines/reference/user/minimatch.log +++ b/tests/baselines/reference/user/minimatch.log @@ -17,19 +17,19 @@ node_modules/minimatch/minimatch.js(575,28): error TS2532: Object is possibly 'u node_modules/minimatch/minimatch.js(575,31): error TS2339: Property 'reEnd' does not exist on type '{ type: any; start: number; reStart: number; open: any; close: any; }'. node_modules/minimatch/minimatch.js(631,10): error TS2339: Property '_glob' does not exist on type 'RegExp'. node_modules/minimatch/minimatch.js(632,10): error TS2339: Property '_src' does not exist on type 'RegExp'. -node_modules/minimatch/minimatch.js(763,3): error TS2554: Expected 0 arguments, but got 2. -node_modules/minimatch/minimatch.js(766,3): error TS2554: Expected 0 arguments, but got 3. -node_modules/minimatch/minimatch.js(774,5): error TS2554: Expected 0 arguments, but got 1. -node_modules/minimatch/minimatch.js(778,5): error TS2554: Expected 0 arguments, but got 3. -node_modules/minimatch/minimatch.js(785,7): error TS2554: Expected 0 arguments, but got 2. -node_modules/minimatch/minimatch.js(812,9): error TS2554: Expected 0 arguments, but got 1. -node_modules/minimatch/minimatch.js(830,9): error TS2554: Expected 0 arguments, but got 6. -node_modules/minimatch/minimatch.js(834,11): error TS2554: Expected 0 arguments, but got 4. -node_modules/minimatch/minimatch.js(842,13): error TS2554: Expected 0 arguments, but got 5. -node_modules/minimatch/minimatch.js(847,11): error TS2554: Expected 0 arguments, but got 1. -node_modules/minimatch/minimatch.js(857,9): error TS2554: Expected 0 arguments, but got 5. -node_modules/minimatch/minimatch.js(873,7): error TS2554: Expected 0 arguments, but got 4. -node_modules/minimatch/minimatch.js(876,7): error TS2554: Expected 0 arguments, but got 4. +node_modules/minimatch/minimatch.js(763,14): error TS2554: Expected 0 arguments, but got 2. +node_modules/minimatch/minimatch.js(766,14): error TS2554: Expected 0 arguments, but got 3. +node_modules/minimatch/minimatch.js(774,16): error TS2554: Expected 0 arguments, but got 1. +node_modules/minimatch/minimatch.js(778,16): error TS2554: Expected 0 arguments, but got 3. +node_modules/minimatch/minimatch.js(785,18): error TS2554: Expected 0 arguments, but got 2. +node_modules/minimatch/minimatch.js(812,20): error TS2554: Expected 0 arguments, but got 1. +node_modules/minimatch/minimatch.js(830,20): error TS2554: Expected 0 arguments, but got 6. +node_modules/minimatch/minimatch.js(834,22): error TS2554: Expected 0 arguments, but got 4. +node_modules/minimatch/minimatch.js(842,24): error TS2554: Expected 0 arguments, but got 5. +node_modules/minimatch/minimatch.js(847,22): error TS2554: Expected 0 arguments, but got 1. +node_modules/minimatch/minimatch.js(857,20): error TS2554: Expected 0 arguments, but got 5. +node_modules/minimatch/minimatch.js(873,18): error TS2554: Expected 0 arguments, but got 4. +node_modules/minimatch/minimatch.js(876,18): error TS2554: Expected 0 arguments, but got 4. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 5bd9229417c..d8b2b47141a 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -368,7 +368,7 @@ node_modules/npm/lib/install.js(745,32): error TS2339: Property 'config' does no node_modules/npm/lib/install.js(751,12): error TS2339: Property 'failing' does not exist on type 'Installer'. node_modules/npm/lib/install.js(768,13): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install.js(770,20): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. -node_modules/npm/lib/install.js(771,14): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/npm/lib/install.js(771,53): error TS2554: Expected 0-1 arguments, but got 2. node_modules/npm/lib/install.js(890,26): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. node_modules/npm/lib/install.js(897,26): error TS2345: Argument of type '{ action: any; name: any; version: any; path: any; }' is not assignable to parameter of type 'never'. node_modules/npm/lib/install.js(899,25): error TS2345: Argument of type '{ action: any; name: any; version: any; path: any; }' is not assignable to parameter of type 'never'. @@ -378,7 +378,7 @@ node_modules/npm/lib/install.js(905,27): error TS2345: Argument of type '{ actio node_modules/npm/lib/install.js(948,8): error TS2454: Variable 'previousPath' is used before being assigned. node_modules/npm/lib/install.js(985,53): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install.js(1007,53): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. -node_modules/npm/lib/install/access-error.js(4,18): error TS2554: Expected 0-1 arguments, but got 2. +node_modules/npm/lib/install/access-error.js(4,60): error TS2554: Expected 0-1 arguments, but got 2. node_modules/npm/lib/install/action/build.js(10,50): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install/action/extract.js(39,40): error TS2339: Property 'limit' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/install/action/extract.js(81,9): error TS2322: Type 'string' is not assignable to type 'any[]'. @@ -483,7 +483,7 @@ node_modules/npm/lib/logout.js(16,7): error TS2339: Property 'config' does not e node_modules/npm/lib/logout.js(17,7): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/logout.js(23,26): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/logout.js(28,11): error TS2339: Property 'registry' does not exist on type 'typeof EventEmitter'. -node_modules/npm/lib/logout.js(38,10): error TS2554: Expected 0-1 arguments, but got 3. +node_modules/npm/lib/logout.js(39,29): error TS2554: Expected 0-1 arguments, but got 3. node_modules/npm/lib/ls.js(37,30): error TS2339: Property 'dir' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/ls.js(88,18): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/ls.js(89,18): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. @@ -1490,7 +1490,7 @@ node_modules/npm/test/tap/prepublish-only.js(5,20): error TS2307: Cannot find mo node_modules/npm/test/tap/prepublish-only.js(6,21): error TS2307: Cannot find module 'tacks'. node_modules/npm/test/tap/prepublish.js(3,20): error TS2307: Cannot find module 'tap'. node_modules/npm/test/tap/process-logger.js(2,22): error TS2307: Cannot find module 'tap'. -node_modules/npm/test/tap/process-logger.js(7,24): error TS2554: Expected 1-3 arguments, but got 4. +node_modules/npm/test/tap/process-logger.js(7,61): error TS2554: Expected 1-3 arguments, but got 4. node_modules/npm/test/tap/process-logger.js(8,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. node_modules/npm/test/tap/process-logger.js(9,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. node_modules/npm/test/tap/process-logger.js(10,37): error TS2345: Argument of type '"log"' is not assignable to parameter of type 'Signals'. diff --git a/tests/baselines/reference/user/prettier.log b/tests/baselines/reference/user/prettier.log index f852b651ced..45989ee91da 100644 --- a/tests/baselines/reference/user/prettier.log +++ b/tests/baselines/reference/user/prettier.log @@ -10,6 +10,12 @@ src/cli/util.js(454,16): error TS2339: Property 'type' does not exist on type 'n src/cli/util.js(455,16): error TS2339: Property 'oppositeDescription' does not exist on type 'never'. src/cli/util.js(456,17): error TS2339: Property 'name' does not exist on type 'never'. src/common/parser-create-error.js(8,9): error TS2339: Property 'loc' does not exist on type 'SyntaxError'. +src/config/resolve-config-editorconfig.js(20,36): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("../../../node_modules/mem/index")' has no compatible call signatures. +src/config/resolve-config-editorconfig.js(27,35): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("../../../node_modules/mem/index")' has no compatible call signatures. +src/config/resolve-config-editorconfig.js(42,7): error TS2339: Property 'clear' does not exist on type 'typeof import("../../../node_modules/mem/index")'. +src/config/resolve-config-editorconfig.js(43,7): error TS2339: Property 'clear' does not exist on type 'typeof import("../../../node_modules/mem/index")'. +src/config/resolve-config.js(10,29): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("../../../node_modules/mem/index")' has no compatible call signatures. +src/config/resolve-config.js(70,7): error TS2339: Property 'clear' does not exist on type 'typeof import("../../../node_modules/mem/index")'. src/config/resolve-config.js(75,32): error TS2345: Argument of type '{ sync: false; }' is not assignable to parameter of type '{ cache: boolean; sync: boolean; }'. Property 'cache' is missing in type '{ sync: false; }' but required in type '{ cache: boolean; sync: boolean; }'. src/config/resolve-config.js(82,32): error TS2345: Argument of type '{ sync: true; }' is not assignable to parameter of type '{ cache: boolean; sync: boolean; }'. @@ -34,7 +40,7 @@ src/language-handlebars/parser-glimmer.js(27,26): error TS2345: Argument of type Type '(() => { visitor: { Program(node: any): void; ElementNode(node: any): void; }; })[]' is not assignable to type 'ASTPluginBuilder[]'. Type '() => { visitor: { Program(node: any): void; ElementNode(node: any): void; }; }' is not assignable to type 'ASTPluginBuilder'. Property 'name' is missing in type '{ visitor: { Program(node: any): void; ElementNode(node: any): void; }; }' but required in type 'ASTPlugin'. -src/language-handlebars/printer-glimmer.js(270,7): error TS2554: Expected 0-1 arguments, but got 2. +src/language-handlebars/printer-glimmer.js(270,30): error TS2554: Expected 0-1 arguments, but got 2. src/language-js/printer-estree.js(99,9): error TS2741: Property 'parts' is missing in type '{ type: string; }' but required in type '{ type: string; parts: any; }'. src/language-js/printer-estree.js(302,9): error TS2345: Argument of type '{ type: string; parts: any; } | { type: string; contents: any; }' is not assignable to parameter of type 'ConcatArray'. Type '{ type: string; parts: any; }' is missing the following properties from type 'ConcatArray': length, join, slice @@ -51,8 +57,8 @@ src/language-js/printer-estree.js(3647,5): error TS2345: Argument of type '"" | Type '{ type: string; parts: any; }' is not assignable to type 'string'. src/language-js/printer-estree.js(3651,16): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. src/language-js/printer-estree.js(3693,9): error TS2345: Argument of type '{ type: string; parts: any; }' is not assignable to parameter of type 'string'. -src/language-js/printer-estree.js(3995,14): error TS2554: Expected 0-2 arguments, but got 3. -src/language-js/printer-estree.js(5034,9): error TS2554: Expected 0-1 arguments, but got 2. +src/language-js/printer-estree.js(3998,9): error TS2554: Expected 0-2 arguments, but got 3. +src/language-js/printer-estree.js(5034,55): error TS2554: Expected 0-1 arguments, but got 2. src/language-js/printer-estree.js(5070,7): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type '((childPath: any) => any) | ConcatArray<(childPath: any) => any>'. Type '(string | number)[]' is not assignable to type 'ConcatArray<(childPath: any) => any>'. Types of property 'slice' are incompatible. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 0d6d611fbe4..4bb7680cd76 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -1,6 +1,6 @@ Exit Code: 1 Standard output: -node_modules/uglify-js/lib/ast.js(207,23): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/ast.js(207,38): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/ast.js(328,33): error TS2339: Property 'transform' does not exist on type 'string'. node_modules/uglify-js/lib/ast.js(869,5): error TS2322: Type '{ _visit: (node: any, descend: any) => any; parent: (n: any) => any; push: typeof push; pop: typeof pop; self: () => any; find_parent: (type: any) => any; has_directive: (type: any) => any; loopcontrol_target: (node: any) => any; in_boolean_context: () => boolean | undefined; }' is not assignable to type 'TreeWalker'. Object literal may only specify known properties, but '_visit' does not exist in type 'TreeWalker'. Did you mean to write 'visit'? @@ -8,64 +8,64 @@ node_modules/uglify-js/lib/ast.js(870,14): error TS2339: Property 'push' does no node_modules/uglify-js/lib/ast.js(877,14): error TS2339: Property 'pop' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/ast.js(932,25): error TS2339: Property 'self' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/ast.js(933,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(167,27): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(500,26): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(817,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1072,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1086,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. -node_modules/uglify-js/lib/compress.js(1150,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1192,112): error TS2454: Variable 'args' is used before being assigned. -node_modules/uglify-js/lib/compress.js(1193,29): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(1202,87): error TS2322: Type 'false' is not assignable to type 'number'. -node_modules/uglify-js/lib/compress.js(1210,29): error TS2322: Type 'false' is not assignable to type 'never'. -node_modules/uglify-js/lib/compress.js(1316,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1411,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1519,27): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1551,26): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1652,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(174,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(516,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(839,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1094,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1108,51): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'true | ((node: any) => any)' has no compatible call signatures. +node_modules/uglify-js/lib/compress.js(1172,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1213,112): error TS2454: Variable 'args' is used before being assigned. +node_modules/uglify-js/lib/compress.js(1214,29): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(1223,87): error TS2322: Type 'false' is not assignable to type 'number'. +node_modules/uglify-js/lib/compress.js(1231,29): error TS2322: Type 'false' is not assignable to type 'never'. +node_modules/uglify-js/lib/compress.js(1337,53): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1438,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1548,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1580,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1687,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'number[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(1975,44): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2013,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. +node_modules/uglify-js/lib/compress.js(2010,59): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2048,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'any[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 -node_modules/uglify-js/lib/compress.js(2161,19): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3214,23): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3227,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3367,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3422,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3439,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3464,62): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3690,23): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3711,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3721,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(3880,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(3932,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(3988,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4097,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4396,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4480,22): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4672,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. +node_modules/uglify-js/lib/compress.js(2196,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3291,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3304,33): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3438,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3493,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3510,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3535,75): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3761,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3782,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3792,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(3951,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4003,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(4059,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4171,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4470,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4554,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4762,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[RegExp, (string | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[RegExp, (string | undefined)?]'. -node_modules/uglify-js/lib/compress.js(4830,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4837,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(4841,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(4846,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(5333,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(5765,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. -node_modules/uglify-js/lib/compress.js(5792,32): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5855,24): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5927,24): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5933,26): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(6337,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6352,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6355,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(6361,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(6389,19): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4920,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4927,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: () => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 24 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(4931,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(4936,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(5423,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(5855,25): error TS2367: This condition will always return 'false' since the types 'boolean' and '"f"' have no overlap. +node_modules/uglify-js/lib/compress.js(5882,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5956,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6028,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6034,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(6467,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6482,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6485,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(6491,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(6519,34): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(170,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. -node_modules/uglify-js/lib/mozilla-ast.js(566,18): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(246,9): error TS2554: Expected 0 arguments, but got 2. -node_modules/uglify-js/lib/output.js(475,22): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(767,23): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1163,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(246,25): error TS2554: Expected 0 arguments, but got 2. +node_modules/uglify-js/lib/output.js(475,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(767,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1163,44): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/output.js(1445,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/uglify-js/lib/parse.js(367,20): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. @@ -76,36 +76,37 @@ node_modules/uglify-js/lib/parse.js(622,57): error TS2339: Property 'push' does node_modules/uglify-js/lib/parse.js(632,32): error TS2345: Argument of type 'never[]' is not assignable to parameter of type 'never'. node_modules/uglify-js/lib/parse.js(638,40): error TS2339: Property 'length' does not exist on type 'never'. node_modules/uglify-js/lib/parse.js(739,13): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(771,52): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(771,74): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(815,31): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(821,17): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(825,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(830,43): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(849,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(868,21): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(983,23): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. -node_modules/uglify-js/lib/parse.js(1097,9): error TS2322: Type 'any[]' is not assignable to type 'never[]'. +node_modules/uglify-js/lib/parse.js(775,69): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(775,83): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(819,31): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(825,17): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(829,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(834,43): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(853,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(872,21): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(987,23): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. +node_modules/uglify-js/lib/parse.js(1101,9): error TS2322: Type 'any[]' is not assignable to type 'never[]'. Type 'any' is not assignable to type 'never'. -node_modules/uglify-js/lib/parse.js(1156,17): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1324,32): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1430,20): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1516,48): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1542,35): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/parse.js(1587,52): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1158,17): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1326,32): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1426,20): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1432,20): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1518,48): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1544,35): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/parse.js(1589,52): error TS2531: Object is possibly 'null'. node_modules/uglify-js/lib/propmangle.js(69,18): error TS2339: Property 'prototype' does not exist on type 'ObjectConstructor | FunctionConstructor | StringConstructor | BooleanConstructor | NumberConstructor | Math | DateConstructor | RegExpConstructor | ErrorConstructor | ArrayConstructor'. Property 'prototype' does not exist on type 'Math'. node_modules/uglify-js/lib/propmangle.js(70,45): error TS2339: Property 'prototype' does not exist on type 'ObjectConstructor | FunctionConstructor | StringConstructor | BooleanConstructor | NumberConstructor | Math | DateConstructor | RegExpConstructor | ErrorConstructor | ArrayConstructor'. Property 'prototype' does not exist on type 'Math'. -node_modules/uglify-js/lib/propmangle.js(80,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/propmangle.js(94,15): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/propmangle.js(146,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(104,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(159,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(194,32): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(405,14): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(462,15): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(487,15): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/propmangle.js(80,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/propmangle.js(94,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/propmangle.js(146,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(104,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(159,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(194,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(409,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(466,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(491,30): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/sourcemap.js(55,25): error TS2304: Cannot find name 'MOZ_SourceMap'. node_modules/uglify-js/lib/sourcemap.js(61,23): error TS2304: Cannot find name 'MOZ_SourceMap'. node_modules/uglify-js/tools/exit.js(7,32): error TS2339: Property 'bufferSize' does not exist on type 'WriteStream'. diff --git a/tests/cases/compiler/contravariantInferenceAndTypeGuard.ts b/tests/cases/compiler/contravariantInferenceAndTypeGuard.ts new file mode 100644 index 00000000000..a1bcf4ae25d --- /dev/null +++ b/tests/cases/compiler/contravariantInferenceAndTypeGuard.ts @@ -0,0 +1,27 @@ +// @strict: true +interface ListItem { + prev: ListItem | null; + next: ListItem | null; + data: TData; +} +type IteratorFn> = (this: TContext, item: TData, node: ListItem, list: List) => TResult; +type FilterFn> = (this: TContext, item: TData, node: ListItem, list: List) => item is TResult; + +declare class List { + filter(fn: FilterFn, context: TContext): List; + filter(fn: FilterFn): List; + filter(fn: IteratorFn, context: TContext): List; + filter(fn: IteratorFn): List; +} +interface Test { + a: string; +} +const list2 = new List(); +const filter1 = list2.filter(function(item, node, list): item is Test { + this.b; // $ExpectType string + item; // $ExpectType Test | null + node; // $ExpectType ListItem + list; // $ExpectType List + return !!item; +}, {b: 'c'}); +const x: List = filter1; // $ExpectType List diff --git a/tests/cases/compiler/decoratorReferences.ts b/tests/cases/compiler/decoratorReferences.ts new file mode 100644 index 00000000000..c6222e67fd9 --- /dev/null +++ b/tests/cases/compiler/decoratorReferences.ts @@ -0,0 +1,9 @@ +// @experimentalDecorators: true + +declare function y(...args: any[]): any; +type T = number; +@y(1 as T, C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +class C { + @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class + method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. +} \ No newline at end of file diff --git a/tests/cases/compiler/extendGlobalThis.ts b/tests/cases/compiler/extendGlobalThis.ts new file mode 100644 index 00000000000..1ad9f0552b4 --- /dev/null +++ b/tests/cases/compiler/extendGlobalThis.ts @@ -0,0 +1,14 @@ +// @filename: extension.d.ts +declare global { + namespace globalThis { + var test: string; + } +} + +export {} + +// @filename: index.ts +import "./extention"; + +globalThis.tests = "a-b"; +console.log(globalThis.test.split("-")); diff --git a/tests/cases/compiler/genericFunctionInference1.ts b/tests/cases/compiler/genericFunctionInference1.ts index 237b135ca94..c6b864f82e5 100644 --- a/tests/cases/compiler/genericFunctionInference1.ts +++ b/tests/cases/compiler/genericFunctionInference1.ts @@ -60,6 +60,11 @@ declare function pipe5(f: (a: A) => B): { f: (a: A) => B }; const f50 = pipe5(list); // No higher order inference +declare function wrap3(f: (a: A, b1: B, b2: B) => C): (a: A, b1: B, b2: B) => C; +declare function baz(t1: T, t2: T, u: U): [T, U]; + +let f60 = wrap3(baz); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; } @@ -193,3 +198,8 @@ declare function foo2(fn: T, a?: U, b?: U): [T, U]; foo2(() => {}); foo2(identity); foo2(identity, 1); + +// Repro from #30324 + +declare function times(fn: (i: number) => T): (n: number) => T[]; +const a2 = times(identity)(5); // => [0, 1, 2, 3, 4] diff --git a/tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts b/tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts new file mode 100644 index 00000000000..940031c52c2 --- /dev/null +++ b/tests/cases/compiler/reactReduxLikeDeferredInferenceAllowsAssignment.ts @@ -0,0 +1,145 @@ +// @strict: true +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 +>; + +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); diff --git a/tests/cases/compiler/selfReferentialDefaultNoStackOverflow.ts b/tests/cases/compiler/selfReferentialDefaultNoStackOverflow.ts new file mode 100644 index 00000000000..55199e6da29 --- /dev/null +++ b/tests/cases/compiler/selfReferentialDefaultNoStackOverflow.ts @@ -0,0 +1,11 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @outDir: ./out +// @filename: QSpinner.js +import DefaultSpinner from './QSpinner' + +export default { + mixins: [DefaultSpinner], + name: 'QSpinner' +} diff --git a/tests/cases/compiler/substitutionTypesCompareCorrectlyInRestrictiveInstances.ts b/tests/cases/compiler/substitutionTypesCompareCorrectlyInRestrictiveInstances.ts new file mode 100644 index 00000000000..441c556e331 --- /dev/null +++ b/tests/cases/compiler/substitutionTypesCompareCorrectlyInRestrictiveInstances.ts @@ -0,0 +1,6 @@ +// @strict: true +type UnionKeys = T extends any ? keyof T : never; +type BugHelper = T extends any ? Exclude, keyof T> : never +type Bug = BugHelper +type Q = UnionKeys<{ a : any } | { b: any }> // should be "a" | "b" +type R = Bug<{ a : any } | { b: any }> // should be "a" | "b" diff --git a/tests/cases/conformance/async/es6/asyncMethodWithSuper_es6.ts b/tests/cases/conformance/async/es6/asyncMethodWithSuper_es6.ts index c754ac26c00..41208f6e63e 100644 --- a/tests/cases/conformance/async/es6/asyncMethodWithSuper_es6.ts +++ b/tests/cases/conformance/async/es6/asyncMethodWithSuper_es6.ts @@ -1,4 +1,5 @@ // @target: ES6 +// @lib: esnext // @noEmitHelpers: true class A { x() { @@ -125,4 +126,64 @@ class B extends A { // element access (assign) in async arrow (async () => super["x"] = f); } + + async * property_access_only_read_only_in_generator() { + // call with property access + super.x(); + + // property access (read) + const a = super.x; + + // property access in arrow + (() => super.x()); + + // property access in async arrow + (async () => super.x()); + } + + async * property_access_only_write_only_in_generator() { + const f = () => {}; + + // property access (assign) + super.x = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // property access (assign) in arrow + (() => super.x = f); + + // property access (assign) in async arrow + (async () => super.x = f); + } + + async * element_access_only_read_only_in_generator() { + // call with element access + super["x"](); + + // element access (read) + const a = super["x"]; + + // element access in arrow + (() => super["x"]()); + + // element access in async arrow + (async () => super["x"]()); + } + + async * element_access_only_write_only_in_generator() { + const f = () => {}; + + // element access (assign) + super["x"] = f; + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + + // element access (assign) in arrow + (() => super["x"] = f); + + // element access (assign) in async arrow + (async () => super["x"] = f); + } } diff --git a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter2.ts b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter2.ts new file mode 100644 index 00000000000..1a8c6faf84b --- /dev/null +++ b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter2.ts @@ -0,0 +1,7 @@ +// @target:es5 +// @experimentaldecorators: true +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + method(this: C, @dec p: number) {} +} \ No newline at end of file diff --git a/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts new file mode 100644 index 00000000000..d111fc9047a --- /dev/null +++ b/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts @@ -0,0 +1,7 @@ +// @target:es5 +// @experimentaldecorators: true +declare function dec(target: Object, propertyKey: string | symbol, parameterIndex: number): void; + +class C { + method(@dec this: C) {} +} \ No newline at end of file diff --git a/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts b/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts new file mode 100644 index 00000000000..46935aabe83 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts @@ -0,0 +1,17 @@ +// @noImplicitAny: true +var x = 1 +const y = 2 +let z = 3 +globalThis.x // ok +globalThis.y // should error, no property 'y' +globalThis.z // should error, no property 'z' +globalThis['x'] // ok +globalThis['y'] // should error, no property 'y' +globalThis['z'] // should error, no property 'z' +globalThis.Float64Array // ok +globalThis.Infinity // ok + +declare let test1: (typeof globalThis)['x'] // ok +declare let test2: (typeof globalThis)['y'] // error +declare let test3: (typeof globalThis)['z'] // error +declare let themAll: keyof typeof globalThis diff --git a/tests/cases/fourslash/completionAfterGlobalThis.ts b/tests/cases/fourslash/completionAfterGlobalThis.ts new file mode 100644 index 00000000000..f5241d93c6a --- /dev/null +++ b/tests/cases/fourslash/completionAfterGlobalThis.ts @@ -0,0 +1,12 @@ +/// + +////globalThis./**/ + +verify.completions({ + marker: "", + exact: [ + { name: "globalThis", kind: "module" }, + ...completion.globalsVars, + { name: "undefined", kind: "var" } + ] +}); diff --git a/tests/cases/fourslash/completionEntryInJsFile.ts b/tests/cases/fourslash/completionEntryInJsFile.ts new file mode 100644 index 00000000000..a3492d9de3e --- /dev/null +++ b/tests/cases/fourslash/completionEntryInJsFile.ts @@ -0,0 +1,20 @@ +/// + +// @allowJs: true +// @Filename: /Foo.js +//// /*global*/ +////class classA { +//// /*class*/ +////} +////class Test7 { +//// constructor(/*constructorParameter*/){} +////} +////function foo() { +/////*insideFunction*/ +////} +verify.completions( + { marker: "global", exact: completion.globalsInJsPlus(["foo", "classA", "Test7"]) }, + { marker: "class", isNewIdentifierLocation: true, exact: ["classA", "Test7", "foo", ...completion.classElementInJsKeywords] }, + { marker: "constructorParameter", isNewIdentifierLocation: true, exact: ["classA", "Test7", "foo"] }, + { marker: "insideFunction", exact: completion.globalsInJsInsideFunction(["foo", "classA", "Test7"]) }, +); diff --git a/tests/cases/fourslash/findAllRefsOfConstructor.ts b/tests/cases/fourslash/findAllRefsOfConstructor.ts new file mode 100644 index 00000000000..08846380749 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsOfConstructor.ts @@ -0,0 +1,27 @@ +/// + + +////class A { +//// [|constructor|](s: string) {} +////} +////class B extends A { } +////class C extends B { +//// [|constructor|]() { +//// [|super|](""); +//// } +////} +////class D extends B { } +////class E implements A { } +////const a = new [|A|]("a"); +////const b = new [|B|]("b"); +////const c = new [|C|](); +////const d = new [|D|]("d"); +////const e = new E(); + +verify.noErrors(); +const [aCtr, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); +verify.referenceGroups(aCtr, [ + { definition: "class A", ranges: [aCtr, aNew] }, + { definition: "class B", ranges: [cSuper, bNew]}, + { definition: "class D", ranges: [dNew]}]); +verify.referenceGroups(cCtr, [{ definition: "class C", ranges: [cCtr, cNew]}]); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsOfConstructor2.ts b/tests/cases/fourslash/findAllRefsOfConstructor2.ts new file mode 100644 index 00000000000..17991cb555c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsOfConstructor2.ts @@ -0,0 +1,25 @@ +/// + + +////class A { +//// [|constructor|](s: string) {} +////} +////class B extends A { +//// [|constructor|]() { [|super|](""); } +////} +////class C extends B { +//// [|constructor|]() { +//// [|super|](); +//// } +////} +////class D extends B { } +////const a = new [|A|]("a"); +////const b = new [|B|](); +////const c = new [|C|](); +////const d = new [|D|](); + +verify.noErrors(); +const [aCtr, bCtr, bSuper, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); +verify.referenceGroups(aCtr, [{ definition: "class A", ranges: [aCtr, bSuper, aNew] }]); +verify.referenceGroups(bCtr, [{ definition: "class B", ranges: [bCtr, cSuper, bNew]}, { definition: "class D", ranges: [dNew]}]); +verify.referenceGroups(cCtr, [{ definition: "class C", ranges: [cCtr, cNew]}]); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts b/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts new file mode 100644 index 00000000000..a20d9fc1f29 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: f.ts + +////class A { +//// [|constructor|](s: string) {} +////} +////class B extends A { } +////export { [|{| "isWriteAccess": true, "isDefinition": true |}A|], [|{| "isWriteAccess": true, "isDefinition": true |}B|] }; + +// @Filename: a.ts + +////import { [|A|] as A1 } from "./f"; +////const a1 = new [|A1|]("a1"); +////export default class extends A1 { } +////export { [|B|] as [|{| "isWriteAccess": true, "isDefinition": true |}B1|] } from "./f"; + +// @Filename: b.ts + +////import [|B|], { B1 } from "./a"; +////const d = new [|B|]("b"); +////const d1 = new [|B1|]("b1"); + +verify.noErrors(); +const [aCtr, aExport, bExport, aImport, a1New, bReExport, b1Export, bDefault, bNew, b1New ] = test.ranges(); +verify.referenceGroups(aCtr, [ + { definition: "class A", ranges: [aCtr, aExport] }, + { definition: "class B", ranges: [bExport]}, + { definition: "(alias) class B\nexport B", ranges: [bReExport]}, + { definition: "(alias) class B1\nexport B1", ranges: [b1Export]}, + { definition: "(alias) class B1\nimport B1", ranges: [b1New]}, + { definition: "(alias) class A\nexport A", ranges: [aImport]}, + { definition: "(alias) class A1\nimport A1", ranges: [a1New]}, + { definition: "class default", ranges: []}, + { definition: { text: "import B", range: bDefault }, ranges: [bNew]}]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index db4f7be009b..6488748b728 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -650,22 +650,29 @@ declare var classification: typeof FourSlashInterface.classification; declare namespace completion { type Entry = FourSlashInterface.ExpectedCompletionEntryObject; export const globals: ReadonlyArray; + export const globalsInJs: ReadonlyArray; export const globalKeywords: ReadonlyArray; + export const globalInJsKeywords: ReadonlyArray; export const insideMethodKeywords: ReadonlyArray; + export const insideMethodInJsKeywords: ReadonlyArray; export const globalKeywordsPlusUndefined: ReadonlyArray; export const globalsVars: ReadonlyArray; export function globalsInsideFunction(plus: ReadonlyArray): ReadonlyArray; + export function globalsInJsInsideFunction(plus: ReadonlyArray): ReadonlyArray; export function globalsPlus(plus: ReadonlyArray): ReadonlyArray; + export function globalsInJsPlus(plus: ReadonlyArray): ReadonlyArray; export const keywordsWithUndefined: ReadonlyArray; export const keywords: ReadonlyArray; export const typeKeywords: ReadonlyArray; export const globalTypes: ReadonlyArray; export function globalTypesPlus(plus: ReadonlyArray): ReadonlyArray; export const classElementKeywords: ReadonlyArray; + export const classElementInJsKeywords: ReadonlyArray; export const constructorParameterKeywords: ReadonlyArray; export const functionMembers: ReadonlyArray; export const stringMembers: ReadonlyArray; export const functionMembersWithPrototype: ReadonlyArray; export const statementKeywordsWithTypes: ReadonlyArray; export const statementKeywords: ReadonlyArray; + export const statementInJsKeywords: ReadonlyArray; } diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_badRestParam.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_badRestParam.ts new file mode 100644 index 00000000000..187086bcec8 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_badRestParam.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: a.ts +////function /*a*/gen/*b*/(a: boolean, ...b: T): T { +//// return b; +////} +////gen(false); +////gen(false, 1); +////gen(true, 1, "two"); + +// @Filename: b.ts +////function /*c*/un/*d*/(a: boolean, ...b: number[] | [string, string]) { +//// return b; +////} + +goTo.select("a", "b"); +verify.not.refactorAvailable("Convert to named parameters"); + +goTo.select("c", "d"); +verify.not.refactorAvailable("Convert to named parameters"); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionJSDoc.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionJSDoc.ts new file mode 100644 index 00000000000..fb87c205025 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionJSDoc.ts @@ -0,0 +1,18 @@ +/// + +/////** +//// * Return the boolean state of attribute from an element +//// * /*a*/@param/*b*/ el The source of the attributes. +//// * @param atty Name of the attribute or a string of candidate attribute names. +//// * @param def Default boolean value when attribute is undefined. +//// */ +////export function /*c*/getBoolFromAttribute/*d*/( +//// /*e*//** inline JSDoc *//*f*/ attr: string | string[], +//// def: boolean = false): boolean { } + +goTo.select("a", "b"); +verify.not.refactorAvailable("Convert parameters to destructured object"); +goTo.select("c", "d"); +verify.refactorAvailable("Convert parameters to destructured object"); +goTo.select("e", "f"); +verify.refactorAvailable("Convert parameters to destructured object"); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts index 6e27c33078a..70a5d2022b5 100644 --- a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts @@ -8,9 +8,6 @@ ////var foo = new Foo("c", "d"); goTo.select("a", "b"); -/* The expected new content is currently wrong. - `new Bar("a", "b")` should be modified by the refactor to be `new Bar({ t: "a", s: "b" })` -*/ edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", @@ -19,6 +16,6 @@ edit.applyRefactor({ constructor({ t, s }: { t: string; s: string; }) { } } class Bar extends Foo { } -var bar = new Bar("a", "b"); +var bar = new Bar({ t: "a", s: "b" }); var foo = new Foo({ t: "c", s: "d" });` }); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts index 031b50dc45e..fca08439b6d 100644 --- a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts @@ -6,9 +6,8 @@ ////class B { //// foo(c: number, d: number) { return c + d; } ////} -////function foo(ab: A | B) { -//// return ab.foo(1, 2); -////} +////declare var ab: A | B; +////ab.foo(1, 2); goTo.select("a", "b"); @@ -23,7 +22,6 @@ edit.applyRefactor({ class B { foo(c: number, d: number) { return c + d; } } -function foo(ab: A | B) { - return ab.foo(1, 2); -}` +declare var ab: A | B; +ab.foo(1, 2);` }); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_shorthandProperty.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_shorthandProperty.ts new file mode 100644 index 00000000000..86ea98582ab --- /dev/null +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_shorthandProperty.ts @@ -0,0 +1,25 @@ +/// + +// @Filename: f.ts +////function /*a*/f/*b*/(a: number, b: number, ...rest: string[]) { } +////const a = 4; +////const b = 5; +////f(a, b); +////const rest = ["a", "b", "c"]; +////f(a, b, ...rest); +////f(/** a */ a /** aa */, /** b */ b /** bb */); + + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: `function f({ a, b, rest = [] }: { a: number; b: number; rest?: string[]; }) { } +const a = 4; +const b = 5; +f({ a, b }); +const rest = ["a", "b", "c"]; +f({ a, b, rest: [...rest] }); +f({ /** a */ a /** aa */, /** b */ b /** bb */ });` +}); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts index 56227a9078a..2bdee836472 100644 --- a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts @@ -19,7 +19,7 @@ edit.applyRefactor({ } class B extends A { constructor(a: string, b: string, c: string) { - super({ a: a, b: b }); + super({ a, b }); } }` }); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_tupleRestParam.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_tupleRestParam.ts new file mode 100644 index 00000000000..7584308fec0 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_tupleRestParam.ts @@ -0,0 +1,57 @@ +/// + +// @Filename: a.ts +////function /*a*/fn1/*b*/(a: number, b: number, ...args: [number, number]) { } +////fn1(1, 2, 3, 4); + +// @Filename: b.ts +////function /*c*/fn2/*d*/(a: number, b: number, ...args: [number, number, ...string[]]) { } +////fn2(1, 2, 3, 4); +////fn2(1, 2, 3, 4, "a"); + +// @Filename: c.ts +////function /*e*/fn3/*f*/(b: boolean, c: []) { } +////fn3(true, []); + +// @Filename: d.ts +////function /*g*/fn4/*h*/(a: number, ...args: [...string[]] ) { } +////fn4(2); +////fn4(1, "two", "three"); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: `function fn1({ a, b, args }: { a: number; b: number; args: [number, number]; }) { } +fn1({ a: 1, b: 2, args: [3, 4] });` +}); + +goTo.select("c", "d"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: `function fn2({ a, b, args }: { a: number; b: number; args: [number, number, ...string[]]; }) { } +fn2({ a: 1, b: 2, args: [3, 4] }); +fn2({ a: 1, b: 2, args: [3, 4, "a"] });` +}); + +goTo.select("e", "f"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: `function fn3({ b, c }: { b: boolean; c: []; }) { } +fn3({ b: true, c: [] });` +}); + +goTo.select("g", "h"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: `function fn4({ a, args = [] }: { a: number; args?: [...string[]]; }) { } +fn4({ a: 2 }); +fn4({ a: 1, args: ["two", "three"] });` +}); \ No newline at end of file diff --git a/tests/cases/fourslash/regexDetection.ts b/tests/cases/fourslash/regexDetection.ts index d19fc64ba79..0de24df9db9 100644 --- a/tests/cases/fourslash/regexDetection.ts +++ b/tests/cases/fourslash/regexDetection.ts @@ -6,11 +6,11 @@ goTo.marker("1"); verify.not.quickInfoExists(); goTo.marker("2"); -verify.quickInfoIs("const Math: Math", +verify.quickInfoIs("var Math: Math", "An intrinsic object that provides basic mathematics functionality and constants."); goTo.marker("3"); verify.not.quickInfoExists(); goTo.marker("4"); -verify.not.quickInfoExists(); \ No newline at end of file +verify.not.quickInfoExists(); diff --git a/tests/cases/fourslash/signatureHelpCallExpressionTuples.ts b/tests/cases/fourslash/signatureHelpCallExpressionTuples.ts new file mode 100644 index 00000000000..bcad3ccde48 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpCallExpressionTuples.ts @@ -0,0 +1,56 @@ +/// + + +//// function fnTest(str: string, num: number) { } +//// declare function wrap(fn: (...a: A) => R) : (...a: A) => R; +//// var fnWrapped = wrap(fnTest); +//// fnWrapped/*3*/(/*1*/'', /*2*/5); +//// function fnTestVariadic (str: string, ...num: number[]) { } +//// var fnVariadicWrapped = wrap(fnTestVariadic); +//// fnVariadicWrapped/*4*/(/*5*/'', /*6*/5); +//// function fnNoParams () { } +//// var fnNoParamsWrapped = wrap(fnNoParams); +//// fnNoParamsWrapped/*7*/(/*8*/); + +verify.quickInfoAt("3", "var fnWrapped: (str: string, num: number) => void"); +verify.signatureHelp( + { + marker: "1", + text: "fnWrapped(str: string, num: number): void", + parameterCount: 2, + parameterName: "str", + parameterSpan: "str: string", + }, + { + marker: "2", + parameterName: "num", + parameterSpan: "num: number", + }, +); + +verify.quickInfoAt("4", "var fnVariadicWrapped: (str: string, ...num: number[]) => void"); +verify.signatureHelp( + { + marker: "5", + text: "fnVariadicWrapped(str: string, ...num: number[]): void", + parameterCount: 2, + parameterName: "str", + parameterSpan: "str: string", + isVariadic: true, + }, + { + marker: "6", + parameterName: "num", + parameterSpan: "...num: number[]", + isVariadic: true, + }, +); + +verify.quickInfoAt("7", "var fnNoParamsWrapped: () => void"); +verify.signatureHelp( + { + marker: "8", + text: "fnNoParamsWrapped(): void", + parameterCount: 0, + } +);